diff options
author | bjj <bjj> | 1999-08-14 19:44:15 +0000 |
---|---|---|
committer | bjj <bjj> | 1999-08-14 19:44:15 +0000 |
commit | 7fbf98e25699c2e4a52134e1ddeb4119e906dbc8 (patch) | |
tree | 2cb72d4c8fbcc8bf523ffe8193cdaac2992e8149 | |
parent | 10dc7c2272a6d99cdb6d750bbdc7768dadd13702 (diff) | |
download | moo-7fbf98e25699c2e4a52134e1ddeb4119e906dbc8.tar.gz moo-7fbf98e25699c2e4a52134e1ddeb4119e906dbc8.tar.xz moo-7fbf98e25699c2e4a52134e1ddeb4119e906dbc8.zip |
Code generator will no longer PUSH_CLEAR things like dobj/dobjstr/prepstr
around CALL_VERB operations, since those variables are passed directly
from one environment to the next.
-rw-r--r-- | code_gen.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -90,6 +90,13 @@ typedef struct state State; #ifdef BYTECODE_REDUCE_REF #define INCR_TRY_DEPTH(SSS) (++(SSS)->try_depth) #define DECR_TRY_DEPTH(SSS) (--(SSS)->try_depth) +#define NON_VR_VAR_MASK ~((1 << SLOT_ARGSTR) | \ + (1 << SLOT_DOBJ) | \ + (1 << SLOT_DOBJSTR) | \ + (1 << SLOT_PREPSTR) | \ + (1 << SLOT_IOBJ) | \ + (1 << SLOT_IOBJSTR) | \ + (1 << SLOT_PLAYER)) #else /* no BYTECODE_REDUCE_REF */ #define INCR_TRY_DEPTH(SSS) #define DECR_TRY_DEPTH(SSS) @@ -472,6 +479,15 @@ exit_loop(State * state) static void +emit_call_verb_op(Opcode op, State * state) +{ + emit_byte(op, state); +#ifdef BYTECODE_REDUCE_REF + state->pushmap[state->num_bytes - 1] = OP_CALL_VERB; +#endif /* BYTECODE_REDUCE_REF */ +} + +static void emit_ending_op(Opcode op, State * state) { emit_byte(op, state); @@ -733,7 +749,7 @@ generate_expr(Expr * expr, State * state) generate_expr(expr->e.verb.obj, state); generate_expr(expr->e.verb.verb, state); generate_arg_list(expr->e.verb.args, state); - emit_byte(OP_CALL_VERB, state); + emit_call_verb_op(OP_CALL_VERB, state); pop_stack(2, state); break; case EXPR_COND: @@ -1225,6 +1241,13 @@ stmt_to_code(Stmt * stmt, GState * gstate) * a ref to `args' during the called verb. */ varbits = ~0U; + } else if (state.pushmap[old_i] == OP_CALL_VERB) { + /* + * Verb calls implicitly pass the VR variables (dobj, + * dobjstr, player, etc). They can't be clear at the + * time of a verbcall. + */ + varbits &= NON_VR_VAR_MASK; } } } @@ -1334,6 +1357,11 @@ char rcsid_code_gen[] = "$Id$"; /* * $Log$ + * Revision 1.9 1999/08/14 19:44:15 bjj + * Code generator will no longer PUSH_CLEAR things like dobj/dobjstr/prepstr + * around CALL_VERB operations, since those variables are passed directly + * from one environment to the next. + * * Revision 1.8 1999/08/12 05:40:09 bjj * Consider OP_FORK a nonlocal goto so that no variables are undefined * when it happens (the saved environment has to be complete for the forked |