From: Jérémie Astor Date: Fri, 29 Nov 2019 10:35:50 +0000 (+0100) Subject: :art: Imporve emit_except X-Git-Tag: nightly~2071 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=01ea5e42aff570d5c20f1862b75f3e38ec5dd5ef;p=gwion.git :art: Imporve emit_except --- diff --git a/include/opcode.h b/include/opcode.h index d8d57041..730c3f38 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -153,6 +153,7 @@ enum { eObjectAssign, eAssign, eObjectRelease, + eSetObj, eGWOP_EXCEPT, eAllocMember4, eDotMember, @@ -328,6 +329,7 @@ enum { #define ObjectAssign (f_instr)eObjectAssign #define Assign (f_instr)eAssign #define ObjectRelease (f_instr)eObjectRelease +#define SetObj (f_instr)eSetObj #define GWOP_EXCEPT (f_instr)eGWOP_EXCEPT #define AllocMember4 (f_instr)eAllocMember4 #define DotMember (f_instr)eDotMember diff --git a/opcode.txt b/opcode.txt index d3dea2a6..ac8fb174 100644 --- a/opcode.txt +++ b/opcode.txt @@ -150,6 +150,7 @@ RegAddRef ObjectAssign Assign ObjectRelease +SetObj GWOP_EXCEPT AllocMember4 DotMember diff --git a/src/emit/emit.c b/src/emit/emit.c index 7767359c..4894ed2d 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -477,6 +477,8 @@ ANN static inline m_bool _emit_indexes(const Emitter emit, struct ArrayAccessInf ANN void emit_except(const Emitter emit, const Type t) { if(!GET_FLAG(t, nonnull)) emit_add_instr(emit, GWOP_EXCEPT); + else + emit_add_instr(emit, SetObj); } ANN static inline m_bool tuple_index(const Emitter emit, struct ArrayAccessInfo *const info) { diff --git a/src/vm/vm.c b/src/vm/vm.c index 0c2fc5b8..fa3dd6ba 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -300,7 +300,7 @@ ANN void vm_run(const VM* vm) { // lgtm [cpp/use-of-goto] &&brancheqint, &&branchneint, &&brancheqfloat, &&branchnefloat, &&arrayappend, &&autoloop, &&autoloopptr, &&autoloopcount, &&arraytop, &&arrayaccess, &&arrayget, &&arrayaddr, &&arrayvalid, &&newobj, &&addref, &&objassign, &&assign, &&remref, - &&except, &&allocmemberaddr, &&dotmember, &&dotfloat, &&dotother, &&dotaddr, + &&setobj, &&except, &&allocmemberaddr, &&dotmember, &&dotfloat, &&dotother, &&dotaddr, &&staticint, &&staticfloat, &&staticother, &&dotfunc, &&dotstaticfunc, &&pushstaticcode, &&gcini, &&gcadd, &&gcend, @@ -733,6 +733,9 @@ assign: remref: release(*(M_Object*)(mem + VAL), shred); DISPATCH() +setobj: + a.obj = *(M_Object*)(reg-SZ_INT-VAL); + DISPATCH(); except: /* TODO: Refactor except instruction * * so that *