From 0912497863a66d3fc33e366f249514aad9ee32ac Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Sun, 13 Oct 2002 17:05:40 +0000 Subject: [PATCH] Simplify use of local variables, eliminating the redundant symbol from the bytecodes. --- src/c/compiler.d | 1 - src/c/disassembler.d | 12 ++++-------- src/c/interpreter.d | 15 ++++++--------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/c/compiler.d b/src/c/compiler.d index 0d01a3ec4..cd42fe32e 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -1807,7 +1807,6 @@ compile_form(cl_object stmt, bool push) { index = c_var_ref(stmt); if (index >= 0) { asm_op2(push? OP_PUSHV : OP_VAR, index); - asm1(stmt); } else { asm_op(push? OP_PUSHVS : OP_VARS); asm1(stmt); diff --git a/src/c/disassembler.d b/src/c/disassembler.d index e4a25e8b3..d81837d81 100644 --- a/src/c/disassembler.d +++ b/src/c/disassembler.d @@ -464,14 +464,12 @@ disassemble(cl_object *vector) { s = next_code(vector); goto ARG; - /* OP_VAR n{arg}, var{symbol} + /* OP_VAR n{arg} Sets NValues=1 and VALUES(0) to the value of the n-th local. - VAR is the name of the variable for readability purposes. */ case OP_VAR: string = "VAR\t"; n = get_oparg(s); - s = next_code(vector); - goto OPARG_ARG; + goto OPARG; /* OP_VARS var{symbol} Sets NValues=1 and VALUES(0) to the value of the symbol VAR. @@ -487,14 +485,12 @@ disassemble(cl_object *vector) { case OP_PUSH: string = "PUSH\tVALUES(0)"; goto NOARG; - /* OP_PUSHV n{arg}, var{symbol} + /* OP_PUSHV n{arg} Pushes the value of the n-th local onto the stack. - VAR is the name of the variable for readability purposes. */ case OP_PUSHV: string = "PUSHV\t"; n = get_oparg(s); - s = next_code(vector); - goto OPARG_ARG; + goto OPARG; /* OP_PUSHVS var{symbol} Pushes the value of the symbol VAR onto the stack. diff --git a/src/c/interpreter.d b/src/c/interpreter.d index defa3cb1a..dc4b6eef2 100644 --- a/src/c/interpreter.d +++ b/src/c/interpreter.d @@ -139,10 +139,10 @@ bind_special(register cl_object var, register cl_object val) } static cl_object -search_local(register cl_object name, register int s) { +search_local(register int s) { cl_object x; for (x = lex_env; s-- > 0 && !Null(x); x = CDDR(x)); - if (Null(x) || CAR(x) != name) + if (Null(x)) FEerror("Internal error: local not found.", 0); return CADR(x); } @@ -939,8 +939,7 @@ interpret(cl_object *vector) { */ case OP_VAR: { int lex_env_index = get_oparg(s); - cl_object var_name = next_code(vector); - VALUES(0) = search_local(var_name, lex_env_index); + VALUES(0) = search_local(lex_env_index); NValues = 1; break; } @@ -963,14 +962,12 @@ interpret(cl_object *vector) { cl_stack_push(VALUES(0)); break; - /* OP_PUSHV n{arg}, var{symbol} + /* OP_PUSHV n{arg} Pushes the value of the n-th local onto the stack. - VAR is the name of the variable for readability purposes. */ case OP_PUSHV: { int lex_env_index = get_oparg(s); - cl_object var_name = next_code(vector); - cl_stack_push(search_local(var_name, lex_env_index)); + cl_stack_push(search_local(lex_env_index)); break; } @@ -1137,7 +1134,7 @@ interpret(cl_object *vector) { */ case OP_GO: { cl_object tag_name = next_code(vector); - cl_object id = search_local(@':tag',get_oparg(s)); + cl_object id = search_local(get_oparg(s)); VALUES(0) = Cnil; NValues = 0; cl_go(id, tag_name);