From: fennecdjay Date: Sun, 10 Mar 2019 11:01:51 +0000 (+0100) Subject: :art: Add dotstaticfunc X-Git-Tag: nightly~2753^2~16 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=afcb9fc23605a6d8cae2b02be0b8d767fa69fd22;p=gwion.git :art: Add dotstaticfunc --- diff --git a/include/opcode.h b/include/opcode.h index 93547db2..1e2579c3 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -148,6 +148,7 @@ enum { DotStatic2, DotStatic3, DotFunc, + DotStaticFunc, PushStaticCode, RegPushStr, GcIni, @@ -304,6 +305,7 @@ enum { #define DotStatic2 (f_instr)DotStatic2 #define DotStatic3 (f_instr)DotStatic3 #define DotFunc (f_instr)DotFunc +#define DotStaticFunc (f_instr)DotStaticFunc #define PushStaticCode (f_instr)PushStaticCode #define RegPushStr (f_instr)RegPushStr #define GcIni (f_instr)GcIni diff --git a/opcode.txt b/opcode.txt index 217f8ee0..1764f404 100644 --- a/opcode.txt +++ b/opcode.txt @@ -145,6 +145,7 @@ DotStatic DotStatic2 DotStatic3 DotFunc +DotStaticFunc PushStaticCode RegPushStr GcIni diff --git a/src/emit/emit.c b/src/emit/emit.c index 11677599..ddbc5dcd 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -763,7 +763,7 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { GWDEBUG_EXE push_func_code(emit, f); else { const Instr back = (Instr)vector_back(&emit->code->instr); - if((f_instr)(m_uint)back->opcode == DotFunc) + if((f_instr)(m_uint)back->opcode == DotFunc || (f_instr)(m_uint)back->opcode == DotStaticFunc) back->m_val = f->vt_index; } if(GET_FLAG(f, member) && isa(actual_type(f->value_ref->type), t_fptr) > 0) { @@ -1475,7 +1475,7 @@ ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, co return GW_OK; } if(!func->def->tmpl) { - const Instr func_i = emit_add_instr(emit, DotFunc); + const Instr func_i = emit_add_instr(emit, GET_FLAG(func, member) ? DotFunc : DotStaticFunc); func_i->m_val = func->vt_index; return GW_OK; } diff --git a/src/vm/vm.c b/src/vm/vm.c index 94d2ed56..a0897ebe 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -268,7 +268,7 @@ ANN void vm_run(const VM* vm) { /* lgtm [cpp/use-of-goto] */ &&addref, &&assign, &&remref, &&except, &&allocmemberaddr, &&dotmember, &&dotfloat, &&dotother, &&dotaddr, &&staticint, &&staticfloat, &&staticother, - &&dotfunc,&&staticcode, &&pushstr, + &&dotfunc, &&dotstaticfunc, &&staticcode, &&pushstr, &&gcini, &&gcadd, &&gcend, &&gack, &&other }; @@ -761,8 +761,9 @@ staticother: DISPATCH() dotfunc: assert(a.obj); - *(VM_Code*)(reg) = ((Func)vector_at(a.obj->vtable, instr->m_val))->code; reg += SZ_INT; +dotstaticfunc: + *(VM_Code*)(reg-SZ_INT) = ((Func)vector_at(a.obj->vtable, instr->m_val))->code; DISPATCH() staticcode: (*(VM_Code*)reg = ((Func)instr->m_val)->code);