From f33bbfe724610ffb610dca8ec255274555ef53ed Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Mon, 29 Jun 2015 14:24:04 +0000 Subject: [PATCH] collapsed store_into_xxx followed by pop_statcktop into pop_into_xxx --- stix/lib/comp.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/stix/lib/comp.c b/stix/lib/comp.c index 15ee912..8924671 100644 --- a/stix/lib/comp.c +++ b/stix/lib/comp.c @@ -3234,27 +3234,25 @@ printf ("\n"); goto oops; case VAR_TEMPORARY: -printf ("\tstore_into_tempvar %d\n", (int)var.pos); -/* TODO: if pop is 1, emit BCODE_POP_INTO_TEMPVAR. -ret = pop; -*/ - if (emit_single_param_instruction (stix, BCODE_STORE_INTO_TEMPVAR_0, var.pos) <= -1) goto oops; + +printf ("\t%s_into_tempvar %d\n", (pop? "pop":"store"), (int)var.pos); + if (emit_single_param_instruction (stix, (pop? BCODE_POP_INTO_TEMPVAR_0: BCODE_STORE_INTO_TEMPVAR_0), var.pos) <= -1) goto oops; + ret = pop; break; case VAR_INSTANCE: case VAR_CLASSINST: -printf ("\tstore_into_instvar %d\n", (int)var.pos); -/* TODO: if pop is 1, emit BCODE_POP_INTO_INSTVAR -ret = pop; -*/ - if (emit_single_param_instruction (stix, BCODE_STORE_INTO_INSTVAR_0, var.pos) <= -1) goto oops; +printf ("\t%s_into_instvar %d\n", (pop? "pop":"store"), (int)var.pos); + if (emit_single_param_instruction (stix, (pop? BCODE_POP_INTO_INSTVAR_0: BCODE_STORE_INTO_INSTVAR_0), var.pos) <= -1) goto oops; + ret = pop; break; case VAR_CLASS: /* TODO is this correct? */ if (add_literal (stix, (stix_oop_t)var.cls, &index) <= -1 || - emit_double_param_instruction (stix, BCODE_STORE_INTO_OBJVAR_0, var.pos, index) <= -1) goto oops; -printf ("\tstore_into_objvar %d %d\n", (int)var.pos, (int)index); + emit_double_param_instruction (stix, (pop? BCODE_POP_INTO_OBJVAR_0: BCODE_STORE_INTO_OBJVAR_0), var.pos, index) <= -1) goto oops; +printf ("\t%s_into_objvar %d %d\n", (pop? "pop":"store"), (int)var.pos, (int)index); + ret = pop; break; case VAR_GLOBAL: