diff --git a/lib/srfi/39.module b/lib/srfi/39.module index 11b9ed9f..e77a3c50 100644 --- a/lib/srfi/39.module +++ b/lib/srfi/39.module @@ -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)) diff --git a/vm.c b/vm.c index 97c162ea..4d272bbc 100644 --- a/vm.c +++ b/vm.c @@ -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;