-Subproject commit 195d19f71c7a10ffb7964d0727746640e344ddba
+Subproject commit 0edd66928516857b57cd1a8878197bb84eb6a08c
#define DECL_SECTION_FUNC(prefix) \
static const _exp_func section_func[] = { \
(_exp_func)prefix##_stmt_list, (_exp_func)prefix##_func_def, (_exp_func)prefix##_class_def, \
- (_exp_func)prefix##_enum_def, (_exp_func)prefix##_union_def \
+ (_exp_func)prefix##_enum_def, (_exp_func)prefix##_union_def, \
+ (_exp_func)prefix##_fptr_def, (_exp_func)prefix##_type_def \
}; \
ANN static inline m_bool prefix##_section(const void* a, /* const */ Section* section) { GWDEBUG_EXE \
void* d = §ion->d.stmt_list; \
ANN m_bool traverse_func_def(const Env, const Func_Def);
ANN m_bool traverse_union_def(const Env, const Union_Def);
ANN m_bool traverse_enum_def(const Env, const Enum_Def);
-ANN m_bool traverse_stmt_fptr(const Env, const Stmt_Fptr );
-ANN m_bool traverse_stmt_type(const Env env, const Stmt_Type def);
+ANN m_bool traverse_fptr_def(const Env, const Fptr_Def);
+ANN m_bool traverse_type_def(const Env env, const Type_Def);
ANN m_bool traverse_decl(const Env, const Exp_Decl*);
ANN m_bool scan0_ast(const Env, Ast);
ANN m_bool scan2_func_def(const Env, const Func_Def);
ANN m_bool check_func_def(const Env, const Func_Def);
-ANN m_bool scan0_stmt_fptr(const Env, const Stmt_Fptr);
-ANN m_bool scan1_stmt_fptr(const Env, const Stmt_Fptr);
-ANN m_bool scan2_stmt_fptr(const Env, const Stmt_Fptr);
-//ANN m_bool check_stmt_fptr(const Env, const Stmt_Fptr);
+ANN m_bool scan0_fptr_def(const Env, const Fptr_Def);
+ANN m_bool scan1_fptr_def(const Env, const Fptr_Def);
+ANN m_bool scan2_fptr_def(const Env, const Fptr_Def);
+//ANN m_bool check_fptr_def(const Env, const Fptr);
ANN m_bool scan0_union_def(const Env, const Union_Def);
ANN m_bool scan1_union_def(const Env, const Union_Def);
//ANN m_bool scan2_enum_def(const Env, const Enum_Def);
ANN m_bool check_enum_def(const Env, const Enum_Def);
-ANN m_bool scan0_stmt_type(const Env, const Stmt_Type);
-ANN m_bool scan1_stmt_type(const Env, const Stmt_Type);
-ANN m_bool scan2_stmt_type(const Env, const Stmt_Type);
-ANN m_bool check_stmt_type(const Env, const Stmt_Type);
+ANN m_bool scan0_type_def(const Env, const Type_Def);
+ANN m_bool scan1_type_def(const Env, const Type_Def);
+ANN m_bool scan2_type_def(const Env, const Type_Def);
+ANN m_bool check_type_def(const Env, const Type_Def);
ANN m_bool scan0_class_def(const Env, const Class_Def);
ANN m_bool scan1_class_def(const Env, const Class_Def);
return GW_OK;
}
-ANN static m_bool emit_stmt_type(const Emitter emit, const Stmt_Type stmt) {
- return stmt->type->e->def ? emit_class_def(emit, stmt->type->e->def) : 1;
+ANN static m_bool emit_type_def(const Emitter emit, const Type_Def tdef) {
+ return tdef->type->e->def ? emit_class_def(emit, tdef->type->e->def) : 1;
}
ANN static m_bool emit_enum_def(const Emitter emit, const Enum_Def edef) {
(_exp_func)emit_stmt_if, (_exp_func)emit_stmt_code, (_exp_func)emit_stmt_switch,
(_exp_func)emit_stmt_break, (_exp_func)emit_stmt_continue, (_exp_func)emit_stmt_return,
(_exp_func)emit_stmt_case, (_exp_func)emit_stmt_jump,
- (_exp_func)dummy_func, (_exp_func)emit_stmt_type
};
ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) {
return GW_OK;
}
+#define emit_fptr_def dummy_func
DECL_SECTION_FUNC(emit)
ANN Code* emit_class_code(const Emitter emit, const m_str name) {
return GW_OK;
}
-ANN static Stmt import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) {
+ANN static Fptr_Def import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) {
const Env env = gwi->gwion->env;
m_uint array_depth;
ID_List type_path;
!(type_decl = new_type_decl(env->gwion->mp, type_path)))
GWI_ERR_O(_(" ... during fptr import '%s' (type)."), dl_fun->name);
Func_Base *base = new_func_base(env->gwion->mp, type_decl, insert_symbol(env->gwion->st, dl_fun->name), args);
- return new_stmt_fptr(env->gwion->mp, base, flag);
+ return new_fptr_def(env->gwion->mp, base, flag);
}
ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
- const Stmt stmt = import_fptr(gwi, &gwi->func, flag);
- CHECK_BO(traverse_stmt_fptr(gwi->gwion->env, &stmt->d.stmt_fptr))
+ const Fptr_Def fptr = import_fptr(gwi, &gwi->func, flag);
+ CHECK_BO(traverse_fptr_def(gwi->gwion->env, fptr))
if(gwi->gwion->env->class_def)
- SET_FLAG(stmt->d.stmt_fptr.base->func->def, builtin);
+ SET_FLAG(fptr->base->func->def, builtin);
else
- SET_FLAG(stmt->d.stmt_fptr.base->func, builtin);
- const Type t = stmt->d.stmt_fptr.type;
- free_stmt(gwi->gwion->mp, stmt);
+ SET_FLAG(fptr->base->func, builtin);
+ const Type t = fptr->type;
+ free_fptr_def(gwi->gwion->mp, fptr);
return t;
}
GWI_ERR_O(_("'%s' : invalid type"), gwi->val.type);
td->flag |= flag;
const Symbol sym = insert_symbol(gwi->gwion->st, gwi->val.name);
- const Stmt stmt = new_stmt_type(gwi->gwion->mp, td, sym);
- traverse_stmt_type(gwi->gwion->env, &stmt->d.stmt_type);
- const Type t = stmt->d.stmt_type.type;
- free_stmt(gwi->gwion->mp, stmt);
+ const Type_Def tdef = new_type_def(gwi->gwion->mp, td, sym);
+ traverse_type_def(gwi->gwion->env, tdef);
+ const Type t = tdef->type;
+ free_type_def(gwi->gwion->mp, tdef);
return t;
}
fbase->tmpl->base = 0;
fbase->tmpl->call = types;
if(template_push_types(env, fbase->tmpl) > 0) {
- const Stmt stmt = new_stmt_fptr(env->gwion->mp, fbase, base->flag);
+ const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase, base->flag);
if(value) {
- stmt->d.stmt_fptr.type = actual_type(value->type);
- stmt->d.stmt_fptr.value = value;
+ fptr->type = actual_type(value->type);
+ fptr->value = value;
}
- if(traverse_stmt_fptr(env, &stmt->d.stmt_fptr) > 0 &&
+ if(traverse_fptr_def(env, fptr) > 0 &&
(base->base->ret_type = known_type(env, base->base->td)) &&
(!exp->args || !!check_exp(env, exp->args))) {
m_func = find_func_match(env, fbase->func, exp->args);
map_set(&v->owner->info->type->map, (vtype)sym, (vtype)actual_type(m_func->value_ref->type));
}
}
- free_stmt(env->gwion->mp, stmt);
+ free_fptr_def(env->gwion->mp, fptr);
}
} else {
for(m_uint i = 0; i < v->offset + 1; ++i) {
return value->type;
}
-ANN m_bool check_stmt_type(const Env env, const Stmt_Type stmt) {
- return stmt->type->e->def ? check_class_def(env, stmt->type->e->def) : GW_OK;
+ANN m_bool check_type_def(const Env env, const Type_Def tdef) {
+ return tdef->type->e->def ? check_class_def(env, tdef->type->e->def) : GW_OK;
}
ANN static Type check_exp_lambda(const Env env NUSED,
const Exp_If* exp_if NUSED) { return t_lambda; }
(_exp_func)check_stmt_if, (_exp_func)check_stmt_code, (_exp_func)check_stmt_switch,
(_exp_func)check_stmt_break, (_exp_func)check_stmt_continue, (_exp_func)check_stmt_return,
(_exp_func)check_stmt_case, (_exp_func)check_stmt_jump,
- (_exp_func)dummy_func, (_exp_func)check_stmt_type
};
ANN m_bool check_stmt(const Env env, const Stmt stmt) {
return ret;
}
+#define check_fptr_def dummy_func
DECL_SECTION_FUNC(check)
ANN static m_bool check_class_parent(const Env env, const Class_Def cdef) {
a->else_body = cpy_stmt(p, src->else_body);
}
-ANN static void cpy_stmt_jump(MemPool p, const Stmt_Jump a,const Stmt_Jump src) {
+ANN static void cpy_stmt_jump(MemPool p NUSED, const Stmt_Jump a,const Stmt_Jump src) {
a->name = src->name;
}
return a;
}
-ANN static void cpy_stmt_fptr(MemPool p, Stmt_Fptr a, const Stmt_Fptr src) {
+ANN static Fptr_Def cpy_fptr_def(MemPool p, const Fptr_Def src) {
+ Fptr_Def a = mp_calloc(p, Fptr_Def);
a->base = cpy_func_base(p, src->base);
+ return a;
}
-ANN static void cpy_stmt_type(MemPool p, Stmt_Type a, const Stmt_Type src) {
+ANN static void cpy_type_def2(MemPool p, Type_Def a, const Type_Def src) {
if(src->ext)
a->ext = cpy_type_decl(p, src->ext);
a->xid = src->xid;
a->tmpl = cpy_tmpl(p, src->tmpl);
}
+ANN static Type_Def cpy_type_def(MemPool p, const Type_Def src) {
+ Type_Def a = mp_calloc(p, Type_Def);
+ cpy_type_def2(p, a, src);
+ return a;
+}
+
ANN static Union_Def cpy_union_def(MemPool p, const Union_Def src) {
Union_Def a = mp_calloc(p, Union_Def);
a->l = cpy_decl_list(p, src->l); // 1
switch(src->stmt_type) {
case ae_stmt_case:
case ae_stmt_exp:
- if(src->d.stmt_exp.val)
- a->d.stmt_exp.val = cpy_exp(p, src->d.stmt_exp.val);
-
-// cpy_stmt_exp(p, &a->d.stmt_exp, &src->d.stmt_exp);
- break;
case ae_stmt_return:
- if(&src->d.stmt_exp)
- cpy_stmt_exp(p, &a->d.stmt_exp, &src->d.stmt_exp);
+ cpy_stmt_exp(p, &a->d.stmt_exp, &src->d.stmt_exp);
break;
case ae_stmt_code:
cpy_stmt_code(p, &a->d.stmt_code, &src->d.stmt_code);
case ae_stmt_switch:
cpy_stmt_switch(p, &a->d.stmt_switch, &src->d.stmt_switch);
break;
- case ae_stmt_fptr:
- cpy_stmt_fptr(p, &a->d.stmt_fptr, &src->d.stmt_fptr);
- break;
- case ae_stmt_type:
- cpy_stmt_type(p, &a->d.stmt_type, &src->d.stmt_type);
- break;
case ae_stmt_break:
case ae_stmt_continue:
break;
case ae_section_union:
a->d.union_def = cpy_union_def(p, src->d.union_def);
break;
+ case ae_section_fptr:
+ a->d.fptr_def = cpy_fptr_def(p, src->d.fptr_def);
+ break;
+ case ae_section_type:
+ a->d.type_def = cpy_type_def(p, src->d.type_def);
+ break;
}
a->section_type = src->section_type;
return a;
ANN Class_Def cpy_class_def(MemPool p, const Class_Def src) {
Class_Def a = mp_calloc(p, Class_Def);
- cpy_stmt_type(p, &a->base, &src->base);
+ cpy_type_def2(p, &a->base, &src->base);
if(src->body) {
if(!GET_FLAG(src, union))
a->body = cpy_class_body(p, src->body);
return already_defined(env, s, pos);
}
-static void fptr_def(const Env env, const Stmt_Fptr stmt) {
- const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, stmt->base->td, stmt->base->xid, stmt->base->args),
- NULL,stmt->base->td->flag, loc_cpy(env->gwion->mp, stmt_self(stmt)->pos));
- stmt->base->func = new_func(env->gwion->mp, s_name(stmt->base->xid), def);
- stmt->value->d.func_ref = stmt->base->func;
- stmt->base->func->value_ref = stmt->value;
- stmt->type->e->d.func = stmt->base->func;
- def->base->tmpl = stmt->base->tmpl;
- def->base->func = stmt->base->func;
+static void fptr_def(const Env env, const Fptr_Def fptr) {
+ const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, fptr->base->td, fptr->base->xid, fptr->base->args),
+ NULL,fptr->base->td->flag, loc_cpy(env->gwion->mp, td_pos(fptr->base->td)));
+ fptr->base->func = new_func(env->gwion->mp, s_name(fptr->base->xid), def);
+ fptr->value->d.func_ref = fptr->base->func;
+ fptr->base->func->value_ref = fptr->value;
+ fptr->type->e->d.func = fptr->base->func;
+ def->base->tmpl = fptr->base->tmpl;
+ def->base->func = fptr->base->func;
}
-ANN m_bool scan0_stmt_fptr(const Env env, const Stmt_Fptr stmt) {
- CHECK_BB(env_access(env, stmt->base->td->flag, stmt_self(stmt)->pos))
- CHECK_BB(scan0_defined(env, stmt->base->xid, td_pos(stmt->base->td)));
- const m_str name = s_name(stmt->base->xid);
+ANN m_bool scan0_fptr_def(const Env env, const Fptr_Def fptr) {
+ CHECK_BB(env_access(env, fptr->base->td->flag, td_pos(fptr->base->td)))
+ CHECK_BB(scan0_defined(env, fptr->base->xid, td_pos(fptr->base->td)));
+ const m_str name = s_name(fptr->base->xid);
const Type t = new_type(env->gwion->mp, t_fptr->xid, name, t_fptr);
- t->e->owner = !(!env->class_def && GET_FLAG(stmt->base->td, global)) ?
+ t->e->owner = !(!env->class_def && GET_FLAG(fptr->base->td, global)) ?
env->curr : env->global_nspc;
t->nspc = new_nspc(env->gwion->mp, name);
- t->flag = stmt->base->td->flag;
- stmt->type = t;
- stmt->value = mk_class(env, t);
- stmt->value->owner = env->curr;
- stmt->value->owner_class = env->class_def;
- fptr_def(env, stmt);
+ t->flag = fptr->base->td->flag;
+ fptr->type = t;
+ fptr->value = mk_class(env, t);
+ fptr->value->owner = env->curr;
+ fptr->value->owner_class = env->class_def;
+ fptr_def(env, fptr);
if(env->class_def)
- fptr_assign(env, stmt);
- SET_FLAG(stmt->value, func);
+ fptr_assign(env, fptr);
+ SET_FLAG(fptr->value, func);
add_type(env, t->e->owner, t);
return GW_OK;
}
-ANN static void typedef_simple(const Env env, const Stmt_Type stmt, const Type base) {
- const Type t = new_type(env->gwion->mp, ++env->scope->type_xid, s_name(stmt->xid), base);
+ANN static void typedef_simple(const Env env, const Type_Def tdef, const Type base) {
+ const Type t = new_type(env->gwion->mp, ++env->scope->type_xid, s_name(tdef->xid), base);
t->size = base->size;
- const Nspc nspc = (!env->class_def && GET_FLAG(stmt->ext, global)) ?
+ const Nspc nspc = (!env->class_def && GET_FLAG(tdef->ext, global)) ?
env->global_nspc : env->curr;
add_type(env, nspc, t);
t->e->owner = nspc;
- stmt->type = t;
+ tdef->type = t;
if(base->nspc)
ADD_REF((t->nspc = base->nspc));
- t->flag = stmt->ext->flag | ae_flag_checked;
- if(stmt->ext->array && !stmt->ext->array->exp)
+ t->flag = tdef->ext->flag | ae_flag_checked;
+ if(tdef->ext->array && !tdef->ext->array->exp)
SET_FLAG(t, empty);
}
-ANN static m_bool typedef_complex(const Env env, const Stmt_Type stmt, const Type base) {
+ANN static m_bool typedef_complex(const Env env, const Type_Def tdef, const Type base) {
const ae_flag flag = base->e->def ? base->e->def->flag : 0;
- const Class_Def cdef = new_class_def(env->gwion->mp, flag, stmt->xid, stmt->ext, NULL,
- loc_cpy(env->gwion->mp, td_pos(stmt->ext)));
+ const Class_Def cdef = new_class_def(env->gwion->mp, flag, tdef->xid, tdef->ext, NULL,
+ loc_cpy(env->gwion->mp, td_pos(tdef->ext)));
CHECK_BB(scan0_class_def(env, cdef))
- stmt->type = cdef->base.type;
- cdef->base.tmpl = stmt->tmpl;
+ tdef->type = cdef->base.type;
+ cdef->base.tmpl = tdef->tmpl;
return GW_OK;
}
-ANN static void typedef_fptr(const Env env, const Stmt_Type stmt, const Type base) {
- stmt->type = type_copy(env->gwion->mp, base);
- stmt->type->name = s_name(stmt->xid);
- stmt->type->e->parent = base;
- add_type(env, env->curr, stmt->type);
- mk_class(env, stmt->type);
+ANN static void typedef_fptr(const Env env, const Type_Def tdef, const Type base) {
+ tdef->type = type_copy(env->gwion->mp, base);
+ tdef->type->name = s_name(tdef->xid);
+ tdef->type->e->parent = base;
+ add_type(env, env->curr, tdef->type);
+ mk_class(env, tdef->type);
if(base->e->d.func->def->base->tmpl)
- SET_FLAG(stmt->type, func);
+ SET_FLAG(tdef->type, func);
}
-ANN m_bool scan0_stmt_type(const Env env, const Stmt_Type stmt) {
- CHECK_BB(env_access(env, stmt->ext->flag, stmt_self(stmt)->pos))
- DECL_OB(const Type, base, = stmt->tmpl ? find_type(env, stmt->ext->xid) : known_type(env, stmt->ext))
- CHECK_BB(scan0_defined(env, stmt->xid, td_pos(stmt->ext)))
+ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) {
+ CHECK_BB(env_access(env, tdef->ext->flag, td_pos(tdef->ext)))
+ DECL_OB(const Type, base, = tdef->tmpl ? find_type(env, tdef->ext->xid) : known_type(env, tdef->ext))
+ CHECK_BB(scan0_defined(env, tdef->xid, td_pos(tdef->ext)))
if(isa(base, t_function) < 0) {
- if(!stmt->ext->types && (!stmt->ext->array || !stmt->ext->array->exp))
- typedef_simple(env, stmt, base);
+ if(!tdef->ext->types && (!tdef->ext->array || !tdef->ext->array->exp))
+ typedef_simple(env, tdef, base);
else
- CHECK_BB(typedef_complex(env, stmt, base))
+ CHECK_BB(typedef_complex(env, tdef, base))
} else
- typedef_fptr(env, stmt, base);
- SET_FLAG(stmt->type, typedef);
+ typedef_fptr(env, tdef, base);
+ SET_FLAG(tdef->type, typedef);
return GW_OK;
}
return GW_OK;
}
-ANN static m_bool scan0_stmt_switch(const Env env, const Stmt_Switch stmt);
-ANN static m_bool scan0_stmt_code(const Env env, const Stmt_Code stmt);
-ANN static m_bool scan0_stmt(const Env env, const Stmt stmt) {
- if(stmt->stmt_type == ae_stmt_fptr)
- return scan0_stmt_fptr(env, &stmt->d.stmt_fptr);
- if(stmt->stmt_type == ae_stmt_type)
- return scan0_stmt_type(env, &stmt->d.stmt_type);
- if(stmt->stmt_type == ae_stmt_code)
- return scan0_stmt_code(env, &stmt->d.stmt_code);
- if(stmt->stmt_type == ae_stmt_switch)
- return scan0_stmt_switch(env, &stmt->d.stmt_switch);
- return GW_OK;
-}
-
-ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l);
-ANN static m_bool scan0_stmt_switch(const Env env, const Stmt_Switch stmt) {
- return scan0_stmt(env, stmt->stmt);
-}
-ANN static m_bool scan0_stmt_code(const Env env, const Stmt_Code stmt) {
- return stmt->stmt_list ? scan0_stmt_list(env, stmt->stmt_list) : GW_OK;
-}
-
-ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) {
- do CHECK_BB(scan0_stmt(env, l->stmt))
- while((l = l->next));
- return GW_OK;
-}
ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def cdef) {
CHECK_BB(env_storage(env, cdef->flag, cdef->pos))
return t;
}
-ANN static m_bool scan0_func_def(const Env env, const Func_Def fdef) {
- return fdef->d.code ? scan0_stmt(env, fdef->d.code) : GW_OK;
-}
-
ANN static m_bool scan0_section(const Env env, const Section* section) {
- if(section->section_type == ae_section_stmt)
- return scan0_stmt_list(env, section->d.stmt_list);
if(section->section_type == ae_section_class)
return scan0_class_def(env, section->d.class_def);
- if(section->section_type == ae_section_func)
- return scan0_func_def(env, section->d.func_def);
if(section->section_type == ae_section_enum)
return scan0_enum_def(env, section->d.enum_def);
if(section->section_type == ae_section_union)
return scan0_union_def(env, section->d.union_def);
+ if(section->section_type == ae_section_fptr)
+ return scan0_fptr_def(env, section->d.fptr_def);
+ if(section->section_type == ae_section_type)
+ return scan0_type_def(env, section->d.type_def);
return GW_OK;
}
return GW_OK;
}
-ANN m_bool scan1_stmt_fptr(const Env env, const Stmt_Fptr stmt) {
- if(!stmt->type)
- CHECK_BB(scan0_stmt_fptr(env, stmt))
- if(tmpl_base(stmt->base->tmpl))
+ANN m_bool scan1_fptr_def(const Env env, const Fptr_Def fptr) {
+ if(tmpl_base(fptr->base->tmpl))
return GW_OK;
- CHECK_OB((stmt->base->ret_type = known_type(env, stmt->base->td)))
- return stmt->base->args ? scan1_args(env, stmt->base->args) : GW_OK;
+ CHECK_OB((fptr->base->ret_type = known_type(env, fptr->base->td)))
+ return fptr->base->args ? scan1_args(env, fptr->base->args) : GW_OK;
}
-ANN m_bool scan1_stmt_type(const Env env, const Stmt_Type stmt) {
- if(!stmt->type)
- CHECK_BB(scan0_stmt_type(env, stmt))
- return stmt->type->e->def ? scan1_cdef(env, stmt->type->e->def) : GW_OK;
+ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) {
+ return tdef->type->e->def ? scan1_cdef(env, tdef->type->e->def) : GW_OK;
}
ANN m_bool scan1_union_def(const Env env, const Union_Def udef) {
(_exp_func)scan1_stmt_for, (_exp_func)scan1_stmt_auto, (_exp_func)scan1_stmt_loop,
(_exp_func)scan1_stmt_if, (_exp_func)scan1_stmt_code, (_exp_func)scan1_stmt_switch,
(_exp_func)dummy_func, (_exp_func)dummy_func, (_exp_func)scan1_stmt_exp,
- (_exp_func)scan1_stmt_case, (_exp_func)dummy_func,
- (_exp_func)scan1_stmt_fptr, (_exp_func)scan1_stmt_type,
+ (_exp_func)scan1_stmt_case, (_exp_func)dummy_func
};
ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) {
}
-ANN void fptr_assign(const Env env, const Stmt_Fptr ptr) {
- const Func_Def def = ptr->type->e->d.func->def;
- if(GET_FLAG(ptr->base->td, global)) {
- SET_FLAG(ptr->value, global);
- SET_FLAG(ptr->base->func, global);
+ANN void fptr_assign(const Env env, const Fptr_Def fptr) {
+ const Func_Def def = fptr->type->e->d.func->def;
+ if(GET_FLAG(fptr->base->td, global)) {
+ SET_FLAG(fptr->value, global);
+ SET_FLAG(fptr->base->func, global);
SET_FLAG(def, global);
- } else if(!GET_FLAG(ptr->base->td, static)) {
- SET_FLAG(ptr->value, member);
- SET_FLAG(ptr->base->func, member);
+ } else if(!GET_FLAG(fptr->base->td, static)) {
+ SET_FLAG(fptr->value, member);
+ SET_FLAG(fptr->base->func, member);
SET_FLAG(def, member);
def->stack_depth += SZ_INT;
} else {
- SET_FLAG(ptr->value, static);
- SET_FLAG(ptr->base->func, static);
+ SET_FLAG(fptr->value, static);
+ SET_FLAG(fptr->base->func, static);
SET_FLAG(def, static);
}
if(GET_FLAG(def, variadic))
def->stack_depth += SZ_INT;
- ptr->value->owner_class = env->class_def;
+ fptr->value->owner_class = env->class_def;
}
-ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) {
- const Func_Def def = ptr->type->e->d.func->def;
- if(!tmpl_base(ptr->base->tmpl)) {
- def->base->ret_type = ptr->base->ret_type;
- if(ptr->base->args)
+ANN m_bool scan2_fptr_def(const Env env, const Fptr_Def fptr) {
+ const Func_Def def = fptr->type->e->d.func->def;
+ if(!tmpl_base(fptr->base->tmpl)) {
+ def->base->ret_type = fptr->base->ret_type;
+ if(fptr->base->args)
CHECK_BB(scan2_args(env, def))
} else
- SET_FLAG(ptr->type, func);
- nspc_add_func(ptr->type->e->owner, ptr->base->xid, ptr->base->func);
+ SET_FLAG(fptr->type, func);
+ nspc_add_func(fptr->type->e->owner, fptr->base->xid, fptr->base->func);
return GW_OK;
}
-ANN m_bool scan2_stmt_type(const Env env, const Stmt_Type stmt) {
- return stmt->type->e->def ? scan2_class_def(env, stmt->type->e->def) : GW_OK;
+ANN m_bool scan2_type_def(const Env env, const Type_Def tdef) {
+ return tdef->type->e->def ? scan2_class_def(env, tdef->type->e->def) : GW_OK;
}
ANN static inline Value prim_value(const Env env, const Symbol s) {
(_exp_func)scan2_stmt_for, (_exp_func)scan2_stmt_auto, (_exp_func)scan2_stmt_loop,
(_exp_func)scan2_stmt_if, (_exp_func)scan2_stmt_code, (_exp_func)scan2_stmt_switch,
(_exp_func)dummy_func, (_exp_func)dummy_func, (_exp_func)scan2_stmt_exp,
- (_exp_func)scan2_stmt_case, (_exp_func)scan2_stmt_jump,
- (_exp_func)scan2_stmt_fptr, (_exp_func)scan2_stmt_type,
+ (_exp_func)scan2_stmt_case, (_exp_func)scan2_stmt_jump
};
ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) {
return check_enum_def(env, def);
}
-ANN m_bool traverse_stmt_fptr(const Env env, const Stmt_Fptr def) {
-// CHECK_BB(scan0_stmt_fptr(env, def))
- CHECK_BB(scan1_stmt_fptr(env, def))
- return scan2_stmt_fptr(env, def);
-// CHECK_BB(check_stmt_fptr(env, def))
-}
-
-ANN m_bool traverse_stmt_type(const Env env, const Stmt_Type def) {
- CHECK_BB(scan0_stmt_type(env, def))
- CHECK_BB(scan1_stmt_type(env, def))
- CHECK_BB(scan2_stmt_type(env, def))
- return check_stmt_type(env, def);
+ANN m_bool traverse_fptr_def(const Env env, const Fptr_Def def) {
+ CHECK_BB(scan0_fptr_def(env, def))
+ CHECK_BB(scan1_fptr_def(env, def))
+ return scan2_fptr_def(env, def);
+// CHECK_BB(check_fptr_def(env, def))
+}
+
+ANN m_bool traverse_type_def(const Env env, const Type_Def def) {
+ CHECK_BB(scan0_type_def(env, def))
+ CHECK_BB(scan1_type_def(env, def))
+ CHECK_BB(scan2_type_def(env, def))
+ return check_type_def(env, def);
}
ANN m_bool traverse_class_def(const Env env, const Class_Def def) {