const Instr ex = (Instr)vector_back(&emit->code->instr);
if(ex->execute == fast_except) {
vector_rem(&emit->code->instr, vector_size(&emit->code->instr) - 1);
- if(ex->m_val2)
- mp_free2(emit->gwion->mp, sizeof(struct FastExceptInfo), (struct FastExceptInfo*)ex->m_val2);
free_instr(emit->gwion, ex);
}
}
const Instr instr = emit_add_instr(emit, HandleEffect);
instr->m_val2 = (m_uint)handler->xid;
CHECK_BB(scoped_stmt(emit, handler->stmt, 1));
- //if (handler->next) CHECK_BB(emit_handler_list(emit, handler->next, v));
emit_try_goto(emit, v);
instr->m_val = emit_code_size(emit);
}
VAL = -SZ_INT;
instr->opcode = eNoOp;
if(info) mp_free2(shred->info->mp, sizeof(struct FastExceptInfo), info);
+ instr->m_val2 = 0;
return;
} else if(info) {
if(info->file)
gwerr_basic("Object not instantiated", NULL, NULL, info->file, info->loc, 0);
if(info->file2)
gwerr_warn("declared here", NULL, NULL, info->file2, info->loc2);
- mp_free2(shred->info->mp, sizeof(struct FastExceptInfo), info);
+// mp_free2(shred->info->mp, sizeof(struct FastExceptInfo), info);
+// instr->m_val2 = 0;
}
handle(shred, "NullPtrException");
}
static FREEARG(freearg_xork) { vmcode_remref((VM_Code)instr->m_val, gwion); }
+static FREEARG(clean_fast_except) {
+ struct FastExceptInfo *info = (struct FastExceptInfo *)instr->m_val2;
+ if(info) mp_free2(((Gwion)gwion)->mp, sizeof(struct FastExceptInfo), info);
+}
+
GWION_IMPORT(xork) {
GWI_BB(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL))
GWI_BB(gwi_oper_add(gwi, opck_spork))
GWI_BB(gwi_oper_emi(gwi, opem_spork))
GWI_BB(gwi_oper_end(gwi, "fork", NULL))
gwi_register_freearg(gwi, SporkIni, freearg_xork);
+ gwi_register_freearg(gwi, fast_except, clean_fast_except);
return GW_OK;
}
}
ANN m_bool check_fptr_def(const Env env, const Fptr_Def fptr) {
- return check_class_def(env, fptr->cdef);
+ if(GET_FLAG(fptr->cdef, global)) env_push_global(env);
+ const m_bool ret = check_class_def(env, fptr->cdef);
+ if(GET_FLAG(fptr->cdef, global)) env_pop(env, 0);
+ return ret;
}
//#define check_fptr_def dummy_func
#include "import.h"
ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) {
- return scan1_class_def(env, fptr->cdef);
+ if(GET_FLAG(fptr->cdef, global))env_push_global(env);
+ const m_bool ret = scan1_class_def(env, fptr->cdef);
+ if(GET_FLAG(fptr->cdef, global)) env_pop(env, 0);
+ return ret;
}
ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) {
}
ANN m_bool scan2_fptr_def(const Env env NUSED, const Fptr_Def fptr) {
- CHECK_BB(scan2_class_def(env, fptr->cdef));
- const Func_Def fdef = mp_vector_at(fptr->cdef->body, struct Section_ , 0)->d.func_def;
+ if(GET_FLAG(fptr->cdef, global)) env_push_global(env);
+ const m_bool ret = scan2_class_def(env, fptr->cdef);
+ const Func_Def fdef = mp_vector_at(fptr->cdef->base.type->info->cdef->body, struct Section_ , 0)->d.func_def;
if(fdef->base->func) set_fflag(fdef->base->func, fflag_fptr);
- return GW_OK;
+ if(GET_FLAG(fptr->cdef, global)) env_pop(env, 0);
+ return ret;
}
ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f);
ANN static uint16_t find_pc(const VM_Shred shred, const Symbol effect, const m_uint size) {
const VM_Code code = shred->code;
- const m_uint start = VKEY(&shred->info->frame, size - 1);
+ const m_uint start = vector_at(&shred->info->frame, vector_size(&shred->info->frame) - 2);
if (start > shred->pc) return true;
const Map m = &shred->code->handlers;
for (m_uint i = 0; i < map_size(m); i++) {
}
ANN static inline bool find_handle(const VM_Shred shred, const Symbol effect, const m_uint size) {
- const m_uint start = VKEY(&shred->info->frame, size - 1);
- if (start > shred->pc) return true;
const uint16_t pc = find_pc(shred, effect, size);
- if (!pc) // outside of a try statement
- return false;
- // we should clean values here
+ if (!pc) return false; // outside of a try statement
shred->reg = // restore reg
(m_bit *)VPTR(&shred->info->frame, VLEN(&shred->info->frame) - 1);
shredule(shred->tick->shreduler, shred, 0);