-Subproject commit c63343d7bf486a47001f32d71b8160bf997ae4d2
+Subproject commit a196ff3fb91adc7c205c23fd4e07946073e5a308
Vec3 v;
Vec4 w;
Object o;
- dtor { <<< "dtor" >>>; }
+ operator @dtor void () { <<< "dtor" >>>; }
}
C c;
class C
{
- dtor {<<< 1 >>>;}
+ operator @dtor void () {<<< 1 >>>;}
}
C c;
ANN static m_bool prim_unpack(const Emitter emit NUSED, const Exp_Primary* primary) {
// TODO err_msg
- return primary->d.tuple.ok ? GW_OK : GW_ERROR;
+ return exp_self(primary)->emit_var ? GW_OK : GW_ERROR;
}
static const _exp_func prim_func[] = {
} else {
const Instr spork = emit_add_instr(emit, is_spork ? SporkExp : ForkEnd);
spork->m_val = exp_self(unary)->emit_var;
-// spork->m_val2 = f->def->base->ret_type->size;
+ if(!(spork->m_val = exp_self(unary)->emit_var))
+return NULL;// err_msg
}
} else {
if(GET_FLAG(f, member) && is_fptr(emit->gwion, f->value_ref->type)) {
} else
emit_exp_spork_finish(emit, f->def->stack_depth);
const Instr end = emit_add_instr(emit, is_spork ? SporkEnd : ForkEnd);
- end->m_val = exp_self(unary)->emit_var;
+ if(!is_spork && !(end->m_val = exp_self(unary)->emit_var))
+ return NULL;// err_msg
end->m_val2 = f->def->base->ret_type->size;
}
return ini;
}
ANN static void emit_func_def_code(const Emitter emit, const Func func) {
- func->code = finalyze(emit, !GET_FLAG(func->def, dtor) ? FuncReturn : DTOR_EOC);
- if(GET_FLAG(func->def, dtor)) {
+ const m_bool is_dtor = func->def->base->xid == insert_symbol("@dtor");// could be get flag
+ func->code = finalyze(emit, !is_dtor ? FuncReturn : DTOR_EOC);
+ if(is_dtor) {
emit->env->class_def->nspc->dtor = func->code;
ADD_REF(func->code)
- } else if(func->def->base->xid == insert_symbol("@gack")) {
+ } else if(func->def->base->xid == insert_symbol("@gack"))
emit->env->class_def->e->gack = func->code;
- ADD_REF(func->code)
- }
}
ANN static m_bool _fdef_body(const Emitter emit, const Func_Def fdef) {
}
++i;
} while((e = e->next));
- bin->rhs->d.exp_primary.d.tuple.ok = 1;
+ bin->rhs->emit_var = 1;
return bin->lhs->type;
}
return opck_at_object_tuple(env, data, mut);
CHECK_BB(env_storage(env, fdef->flag, td_pos(fdef->base->td)))
if(tmpl_base(fdef->base->tmpl))
return GW_OK;
- if(!env->class_def && (GET_FLAG(fdef, dtor) || fdef->base->xid == insert_symbol("@gack")))
- ERR_B(td_pos(fdef->base->td), _("'%s' must be in class def!!"), s_name(fdef->base->xid))
- if(GET_FLAG(fdef, op) && env->class_def)
+ if(fdef->base->xid == insert_symbol("@dtor") || fdef->base->xid == insert_symbol("@gack")) {
+ if(!env->class_def)
+ ERR_B(td_pos(fdef->base->td), _("'%s' must be in class def!!"), s_name(fdef->base->xid))
+ if(fdef->base->args)exit(3);
+ } else if(GET_FLAG(fdef, op) && env->class_def)
SET_FLAG(fdef, static);
struct Func_ fake = { .name=s_name(fdef->base->xid) }, *const former = env->func;
env->func = &fake;
const m_str str = s_name(f->base->xid);
const uint is_unary = GET_FLAG(f, unary) + (!strcmp(str, "@conditionnal") || !strcmp(str, "@unconditionnal"));
const Type l = is_unary ? NULL :
- f->base->args->var_decl->value->type;
- const Type r = is_unary ? f->base->args->var_decl->value->type :
+ f->base->args ? f->base->args->var_decl->value->type : NULL;
+ const Type r = f->base->args ? is_unary ? f->base->args->var_decl->value->type :
f->base->args->next ? f->base->args->next->var_decl->value->type :
- f->base->ret_type;
+ f->base->ret_type : NULL;
struct Op_Import opi = { .op=f->base->xid, .lhs=l, .rhs=r, .ret=f->base->ret_type,
.pos=f->pos, .data=(uintptr_t)f->base->func };
- if(!strcmp(str, "@implicit"))
+ if(!strcmp(str, "@implicit")) {
opi.ck = opck_usr_implicit;
+ }
CHECK_BB(add_op(env->gwion, &opi))
operator_set_func(&opi);
return GW_OK;
ANN static void scan2_func_def_flag(const Env env, const Func_Def f) {
if(!GET_FLAG(f, builtin))
SET_FLAG(f->base->func, pure);
- if(GET_FLAG(f, dtor)) {
+ if(f->base->xid == insert_symbol("@dtor"))
SET_FLAG(env->class_def, dtor);
- SET_FLAG(f->base->func, dtor);
- }
}
ANN static m_str func_tmpl_name(const Env env, const Func_Def f) {
-#! [contains] 'dtor' must be in class def!!
-dtor {}
+#! [contains] '@dtor' must be in class def!!
+operator @dtor void () {}
class <~A~>C {
- dtor { <<< __func__ >>>; }
+ operator @dtor void { <<< __func__ >>>; }
}
class <~A~>D extends <~A~>C {
- dtor { <<< __func__ >>>; }
+ operator @dtor { <<< __func__ >>>; }
}
class E extends <~int~>D {
- dtor { <<< __func__ >>>; }
+ operator @dtor { <<< __func__ >>>; }
}
E e;
#!<<< u.i >>>;
class <~A~>C extends <~A~>U {
fun void test() { <<< this >>>; }
- dtor { <<< __func__ >>>; }
+ operator @dtor void () { <<< __func__ >>>; }
}
<~float~>C c;