RegDup,
MemSetImm,
RegPop,
- RegPushPtr,
RegPushMe,
RegPushMaybe,
FuncReturn,
#define RegDup (f_instr)RegDup
#define MemSetImm (f_instr)MemSetImm
#define RegPop (f_instr)RegPop
-#define RegPushPtr (f_instr)RegPushPtr
#define RegPushMe (f_instr)RegPushMe
#define RegPushMaybe (f_instr)RegPushMaybe
#define FuncReturn (f_instr)FuncReturn
RegDup
MemSetImm
RegPop
-RegPushPtr
RegPushMe
RegPushMaybe
FuncReturn
_instr->m_val2 = strlen(c);
return GW_OK;
}
- const Instr instr = emit_add_instr(emit, RegPushPtr);
- return !!(instr->m_val = (m_uint)f->code);
+ const Instr _instr = (Instr)vector_back(&emit->code->instr);
+ if(_instr->opcode == (m_bit)(m_uint)RegPushImm)
+ return !!(_instr->m_val = (m_uint)f->code);
+ assert(_instr->opcode == (m_bit)(m_uint)RegPushBase);
+ _instr->m_val = (m_uint)f->code;
+ _instr->opcode = (m_bit)(m_uint)RegPushImm;
+ return GW_OK;
}
+
static m_bool emit_template_code(const Emitter emit, const Func f) {
if(GET_FLAG(f, ref))
CHECK_BB(traverse_template(emit->env, f->value_ref->owner_class->def))
emit_func_def_code(emit, func);
emit->env->func = former;
emit_pop_code(emit);
- if(!emit->env->class_def && !GET_FLAG(func_def, global))
+ if(!emit->env->class_def && !GET_FLAG(func_def, global) && !func_def->tmpl)
emit_func_def_global(emit, func->value_ref);
MEMOIZE_INI
return GW_OK;
}
ANN static m_bool check_call(const Env env, const Exp_Call* exp) {
+ ae_exp_t et = exp->func->exp_type;
+ if(et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast)
+ ERR_B(exp->func->pos, "invalid expression for function call.")
CHECK_OB(check_exp(env, exp->func))
return exp->args ? !!check_exp(env, exp->args) : -1;
}
Tmpl_Call tmpl = { .types=tl[0] };
const Exp_Call tmp_func = { .func=call, .args=args, .tmpl=&tmpl, .self=base };
const Func func = get_template_func(env, &tmp_func, base, value);
-//exit(2);
if(base->exp_type == ae_exp_call)
base->d.exp_call.m_func = func;
else // if(base->exp_type == ae_exp_binary)
&&baseint, &&basefloat, &&baseother, &&baseaddr,
&®dup,
&&memsetimm,
- &®pop, &®pushptr, &®pushme, &®pushmaybe,
+ &®pop, &®pushme, &®pushmaybe,
&&funcreturn,
&&_goto,
&&allocint, &&allocfloat, &&allocother, &&allocaddr,
regpop:
reg -= instr->m_val;
DISPATCH();
-regpushptr:
- *(m_uint*)(reg-SZ_INT) = instr->m_val;
- DISPATCH()
regpushme:
*(M_Object*)reg = shred->info->me;
reg += SZ_INT;
+// [contains] invalid expression for function call
template<~A~>
function void test(A a){}