return GW_OK;
}
-ANN static m_bool emit_stmt_if(const Emitter emit, const Stmt_If stmt) {
- emit_push_scope(emit);
- CHECK_BB(emit_exp(emit, stmt->cond, 0))
- DECL_OB(const Instr, op, = emit_flow(emit, isa(stmt->cond->type, t_object) > 0 ?
- t_int : stmt->cond->type, BranchEqInt, BranchEqFloat))
- CHECK_BB(scoped_stmt(emit, stmt->if_body, 1))
- const Instr op2 = emit_add_instr(emit, Goto);
- op->m_val = emit_code_size(emit);
- if(stmt->else_body)
- CHECK_BB(scoped_stmt(emit, stmt->else_body, 1))
- op2->m_val = emit_code_size(emit);
- emit_pop_scope(emit);
- return GW_OK;
-}
-
-ANN static m_bool emit_stmt_code(const Emitter emit, const Stmt_Code stmt) {
- ++emit->env->scope->depth;
- const m_bool ret = stmt->stmt_list ? emit_stmt_list(emit, stmt->stmt_list) : 1;
- --emit->env->scope->depth;
- return ret;
-}
-
-ANN static m_bool optimize_taill_call(const Emitter emit, const Exp_Call* e) {
- if(e->args) {
- CHECK_BB(emit_exp(emit, e->args, 0))
- regpop(emit, SZ_INT);
- emit_args(emit, e->m_func);
- }
- emit_add_instr(emit, Goto);
- return GW_OK;
-}
-
ANN static m_uint get_decl_size(Var_Decl_List a) {
m_uint size = 0;
do //if(GET_FLAG(a->self->value, used))
return GW_OK;
}
+ANN static m_bool emit_stmt_if(const Emitter emit, const Stmt_If stmt) {
+ emit_push_scope(emit);
+ CHECK_BB(emit_exp_pop_next(emit, stmt->cond))
+ DECL_OB(const Instr, op, = emit_flow(emit, isa(stmt->cond->type, t_object) > 0 ?
+ t_int : stmt->cond->type, BranchEqInt, BranchEqFloat))
+ CHECK_BB(scoped_stmt(emit, stmt->if_body, 1))
+ const Instr op2 = emit_add_instr(emit, Goto);
+ op->m_val = emit_code_size(emit);
+ if(stmt->else_body)
+ CHECK_BB(scoped_stmt(emit, stmt->else_body, 1))
+ op2->m_val = emit_code_size(emit);
+ emit_pop_scope(emit);
+ return GW_OK;
+}
+
+ANN static m_bool emit_stmt_code(const Emitter emit, const Stmt_Code stmt) {
+ ++emit->env->scope->depth;
+ const m_bool ret = stmt->stmt_list ? emit_stmt_list(emit, stmt->stmt_list) : 1;
+ --emit->env->scope->depth;
+ return ret;
+}
+
+ANN static m_bool optimize_taill_call(const Emitter emit, const Exp_Call* e) {
+ if(e->args) {
+ CHECK_BB(emit_exp(emit, e->args, 0))
+ regpop(emit, SZ_INT);
+ emit_args(emit, e->m_func);
+ }
+ emit_add_instr(emit, Goto);
+ return GW_OK;
+}
+
ANN static m_bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) {
if(stmt->val) {
if(stmt->val->exp_type == ae_exp_call && emit->env->func == stmt->val->d.exp_call.m_func)
ANN static inline Type get_base_type(const Env env, const Type t) {
const m_str decl_name = get_type_name(env, t->name, 0);
- return nspc_lookup_type1(env->curr, insert_symbol(decl_name));
+ const Type ret = nspc_lookup_type1(env->curr, insert_symbol(decl_name));
+ return !SAFE_FLAG(ret, nonnull) ? ret : ret->e->parent;
}
ANN static inline void type_contains(const Type base, const Type t) {
type_contains(base, decl_base); // NEEDED
type_contains(env->class_def, t);
if(decl_base->e->contains.ptr) {
- for(m_uint i = 0; i < vector_size(&t->e->contains); ++i) {
- if(env->class_def == (Type)vector_at(&t->e->contains, i) && !GET_FLAG(decl->td, ref))
+ for(m_uint i = 0; i < vector_size(&decl_base->e->contains); ++i) {
+ if(env->class_def == (Type)vector_at(&decl_base->e->contains, i) && !GET_FLAG(decl->td, ref))
ERR_B(exp_self(decl)->pos, _("%s declared inside %s\n. (make it a ref ?)"),
decl_base->name, decl_base == base ? "itself" : base->name);
}
ANN m_bool scanx_cdef(const Env env, void* opt, const Class_Def cdef,
const _exp_func f_cdef, const _exp_func f_union) {
- if(cdef->base.type->e->parent != t_union)
- return f_cdef(opt, cdef);
- CHECK_BB(template_push_types(env, cdef->base.tmpl))
- const m_bool ret = f_union(opt, cdef->union_def);
+ const Type t = get_type(cdef->base.type);
+ if(t->e->parent != t_union)
+ return f_cdef(opt, t->e->def);
+ CHECK_BB(template_push_types(env, t->e->def->base.tmpl))
+ const m_bool ret = f_union(opt, t->e->def->union_def);
nspc_pop_type(env->gwion->mp, env->curr);
return ret;
}