ANN m_bool scan0_fptr_def(const Env env, const Fptr_Def fptr) {
CHECK_BB(env_access(env, fptr->base->flag, fptr->base->td->pos));
CHECK_BB(scan0_defined(env, fptr->base->xid, fptr->base->td->pos));
- ;
const m_str name = s_name(fptr->base->xid);
const Type t = scan0_type(env, name, env->gwion->type[et_fptr]);
const bool global = !env->class_def && GET_FLAG(fptr->base, global);
return ret;
}
-ANN static inline int opiscall(const Symbol sym) {
- const m_str opname = s_name(sym);
- return (opname[0] == '@' || opname[0] == '&') &&
- (isalpha(opname[1]) || opname[1] == '_');
-}
-
-ANN static inline Exp sym2func(const Env env, const Symbol sym,
- const loc_t pos) {
- MemPool mp = env->gwion->mp;
- const m_str name = s_name(sym);
- return new_prim_id(mp, insert_symbol(name + 1), pos);
-}
-
-ANN static void binary_args(const Exp_Binary *bin) {
- Exp arg = bin->lhs;
- while (arg->next) arg = arg->next;
- arg->next = bin->rhs;
-}
-
-ANN static m_bool exp2call(const Env env, const Exp e, const Symbol sym,
- const Exp args) {
- e->exp_type = ae_exp_call;
- e->d.exp_call.func = sym2func(env, sym, e->pos);
- e->d.exp_call.args = args;
- e->d.exp_call.tmpl = NULL;
- return scan1_exp(env, e);
-}
-
-ANN static m_bool binary2call(const Env env, const Exp_Binary *bin) {
- binary_args(bin);
- return exp2call(env, exp_self(bin), bin->op, bin->lhs);
-}
-
ANN static inline m_bool scan1_exp_binary(const Env env,
const Exp_Binary *bin) {
- if (opiscall(bin->op)) return binary2call(env, bin);
CHECK_BB(scan1_exp(env, bin->lhs));
return scan1_exp(env, bin->rhs);
}
}
ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix *post) {
- if (opiscall(post->op))
- return exp2call(env, exp_self(post), post->op, post->exp);
CHECK_BB(scan1_exp(env, post->exp));
const m_str access = exp_access(post->exp);
if (!access) return GW_OK;
const Exp_Unary * unary) {
if (unary->unary_type == unary_code) {
RET_NSPC(scan1_stmt(env, unary->code))
- } else if (opiscall(unary->op))
- return exp2call(env, exp_self(unary), unary->op, unary->exp);
+ }
return unary->unary_type == unary_exp ? scan1_exp(env, unary->exp) : GW_OK;
}