return envset_run(&es, t);
}
+ANN static inline m_uint emit_code_size(const Emitter emit) {
+ return vector_size(&emit->code->instr);
+}
+
ANN static void emit_struct_ctor(const Emitter emit, const Type type, const m_uint offset) {
emit->code->frame->curr_offset += SZ_INT;
const Instr instr = emit_add_instr(emit, RegPushMem4);
const Instr prelude = emit_add_instr(emit, SetCode);
prelude->m_val = -SZ_INT*4;
prelude->udata.one = 2;
-// prelude->udata.two = emit_code_offset(emit) + SZ_INT + sizeof(frame_t);
const Instr next = emit_add_instr(emit, Overflow);
next->m_val2 = code_offset;
emit->code->frame->curr_offset -= SZ_INT;
emit_add_instr(emit, DebugPush);
}
-ANN static inline m_uint emit_code_size(const Emitter emit) {
- return vector_size(&emit->code->instr);
-}
-
ANN m_uint emit_code_offset(const Emitter emit) {
return emit->code->frame->curr_offset;
}
const Instr prelude = emit_add_instr(emit, SetCode);
prelude->m_val = -SZ_INT * 2;
prelude->udata.one = 2;
-// prelude->udata.two = emit_code_offset(emit) + SZ_INT + sizeof(frame_t);
emit_add_instr(emit, Reg2Mem);
const Instr next = emit_add_instr(emit, Overflow);
next->m_val2 = offset;
const Instr instr = emit_add_instr(emit, Recurs);
instr->m_val = SZ_INT;
instr->udata.one = 1;
+ instr->udata.two = emit_code_offset(emit) + sizeof(frame_t);
return instr;
}
ANN static Instr emit_call(const Emitter emit, const Func f, const bool is_static) {
const Instr prelude = get_prelude(emit, f, is_static);
prelude->m_val += -f->def->stack_depth - SZ_INT;
- prelude->udata.two = emit_code_offset(emit) + f->def->stack_depth + sizeof(frame_t);
const m_uint member = vflag(f->value_ref, vflag_member) ? SZ_INT : 0;
if(member) {
const Instr instr = emit_add_instr(emit, Reg2Mem);
*(unsigned*)byte = eOP_MAX;
*(f_instr*)(byte + SZ_INT*2) = ini;
*(unsigned*)(byte+ BYTECODE_SZ) = eSetCode;
-// *(m_uint*)(byte + BYTECODE_SZ + SZ_INT*2) = 3;
*(uint16_t*)(byte + BYTECODE_SZ + SZ_INT*2) = 3;
-// *(uint16_t*)(byte + BYTECODE_SZ + SZ_INT*2 + sizeof(uint16_t)) = sizeof(frame_t);
*(unsigned*)(byte+ BYTECODE_SZ*2) = eOverflow;
*(unsigned*)(byte+ BYTECODE_SZ*3) = eOP_MAX;
*(f_instr*)(byte + BYTECODE_SZ*3 + SZ_INT*2) = end;
PRAGMA_PUSH()
a.code = *(VM_Code*)(reg - SZ_INT);
if(!a.code->builtin) {
- register const uint push = *(m_uint*)reg + code->stack_depth + sizeof(frame_t);
+ register const uint push = *(m_uint*)reg /*+ code->stack_depth*/ + sizeof(frame_t);
mem += push;
*(frame_t*)(mem - sizeof(frame_t)) = (frame_t){ .code=code, .pc=PC+UVAL, .push=push };
next = eFuncUsrEnd;
} else {
- mem += *(m_uint*)reg /*- (code->stack_depth + */ /*- sizeof(frame_t)*/;
+ mem += *(m_uint*)reg;
next = eFuncMemberEnd;
}
PRAGMA_POP()