-Subproject commit 2ed499104f6366ec0fbdb460e91cf31e8c5bb13e
+Subproject commit 820ad7c108f5dbd692cb39fec04e69dc90a986c1
DECL_SECTION_FUNC(prefix, type, Arg) \
ANN static inline type prefix##_section(const Arg a, /* const */ Section* section) { \
void* d = §ion->d.stmt_list; \
- return section_func[section->section_type](a, *(void**)d); \
+ return prefix##_section_func[section->section_type](a, *(void**)d); \
}
-#define HANDLE_EXP_FUNC(prefix, type, Arg) \
-DECL_EXP_FUNC(prefix, type, Arg) \
-ANN type prefix##_exp(const Arg arg, Exp exp) { \
- do CHECK_BB(exp_func[exp->exp_type](arg, &exp->d)) \
- while((exp = exp->next)); \
- return GW_OK; \
+#define HANDLE_EXP_FUNC(prefix, type, Arg) \
+DECL_EXP_FUNC(prefix, type, Arg) \
+ANN type prefix##_exp(const Arg arg, Exp exp) { \
+ do CHECK_BB(prefix##_exp_func[exp->exp_type](arg, &exp->d)) \
+ while((exp = exp->next)); \
+ return GW_OK; \
}
ANN m_bool scan1_exp(const Env, Exp);
ANN m_bool scan2_exp(const Env, Exp);
ANN m_bool traverse_enum_def(const Env, const Enum_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 traverse_exp(const Env, const Exp);
ANN m_bool scan0_ast(const Env, Ast);
ANN m_bool scan1_ast(const Env, Ast);
ANN m_bool scan2_ast(const Env, Ast);
ANN m_bool check_ast(const Env, Ast);
-ANN m_bool scan1_exp_decl(const Env, const Exp_Decl*);
-ANN m_bool scan2_exp_decl(const Env, const Exp_Decl*);
-ANN Type check_exp_decl(const Env, const Exp_Decl*);
+ANN m_bool scan1_exp(const Env, const Exp);
+ANN m_bool scan2_exp(const Env, const Exp);
+ANN Type check_exp(const Env, const Exp);
ANN m_bool scan1_func_def(const Env, const Func_Def);
ANN m_bool scan2_func_def(const Env, const Func_Def);
DECL_PRIM_FUNC(emit, m_bool , Emitter);
ANN static m_bool emit_prim(const Emitter emit, Exp_Primary *const prim) {
- return prim_func[prim->prim_type](emit, &prim->d);
+ return emit_prim_func[prim->prim_type](emit, &prim->d);
}
ANN static m_bool emit_dot_static_data(const Emitter emit, const Value v, const uint emit_var) {
ANN2(1) static m_bool emit_exp(const Emitter emit, Exp exp, const m_bool ref) {
do {
- CHECK_BB(exp_func[exp->exp_type](emit, &exp->d))
+ CHECK_BB(emit_exp_func[exp->exp_type](emit, &exp->d))
if(ref && isa(exp->type, emit->gwion->type[et_object]) > 0) {
const Instr instr = emit_add_instr(emit, RegAddRef);
instr->m_val = exp->emit_var;
DECL_STMT_FUNC(emit, m_bool , Emitter)
ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) {
- CHECK_BB(stmt_func[stmt->stmt_type](emit, &stmt->d))
+ CHECK_BB(emit_stmt_func[stmt->stmt_type](emit, &stmt->d))
if(pop && stmt->stmt_type == ae_stmt_exp && stmt->d.stmt_exp.val)
pop_exp(emit, stmt->d.stmt_exp.val);
return GW_OK;
gwi->ck->exp->d.exp_decl.td->flag = flag;
if(env->class_def && GET_FLAG(env->class_def, template))
return gwi_item_tmpl(gwi);
- CHECK_BB(traverse_decl(env, &gwi->ck->exp->d.exp_decl))
+ CHECK_BB(traverse_exp(env, gwi->ck->exp))
const Value value = gwi->ck->exp->d.exp_decl.list->self->value;
SET_FLAG(value, builtin);
const m_uint offset = value->from->offset;
if(e->exp_type == ae_exp_decl) {
DECL_OO(const Type, t, = (Type)VPTR(&bin->lhs->type->e->tuple->types, i))
e->d.exp_decl.td->xid->xid = insert_symbol(t->name);
- CHECK_BO(traverse_decl(env, &e->d.exp_decl))
+ CHECK_BO(traverse_exp(env, e))
bin->rhs->meta = ae_meta_var;
}
++i;
#include "emit.h"
#include "specialid.h"
-ANN static Type check_exp(const Env env, Exp exp);
ANN static m_bool check_stmt_list(const Env env, Stmt_List list);
ANN m_bool check_class_def(const Env env, const Class_Def class_def);
ANN static Type no_xid(const Env env, const Exp_Decl *decl) {
CHECK_OO((((Exp_Decl*)decl)->type = check_td(env, decl->td)))
clear_decl(env, decl);
- CHECK_BO(traverse_decl(env, decl))
+ CHECK_BO(traverse_exp(env, exp_self(decl)))
return decl->type;
}
DECL_PRIM_FUNC(check, Type, Env);
ANN static Type check_prim(const Env env, Exp_Primary *prim) {
- return exp_self(prim)->type = prim_func[prim->prim_type](env, &prim->d);
+ return exp_self(prim)->type = check_prim_func[prim->prim_type](env, &prim->d);
}
ANN static Type at_depth(const Env env, const Array_Sub array);
DECL_EXP_FUNC(check, Type, Env)
-ANN static inline Type check_exp(const Env env, const Exp exp) {
+ANN Type check_exp(const Env env, const Exp exp) {
Exp curr = exp, next = NULL, prev = NULL;
do {
next = curr->next;
- CHECK_OO((curr->type = exp_func[curr->exp_type](env, &curr->d)))
- if(isa(curr->type, env->gwion->type[et_varloop]) > 0 && (prev || next))
- ERR_O(exp->pos, _("Varloop must be the only expression"))
+ CHECK_OO((curr->type = check_exp_func[curr->exp_type](env, &curr->d)))
+// if(isa(curr->type, env->gwion->type[et_varloop]) > 0 && (prev || next))
+// ERR_O(exp->pos, _("Varloop must be the only expression"))
if(env->func && isa(curr->type, env->gwion->type[et_lambda]) < 0 && isa(curr->type, env->gwion->type[et_function]) > 0 &&
!GET_FLAG(curr->type->e->d.func, pure))
UNSET_FLAG(env->func, pure);
DECL_STMT_FUNC(check, m_bool , Env)
ANN m_bool check_stmt(const Env env, const Stmt stmt) {
- return stmt_func[stmt->stmt_type](env, &stmt->d);
+ return check_stmt_func[stmt->stmt_type](env, &stmt->d);
}
ANN static m_bool check_stmt_list(const Env env, Stmt_List l) {
DECL_STMT_FUNC(scan1, m_bool, Env)
ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) {
- return stmt_func[stmt->stmt_type](env, &stmt->d);
+ return scan1_stmt_func[stmt->stmt_type](env, &stmt->d);
}
ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) {
DECL_STMT_FUNC(scan2, m_bool, Env)
ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) {
- return stmt_func[stmt->stmt_type](env, &stmt->d);
+ return scan2_stmt_func[stmt->stmt_type](env, &stmt->d);
}
ANN static m_bool scan2_stmt_list(const Env env, Stmt_List list) {
return check_ast(env, ast);
}
-ANN m_bool traverse_decl(const Env env, const Exp_Decl* decl) {
- CHECK_BB(scan1_exp_decl(env, decl))
- CHECK_BB(scan2_exp_decl(env, decl))
- return check_exp_decl(env, decl) ? 1 : -1;
+ANN m_bool traverse_exp(const Env env, const Exp exp) {
+ CHECK_BB(scan1_exp(env, exp))
+ CHECK_BB(scan2_exp(env, exp))
+ return check_exp(env, exp) ? 1 : -1;
}
ANN m_bool traverse_func_def(const Env env, const Func_Def def) {