-Subproject commit b10c0fd3b94edab4cb7881f9454529ef536dc5c6
+Subproject commit 9dd3e3748de42cc3abe9006d5220b7aec821b612
ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) { GWDEBUG_EXE
if(lambda->def) {
- const m_uint scope = !lambda->owner ?
- emit->env->scope->depth : emit_push_type(emit, lambda->owner);
- CHECK_BB(emit_func_def(emit, lambda->def))
- const Instr instr = emit_add_instr(emit, RegPushImm);
- instr->m_val = (m_uint)lambda->def->func->code;
- if(lambda->owner)
- emit_pop(emit, scope);
+ const m_uint scope = !lambda->owner ?
+ emit->env->scope->depth : emit_push_type(emit, lambda->owner);
+ CHECK_BB(emit_func_def(emit, lambda->def))
+ if(GET_FLAG(lambda->def, member))
+ emit_add_instr(emit, RegPushMem);
+ const Instr instr = emit_add_instr(emit, RegPushImm);
+ instr->m_val = (m_uint)lambda->def->func->code;
+ if(lambda->owner)
+ emit_pop(emit, scope);
} else
emit_add_instr(emit, RegPushImm);
return GW_OK;
const Instr instr = emit_add_instr(emit, RegAddRef);
instr->m_val = exp->emit_var;
}
- if(emit->env->func && isa(exp->type, t_function) > 0 &&
+ if(emit->env->func && isa(exp->type, t_lambda) < 0 && isa(exp->type, t_function) > 0 &&
!GET_FLAG(exp->type->d.func->value_ref->d.func_ref, pure))
UNSET_FLAG(emit->env->func, pure);
} while((exp = exp->next));
const m_bool match = (specific ? e->type == t : isa(e->type, t) > 0) &&
e->type->array_depth == t->array_depth &&
array_base(e->type) == array_base(t);
- if(!match) {
- if(e->type == t_lambda && isa(t, t_fptr) > 0) {
- const Type owner = nspc_lookup_type1(t->owner->parent,
- insert_symbol(t->owner->name));
- return check_lambda(env, owner, &e->d.exp_lambda, t->d.func->def);
+ if(!match) {
+ if(e->type == t_lambda && isa(t, t_fptr) > 0) {
+ const Type owner = nspc_lookup_type1(t->owner->parent,
+ insert_symbol(t->owner->name));
+ return check_lambda(env, owner, &e->d.exp_lambda, t->d.func->def);
+ }
+ if(implicit) {
+ const struct Implicit imp = { e, t };
+ struct Op_Import opi = { .op=op_impl, .lhs=e->type, .rhs=t, .data=(m_uint)&imp };
+ return op_check(env, &opi) ? 1 : -1;
}
}
- if(implicit) {
- const struct Implicit imp = { e, t };
- struct Op_Import opi = { .op=op_impl, .lhs=e->type, .rhs=t, .data=(m_uint)&imp };
- return op_check(env, &opi) ? 1 : -1;
- }
return match ? 1 : -1;
}
ERR_O(exp->self->pos, "argument number does not match for lambda")
l->def = new_func_def(NULL, l->name, l->arg, l->code, 0);
CHECK_BO(traverse_func_def(env, l->def))
+ if(env->class_def)
+ SET_FLAG(l->def, member);
set_call(exp->self, l->def->func);
return l->def->ret_type ?: (l->def->ret_type = t_void);
}
Exp curr = exp;
do {
CHECK_OO((curr->type = exp_func[curr->exp_type](env, &curr->d)))
- if(env->func && isa(curr->type, t_function) > 0 && !GET_FLAG(curr->type->d.func, pure))
+ if(env->func && isa(curr->type, t_lambda) < 0 && isa(curr->type, t_function) > 0 &&
+ !GET_FLAG(curr->type->d.func, pure))
UNSET_FLAG(env->func, pure);
} while((curr = curr->next));
return exp->type;
Except(shred, "StackOverflow");
shred->mem = m;
shred->pc = pc;
+ shred->code = code;
if(GET_FLAG(a.code, ctor)) {
register const f_xtor f = (f_xtor)a.code->native_func;
f(*(M_Object*)m, NULL, shred);// callnat
register const f_sfun f = (f_sfun)a.code->native_func;
f(reg, shred);
funcend:
- reg += instr->m_val;
+ shred->reg = reg += instr->m_val;
funcend2:
shred->mem = mem;
if(!s->curr)break;
a.child->reg += instr->m_val;
DISPATCH()
sporkthis:
- *(M_Object*)a.child->reg = *(M_Object*)(reg + instr->m_val);
+ *(M_Object*)a.child->reg = *(M_Object*)(reg -SZ_INT + instr->m_val);
a.child->reg += SZ_INT;
DISPATCH()
sporkexp:
// [contains] argument number does not match for lambda
-`a b`{ <<<a, " ", b>>>; }(1);
+\a b { <<<a, " ", b>>>; }(1);
// [contains] argument number does not match for lambda
typedef void ptr_t(int i);
-`a b`{ <<<a, " ", b>>>; } @=> ptr_t ptr;
+\a b { <<<a, " ", b>>>; } @=> ptr_t ptr;
ptr(2);
// [contains] argument number does not match for lambda
typedef void ptr_t(int i);
-`a b`{ <<<a, " ", b>>>; } @=> ptr_t ptr;
+\a b { <<<a, " ", b>>>; } @=> ptr_t ptr;
fun void test(ptr_t ptr) {
ptr(2);
}
class C {
typedef void ptr_t(int i,int j);
- `a b` { <<<this, " ", a, " ", b, " test">>>; } @=> ptr_t ptr;
+ \a b { <<<this, " ", a, " ", b, " test">>>; } @=> ptr_t ptr;
// `a,b` { <<<"test">>>; } @=>
// ptr_t ptr;
// ptr(1,2);
class C {
typedef void ptr_t(int i);
-`a` { <<<this, " ", a>>>; } @=>
+\a { <<<this, " ", a>>>; } @=>
ptr_t ptr;
//ptr(3);
fun void t1(int i) { <<<this, " t1 ", i>>>; }
12 => int i;
-`a b` { <<<"i: ", i, " ", a, " ", b>>>; }(1,2);
+\a b { <<<"i: ", i, " ", a, " ", b>>>; }(1,2);
-Subproject commit fa9f700bb617e6368150c9a29ffac4c6d5256d2d
+Subproject commit 55e2a6ba6d382f8dcb27661773df82de5fe9c470