Skip to content

Commit

Permalink
👕 Some clean
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Jul 23, 2019
1 parent 4c083b6 commit 3dc4a8a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ast
Submodule ast updated from 0edd66 to 2a5fcf
8 changes: 4 additions & 4 deletions src/parse/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,12 @@ ANN static Func get_template_func(const Env env, const Exp_Call* func, const Val
ANN static Func predefined_func(const Env env, const Value v,
Exp_Call *exp, const Tmpl *tm) {
Tmpl tmpl = { .call=tm->call };
((Exp_Call*)exp)->tmpl = &tmpl;
exp->tmpl = &tmpl;
DECL_OO(const Func, func, = get_template_func(env, exp, v))
return v->d.func_ref = func;
}

ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) {
ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) {
const Exp call = exp->func;
const Exp args = exp->args;
DECL_OO(const Value, value, = nspc_lookup_value1(call->type->e->owner, insert_symbol(call->type->name)))
Expand All @@ -628,7 +628,7 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) {
CHECK_BO(traverse_func_def(env, func->def))
env_pop(env, scope);
}
((Exp_Call*)exp)->m_func = func;
exp->m_func = func;
return func->def->base->ret_type;
}
m_uint args_number = 0;
Expand Down Expand Up @@ -701,7 +701,7 @@ ANN Type check_exp_call1(const Env env, const Exp_Call *exp) {
if(exp->args)
CHECK_OO(check_exp(env, exp->args))
if(GET_FLAG(exp->func->type, func))
return check_exp_call_template(env, exp);
return check_exp_call_template(env, (Exp_Call*)exp);
const Func func = find_func_match(env, exp->func->type->e->d.func, exp->args);
return (exp_self(exp)->d.exp_call.m_func = func) ?
func->def->base->ret_type : function_alternative(env, exp->func->type, exp->args, exp_self(exp)->pos);
Expand Down
22 changes: 22 additions & 0 deletions src/parse/scan0.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ ANN static inline m_bool scan0_defined(const Env env, const Symbol s, const loc_
return already_defined(env, s, pos);
}


ANN static 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(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(fptr->value, static);
SET_FLAG(fptr->base->func, static);
SET_FLAG(def, static);
}
if(GET_FLAG(def, variadic))
def->stack_depth += SZ_INT;
fptr->value->owner_class = env->class_def;
}

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)));
Expand Down
3 changes: 0 additions & 3 deletions src/parse/scan1.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ANN static Type void_type(const Env env, const Type_Decl* td) {
ERR_O(td_pos(td), _("cannot declare variables of size '0' (i.e. 'void')..."))
}


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));
Expand Down Expand Up @@ -366,8 +365,6 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) {
}

ANN m_bool scan1_class_def(const Env env, const Class_Def cdef) {
if(!cdef->base.type)
CHECK_BB(scan0_class_def(env, cdef))
if(tmpl_base(cdef->base.tmpl))
return GW_OK;
SET_FLAG(cdef->base.type, scan1);
Expand Down
21 changes: 0 additions & 21 deletions src/parse/scan2.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,6 @@ ANN static Value scan2_func_assign(const Env env, const Func_Def d,
}


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(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(fptr->value, static);
SET_FLAG(fptr->base->func, static);
SET_FLAG(def, static);
}
if(GET_FLAG(def, variadic))
def->stack_depth += SZ_INT;
fptr->value->owner_class = env->class_def;
}

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)) {
Expand Down

0 comments on commit 3dc4a8a

Please sign in to comment.