From 7bdc8ce4cdc5f151c5554511fe1e5f1c7d064b40 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Mon, 9 Jun 2008 18:30:58 +0200 Subject: [PATCH] ecl_interpret returns the first value --- src/c/compiler.d | 8 +++++--- src/c/interpreter.d | 19 ++++++++----------- src/h/external.h | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/c/compiler.d b/src/c/compiler.d index 6865cde3f..0a1dfc26a 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -1540,7 +1540,7 @@ c_nth_value(cl_object args, int flags) { if (args != Cnil) FEprogram_error("NTH-VALUE: Too many arguments.",0); asm_op(OP_NTHVAL); - return FLAG_VALUES; + return FLAG_REG0; } @@ -2562,12 +2562,14 @@ si_make_lambda(cl_object name, cl_object rest) ihs_push(&ihs, bytecodes, Cnil); VALUES(0) = Cnil; NVALUES = 0; - ecl_interpret(interpreter_env, bytecodes, bytecodes->bytecodes.code); + { + cl_object output = ecl_interpret(interpreter_env, bytecodes, bytecodes->bytecodes.code); #ifdef GBC_BOEHM GC_free(bytecodes->bytecodes.code); GC_free(bytecodes->bytecodes.data); GC_free(bytecodes); #endif ihs_pop(); - return VALUES(0); + return output; + } @) diff --git a/src/c/interpreter.d b/src/c/interpreter.d index 7986b4128..a21761030 100644 --- a/src/c/interpreter.d +++ b/src/c/interpreter.d @@ -332,8 +332,7 @@ lambda_bind(cl_object env, cl_narg narg, cl_object lambda, cl_object *sp) } else { cl_object defaults = data[1]; if (FIXNUMP(defaults)) { - ecl_interpret(env, lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults)); - defaults = VALUES(0); + defaults = ecl_interpret(env, lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults)); } env = lambda_bind_var(env, data[0], defaults, specials); if (!Null(data[2])) { @@ -422,8 +421,7 @@ lambda_bind(cl_object env, cl_narg narg, cl_object lambda, cl_object *sp) } else { cl_object defaults = data[2]; if (FIXNUMP(defaults)) { - ecl_interpret(env, lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults)); - defaults = VALUES(0); + defaults = ecl_interpret(env, lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults)); } env = lambda_bind_var(env, data[1],defaults,specials); } @@ -454,9 +452,9 @@ ecl_apply_lambda(cl_object frame, cl_object fun) VALUES(0) = Cnil; NVALUES = 0; name = fun->bytecodes.name; - ecl_interpret(env, fun, fun->bytecodes.code); + fun = ecl_interpret(env, fun, fun->bytecodes.code); bds_unwind(old_bds_top); - returnn(VALUES(0)); + return fun; } @@ -513,7 +511,7 @@ close_around(cl_object fun, cl_object lex) { } \ *(the_env->stack_top++) = __aux; } -void * +cl_object ecl_interpret(cl_object env, cl_object bytecodes, void *pc) { ECL_OFFSET_TABLE; @@ -682,7 +680,7 @@ ecl_interpret(cl_object env, cl_object bytecodes, void *pc) */ CASE(OP_EXIT); { ihs_pop(); - return (char *)vector; + return VALUES(0); } /* OP_FLET nfun{arg} fun1{object} @@ -1160,11 +1158,10 @@ ecl_interpret(cl_object env, cl_object bytecodes, void *pc) if (n < 0) { FEerror("Wrong index passed to NTH-VAL", 1, MAKE_FIXNUM(n)); } else if ((cl_index)n >= the_env->nvalues) { - the_env->values[0] = reg0 = Cnil; + reg0 = Cnil; } else { - the_env->values[0] = reg0 = the_env->values[n]; + reg0 = the_env->values[n]; } - the_env->nvalues = 1; THREAD_NEXT; } /* OP_PROTECT label diff --git a/src/h/external.h b/src/h/external.h index cb7dbe83e..86055e3f3 100644 --- a/src/h/external.h +++ b/src/h/external.h @@ -459,7 +459,7 @@ extern ECL_API cl_index cl_stack_push_values(void); extern ECL_API void cl_stack_pop_values(cl_index n); extern ECL_API cl_object ecl_apply_lambda(cl_object frame, cl_object fun); -extern ECL_API void *ecl_interpret(cl_object env, cl_object bytecodes, void *pc); +extern ECL_API cl_object ecl_interpret(cl_object env, cl_object bytecodes, void *pc); /* disassembler.c */