nspc_add_type_front(nspc, insert_symbol(t->name), t);
}
-static inline void context_global(const Env env) {
- if (env->context) env->context->global = true;
-}
-
-static inline Type scan0_type(const Env env, const m_str name, const Type t) {
- return new_type(env->gwion->mp, name, t);
-}
-
ANN static inline m_bool scan0_defined(const Env env, const Symbol s,
const loc_t pos) {
if (nspc_lookup_type1(env->curr, s))
ANN static Arg_List fptr_arg_list(const Env env, const Fptr_Def fptr) {
if(env->class_def && !GET_FLAG(fptr->base, static)) {
Arg arg = { .td = type2td(env->gwion, env->class_def, fptr->base->td->pos) };
- if(fptr->base->args) {
- Arg_List args = new_mp_vector(env->gwion->mp, Arg, fptr->base->args->len + 1);
- mp_vector_set(args, Arg, 0, arg);
- for(uint32_t i = 0; i < fptr->base->args->len; i++) {
- Arg *base = mp_vector_at(fptr->base->args, Arg, i);
- Arg arg = { .td = cpy_type_decl(env->gwion->mp, base->td) };
- mp_vector_set(args, Arg, i+1, arg);
- }
- return args;
- } else {
- Arg_List args = new_mp_vector(env->gwion->mp, Arg, 1);
- mp_vector_set(args, Arg, 0, arg);
- return args;
+ const uint32_t len = mp_vector_len(fptr->base->args);
+ Arg_List args = new_mp_vector(env->gwion->mp, Arg, len + 1);
+ mp_vector_set(args, Arg, 0, arg);
+ for(uint32_t i = 0; i < len; i++) {
+ Arg *base = mp_vector_at(fptr->base->args, Arg, i);
+ Arg arg = { .td = cpy_type_decl(env->gwion->mp, base->td) };
+ mp_vector_set(args, Arg, i+1, arg);
}
+ return args;
} else if(fptr->base->args)
return cpy_arg_list(env->gwion->mp, fptr->base->args);
return NULL;
if (!global) return global;
if (!env->class_def) {
env_push_global(env);
- context_global(env);
+ if (env->context) env->context->global = true;
return GW_OK;
}
ERR_B(loc, _("can't declare as global in class def"))
ANN static void typedef_simple(const Env env, const Type_Def tdef,
const Type base) {
- const Type t = scan0_type(env, s_name(tdef->xid), base);
+ const Type t = new_type(env->gwion->mp, s_name(tdef->xid), base);
t->size = base->size;
const Nspc nspc = (!env->class_def && GET_FLAG(tdef->ext, global))
? env->global_nspc
return GW_OK;
}
-#include "gack.h"
-static GACK(gack_enum) {
- const Map m = &t->nspc->info->value->map;
- const m_uint value = *(m_uint*)VALUE;
- if(value < map_size(m)) {
- const Value v = (Value)map_at(&t->nspc->info->value->map, *(m_uint*)VALUE);
- INTERP_PRINTF("%s", v->name);
- } else
- INTERP_PRINTF("%s", t->name);
-}
-
ANN static Type enum_type(const Env env, const Enum_Def edef) {
- const Type t = type_copy(env->gwion->mp, env->gwion->type[et_int]);
+ const Type t = type_copy(env->gwion->mp, env->gwion->type[et_enum]);
t->name = s_name(edef->xid);
- t->info->parent = env->gwion->type[et_int];
+ t->info->parent = env->gwion->type[et_enum];
add_type(env, env->curr, t);
mk_class(env, t, edef->pos);
- set_tflag(t, tflag_enum);
- CHECK_BO(mk_gack(env->gwion->mp, t, gack_enum));
-// scan0_implicit_similar(env, t, env->gwion->type[et_int]);
-// scan0_implicit_similar(env, env->gwion->type[et_int], t);
return t;
}
return NULL;
}
if (cdef->traits) CHECK_BO(find_traits(env, cdef->traits, cdef->pos));
- const Type t = scan0_type(env, s_name(cdef->base.xid), parent);
+ const Type t = new_type(env->gwion->mp, s_name(cdef->base.xid), parent);
if (cflag(cdef, cflag_struct)) {
t->size = 0;
set_tflag(t, tflag_struct);
Arg *arg = mp_vector_at(args, Arg, i);
const Value v = arg->var_decl.value;
v->from->offset = f->stack_depth;
- // when can there be no type?
- f->stack_depth += v->type ? v->type->size : SZ_INT;
+ f->stack_depth += v->type->size;
set_vflag(v, vflag_arg);
}
return GW_OK;
} else {
if (GET_FLAG(d->base, static))
SET_FLAG(v, static);
- else
- set_vflag(v, vflag_member);
+ else set_vflag(v, vflag_member);
SET_ACCESS(d->base, v)
}
d->base->func = v->d.func_ref = f;
ANN static inline m_bool scan2_prim(const Env env, const Exp_Primary *prim) {
if (prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_dict || prim->prim_type == ae_prim_interp)
CHECK_BB(scan2_exp(env, prim->d.exp));
- /* else if(prim->prim_type == ae_prim_id) {
- const Value v = prim_value(env, prim->d.var);
- if(v)
- v->vflag |= used;
- } */
else if (prim->prim_type == ae_prim_array && prim->d.array->exp)
return scan2_exp(env, prim->d.array->exp);
else if (prim->prim_type == ae_prim_range)
vector_add(&v, (vtype)t);
tlen += strlen(t->name); // this can be improved to use fully qualified name
++tlen;
- } //while ((id = id->next) && ++tlen);
+ }
if(spread && f->base->tmpl->call) {
Type_List tl = f->base->tmpl->call;