From 8ca34f40ec9aab45542bdae1b41dbdb98e0109cd Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 5 Dec 2009 15:44:01 -0600 Subject: [PATCH] Add a bytecode which returns the type of a given structure. --- doc/bytecode.txt | 1 + interp.c | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/bytecode.txt b/doc/bytecode.txt index 7d9da6a..775101b 100644 --- a/doc/bytecode.txt +++ b/doc/bytecode.txt @@ -36,6 +36,7 @@ unary-expr: up to 255, 1 out, 1 in 28 (set! out (vector-size in)) 29 (set! out (byte-string-size in)) 2a (set! out (struct-nslots in)) + 2b (set! out (struct-type in)) ; ISO C floating-point 30 (set! out (acos in)) diff --git a/interp.c b/interp.c index bc954a7..cbe3978 100644 --- a/interp.c +++ b/interp.c @@ -417,6 +417,7 @@ static value_t eval_unary_expression(interp_state_t *state, uint8_t subcode, uin case 0x28: return fixnum_value(get_vector(ST1)->size); case 0x29: return fixnum_value(get_byte_string(ST1)->size); case 0x2a: return fixnum_value(get_struct(ST1)->nslots); + case 0x2b: return get_struct(ST1)->type; case 0x30: return make_float(acos(get_float(ST1))); case 0x31: return make_float(asin(get_float(ST1))); case 0x32: return make_float(atan(get_float(ST1)));