diff --git a/doc/bytecode.txt b/doc/bytecode.txt index 7ac5b99..e778127 100644 --- a/doc/bytecode.txt +++ b/doc/bytecode.txt @@ -12,6 +12,7 @@ unary-expr: up to 255, 1 out, 1 in 02 (set! out (unbox in)) 03 (set! out (car in)) 04 (set! out (cdr in)) + 05 (set! out (weak-unbox in)) 08 (set! out (boolean? in)) ; value => bool 09 (set! out (fixnum? in)) ; value => bool diff --git a/interp.c b/interp.c index 7d962b1..81a9a89 100644 --- a/interp.c +++ b/interp.c @@ -407,9 +407,10 @@ static value_t eval_unary_expression(interp_state_t *state, uint8_t subcode, uin switch (subcode) { case 0x01: return ST1; - case 0x02: return is_weak_box(ST1) ? _get_weak_box(ST1)->value : get_box(ST1)->value; + case 0x02: return get_box(ST1)->value; case 0x03: return get_pair(ST1)->car; case 0x04: return get_pair(ST1)->cdr; + case 0x05: return get_weak_box(ST1)->value; case 0x08: return boolean_value(is_boolean(ST1)); case 0x09: return boolean_value(is_fixnum(ST1)); case 0x0a: return boolean_value(is_box(ST1)); diff --git a/libcompiler/primitives.scm b/libcompiler/primitives.scm index d293b0b..a5e34a4 100644 --- a/libcompiler/primitives.scm +++ b/libcompiler/primitives.scm @@ -23,6 +23,7 @@ '((#%unbox #x02 unbox) (#%car #x03 car) (#%cdr #x04 cdr) + (#%weak-unbox #x05 weak-unbox) (#%boolean? #x08 boolean?) (#%fixnum? #x09 fixnum?) (#%box? #x0a box?) diff --git a/src/lib/primitives.rls b/src/lib/primitives.rls index 4f451b6..430003a 100644 --- a/src/lib/primitives.rls +++ b/src/lib/primitives.rls @@ -4,6 +4,7 @@ (define (unbox x) (unbox x)) (define (car x) (car x)) (define (cdr x) (cdr x)) +(define (weak-unbox x) (weak-unbox x)) (define (boolean? x) (boolean? x)) (define (fixnum? x) (fixnum? x)) (define (box? x) (box? x))