ANN void env_reset(const Env);
ANN void free_env(Env);
ANN2(1, 3) m_uint env_push(const Env, const Type, const Nspc);
+ANN static inline m_uint env_push_nspc(const Env env, const Nspc nspc) {
+ return env_push(env, NULL, nspc);
+}
ANN static inline m_uint env_push_global(const Env env) {
- return env_push(env, NULL, env->global_nspc);
+ return env_push_nspc(env, env->global_nspc);
}
+
ANN void env_pop(const Env, const m_uint);
ANN Type scan_type(const Env, const Type, Type_Decl *);
ANN Value mk_class(const Env env, const Type base, const loc_t);
set_vflag(v, vflag_valid);
nspc_add_value(env->curr, xid, v);
}
+
+ANN static inline m_uint env_pushv(const Env env, const Value value) {
+ return env_push(env, value->from->owner_class, value->from->owner);
+}
+
#endif
-Subproject commit 748e6a8c493dbb14c918558ac254acce7ea84bd1
+Subproject commit 0a0c846ccd7efe3cac7007e1561f760da0a6bff5
static inline void emit_pop(const Emitter emit, const m_uint scope) {
env_pop(emit->env, scope);
}
-static inline m_uint emit_push(const Emitter emit, const Type type,
- const Nspc nspc) {
- return env_push(emit->env, type, nspc);
+static inline m_uint emit_pushv(const Emitter emit, const Value value) {
+ return env_pushv(emit->env, value);
}
static inline m_uint emit_push_global(const Emitter emit) {
if(from->owner_class)
CHECK_B(ensure_emit(emit, from->owner_class));
if(f->code) return true;
- const m_uint scope = emit_push(emit, from->owner_class, from->owner);
+ const m_uint scope = emit_pushv(emit, f->value_ref);
const bool ret = emit_func_def(emit, f->def);
emit_pop(emit, scope);
return ret;
if(_f) {
const Func base = emit->env->func;
emit->env->func = _f;
- const m_uint scope = emit_push(emit, _f->value_ref->from->owner_class, _f->value_ref->from->owner);
+ const m_uint scope = emit_pushv(emit, _f->value_ref);
const bool ret = emit_inline(emit, _f, call);
emit_pop(emit, scope);
emit->env->func = base;
.scope = scope,
.flag = tflag_emit};
CHECK_B(envset_pushv(&es, v));
- (void)emit_push(emit, v->from->owner_class, v->from->owner);
+ (void)emit_pushv(emit, v);
const bool ret = traverse_emit_func_def(emit, fdef);
emit_pop(emit, scope);
envset_pop(&es, v->from->owner_class);
.scope = scope,
.flag = tflag_emit};
CHECK_B(envset_pushv(&es, v));
- (void)emit_push(emit, v->from->owner_class, v->from->owner);
+ (void)emit_pushv(emit, v);
const bool ret = emit_func_def(emit, f->def);
envset_pop(&es, v->from->owner_class);
emit_pop(emit, scope);
if (owner_class)
CHECK_B(push(es, owner_class));
else
- env_push(es->env, NULL,
+ env_push_nspc(es->env,
t->info->value->from->ctx ? t->info->value->from->ctx->nspc
: es->env->curr);
env_push_type((void *)es->env, t); // do not push if is a function?
return es->run ? push(es, t) : true;
}
if (nspc != es->env->curr) {
- env_push(es->env, NULL, nspc);
+ env_push_nspc(es->env, nspc);
es->run = 1;
}
return true;
}
ANN void valuefrom(const Env env, ValueFrom *from) {
+ from->filename = env->name;
from->owner = env->curr;
from->owner_class = env->scope->depth ? NULL : env->class_def;
from->ctx = env->context;
= ts->t != t_array ? ts->t : known_type(env, mp_vector_at(ts->td->types, TmplArg, 0)->d.td));
if (base->size == 0) {
gwerr_basic("Can't use type of size 0 as array base", NULL, NULL,
- env->context->name, ts->td->tag.loc, 0);
+ env->name, ts->td->tag.loc, 0);
env_set_error(env, true);
return env->gwion->type[et_error];
}
if (tflag(base, tflag_ref)) {
gwerr_basic("Can't use ref types as array base", NULL, NULL,
- env->context->name, ts->td->tag.loc, 0);
+ env->name, ts->td->tag.loc, 0);
env_set_error(env, true);
return env->gwion->type[et_error];
}
mp_vector_set(cdef->base.tmpl->call, TmplArg, 0, arg);
const Context ctx = env->context;
env->context = base->info->value->from->ctx;
- const m_uint scope = env_push(env, base->info->value->from->owner_class,
- base->info->value->from->owner);
+ const m_uint scope = env_pushv(env, base->info->value);
CHECK_ON(scan0_class_def(env, cdef));
const Type t = cdef->base.type;
if (GET_FLAG(base, abstract) && !tflag(base, tflag_union))
// s_name(impl->e->d.prim.d.var), func->name);
const Value v = nspc_lookup_value0(opi.nspc, impl->e->d.prim.d.var);
if (v) {
- const m_uint scope = env_push(env, NULL, opi.nspc);
+ const m_uint scope = env_push_nspc(env, opi.nspc);
_lhs.next = &_rhs;
Exp_Call call = {.args = &_lhs};
const Func exists = (Func)find_func_match(env, v->d.func_ref, &call);
def->base->tag.sym = impl->e->d.prim.d.var;
// use envset
// or better, some function with envset and traverse
- const m_uint scope = env_push(env, NULL, opi.nspc);
+ const m_uint scope = env_push_nspc(env, opi.nspc);
// we assume succes here
/*const bool ret = */ traverse_func_def(env, def);
env_pop(env, scope);
const Type owner = t->info->value->from->owner_class;
CHECK_O(envset_pushv(&es, t->info->value));
const bool local = !owner && !tmpl_global(env, td->types) && from_global_nspc(env, env->curr);
- if(local && env->context) env_push(env, NULL, env->context->nspc);
+ if(local && env->context) env_push_nspc(env, env->context->nspc);
const Type ret = _scan_class(env, &info);
if(local && env->context)env_pop(env, es.scope);
envset_pop(&es, owner);
set_tflag(t, tflag_check);
set_tflag(t, tflag_emit);
set_tflag(t, tflag_ref);
- const m_uint scope = env_push(env, base->info->value->from->owner_class,
- base->info->value->from->owner);
+ const m_uint scope = env_pushv(env, base->info->value);
mk_class(env, t, ts->td->tag.loc);
base2ref(env, base, t);
ref2base(env, t, base);
Arg *arg = mp_vector_at(args, Arg, i);
const Var_Decl *decl = &arg->var.vd;
const Value v = decl->value;
- if(decl->tag.sym && !can_define(env, decl->tag.sym, decl->tag.loc))
+ if(decl->tag.sym && !can_define(env, decl->tag.sym, decl->tag.loc)) {
POISON(ok, env);
+ continue;
+ }
valid_value(env, decl->tag.sym, v);
}
return ok;
for(uint32_t i = 0; i < len; i++) {
Specialized *spec = mp_vector_at(sl, Specialized, i);
if (tmplarg_match(env, spec->tag.sym, fdef->base->td->tag.sym, fdef->base->ret_type)) {
- if(!check_exp(env, exp->other))
+ if(!check_exp(env, exp->other)) {
POISON_NODE(ok, env, exp->other);
+ continue;
+ }
if(!is_func(env->gwion, exp->other->type)) {
TmplArg targ = {
.type = tmplarg_td,
for(m_uint i = 0; i < l->len; i++) {
const Stmt* stmt = mp_vector_at(l, Stmt, i);
if (stmt->stmt_type == ae_stmt_exp) {
- if(!traverse_exp(env, stmt->d.stmt_exp.val))
+ if(!traverse_exp(env, stmt->d.stmt_exp.val)) {
POISON_NODE(ok, env, stmt->d.stmt_exp.val);
+ continue;
+ }
Var_Decl vd = stmt->d.stmt_exp.val->d.exp_decl.var.vd;
const Value value = vd.value;
valuefrom(env, value->from);
struct ResolverArgs ra = {
.v = v, .e = exp, .tmpl_name = tmpl_name, .types = types};
CHECK_O(envset_pushv(&es, v));
- (void)env_push(env, v->from->owner_class, v->from->owner);
+ (void)env_pushv(env, v);
const Tmpl *tmpl = v->from->owner_class && v->from->owner_class->info->cdef ?
get_tmpl(v->from->owner_class) : NULL;
if(tmpl)
}
if (arg->var.td) {
SET_FLAG(arg->var.td, late);
- if(!(arg->type = void_type(env, arg->var.td)))
+ if(!(arg->type = void_type(env, arg->var.td))) {
POISON(ok, env);
+ continue;
+ }
if (GET_FLAG(env->func->def->base, global) && !type_global(env, arg->type))
ERR_OK(ok, arg->var.td->tag.loc, "is not global");
}
bool ok = true;
for(uint32_t i = 0; i < l->len; i++) {
Variable *um = mp_vector_at(l, Variable, i);
- if (nspc_lookup_value0(env->curr, um->vd.tag.sym))
+ if (nspc_lookup_value0(env->curr, um->vd.tag.sym)) {
ERR_OK(ok, um->vd.tag.loc, _("'%s' already declared in union"), s_name(um->vd.tag.sym));
+ continue;
+ }
const Type t = known_type(env, um->td);
if(t) {
if(tflag(t, tflag_ref)) {
bool ok = true;
for(i = 0; i < l->len; i++) {
Stmt* stmt = mp_vector_at(l, Stmt, i);
- if(!scan1_stmt(env, stmt))
+ if(!scan1_stmt(env, stmt)) {
POISON_NODE(ok, env, stmt);
+ continue;
+ }
if(end_flow(stmt)) break;
}
if(++i < l->len) dead_code(env, l, i);
const Context ctx = env->context;
const m_str name = env->name;
envset_push(&es, owner, owner->nspc);
- (void)env_push(env, owner, owner->nspc); // TODO: is this needed?
+ (void)env_push_type(env, owner); // TODO: is this needed?
env->context = owner->info->value->from->ctx;
env->name = owner->info->value->from->filename;
const Type ret = known_type(env, td->next);
const Type exists = find_type(env, td);
if(exists) return exists;
const m_uint scope = env->context
- ? env_push(env, NULL, env->context->nspc)
+ ? env_push_nspc(env, env->context->nspc)
: env_push_global(env);
const bool ret = traverse_fptr_def(env, fptr);
env_pop(env, scope);
plug->nspc = new_nspc(gwion->mp, iname);
vector_add(&gwion->data->plugs->vec, (m_uint)plug->nspc);
set_parent(plug->nspc, gwion);
- const m_uint scope = env_push(gwion->env, NULL, plug->nspc);
+ const m_uint scope = env_push_nspc(gwion->env, plug->nspc);
const m_str name = gwion->env->name;
gwion->env->name = iname;
const bool ret = gwi_run(gwion, plug->plugin);