union {
Union_Def udef;
Class_Def cdef;
- };
- union type_data {
Func func;
Type base_type;
- } d;
+ };
struct TupleForm_* tuple;
struct VM_Code_ *gack;
struct Context_ *ctx;
struct Type_ {
m_str name;
Nspc nspc;
- struct TypeInfo_ *e;
+ struct TypeInfo_ *info;
size_t xid;
size_t size;
size_t array_depth;
__attribute__((returns_nonnull))
ANN static inline Type get_gack(Type t) {
- do if(t->e->gack)
+ do if(t->info->gack)
return t;
- while((t = t->e->parent));
+ while((t = t->info->parent));
return t; // unreachable
}
ANN Nspc pop_global(const Gwion gwion);
__attribute__((returns_nonnull))
ANN static inline Value type_value(const Gwion gwion, const Type t) {
- return (Value)nspc_lookup_value1(t->e->owner, insert_symbol(gwion->st, t->name));
+ return (Value)nspc_lookup_value1(t->info->owner, insert_symbol(gwion->st, t->name));
}
__attribute__((returns_nonnull))
ANN static inline Type type_class(const Gwion gwion, const Type t) {
- const Value v = nspc_lookup_value1(t->e->owner, insert_symbol(gwion->st, t->name));
+ const Value v = nspc_lookup_value1(t->info->owner, insert_symbol(gwion->st, t->name));
return v->type;
}
#endif
}
ANN static void struct_pop(const Emitter emit, const Type type, const m_uint offset) {
- if(!type->e->tuple)
+ if(!type->info->tuple)
return;
- for(m_uint i = 0; i < vector_size(&type->e->tuple->types); ++i) {
- const Type t = (Type)vector_at(&type->e->tuple->types, i);
+ for(m_uint i = 0; i < vector_size(&type->info->tuple->types); ++i) {
+ const Type t = (Type)vector_at(&type->info->tuple->types, i);
if(isa(t, emit->gwion->type[et_object]) > 0) {
const Instr instr = emit_add_instr(emit, ObjectRelease);
- instr->m_val = offset + vector_at(&type->e->tuple->offset, i);
+ instr->m_val = offset + vector_at(&type->info->tuple->offset, i);
} else if(tflag(t, tflag_struct))
- struct_pop(emit, t, offset + vector_at(&type->e->tuple->offset, i));
+ struct_pop(emit, t, offset + vector_at(&type->info->tuple->offset, i));
}
}
}
ANN static void emit_pre_ctor(const Emitter emit, const Type type) {
- if(type->e->parent)
- emit_pre_ctor(emit, type->e->parent);
+ if(type->info->parent)
+ emit_pre_ctor(emit, type->info->parent);
maybe_ctor(emit, type);
- if(tflag(type, tflag_typedef) && type->e->parent->array_depth)
- emit_array_extend(emit, type->e->parent, type->e->cdef->base.ext->array->exp);
+ if(tflag(type, tflag_typedef) && type->info->parent->array_depth)
+ emit_array_extend(emit, type->info->parent, type->info->cdef->base.ext->array->exp);
}
#define regxxx(name, instr) \
ANN m_bool emit_array_access(const Emitter emit, struct ArrayAccessInfo *const info) {
if(tflag(info->array.type, tflag_typedef)) {
- info->array.type = info->array.type->e->parent;
+ info->array.type = info->array.type->info->parent;
return emit_array_access(emit, info);
}
// look mum no pos
ANN static m_bool emit_cdef(const Emitter, const Type);
ANN static inline m_bool ensure_emit(const Emitter emit, const Type t) {
+ const Type base = get_type(t);
+ if(tflag(base, tflag_emit) || !(tflag(base, tflag_cdef) || tflag(base, tflag_udef)))
+ return GW_OK;//clean callers
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=emit->env->scope->depth, .flag=tflag_emit };
- return envset_run(&es, t);
+ return envset_run(&es, base);
}
ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) {
ANN /*static */m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) {
const Type t = get_type(decl->type);
- if(!tflag(t, tflag_emit))
- CHECK_BB(ensure_emit(emit, t))
+ CHECK_BB(ensure_emit(emit, t))
const m_bool global = GET_FLAG(decl->td, global);
const m_uint scope = !global ? emit->env->scope->depth : emit_push_global(emit);
const m_bool ret = emit_decl(emit, decl);
if(exp_call->m_func)
CHECK_OB(emit_exp_call1(emit, exp_call->m_func))
else {
- struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=exp_call->func->info->type->e->d.base_type,
+ struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=exp_call->func->info->type->info->base_type,
.data=(uintptr_t)exp_call, .pos=exp_self(exp_call)->pos, .op_type=op_exp };
CHECK_OB(op_emit(emit, &opi))
}
ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) {
const Type t = exp_self(unary)->info->type;
const Type base = get_type(actual_type(emit->gwion, t));
- if(base->e->cdef && !tflag(base, tflag_emit)) // ???
- CHECK_BB(ensure_emit(emit, base))
+ CHECK_BB(ensure_emit(emit, base))
// no pos ?
struct Op_Import opi = { .op=unary->op, .data=(uintptr_t)unary, .op_type=op_unary };
if(unary->op != insert_symbol("spork") && unary->op != insert_symbol("fork") && unary->exp) {
ANN static void struct_addref(const Emitter emit, const Type type,
const m_int size, const m_bool offset, const m_bool emit_var) {
- if(!type->e->tuple)
+ if(!type->info->tuple)
return;
- for(m_uint i = 0; i < vector_size(&type->e->tuple->types); ++i) {
- const Type t = (Type)vector_at(&type->e->tuple->types, i);
+ for(m_uint i = 0; i < vector_size(&type->info->tuple->types); ++i) {
+ const Type t = (Type)vector_at(&type->info->tuple->types, i);
if(isa(t, emit->gwion->type[et_object]) > 0) {
const Instr instr = emit_addref(emit, emit_var);
instr->m_val = size;
- instr->m_val2 = vector_at(&type->e->tuple->offset, i);
+ instr->m_val2 = vector_at(&type->info->tuple->offset, i);
} else if(tflag(t, tflag_struct))
- struct_addref(emit, t, size, offset + vector_at(&type->e->tuple->offset, i), emit_var);
+ struct_addref(emit, t, size, offset + vector_at(&type->info->tuple->offset, i), emit_var);
}
}
}
ANN static m_bool emit_type_def(const Emitter emit, const Type_Def tdef) {
- return tdef->type->e->cdef ? emit_class_def(emit, tdef->type->e->cdef) : GW_OK;
+ return (!is_fptr(emit->gwion, tdef->type) && tdef->type->info->cdef) ?
+ emit_class_def(emit, tdef->type->info->cdef) : GW_OK;
}
ANN static m_bool emit_enum_def(const Emitter emit, const Enum_Def edef) {
const Instr instr = emit_add_instr(emit, RegPushMem);
instr->m_val = SZ_INT;
f->code = finalyze(emit, FuncReturn);
- return emit->env->class_def->e->gack = f->code;
+ return emit->env->class_def->info->gack = f->code;
}
return finalyze(emit, FuncReturn);
}
}
ANN static m_bool emit_parent(const Emitter emit, const Class_Def cdef) {
- const Type parent = cdef->base.type->e->parent;
- return !tflag(parent, tflag_emit) ? ensure_emit(emit, parent) : GW_OK;
+ const Type parent = cdef->base.type->info->parent;
+ return ensure_emit(emit, parent);
}
ANN static inline m_bool emit_cdef(const Emitter emit, const Type t) {
if(tflag(t, tflag_emit))
return GW_OK;
set_tflag(t, tflag_emit);
- if(t->e->owner_class && !tflag(t->e->owner_class, tflag_emit))
- CHECK_BB(ensure_emit(emit, t->e->owner_class))
- if(cdef->base.ext && t->e->parent->e->cdef && !tflag(t->e->parent, tflag_emit)) // ?????
+ if(t->info->owner_class)
+ CHECK_BB(ensure_emit(emit, t->info->owner_class))
+ if(cdef->base.ext && t->info->parent->info->cdef && !tflag(t->info->parent, tflag_emit)) // ?????
CHECK_BB(cdef_parent(emit, cdef))
nspc_allocdata(emit->gwion->mp, t->nspc);
if(cdef->body) {
}
ANN void env_add_type(const Env env, const Type type) {
- type->e->owner = env->curr;
- type->e->owner_class = env->class_def; // t owner_class ?
+ type->info->owner = env->curr;
+ type->info->owner_class = env->class_def; // t owner_class ?
const Symbol sym = insert_symbol(type->name);
nspc_add_type_front(env->curr, sym, type);
const Value v = mk_class(env, type);
const Type t = nspc_lookup_type1(base->nspc, xid);
if(t)
return t;
- base = base->e->parent;
+ base = base->info->parent;
}
return NULL;
}
ANN static Type class_type(const Env env, const Type base) {
const Type t_class = env->gwion->type[et_class];
const Type t = type_copy(env->gwion->mp, t_class);
- t->e->parent = t_class;
- t->e->ctx = base->e->ctx;
- t->e->d.base_type = base;
+ t->info->parent = t_class;
+ t->info->ctx = base->info->ctx;
+ t->info->base_type = base;
set_tflag(t, tflag_infer);
return t;
}
valuefrom(env, v->from);
SET_FLAG(v, const);
set_vflag(v, vflag_valid);
- nspc_add_value_front(base->e->owner, sym, v);
+ nspc_add_value_front(base->info->owner, sym, v);
return v;
}
ANN static void check(struct EnvSet *es, const Type t) {
const Vector v = &es->env->scope->class_stack;
- Type owner = t->e->owner_class;
+ Type owner = t->info->owner_class;
for(vtype i = vector_size(v) + 1; owner && --i;) {
if(owner != (Type)vector_at(v, i - 1)) {
es->run = 1;
return;
}
- owner = owner->e->owner_class;
+ owner = owner->info->owner_class;
}
}
ANN static m_bool push(struct EnvSet *es, const Type t) {
es->env->scope->depth = 0;
- if(t->e->owner_class)
- CHECK_BB(push(es, t->e->owner_class))
+ if(t->info->owner_class)
+ CHECK_BB(push(es, t->info->owner_class))
else
- env_push(es->env, NULL, t->e->ctx ? t->e->ctx->nspc : es->env->curr);
+ env_push(es->env, NULL, t->info->ctx ? t->info->ctx->nspc : es->env->curr);
if(es->func && !(t->tflag & es->flag))
CHECK_BB(es->func((void*)es->data, t))
if(tflag(t, tflag_tmpl))
- CHECK_BB(template_push_types(es->env, t->e->cdef->base.tmpl)) // incorrect templates
+ CHECK_BB(template_push_types(es->env, t->info->cdef->base.tmpl)) // incorrect templates
env_push_type((void*)es->env, t);
return GW_OK;
}
return;
if(tflag(t, tflag_tmpl))
nspc_pop_type(es->env->gwion->mp, es->env->curr);
- if(t->e->owner_class)
- envset_pop(es, t->e->owner_class);
+ if(t->info->owner_class)
+ envset_pop(es, t->info->owner_class);
else
env_pop(es->env, es->scope);
}
ANN m_bool envset_run(struct EnvSet *es, const Type t) {
check(es, t);
if(es->run)
- CHECK_BB(push(es, t->e->owner_class))
- const m_bool ret = t->e->cdef &&
+ CHECK_BB(push(es, t->info->owner_class))
+ const m_bool ret = t->info->cdef &&
!(t->tflag & es->flag) ?
es->func(es->data, t) : GW_OK;
if(es->run)
- envset_pop(es, t->e->owner_class);
+ envset_pop(es, t->info->owner_class);
return ret;
}
(vflag(value, vflag_builtin) && value->d.ptr))) {
const m_bit *ptr = (value && value->d.ptr) ? (m_bit*)value->d.ptr:
(m_bit*)(a->info->class_data + value->from->offset);
- for(m_uint i = 0; i < vector_size(&value->type->e->tuple->types); ++i) {
- const Type t = (Type)vector_at(&value->type->e->tuple->types, i);
+ for(m_uint i = 0; i < vector_size(&value->type->info->tuple->types); ++i) {
+ const Type t = (Type)vector_at(&value->type->info->tuple->types, i);
if(isa(t, gwion->type[et_object]) > 0)
- release(*(M_Object*)(ptr + vector_at(&value->type->e->tuple->offset, i)), gwion->vm->cleaner_shred);
+ release(*(M_Object*)(ptr + vector_at(&value->type->info->tuple->offset, i)), gwion->vm->cleaner_shred);
else if(tflag(t, tflag_struct))
nspc_release_struct(t->nspc, NULL, gwion);
}
#include "array.h"
ANN void tuple_info(const Env env, const Value v) {
- const m_uint offset = vector_back(&env->class_def->e->tuple->offset);
- vector_add(&env->class_def->e->tuple->types, (vtype)v->type);
- vector_add(&env->class_def->e->tuple->offset, offset + v->type->size);
+ const m_uint offset = vector_back(&env->class_def->info->tuple->offset);
+ vector_add(&env->class_def->info->tuple->types, (vtype)v->type);
+ vector_add(&env->class_def->info->tuple->offset, offset + v->type->size);
}
ANN void tuple_contains(const Env env, const Value value) {
const Type t = value->type;
- if(!env->class_def->e->tuple || env->class_def == value->type)
+ if(!env->class_def->info->tuple || env->class_def == value->type)
return;
- const Vector v = &env->class_def->e->tuple->contains;
+ const Vector v = &env->class_def->info->tuple->contains;
const m_int idx = vector_size(v) ? vector_find(v, (vtype)t) : -1;
if(idx == -1) {
type_addref(t);
vector_init(&tuple->contains);
vector_init(&tuple->types);
vector_init(&tuple->offset);
- if(parent_type && parent_type->e->tuple) {
- const TupleForm parent = parent_type->e->tuple;
+ if(parent_type && parent_type->info->tuple) {
+ const TupleForm parent = parent_type->info->tuple;
const m_uint sz = vector_size(&parent->types);
tuple->start = parent->start + sz;
if(sz) {
ANN void free_type(const Type a, struct Gwion_ *const gwion) {
if(freeable(a)) {
if(tflag(a, tflag_udef))
- free_union_def(gwion->mp, a->e->udef);
+ free_union_def(gwion->mp, a->info->udef);
if(tflag(a, tflag_cdef))
- class_def_cleaner(gwion, a->e->cdef);
+ class_def_cleaner(gwion, a->info->cdef);
}
if(a->nspc)
nspc_remref(a->nspc, gwion);
- if(a->e->tuple)
- free_tupleform(a->e->tuple, gwion);
- mp_free(gwion->mp, TypeInfo, a->e);
+ if(a->info->tuple)
+ free_tupleform(a->info->tuple, gwion);
+ mp_free(gwion->mp, TypeInfo, a->info);
mp_free(gwion->mp, Type, a);
}
Type new_type(MemPool p, const m_uint xid, const m_str name, const Type parent) {
const Type type = mp_calloc(p, Type);
- type->xid = xid;
- type->name = name;
- type->e = mp_calloc(p, TypeInfo);
- type->e->parent = parent;
+ type->xid = xid;
+ type->name = name;
+ type->info = mp_calloc(p, TypeInfo);
+ type->info->parent = parent;
if(parent)
type->size = parent->size;
type->ref = 1;
}
ANN Type type_copy(MemPool p, const Type type) {
- const Type a = new_type(p, type->xid, type->name, type->e->parent);
+ const Type a = new_type(p, type->xid, type->name, type->info->parent);
a->nspc = type->nspc;
- a->e->owner = type->e->owner;
- a->e->owner_class = type->e->owner_class;
+ a->info->owner = type->info->owner;
+ a->info->owner_class = type->info->owner_class;
a->size = type->size;
- a->e->d.base_type = type->e->d.base_type;
+ a->info->base_type = type->info->base_type;
a->array_depth = type->array_depth;
- a->e->gack = type->e->gack;
+ a->info->gack = type->info->gack;
return a;
}
ANN m_bool isa(const restrict Type var, const restrict Type parent) {
- return (var->xid == parent->xid) ? 1 : var->e->parent ? isa(var->e->parent, parent) : -1;
+ return (var->xid == parent->xid) ? 1 : var->info->parent ? isa(var->info->parent, parent) : -1;
}
ANN Type find_common_anc(const restrict Type lhs, const restrict Type rhs) {
if(val) \
return val; \
} \
- return type->e->parent ? find_##name(type->e->parent, xid) : NULL; \
+ return type->info->parent ? find_##name(type->info->parent, xid) : NULL; \
}
describe_find(value, Value)
//describe_find(func, Func)
ANN Type typedef_base(Type t) {
while(tflag(t, tflag_typedef))
- t = t->e->parent;
+ t = t->info->parent;
return t;
}
ANN Type array_base(Type type) {
const Type t = typedef_base(type);
- return t->array_depth ? t->e->d.base_type : t;
+ return t->array_depth ? t->info->base_type : t;
}
ANN static Symbol array_sym(const Env env, const Type src, const m_uint depth) {
ANN Type array_type(const Env env, const Type src, const m_uint depth) {
const Symbol sym = array_sym(env, src, depth);
- const Type type = nspc_lookup_type1(src->e->owner, sym);
+ const Type type = nspc_lookup_type1(src->info->owner, sym);
if(type)
return type;
const Type t = new_type(env->gwion->mp, env->gwion->type[et_array]->xid,
s_name(sym), env->gwion->type[et_array]);
t->array_depth = depth + src->array_depth;
- t->e->d.base_type = array_base(src) ?: src;
- t->e->owner = src->e->owner;
+ t->info->base_type = array_base(src) ?: src;
+ t->info->owner = src->info->owner;
if(depth > 1 || isa(src, env->gwion->type[et_compound]) > 0) {
t->nspc = new_nspc(env->gwion->mp, s_name(sym));
inherit(t);
} else
nspc_addref((t->nspc = env->gwion->type[et_array]->nspc));
mk_class(env, t);
- nspc_add_type_front(src->e->owner, sym, t);
+ nspc_add_type_front(src->info->owner, sym, t);
return t;
}
do {
if(tflag(t, tflag_empty))
return GW_OK;
- if(tflag(t, tflag_typedef) && t->e->cdef)
- if(t->e->cdef->base.ext && t->e->cdef->base.ext->array) {
- if(!t->e->cdef->base.ext->array->exp)
+ if(tflag(t, tflag_typedef) && tflag(t, tflag_cdef)) {
+ if(t->info->cdef->base.ext && t->info->cdef->base.ext->array) {
+ if(!t->info->cdef->base.ext->array->exp)
return GW_OK;
else {
- const Type type = t->e->parent->e->d.base_type;
+ const Type type = t->info->parent->info->base_type;
if(tflag(type, tflag_empty))
return GW_OK;
}
}
- } while((t = t->e->parent));
+ }
+ } while((t = t->info->parent));
return 0;
}
do {
if(t->array_depth) {
depth += t->array_depth;
- t = t->e->d.base_type;
+ t = t->info->base_type;
} else
- t = t->e->parent;
+ t = t->info->parent;
} while(t);
return depth;
}
}
ANN Type actual_type(const struct Gwion_* gwion, const Type t) {
- return is_class(gwion, t) ? t->e->d.base_type : t;
+ return is_class(gwion, t) ? t->info->base_type : t;
}
ANN void inherit(const Type t) {
- const Nspc nspc = t->nspc, parent = t->e->parent->nspc;
+ const Nspc nspc = t->nspc, parent = t->info->parent->nspc;
if(!nspc || !parent)
return;
nspc->info->offset = parent->info->offset;
t->name = s_name(s->name);
t->flag = s->type->flag;
t->tflag |= s->type->tflag | s->flag;
- t->e->parent = unflag_type(s->type);
- nspc_add_type_front(s->type->e->owner, s->name, t);
+ t->info->parent = unflag_type(s->type);
+ nspc_add_type_front(s->type->info->owner, s->name, t);
mk_class(env, t);
return t;
}
ANN Type special_type(const Env env, const Type t, const uint st_type) {
SpecialType s = { .type=t, .st_type=st_type };
specialtype_init(env->gwion->st, &s);
- return nspc_lookup_type1(t->e->owner, s.name) ?:
+ return nspc_lookup_type1(t->info->owner, s.name) ?:
specialtype_create(env, &s);
}
do {
if(tflag(t, tflag_check))
break;
- if(t->e->cdef)
- CHECK_BB(traverse_class_def(env, t->e->cdef))
- } while((t = t->e->parent));
+ if(t->info->cdef)
+ CHECK_BB(traverse_class_def(env, t->info->cdef))
+ } while((t = t->info->parent));
return GW_OK;
}
t->nspc->parent = env->curr;
if(isa(t, env->gwion->type[et_object]) > 0)
inherit(t);
- t->e->owner = env->curr;
- t->e->owner_class = env->class_def;
+ t->info->owner = env->curr;
+ t->info->owner_class = env->class_def;
env_push_type(env, t);
}
nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr);
CHECK_OO(p)
const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, s_name(ck.sym), p);
- t->e->cdef = new_class_def(gwi->gwion->mp, 0, ck.sym, td, NULL, loc(gwi));
- t->e->cdef->base.tmpl = tmpl;
- t->e->cdef->base.type = t;
- t->e->tuple = new_tupleform(gwi->gwion->mp, p);
- t->e->parent = p;
+ t->info->cdef = new_class_def(gwi->gwion->mp, 0, ck.sym, td, NULL, loc(gwi));
+ t->info->cdef->base.tmpl = tmpl;
+ t->info->cdef->base.type = t;
+ t->info->tuple = new_tupleform(gwi->gwion->mp, p);
+ t->info->parent = p;
if(td->array)
set_tflag(t, tflag_typedef);
if(ck.tmpl)
ANN Type gwi_struct_ini(const Gwi gwi, const m_str name) {
CHECK_OO(gwi_str2sym(gwi, name))
const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, name, gwi->gwion->type[et_compound]);
- t->e->tuple = new_tupleform(gwi->gwion->mp, NULL);
+ t->info->tuple = new_tupleform(gwi->gwion->mp, NULL);
gwi_type_flag(t);
set_tflag(t, tflag_struct);
return type_finish(gwi, t);
#include "gwi.h"
void gwi_body(const Gwi gwi, const Ast body) {
- const Class_Def cdef = gwi->gwion->env->class_def->e->cdef;
+ const Class_Def cdef = gwi->gwion->env->class_def->info->cdef;
if(!cdef->body)
cdef->body = body;
else
ANN static m_bool mk_gack(MemPool p, const Type type, const f_gack d) {
const VM_Code code = new_vm_code(p, NULL, SZ_INT, 1, "@gack");
code->native_func = (m_uint)d;
- type->e->gack = code;
+ type->info->gack = code;
return GW_OK;
}
}
ANN static Type get_array_type(Type t) {
- while(t->e->d.base_type)
- t = t->e->d.base_type;
+ while(t->info->base_type)
+ t = t->info->base_type;
return t;
}
const Exp_Cast* cast = (Exp_Cast*)data;
Type l = cast->exp->info->type;
Type r = exp_self(cast)->info->type;
- while(!l->e->d.base_type)
- l = l->e->parent;
- while(!r->e->d.base_type)
- r = r->e->parent;
- if(get_depth(cast->exp->info->type) == get_depth(exp_self(cast)->info->type) && isa(l->e->d.base_type, r->e->d.base_type) > 0)
+ while(!l->info->base_type)
+ l = l->info->parent;
+ while(!r->info->base_type)
+ r = r->info->parent;
+ if(get_depth(cast->exp->info->type) == get_depth(exp_self(cast)->info->type) && isa(l->info->base_type, r->info->base_type) > 0)
return l;
return env->gwion->type[et_null];
}
static OP_CHECK(opck_not_array) {
const Array_Sub array = (Array_Sub)data;
if(get_depth(array->type)) {
- struct Array_Sub_ next = { array->exp, array->type->e->parent, array->depth };
+ struct Array_Sub_ next = { array->exp, array->type->info->parent, array->depth };
return check_array_access(env, &next);
}
ERR_O(array->exp->pos, _("array subscripts (%"UINT_F") exceeds defined dimension (%"UINT_F")"),
INSTR(DTOR_EOC) {
const M_Object o = *(M_Object*)MEM(0);
- o->type_ref = o->type_ref->e->parent;
+ o->type_ref = o->type_ref->info->parent;
_release(o, shred);
shred->info->me->ref = 1;
vm_shred_exit(shred);
struct dottmpl_ *dt = (struct dottmpl_*)instr->m_val;
const m_str name = dt->name;
const M_Object o = *(M_Object*)REG(-SZ_INT);
- Type t = !tflag(o->type_ref, tflag_nonnull) ? o->type_ref : o->type_ref->e->parent;
+ Type t = !tflag(o->type_ref, tflag_nonnull) ? o->type_ref : o->type_ref->info->parent;
do {
const Emitter emit = shred->info->vm->gwion->emit;
emit->env->name = "runtime";
*(VM_Code*)(shred->reg-SZ_INT) = f->code;
return;
}
- } while((t = t->e->parent));
+ } while((t = t->info->parent));
Except(shred, "MissigTmplException[internal]");
}
static OP_EMIT(opem_func_assign) {
Exp_Binary* bin = (Exp_Binary*)data;
- if(bin->rhs->info->type->e->d.func->def->base->tmpl)
- fptr_instr(emit, bin->lhs->info->type->e->d.func, 2);
+ if(bin->rhs->info->type->info->func->def->base->tmpl)
+ fptr_instr(emit, bin->lhs->info->type->info->func, 2);
const Instr instr = emit_add_instr(emit, int_r_assign);
- if(!is_fptr(emit->gwion, bin->lhs->info->type) && vflag(bin->rhs->info->type->e->d.func->value_ref, vflag_member)) {
+ if(!is_fptr(emit->gwion, bin->lhs->info->type) && vflag(bin->rhs->info->type->info->func->value_ref, vflag_member)) {
const Instr pop = emit_add_instr(emit, RegPop);
pop->m_val = SZ_INT;
const Instr cpy = emit_add_instr(emit, Reg2Reg);
CHECK_OO((info->lhs = nspc_lookup_func1(nspc, sym)))
else {
DECL_OO(const Type, t, = nspc_lookup_type1(nspc, info->lhs->def->base->xid))
- info->lhs = actual_type(env->gwion, t)->e->d.func;
+ info->lhs = actual_type(env->gwion, t)->info->func;
}
Func_Base *base[2] = { info->lhs->def->base, info->rhs->def->base };
if(fptr_tmpl_push(env, info) > 0) {
}
ANN m_bool check_lambda(const Env env, const Type t, Exp_Lambda *l) {
- const Func_Def fdef = t->e->d.func->def;
+ const Func_Def fdef = t->info->func->def;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=env->scope->depth, .flag=tflag_check };
- l->owner = t->e->owner_class;
- CHECK_BB(envset_push(&es, l->owner, t->e->owner))
+ l->owner = t->info->owner_class;
+ CHECK_BB(envset_push(&es, l->owner, t->info->owner))
const m_bool ret = _check_lambda(env, l, fdef);
if(es.run)
envset_pop(&es, l->owner);
return env->gwion->type[et_null];
// create a matching signature
// TODO: we could check first if there a matching existing one
- Func_Base *const fbase = cpy_func_base(env->gwion->mp, bin->lhs->info->type->e->d.func->def->base);
+ Func_Base *const fbase = cpy_func_base(env->gwion->mp, bin->lhs->info->type->info->func->def->base);
const Fptr_Def fptr_def = new_fptr_def(env->gwion->mp, fbase);
char name[13 + strlen(env->curr->name) +
num_digit(bin->rhs->pos->first.line) + num_digit(bin->rhs->pos->first.column)];
static OP_CHECK(opck_fptr_at) {
Exp_Binary* bin = (Exp_Binary*)data;
- if(bin->rhs->info->type->e->d.func->def->base->tmpl &&
- bin->rhs->info->type->e->d.func->def->base->tmpl->call) {
- struct FptrInfo info = { bin->lhs->info->type->e->d.func, bin->rhs->info->type->e->parent->e->d.func,
+ if(bin->rhs->info->type->info->func->def->base->tmpl &&
+ bin->rhs->info->type->info->func->def->base->tmpl->call) {
+ struct FptrInfo info = { bin->lhs->info->type->info->func, bin->rhs->info->type->info->parent->info->func,
bin->lhs, exp_self(bin)->pos };
CHECK_BO(fptr_do(env, &info))
exp_setvar(bin->rhs, 1);
return bin->rhs->info->type;
}
- struct FptrInfo info = { bin->lhs->info->type->e->d.func, bin->rhs->info->type->e->d.func,
+ struct FptrInfo info = { bin->lhs->info->type->info->func, bin->rhs->info->type->info->func,
bin->lhs, exp_self(bin)->pos };
CHECK_BO(fptr_do(env, &info))
exp_setvar(bin->rhs, 1);
static OP_CHECK(opck_fptr_cast) {
Exp_Cast* cast = (Exp_Cast*)data;
const Type t = exp_self(cast)->info->type;
- struct FptrInfo info = { cast->exp->info->type->e->d.func, t->e->d.func,
+ struct FptrInfo info = { cast->exp->info->type->info->func, t->info->func,
cast->exp, exp_self(cast)->pos };
CHECK_BO(fptr_do(env, &info))
- cast->func = cast->exp->info->type->e->d.func;
+ cast->func = cast->exp->info->type->info->func;
return t;
}
}
static int is_member(const Type from, const Type to) {
- return vflag(from->e->d.func->value_ref, vflag_member) &&
+ return vflag(from->info->func->value_ref, vflag_member) &&
!(tflag(from, tflag_nonnull) || tflag(to, tflag_nonnull));
}
static OP_EMIT(opem_fptr_cast) {
const Exp_Cast* cast = (Exp_Cast*)data;
- if(exp_self(cast)->info->type->e->d.func->def->base->tmpl)
- fptr_instr(emit, cast->exp->info->type->e->d.func, 1);
+ if(exp_self(cast)->info->type->info->func->def->base->tmpl)
+ fptr_instr(emit, cast->exp->info->type->info->func, 1);
if(is_member(cast->exp->info->type, exp_self(cast)->info->type))
member_fptr(emit);
return (Instr)GW_OK;
static OP_CHECK(opck_fptr_impl) {
struct Implicit *impl = (struct Implicit*)data;
- struct FptrInfo info = { impl->e->info->type->e->d.func, impl->t->e->d.func,
+ struct FptrInfo info = { impl->e->info->type->info->func, impl->t->info->func,
impl->e, impl->e->pos };
CHECK_BO(fptr_do(env, &info))
return ((Exp)impl->e)->info->cast_to = impl->t;
struct Implicit *impl = (struct Implicit*)data;
if(is_member(impl->e->info->type, impl->t))
member_fptr(emit);
- if(impl->t->e->d.func->def->base->tmpl)
- fptr_instr(emit, ((Exp)impl->e)->info->type->e->d.func, 1);
+ if(impl->t->info->func->def->base->tmpl)
+ fptr_instr(emit, ((Exp)impl->e)->info->type->info->func, 1);
return (Instr)GW_OK;
}
static OP_CHECK(opck_usrugen) {
Exp_Binary *bin = (Exp_Binary*)data;
- const Arg_List arg = bin->lhs->info->type->e->d.func->def->base->args;
+ const Arg_List arg = bin->lhs->info->type->info->func->def->base->args;
if(!arg || arg->next)
ERR_N(exp_self(bin)->pos, _("Tick function take one and only one argument"))
if(isa(arg->type, env->gwion->type[et_float]) < 0)
ERR_N(exp_self(bin)->pos, _("Tick functions argument must be of type float"))
- if(isa(bin->lhs->info->type->e->d.func->def->base->ret_type, env->gwion->type[et_float]) < 0)
+ if(isa(bin->lhs->info->type->info->func->def->base->ret_type, env->gwion->type[et_float]) < 0)
ERR_N(exp_self(bin)->pos, _("Tick function must return float"))
- if(bin->lhs->info->type->e->d.func->value_ref->from->owner_class)
- CHECK_BN(isa(bin->lhs->info->type->e->d.func->value_ref->from->owner_class,
+ if(bin->lhs->info->type->info->func->value_ref->from->owner_class)
+ CHECK_BN(isa(bin->lhs->info->type->info->func->value_ref->from->owner_class,
bin->rhs->info->type))
return bin->rhs->info->type;
}
static OP_EMIT(opem_usrugen) {
Exp_Binary *bin = (Exp_Binary*)data;
const Instr instr = emit_add_instr(emit, UsrUGenTick);
- instr->m_val = !!bin->lhs->info->type->e->d.func->value_ref->from->owner_class;
+ instr->m_val = !!bin->lhs->info->type->info->func->value_ref->from->owner_class;
return instr;
}
isa(v->type, shred->info->vm->gwion->type[et_object]) > 0)
release(*(M_Object*)(o->data + v->from->offset), shred);
else if(tflag(v->type, tflag_struct) &&
- !GET_FLAG(v, static) && !vflag(v, vflag_union) && v->type->e->tuple) {
- const TupleForm tf = v->type->e->tuple;
+ !GET_FLAG(v, static) && !vflag(v, vflag_union) && v->type->info->tuple) {
+ const TupleForm tf = v->type->info->tuple;
for(m_uint i = 0; i < vector_size(&tf->types); ++i) {
const m_bit *data = o->data + v->from->offset;
const Type t = (Type)vector_at(&tf->types, i);
return;
}
}
- } while((t = t->e->parent));
+ } while((t = t->info->parent));
free_object(p, o);
}
if(env->func && !vflag(env->func->value_ref, vflag_member))
ERR_O(exp_self(prim)->pos, _("keyword 'this' cannot be used inside static functions..."))
if(env->func && !strcmp(s_name(env->func->def->base->xid), "@gack"))
- return force_type(env, get_gack(env->class_def->e->parent)); // get_gack ?
+ return force_type(env, get_gack(env->class_def->info->parent)); // get_gack ?
return env->class_def;
}
ERR_N(pos, _("can't %s '%s' to '%s'"), action, l->name, r->name);
if(isa(l, r) < 0)
ERR_N(pos, _("can't %s '%s' to '%s'"), action, l->name, r->name);
- return r->e->parent;
+ return r->info->parent;
}
if(l != env->gwion->type[et_null] && isa(l, r) < 0)
ERR_N(pos, _("can't %s '%s' to '%s'"), action, l->name, r->name);
static const f_instr dotmember[] = { DotMember, DotMember2, DotMember3, DotMember4 };
ANN static void emit_member_func(const Emitter emit, const Exp_Dot* member) {
- const Func f = exp_self(member)->info->type->e->d.func;
+ const Func f = exp_self(member)->info->type->info->func;
if(f->def->base->tmpl)
emit_add_instr(emit, DotTmplVal);
else
const Exp_Dot *member = (Exp_Dot*)data;
const m_str str = s_name(member->xid);
const m_bool base_static = is_class(env->gwion, member->t_base);
- const Type the_base = base_static ? member->t_base->e->d.base_type : member->t_base;
+ const Type the_base = base_static ? member->t_base->info->base_type : member->t_base;
if(!the_base->nspc)
ERR_N(member->base->pos,
_("type '%s' does not have members - invalid use in dot expression of %s"),
}
ANN static m_bool scantmpl_class_def(const Env env, struct tmpl_info *info) {
- const Class_Def c = info->base->e->cdef;
+ const Class_Def c = info->base->info->cdef;
const Class_Def cdef = new_class_def(env->gwion->mp, c->flag, info->name, c->base.ext ? cpy_type_decl(env->gwion->mp, c->base.ext) : NULL,
c->body ?cpy_ast(env->gwion->mp, c->body) : NULL,
loc_cpy(env->gwion->mp, c->pos));
cdef->base.tmpl = mk_tmpl(env, c->base.tmpl, info->call);
const m_bool ret = scan0_class_def(env, cdef);
if((info->ret = cdef->base.type)) {
- info->ret->e->cdef = cdef;
+ info->ret->info->cdef = cdef;
set_tflag(info->ret, tflag_cdef);
set_tflag(info->ret, tflag_ctmpl);
} else
}
ANN static m_bool scantmpl_union_def(const Env env, struct tmpl_info *info) {
- const Union_Def u = info->base->e->udef;
+ const Union_Def u = info->base->info->udef;
const Union_Def udef = new_union_def(env->gwion->mp, cpy_decl_list(env->gwion->mp, u->l),
loc_cpy(env->gwion->mp, u->pos));
udef->type_xid = info->name;
SET_FLAG(udef, global);
const m_bool ret = scan0_union_def(env, udef);
if(udef->type) {
- udef->type->e->udef = udef;// mark as udef
+ udef->type->info->udef = udef;// mark as udef
info->ret = udef->type;
set_tflag(info->ret, tflag_udef);
// set_tflag(info->ret, tflag_tmpl);
}
ANN static Type _scan_class(const Env env, struct tmpl_info *info) {
- if(info->base->e->parent != env->gwion->type[et_union])
+ if(info->base->info->parent != env->gwion->type[et_union])
CHECK_BO(scantmpl_class_def(env, info))
else
CHECK_BO(scantmpl_union_def(env, info))
}
ANN Type scan_class(const Env env, const Type t, const Type_Decl* td) {
- if(template_match(t->e->cdef->base.tmpl->list, td->types) < 0) // invalid template
+ if(template_match(t->info->cdef->base.tmpl->list, td->types) < 0) // invalid template
ERR_O(td->pos, _("invalid template types number"))
- struct tmpl_info info = { .base=t, .call=td->types, .list=t->e->cdef->base.tmpl->list };
+ struct tmpl_info info = { .base=t, .call=td->types, .list=t->info->cdef->base.tmpl->list };
DECL_OO(const Symbol, name, = info.name = template_id(env, &info))
const Type exists = tmpl_exists(env, name);
if(exists)
return exists;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan0_cdef,
.scope=env->scope->depth, .flag=tflag_scan0 };
- CHECK_BO(envset_push(&es, t->e->owner_class, t->e->ctx ? t->e->ctx->nspc : env->curr))
+ CHECK_BO(envset_push(&es, t->info->owner_class, t->info->ctx ? t->info->ctx->nspc : env->curr))
const Type ret = _scan_class(env, &info);
if(es.run)
- envset_pop(&es, t->e->owner_class);
+ envset_pop(&es, t->info->owner_class);
return ret;
}
}
ANN void struct_release(const VM_Shred shred, const Type base, const m_bit *ptr) {
- const Vector types = &base->e->tuple->types;
- const Vector offsets = &base->e->tuple->offset;
+ const Vector types = &base->info->tuple->types;
+ const Vector offsets = &base->info->tuple->offset;
for(m_uint i = 0; i < vector_size(types); ++i) {
const Type t = (Type)vector_at(types, i);
if(isa(t, shred->info->vm->gwion->type[et_compound]) < 0)
const m_str str = get_type_name(env, u, 1);
if(str && !strcmp(t->name, str))
return bin->lhs->info->type; // use rhs?
- } while((u = u->e->parent));
- } while((t = t->e->parent));
+ } while((u = u->info->parent));
+ } while((t = t->info->parent));
return env->gwion->type[et_null];
}
ERR_N(exp_self(cast)->pos, "'Ptr' needs types to cast")
DECL_ON(const Type, t, = known_type(env, cast->td))
const Type _t = get_type(t);
- if(_t->e->cdef && !tflag(_t, tflag_check))
+ if(_t->info->cdef && !tflag(_t, tflag_check))
CHECK_BN(ensure_traverse(env, _t))
const Type to = known_type(env, cast->td->types->td);
if(isa(cast->exp->info->type, to) > 0)
exp_setvar(e, 1);
const Type t = get_type(imp->t);
if(!tflag(t, tflag_check))
- CHECK_BN(traverse_class_def(env, t->e->cdef))
+ CHECK_BN(traverse_class_def(env, t->info->cdef))
return imp->t;
}
return NULL;
}
static DTOR(ptr_struct_dtor) {
- const Type t = (Type)vector_front(&o->type_ref->e->tuple->types);
+ const Type t = (Type)vector_front(&o->type_ref->info->tuple->types);
struct_release(shred, t, *(m_bit**)o->data);
}
DECL_ON(const Type, t, = (Type)scan_class(env, ts->t, ts->td))
set_tflag(t, tflag_tmpl);
//if(!tflag(t, tflag_scan1))exit(3);
- const Type base = known_type(env, t->e->cdef->base.tmpl->call->td);
+ const Type base = known_type(env, t->info->cdef->base.tmpl->call->td);
if(isa(base, env->gwion->type[et_compound]) > 0 && !t->nspc->dtor) {
t->nspc->dtor = new_vm_code(env->gwion->mp, NULL, SZ_INT, 1, "@PtrDtor");
if(!tflag(t, tflag_struct))
}
ANN static inline m_bool check_exp_decl_parent(const Env env, const Var_Decl var) {
- const Value value = find_value(env->class_def->e->parent, var->xid);
+ const Value value = find_value(env->class_def->info->parent, var->xid);
if(value)
ERR_B(var->pos,
_("in class '%s': '%s' has already been defined in parent class '%s' ..."),
const Value v = var->value;
Type t = v->type;
while(tflag(t, tflag_typedef))
- t = t->e->parent;
- if(!t->e->d.func)
+ t = t->info->parent;
+ if(!t->info->func)
return GW_ERROR;
if(!env->class_def)
return GW_OK;
- const Func func = t->e->d.func;
+ const Func func = t->info->func;
const Type type = func->value_ref->from->owner_class;
if(type && isa(type, env->class_def) < 0 && !GET_FLAG(func, global))
ERR_B(var->pos, _("can't use non global fptr of other class."))
}
ANN static m_bool check_var(const Env env, const Var_Decl var) {
- if(env->class_def && !env->scope->depth && env->class_def->e->parent)
+ if(env->class_def && !env->scope->depth && env->class_def->info->parent)
CHECK_BB(check_exp_decl_parent(env, var))
if(var->array && var->array->exp)
return check_subscripts(env, var->array, 1);
if(env->class_def) {
if(vflag(v, vflag_member)) {
decl_member(env, v);
- if(env->class_def->e->tuple)
+ if(env->class_def->info->tuple)
tuple_info(env, v);
} else if(GET_FLAG(td, static))
decl_static(env, v);
}
ANN static inline m_bool ensure_check(const Env env, const Type t) {
+ const Type base = get_type(t);
+ if(tflag(base, tflag_check) || !(tflag(base, tflag_cdef) || tflag(base, tflag_udef)))
+ return GW_OK;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=env->scope->depth, .flag=tflag_check };
- return envset_run(&es, t);
+ return envset_run(&es, base);
}
ANN m_bool ensure_traverse(const Env env, const Type t) {
+ const Type base = get_type(t);
+ if(tflag(base, tflag_check) || !(tflag(base, tflag_cdef) || tflag(base, tflag_udef)))
+ return GW_OK;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)traverse_cdef,
.scope=env->scope->depth, .flag=tflag_check };
- return envset_run(&es, t);
+ return envset_run(&es, base);
}
ANN static inline m_bool inferable(const Env env, const Type t, const loc_t pos) {
{
const Type t = get_type(decl->type);
CHECK_BO(inferable(env, t, td_pos(decl->td)))
- if(!tflag(t, tflag_check))
- CHECK_BO(ensure_check(env, t))
+ CHECK_BO(ensure_check(env, t))
}
const m_bool global = GET_FLAG(decl->td, global);
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
struct Vector_ v;
vector_init(&v);
vector_add(&v, (vtype)insert_symbol(type->name));
- Type owner = type->e->owner_class;
+ Type owner = type->info->owner_class;
while(owner) {
vector_add(&v, (vtype)insert_symbol(owner->name));
- owner = owner->e->owner_class;
+ owner = owner->info->owner_class;
}
Type_Decl *td = NULL;
for(m_uint i = 0 ; i < vector_size(&v); ++i)
ANN2(1) static void function_alternative(const Env env, const Type f, const Exp args, const loc_t pos){
env_err(env, pos, _("argument type(s) do not match for function. should be :"));
- Func up = f->e->d.func;
+ Func up = f->info->func;
do {
gw_err("(%s) ", up->name);
const Arg_List e = up->def->base->args;
if(f) {
// copy that tmpl->call?
Tmpl* tmpl = new_tmpl_call(env->gwion->mp, func->tmpl->call);
- tmpl->list = v->d.func_ref ? v->d.func_ref->def->base->tmpl->list : func->func->info->type->e->d.func->def->base->tmpl->list;
+ tmpl->list = v->d.func_ref ? v->d.func_ref->def->base->tmpl->list : func->func->info->type->info->func->def->base->tmpl->list;
((Exp_Call*)func)->tmpl = tmpl;
return ((Exp_Call*)func)->m_func = f;
}
ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) {
const Type t = exp->func->info->type;
DECL_OO(const Value, value, = type_value(env->gwion, t))
- const Func_Def fdef = value->d.func_ref ? value->d.func_ref->def : t->e->d.func->def;
+ const Func_Def fdef = value->d.func_ref ? value->d.func_ref->def : t->info->func->def;
Tmpl *tm = fdef->base->tmpl;
if(tm->call)
return check_predefined(env, exp, value, tm, fdef);
// use func flag?
if(isa(exp->func->info->type, env->gwion->type[et_class]) < 0)
ERR_O(exp->func->pos, _("function call using a non-function value"))
- struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=exp->func->info->type->e->d.base_type,
+ struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=exp->func->info->type->info->base_type,
.data=(uintptr_t)exp, .pos=exp_self(exp)->pos, .op_type=op_exp };
const Type t = op_check(env, &opi);
- exp_self(exp)->info->nspc = t ? t->e->owner : NULL;
+ exp_self(exp)->info->nspc = t ? t->info->owner : NULL;
return t;
}
if(exp->func->info->type == env->gwion->type[et_lambda])
return check_lambda_call(env, exp);
- if(fflag(exp->func->info->type->e->d.func, fflag_ftmpl)) {
- const Value value = exp->func->info->type->e->d.func->value_ref;
- if(value->from->owner_class && !tflag(value->from->owner_class, tflag_check))
+ if(fflag(exp->func->info->type->info->func, fflag_ftmpl)) {
+ const Value value = exp->func->info->type->info->func->value_ref;
+ if(value->from->owner_class)
CHECK_BO(ensure_traverse(env, value->from->owner_class))
}
if(exp->args)
CHECK_OO(check_exp(env, exp->args))
if(tflag(exp->func->info->type, tflag_ftmpl))
return check_exp_call_template(env, (Exp_Call*)exp);
- const Func func = find_func_match(env, exp->func->info->type->e->d.func, exp->args);
+ const Func func = find_func_match(env, exp->func->info->type->info->func, exp->args);
if((exp_self(exp)->d.exp_call.m_func = func)) {
exp->func->info->type = func->value_ref->type;
return func->def->base->ret_type;
}
ANN static m_bool predefined_call(const Env env, const Type t, const loc_t pos) {
- const m_str str = tl2str(env, t->e->d.func->def->base->tmpl->call);
+ const m_str str = tl2str(env, t->info->func->def->base->tmpl->call);
env_err(env, pos, _("Type '%s' has '%s' as pre-defined types."),
t->name, str);
free_mstr(env->gwion->mp, str);
if(tflag(t, tflag_typedef)) {
- loc_header(t->e->d.func->def->pos, env->name);
+ loc_header(t->info->func->def->pos, env->name);
gw_err(_("from definition:\n"));
- loc_err(t->e->d.func->def->pos, env->name);
+ loc_err(t->info->func->def->pos, env->name);
}
return GW_ERROR;
}
const Type t = actual_type(env->gwion, unflag_type(exp->func->info->type));
if(isa(t, env->gwion->type[et_function]) < 0)
ERR_O(exp_self(exp)->pos, _("template call of non-function value."))
- if(!t->e->d.func->def->base->tmpl)
+ if(!t->info->func->def->base->tmpl)
ERR_O(exp_self(exp)->pos, _("template call of non-template function."))
- if(t->e->d.func->def->base->tmpl->call) {
- if(env->func == t->e->d.func) {
+ if(t->info->func->def->base->tmpl->call) {
+ if(env->func == t->info->func) {
if(exp->args)
CHECK_OO(check_exp(env, exp->args))
exp->m_func = env->func;
return NULL;
DECL_OO(const Type, ret, = op_check(env, &opi))
const Type t = get_type(actual_type(env->gwion, ret));
- if(!tflag(t, tflag_check))
- CHECK_BO(ensure_traverse(env, t))
+ CHECK_BO(ensure_traverse(env, t))
return ret;
}
}
ANN m_bool check_type_def(const Env env, const Type_Def tdef) {
- return tdef->type->e->cdef ? check_class_def(env, tdef->type->e->cdef) : GW_OK;
+ return (!is_fptr(env->gwion, tdef->type) && tdef->type->info->cdef) ?
+ check_class_def(env, tdef->type->info->cdef) : GW_OK;
}
ANN static Type check_exp_lambda(const Env env,
const Exp_If* exp_if NUSED) { return env->gwion->type[et_lambda]; }
do {
CHECK_OO((curr->info->type = check_exp_func[curr->exp_type](env, &curr->d)))
if(env->func && isa(curr->info->type, env->gwion->type[et_lambda]) < 0 && isa(curr->info->type, env->gwion->type[et_function]) > 0 &&
- !fflag(curr->info->type->e->d.func, fflag_pure))
+ !fflag(curr->info->type->info->func, fflag_pure))
unset_fflag(env->func, fflag_pure);
} while((curr = curr->next));
return exp->info->type;
ANN static m_bool do_stmt_each(const Env env, const Stmt_Each stmt) {
DECL_OB(Type, t, = check_exp(env, stmt->exp))
while(tflag(t, tflag_typedef))
- t = t->e->parent;
+ t = t->info->parent;
Type ptr = array_base(t);
const m_uint depth = t->array_depth - 1;
if(!ptr || isa(t, env->gwion->type[et_array]) < 0)
sprintf(c, "nonnull Ptr:[%s]", ptr->name);
ptr = str2type(env->gwion, c, stmt->exp->pos);
const Type base = get_type(ptr);
- if(!tflag(base, tflag_check))
- CHECK_BB(ensure_traverse(env, base))
+ CHECK_BB(ensure_traverse(env, base))
}
t = (!stmt->is_ptr && depth) ? array_type(env, ptr, depth) : ptr;
stmt->v = new_value(env->gwion->mp, t, s_name(stmt->sym));
ANN static m_bool check_parent_match(const Env env, const Func_Def fdef) {
const Func func = fdef->base->func;
- const Type parent = env->class_def->e->parent;
+ const Type parent = env->class_def->info->parent;
if(!env->curr->info->vtable.ptr)
vector_init(&env->curr->info->vtable);
if(parent) {
ANN static m_bool check_func_def_override(const Env env, const Func_Def fdef) {
const Func func = fdef->base->func;
- if(env->class_def && env->class_def->e->parent) {
- const Value override = find_value(env->class_def->e->parent, fdef->base->xid);
+ if(env->class_def && env->class_def->info->parent) {
+ const Value override = find_value(env->class_def->info->parent, fdef->base->xid);
if(override && override->from->owner_class && isa(override->type, env->gwion->type[et_function]) < 0)
ERR_B(fdef->pos,
_("function name '%s' conflicts with previously defined value...\n"
HANDLE_SECTION_FUNC(check, m_bool, Env)
ANN static m_bool check_parent(const Env env, const Class_Def cdef) {
- const Type parent = cdef->base.type->e->parent;
+ const Type parent = cdef->base.type->info->parent;
const Type_Decl *td = cdef->base.ext;
if(td->array)
CHECK_BB(check_subscripts(env, td->array, 1))
- if(!tflag(parent, tflag_check))
- CHECK_BB(ensure_check(env, parent))
+ CHECK_BB(ensure_check(env, parent))
if(tflag(parent, tflag_typedef)) {
set_tflag(cdef->base.type, tflag_typedef);
}
if(tmpl_base(cdef->base.tmpl))
return GW_OK;
const Type t = cdef->base.type;
- if(t->e->owner_class && !tflag(t->e->owner_class, tflag_check))
- CHECK_BB(ensure_check(env, t->e->owner_class))
+ if(t->info->owner_class)
+ CHECK_BB(ensure_check(env, t->info->owner_class))
if(tflag(t, tflag_check))
return GW_OK;
set_tflag(t, tflag_check);
struct Vector_ v;
vector_init(&v);
do ressembles(&v, t->nspc, name);
- while((t = t->e->parent) && t->nspc);
+ while((t = t->info->parent) && t->nspc);
for(m_uint i = 0; i < vector_size(&v); ++i)
gw_err(_(" (did you mean '%s'?)\n"), (m_str)vector_at(&v, i));
vector_release(&v);
const Symbol sym = func_symbol(env, v->from->owner->name, v->name, tmpl_name, 0);
const Type exists = nspc_lookup_type0(v->from->owner, sym);
if(exists)
- return exists->e->d.func;
+ return exists->info->func;
Func m_func = f_ptr_args->m_func;
- Func_Def base = v->d.func_ref ? v->d.func_ref->def : exp->func->info->type->e->d.func->def;
+ Func_Def base = v->d.func_ref ? v->d.func_ref->def : exp->func->info->type->info->func->def;
Func_Base *fbase = cpy_func_base(env->gwion->mp, base->base);
fbase->xid = sym;
fbase->tmpl->base = 0;
return f;
Type t = value->from->owner_class;
while(t && t->nspc) {
- Func_Def fdef = value->d.func_ref ? value->d.func_ref->def : value->type->e->d.func->def;
+ Func_Def fdef = value->d.func_ref ? value->d.func_ref->def : value->type->info->func->def;
const Value v = nspc_lookup_value0(t->nspc, fdef->base->xid);
if(!v)
goto next;
if(f)
return f;
next:
- t = t->e->parent;
+ t = t->info->parent;
}
ERR_O(exp_self(exp)->pos, _("arguments do not match for template call"))
}
*post = '\0';
return nspc_lookup_type1(env->curr, insert_symbol(env->gwion->st, name));
}
- return t->e->parent;
+ return t->info->parent;
}
static m_bool op_match(const restrict Type t, const restrict Type mo) {
static inline Type scan0_type(const Env env, const m_uint xid,
const m_str name, const Type t) {
const Type type = new_type(env->gwion->mp, xid, name, t);
- type->e->ctx = env->context;
+ type->info->ctx = env->context;
return type;
}
}
ANN static void fptr_assign(const Env env, const Fptr_Def fptr) {
- const Func_Def def = fptr->type->e->d.func->def;
+ const Func_Def def = fptr->type->info->func->def;
if(GET_FLAG(fptr->base, global)) {
context_global(env);
SET_FLAG(fptr->value, global);
fptr->base->func = new_func(env->gwion->mp, s_name(fptr->base->xid), def);
fptr->value->d.func_ref = fptr->base->func;
fptr->base->func->value_ref = fptr->value;
- fptr->type->e->d.func = fptr->base->func;
+ fptr->type->info->func = fptr->base->func;
def->base->func = fptr->base->func;
}
CHECK_BB(scan0_defined(env, fptr->base->xid, td_pos(fptr->base->td)));
const m_str name = s_name(fptr->base->xid);
const Type t = scan0_type(env, env->gwion->type[et_fptr]->xid, name, env->gwion->type[et_fptr]);
- t->e->owner = !(!env->class_def && GET_FLAG(fptr->base, global)) ?
+ t->info->owner = !(!env->class_def && GET_FLAG(fptr->base, global)) ?
env->curr : env->global_nspc;
- t->e->owner_class = env->class_def;
+ t->info->owner_class = env->class_def;
if(GET_FLAG(fptr->base, global))
context_global(env);
t->nspc = new_nspc(env->gwion->mp, name);
if(env->class_def)
fptr_assign(env, fptr);
set_vflag(fptr->value, vflag_func);
- add_type(env, t->e->owner, t);
+ add_type(env, t->info->owner, t);
mk_class(env, t);
type_addref(t);
return GW_OK;
if(GET_FLAG(tdef->ext, global))
context_global(env);
add_type(env, nspc, t);
- t->e->owner = nspc;
- t->e->owner_class = env->class_def;
+ t->info->owner = nspc;
+ t->info->owner_class = env->class_def;
tdef->type = t;
if(base->nspc)
nspc_addref((t->nspc = base->nspc));
}
ANN static m_bool typedef_complex(const Env env, const Type_Def tdef, const Type base) {
- const ae_flag flag = base->e->cdef ? base->e->cdef->flag : 0;
+ const ae_flag flag = base->info->cdef ? base->info->cdef->flag : 0;
const Class_Def cdef = new_class_def(env->gwion->mp, flag, tdef->xid,
cpy_type_decl(env->gwion->mp, tdef->ext), NULL,
loc_cpy(env->gwion->mp, td_pos(tdef->ext)));
ANN static void typedef_fptr(const Env env, const Type_Def tdef, const Type base) {
tdef->type = type_copy(env->gwion->mp, base);
+ tdef->type->info->func = base->info->func;
nspc_addref(tdef->type->nspc);
tdef->type->name = s_name(tdef->xid);
- tdef->type->e->parent = base;
+ tdef->type->info->parent = base;
add_type(env, env->curr, tdef->type);
mk_class(env, tdef->type);
- if(base->e->d.func->def->base->tmpl)
+ if(base->info->func->def->base->tmpl)
set_tflag(tdef->type, tflag_ftmpl);
}
t->xid = ++env->scope->type_xid;
const Symbol sym = scan0_sym(env, "enum", edef->pos);
t->name = edef->xid ? s_name(edef->xid) : s_name(sym);
- t->e->parent = env->gwion->type[et_int];
+ t->info->parent = env->gwion->type[et_int];
const Nspc nspc = GET_FLAG(edef, global) ? env->global_nspc : env->curr;
- t->e->owner = nspc;
- t->e->owner_class = env->class_def;
+ t->info->owner = nspc;
+ t->info->owner_class = env->class_def;
add_type(env, nspc, t);
mk_class(env, t);
scan0_implicit_similar(env, t, env->gwion->type[et_int]);
t->xid = ++env->scope->type_xid;
t->name = name;
t->nspc = new_nspc(env->gwion->mp, name);
- t->e->owner = t->nspc->parent = env->curr;
- t->e->owner_class = env->class_def;
- t->e->parent = env->gwion->type[et_union];
- t->e->tuple = new_tupleform(env->gwion->mp, NULL);
+ t->info->owner = t->nspc->parent = env->curr;
+ t->info->owner_class = env->class_def;
+ t->info->parent = env->gwion->type[et_union];
+ t->info->tuple = new_tupleform(env->gwion->mp, NULL);
add_type(env, env->curr, t);
if(add)
mk_class(env, t);
if(tmpl_base(udef->tmpl)) {
const Union_Def u = cpy_union_def(env->gwion->mp, udef);
u->type = udef->type;
- udef->type->e->udef = u;
+ udef->type->info->udef = u;
set_tflag(u->type, tflag_tmpl);
set_tflag(u->type, tflag_udef);
}
while(owner) {
if(t == owner)
ERR_O(td_pos(td), _("'%s' as parent inside itself\n."), owner->name);
- owner = owner->e->owner_class;
+ owner = owner->info->owner_class;
}
return t;
}
const Type t = scan0_type(env, ++env->scope->type_xid, s_name(cdef->base.xid), parent);
if(cflag(cdef, cflag_struct))
set_tflag(t, tflag_struct);
- t->e->tuple = new_tupleform(env->gwion->mp, parent);
- t->e->owner = env->curr;
- t->e->owner_class = env->class_def;
+ t->info->tuple = new_tupleform(env->gwion->mp, parent);
+ t->info->owner = env->curr;
+ t->info->owner_class = env->class_def;
t->nspc = new_nspc(env->gwion->mp, t->name);
t->nspc->parent = env->curr;
- t->e->cdef = cdef;
+ t->info->cdef = cdef;
t->flag |= cdef->flag;
- add_type(env, t->e->owner, t);
+ add_type(env, t->info->owner, t);
cdef_flag(cdef, t);
if(cdef->base.ext && cdef->base.ext->array)
set_tflag(t, tflag_typedef);
env->curr = (Nspc)vector_pop(&env->scope->nspc_stack);
if(cpy && cdef->base.type) {
c->base.type = cdef->base.type;
- c->base.type->e->cdef = cdef;
+ c->base.type->info->cdef = cdef;
set_tflag(c->base.type, tflag_cdef);
set_tflag(cdef->base.type, tflag_scan0);// redundant
}
while(parent) {
if(parent == owner)
ERR_B(td_pos(td), _("%s declared inside %s"), t->name, owner->name);
- parent = parent->e->parent;
+ parent = parent->info->parent;
}
- } while((owner = owner->e->owner_class));
+ } while((owner = owner->info->owner_class));
return GW_OK;
}
ANN static inline m_bool ensure_scan1(const Env env, const Type t) {
+ const Type base = get_type(t);
+ if(tflag(base, tflag_scan1) || !(tflag(base, tflag_cdef) || tflag(base, tflag_udef)))
+ return GW_OK;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan1_cdef,
.scope=env->scope->depth, .flag=tflag_scan1 };
- return envset_run(&es, t);
+ return envset_run(&es, base);
}
ANN static Type scan1_type(const Env env, Type_Decl* td) {
const Type t = get_type(type);
if(!env->func && env->class_def && !GET_FLAG(td, ref))
CHECK_BO(type_cyclic(env, t, td))
- if(!tflag(t, tflag_scan1))
- CHECK_BO(ensure_scan1(env, t))
+ CHECK_BO(ensure_scan1(env, t))
return type;
}
DECL_OO(const Type ,t, = void_type(env, decl->td))
if(decl->td->xid == insert_symbol("auto") && decl->type)
return decl->type;
- if(GET_FLAG(t, private) && t->e->owner != env->curr)
+ if(GET_FLAG(t, private) && t->info->owner != env->curr)
ERR_O(exp_self(decl)->pos, _("can't use private type %s"), t->name)
if(GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0))
ERR_O(exp_self(decl)->pos, _("can't use protected type %s"), t->name)
if(var->array && !var->array->exp)
SET_FLAG(decl->td, ref);
if(env->class_def) {
- if(env->class_def->e->tuple)
+ if(env->class_def->info->tuple)
tuple_contains(env, v);
} else if(!env->scope->depth)
set_vflag(v, vflag_fglobal);// file global
if(global) {
if(env->context)
env->context->global = 1;
- if(!is_global(decl->type->e->owner, env->global_nspc))
+ if(!is_global(decl->type->info->owner, env->global_nspc))
ERR_B(exp_self(decl)->pos, _("type '%s' is not global"), decl->type->name)
}
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
SET_FLAG(v, const);
set_vflag(v, vflag_valid);
set_vflag(v, vflag_enum);
- nspc_add_value(edef->t->e->owner, list->xid, v);
+ nspc_add_value(edef->t->info->owner, list->xid, v);
vector_add(&edef->values, (vtype)v);
} while((list = list->next));
return GW_OK;
ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) {
if(!tdef->type)
tdef->type = nspc_lookup_type0(env->curr, tdef->xid);
- if(!tdef->type->e->cdef)return GW_OK;
- return !is_fptr(env->gwion, tdef->type) ? scan1_cdef(env, tdef->type) : GW_OK;
+ return (!is_fptr(env->gwion, tdef->type) && tdef->type->info->cdef) ?
+ scan1_cdef(env, tdef->type) : GW_OK;
}
ANN static m_bool scan1_union_def_action(const Env env, const Union_Def udef,
ANN static Type scan1_get_parent(const Env env, const Type_Def tdef) {
const Type parent = known_type(env, tdef->ext);
- CHECK_OO((tdef->type->e->parent = parent));
+ CHECK_OO((tdef->type->info->parent = parent));
Type t = parent;
do if(tdef->type == t)
ERR_O(td_pos(tdef->ext), _("recursive (%s <= %s) class declaration."), tdef->type->name, t->name)
- while((t = t->e->parent));
+ while((t = t->info->parent));
return parent;
}
if(cdef->base.ext->array)
CHECK_BB(scan1_exp(env, cdef->base.ext->array->exp))
DECL_OB(const Type , parent, = scan1_get_parent(env, &cdef->base))
-// if(GET_FLAG(parent, abstract)) // could be final
-//SET_FLAG(cdef->base.type, abstract);
-// ERR_B(td_pos(cdef->base.ext), _("can't inherit from abstract parent class '%s'\n."), parent->name);
if(isa(parent, env->gwion->type[et_object]) < 0)
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
- if(!tflag(parent, tflag_scan1))
- CHECK_BB(ensure_scan1(env, parent))
+ CHECK_BB(ensure_scan1(env, parent))
if(type_ref(parent))
ERR_B(pos, _("can't use ref type in class extend"))
if(tflag(parent, tflag_nonnull))
if(tflag(t, tflag_scan1))
return GW_OK;
set_tflag(t, tflag_scan1);
- if(t->e->owner_class && !tflag(t->e->owner_class, tflag_scan1))
- CHECK_BB(ensure_scan1(env, t->e->owner_class))
+ if(t->info->owner_class)
+ CHECK_BB(ensure_scan1(env, t->info->owner_class))
if(cdef->base.ext)
CHECK_BB(cdef_parent(env, cdef))
if(cdef->body)
ANN static m_bool scan2_stmt_list(const Env, Stmt_List);
ANN static inline m_bool ensure_scan2(const Env env, const Type t) {
+ const Type base = get_type(t);
+ if(tflag(base, tflag_scan2) || !(tflag(base, tflag_cdef) || tflag(base, tflag_udef)))
+ return GW_OK;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan2_cdef,
.scope=env->scope->depth, .flag=tflag_scan2 };
- return envset_run(&es, t);
+ return envset_run(&es, base);
}
ANN static m_bool scan2_decl(const Env env, const Exp_Decl* decl) {
const Type t = get_type(decl->type);
- if(!tflag(t, tflag_scan2))
- CHECK_BB(ensure_scan2(env, t))
+ CHECK_BB(ensure_scan2(env, t))
Var_Decl_List list = decl->list;
do {
const Var_Decl var = list->self;
ANN m_bool scan2_fptr_def(const Env env NUSED, const Fptr_Def fptr) {
if(!tmpl_base(fptr->base->tmpl)) {
- const Func_Def def = fptr->type->e->d.func->def;
+ const Func_Def def = fptr->type->info->func->def;
if(def->base->args) {
RET_NSPC(scan2_args(def))
}
}
ANN m_bool scan2_type_def(const Env env, const Type_Def tdef) {
- if(!tdef->type->e->cdef) return GW_OK;
- return !is_fptr(env->gwion, tdef->type) ? scan2_class_def(env, tdef->type->e->cdef) : GW_OK;
+ if(!tdef->type->info->cdef) return GW_OK;
+ return (!is_fptr(env->gwion, tdef->type) && tdef->type->info->cdef) ?
+ scan2_class_def(env, tdef->type->info->cdef) : GW_OK;
}
ANN static inline Value prim_value(const Env env, const Symbol s) {
if(!fbflag(f->base, fbflag_internal))
ERR_B(f->pos, _("function name '%s' is already used by another value"), overload->name)
}
- const Func obase = !fptr ? overload->d.func_ref : overload->type->e->d.base_type->e->d.func;
+ const Func obase = !fptr ? overload->d.func_ref : overload->type->info->base_type->info->func;
if(GET_FLAG(obase->def->base, final))
ERR_B(f->pos, _("can't overload final function %s"), overload->name)
const m_bool base = tmpl_base(f->base->tmpl);
const Type base = env->gwion->type[func->def->base->td ? et_function : et_lambda];
const Type t = type_copy(env->gwion->mp, base);
t->xid = ++env->scope->type_xid;
- t->e->parent = base;
+ t->info->parent = base;
t->name = func->name;
- t->e->owner = env->curr;
- t->e->owner_class = env->class_def;
- t->e->d.func = func;
+ t->info->owner = env->curr;
+ t->info->owner_class = env->class_def;
+ t->info->func = func;
return t;
}
}
} while((ff = ff->next) && ++i);
}
- } while(type && (type = type->e->parent) && (nspc = type->nspc));
+ } while(type && (type = type->info->parent) && (nspc = type->nspc));
--i;
const Symbol sym = func_symbol(env, env->curr->name, name, "template", i);
nspc_add_value(env->curr, sym, value);
HANDLE_SECTION_FUNC(scan2, m_bool, Env)
ANN static m_bool scan2_parent(const Env env, const Class_Def cdef) {
- const Type parent = cdef->base.type->e->parent;
- if(!tflag(parent, tflag_scan2))
- CHECK_BB(ensure_scan2(env, parent))
+ const Type parent = cdef->base.type->info->parent;
+ CHECK_BB(ensure_scan2(env, parent))
if(cdef->base.ext->array)
CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp))
return GW_OK;
const Type t = cdef->base.type;
if(tflag(t, tflag_scan2))
return GW_OK;
- if(t->e->owner_class && !tflag(t->e->owner_class, tflag_scan2))
- CHECK_BB(ensure_scan2(env, t->e->owner_class))
+ if(t->info->owner_class)
+ CHECK_BB(ensure_scan2(env, t->info->owner_class))
set_tflag(t, tflag_scan2);
if(cdef->base.ext)
CHECK_BB(cdef_parent(env, cdef))
__attribute__((returns_nonnull))
ANN Type unflag_type(const Type t) {
- const Type type = !tflag(t, tflag_nonnull) ? t : t->e->parent;
- return !tflag(type, tflag_force) ? type : type->e->parent;
+ const Type type = !tflag(t, tflag_nonnull) ? t : t->info->parent;
+ return !tflag(type, tflag_force) ? type : type->info->parent;
}
__attribute__((returns_nonnull))
ANN m_bool scanx_cdef(const Env env, void* opt, const Type base,
const _exp_func f_cdef, const _exp_func f_union) {
const Type t = get_type(base);
- if(t->e->parent != env->gwion->type[et_union])
- return f_cdef(opt, t->e->cdef);
- const m_bool ret = f_union(opt, t->e->udef);
+ if(t->info->parent != env->gwion->type[et_union])
+ return f_cdef(opt, t->info->cdef);
+ const m_bool ret = f_union(opt, t->info->udef);
return ret;
}
}
ANN static m_bool _template_push(const Env env, const Type t) {
- if(t->e->owner_class)
- CHECK_BB(template_push(env, t->e->owner_class))
+ if(t->info->owner_class)
+ CHECK_BB(template_push(env, t->info->owner_class))
if(tflag(t, tflag_tmpl))
- return push_types(env, t->e->cdef->base.tmpl); // incorrect
+ return push_types(env, t->info->cdef->base.tmpl); // incorrect
return GW_OK;
}
static ANN Type scan_func(const Env env, const Type t, const Type_Decl* td) {
DECL_OO(const m_str, tl_name, = tl2str(env, td->types))
- const Symbol sym = func_symbol(env, t->e->owner->name, t->e->d.func->name, tl_name, 0);
+ const Symbol sym = func_symbol(env, t->info->owner->name, t->info->func->name, tl_name, 0);
free_mstr(env->gwion->mp, tl_name);
- const Type base_type = nspc_lookup_type1(t->e->owner, sym);
+ const Type base_type = nspc_lookup_type1(t->info->owner, sym);
if(base_type)
return base_type;
const Type ret = type_copy(env->gwion->mp, t);
- ret->e->parent = t;
+ ret->info->parent = t;
ret->name = s_name(sym);
set_tflag(ret, tflag_ftmpl);
- nspc_add_type_front(t->e->owner, sym, ret);
- void* func_ptr = t->e->d.func->def->d.dl_func_ptr;
- if(vflag(t->e->d.func->value_ref, vflag_builtin))
- t->e->d.func->def->d.dl_func_ptr = NULL;
- const Func_Def def = cpy_func_def(env->gwion->mp, t->e->d.func->def);
- const Func func = ret->e->d.func = new_func(env->gwion->mp, s_name(sym), def);
+ nspc_add_type_front(t->info->owner, sym, ret);
+ void* func_ptr = t->info->func->def->d.dl_func_ptr;
+ if(vflag(t->info->func->value_ref, vflag_builtin))
+ t->info->func->def->d.dl_func_ptr = NULL;
+ const Func_Def def = cpy_func_def(env->gwion->mp, t->info->func->def);
+ const Func func = ret->info->func = new_func(env->gwion->mp, s_name(sym), def);
const Value value = new_value(env->gwion->mp, ret, s_name(sym));
func->flag = def->base->flag;
- if(vflag(t->e->d.func->value_ref, vflag_member))
+ if(vflag(t->info->func->value_ref, vflag_member))
set_vflag(value, vflag_member);
value->d.func_ref = func;
- value->from->owner = t->e->owner;
- value->from->owner_class = t->e->owner_class;
+ value->from->owner = t->info->owner;
+ value->from->owner_class = t->info->owner_class;
func->value_ref = value;
- func->def->base->tmpl = mk_tmpl(env, t->e->d.func->def->base->tmpl, td->types);
+ func->def->base->tmpl = mk_tmpl(env, t->info->func->def->base->tmpl, td->types);
def->base->func = func;
- nspc_add_value_front(t->e->owner, sym, value);
- if(vflag(t->e->d.func->value_ref, vflag_builtin)) {
+ nspc_add_value_front(t->info->owner, sym, value);
+ if(vflag(t->info->func->value_ref, vflag_builtin)) {
builtin_func(env->gwion->mp, func, func_ptr);
- t->e->d.func->def->d.dl_func_ptr = func_ptr;
+ t->info->func->def->d.dl_func_ptr = func_ptr;
}
return ret;
}
static ANN Type maybe_func(const Env env, const Type t, const Type_Decl* td) {
- if(isa(t, env->gwion->type[et_function]) > 0 && t->e->d.func->def->base->tmpl)
+ if(isa(t, env->gwion->type[et_function]) > 0 && t->info->func->def->base->tmpl)
return scan_func(env, t, td);
ERR_O(td->pos,
_("type '%s' is not template. You should not provide template types"), t->name)
ANN static Type resolve(const Env env, Type_Decl* td) {
DECL_OO(const Type, base, = find_type(env, td))
- if(base->e->ctx && base->e->ctx->error)
+ if(base->info->ctx && base->info->ctx->error)
ERR_O(td_pos(td), _("type '%s' is invalid"), base->name)
DECL_OO(const Type, t, = scan_type(env, base, td))
const Type ret = !td->array ? t : array_type(env, t, td->array->depth);
ANN void gack(const VM_Shred shred, const m_uint offset) {
const Type t = *(Type*)shred->reg;
- const VM_Code code = get_gack(t)->e->gack;
+ const VM_Code code = get_gack(t)->info->gack;
if(code->builtin) {
const m_uint sz = *(m_uint*)(shred->reg + SZ_INT);
((f_gack)code->native_func)(t, (shred->reg - sz), shred);