fixed parameter mutation (not triggered in current test suite, need to add a case for this)

This commit is contained in:
Alex Shinn 2010-09-24 21:48:08 +09:00
parent 0fb820a8e3
commit 276db59353
2 changed files with 19 additions and 1 deletions

View file

@ -1,4 +1,21 @@
;; (param) => get-cell + cdr
;; (param value) => get-cell + [convert] + set-cdr!
;; need 3 opcodes: param cell
;; context params
;; context-params-set!
;; analyze needs to translate param calls to proper usages of the
;; first two opcodes
;; (parameterize ((param value)) body ...)
;; => (let* ((old-params (thread-parameters))
;; (new-params (cons (cons param (param-convert value)) old-params)))
;; (dynamic-wind (lambda () (thread-set-parameters! new-params))
;; (lambda () body ...)
;; (lambda () (thread-set-parameters! old-params))))
(define-module (srfi 39)
(export make-parameter parameterize)
(import-immutable (scheme))

3
vm.c
View file

@ -279,11 +279,12 @@ static void generate_opcode_app (sexp ctx, sexp app) {
}
break;
case SEXP_OPC_PARAMETER:
emit_push(ctx, sexp_opcode_data(op));
#if SEXP_USE_GREEN_THREADS
emit(ctx, SEXP_OP_PARAMETER_REF);
emit_word(ctx, (sexp_uint_t)op);
sexp_push(ctx, sexp_bytecode_literals(sexp_context_bc(ctx)), op);
#else
emit_push(ctx, sexp_opcode_data(op));
#endif
emit(ctx, ((num_args == 0) ? SEXP_OP_CDR : SEXP_OP_SET_CDR));
break;