struct Vector_ contains;
struct Vector_ types;
struct Vector_ offset;
- m_uint start;
+ uint64_t start;
};
ANN Type tuple_type(const Env, const Vector, const loc_t);
tflag_float = 1 << 20,
tflag_union = 1 << 21,
tflag_enum = 1 << 22,
- tflag_error = 1 << 23,
- tflag_ref = 1 << 24,
+ tflag_ref = 1 << 23,
} __attribute__((packed));
struct Type_ {
m_str name;
Nspc nspc;
struct TypeInfo_ *info;
- size_t size;
- size_t array_depth;
+ uint64_t size;
+ uint32_t array_depth;
struct Vector_ effects; // pre-ctor effects
uint16_t ref;
uint16_t weight;
Nspc owner;
Type owner_class;
struct Context_ *ctx;
- size_t offset;
+ uint32_t offset;
m_str filename;
loc_t loc;
} ValueFrom;
vflag_direct = 1 << 4,
vflag_builtin = 1 << 5,
vflag_member = 1 << 6,
- vflag_inner = 1 << 7, // value is in a scope
- vflag_release = 1 << 8,
- vflag_assigned = 1 << 9,
- vflag_arg = 1 << 10
- // vflag_used = 1 << 3
+ vflag_release = 1 << 7,
+ vflag_assigned = 1 << 8,
+ vflag_arg = 1 << 9
} __attribute__((packed));
union value_data {
}
ANN static void clean_var_decl(Clean *a, Var_Decl *b) {
- if (a->scope && b->value && !tflag(b->value->type, tflag_error)) value_remref(b->value, a->gwion);
+ if (a->scope && b->value) value_remref(b->value, a->gwion);
}
ANN static void clean_exp_decl(Clean *a, Exp_Decl *b) {
_mp_free(gwion->mp, t->size, a->d.ptr);
else if (is_class(gwion, t))
type_remref(t, gwion);
- else if (vflag(a, vflag_inner))
- type_remref(t, gwion);
-
mp_free(gwion->mp, ValueFrom, a->from);
mp_free(gwion->mp, Value, a);
}
*/
exp->func->type = func->value_ref->type;
call_add_effect(env, func, exp->func->pos);
+// used in new. why???
return func->def->base->ret_type != env->gwion->type[et_auto] ?
func->def->base->ret_type : exp->func->d.exp_dot.base->type;
}
if (exp->tmpl) {
DECL_BO(const m_bool, ret, = func_check(env, exp));
if (!ret) return exp_self(exp)->type;
-/* const */Type t = actual_type(env->gwion, exp->func->type);
+ Type t = actual_type(env->gwion, exp->func->type);
if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) {
t = typedef_base(t);
t = mp_vector_at(t->info->cdef->body, Section , 0)->d.func_def->base->func->value_ref->type;
}
if (tflag(tdef->type, tflag_cdef))
return check_class_def(env, tdef->type->info->cdef);
+ else inherit(tdef->type);
return GW_OK;
}
return ret;
}
-//#define check_fptr_def dummy_func
HANDLE_SECTION_FUNC(check, m_bool, Env)
ANN static m_bool check_parent(const Env env, const Class_Def cdef) {
const Type_Decl *td = cdef->base.ext;
if (td->array && td->array->exp)
CHECK_BB(check_subscripts(env, td->array, 1));
- CHECK_BB(ensure_check(env, parent));
- // if(tflag(parent, tflag_typedef)) {
- // set_tflag(cdef->base.type, tflag_typedef);
- // }
+ CHECK_BB(ensure_traverse(env, parent));
return GW_OK;
}
}
ANN static bool class_def_has_body(const Env env, Ast ast) {
-// do {
for(m_uint i = 0; i < ast->len; i++) {
const Section *section = mp_vector_at(ast, Section, i);
if (section->section_type == ae_section_stmt) {
if (GET_FLAG(vd.value, late)) continue;
if (isa(vd.value->type, env->gwion->type[et_compound]) > 0)
return true;
- } else
- return true;
- } //while ((list = list->next));
+ } else return true;
+ }
}
- } //while ((ast = ast->next));
+ }
return false;
}
ANN static inline bool type_is_recurs(const Type t, const Type tgt) {
-// if(tflag(tgt, tflag_union)) return false;
return isa(tgt, t) > 0 || isa(t, tgt) > 0 || (tgt->info->tuple && vector_find(&tgt->info->tuple->contains, (m_uint)t) > -1);
}
gwerr_secondary("in class", t->name, t->info->cdef->base.pos);
const Type first = tgt->info->value->from->loc.first.line < t->info->value->from->loc.first.line ?
-// tgt : t;
v->type : t;
const Type second = tgt->info->value->from->loc.first.line > t->info->value->from->loc.first.line ?
-// tgt : t;
v->type : t;
if(first != second) {
if(t->ref > 2)
type_remref(t, env->gwion);
}
- set_tflag(t, tflag_error);
set_tflag(t, tflag_infer);
set_tflag(tgt, tflag_infer);
unset_tflag(t, tflag_check);
if (cflag(cdef, cflag_struct) || class_def_has_body(env, cdef->body))
set_tflag(t, tflag_ctor);
}
-/*
- // enforce new to be defined in every child class
- if(t->info->parent->nspc && nspc_lookup_value0(t->info->parent->nspc, insert_symbol("new")) && !nspc_lookup_value0(t->nspc, insert_symbol("new"))) {
- env_err(env, cdef->pos, "must define 'new' operator");
- env_warn(env, t->info->parent->info->value->from->loc, "defined here");
- return GW_ERROR;
- }
-*/
if (!GET_FLAG(cdef, abstract)) CHECK_BB(check_abstract(env, cdef));
if (cdef->traits) {
ID_List list = cdef->traits;
for(m_uint i = 0; i < ast->len; i++) {
Section * section = mp_vector_at(ast, Section, i);
(void)check_section(env, section);
- mp_vector_add(env->gwion->mp, &env->context->extend, Section, *section);
+ mp_vector_add(env->gwion->mp, &env->context->tree, Section, *section);
}
free_mp_vector(env->gwion->mp, Section, env->context->extend);
env->context->extend = NULL;
ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) {
CHECK_BB(env_access(env, tdef->ext->flag, tdef->ext->pos));
- DECL_OB(const Type, base, = tdef->tmpl ? find_type(env, tdef->ext)
- : known_type(env, tdef->ext));
+ DECL_OB(const Type, base, = known_type(env, tdef->ext));
CHECK_BB(scan0_defined(env, tdef->xid, tdef->ext->pos));
const bool global =
GET_FLAG(tdef->ext, global); // TODO: handle global in class
if (tdef->type != base && !tdef->distinct && !tdef->when)
scan0_implicit_similar(env, base, tdef->type);
if (tdef->distinct || tdef->when) {
-// tdef->type->info->parent = base->info->parent;
if (base->info->gack)
vmcode_addref(tdef->type->info->gack = base->info->gack);
set_tflag(tdef->type, tflag_distinct);
struct Op_Import opi = {.lhs = base, .rhs = tdef->type};
op_cpy(env, &opi);
scan0_explicit_distinct(env, base, tdef->type);
- type_addref(tdef->type); // maybe because of scope_iter in nspc_free_values
} else //if(tdef->ext->array)
set_tflag(tdef->type, tflag_typedef);
if(tflag(base, tflag_ref)) {
set_tflag(tdef->type, tflag_infer);
}
if (global) env_pop(env, 0);
- if (tdef->type != base)
- tdef->type->info->base_type = base;
return GW_OK;
}
}
ANN static Type get_parent_base(const Env env, Type_Decl *td) {
- DECL_OO(const Type, t, = find_type(env, td));
+ DECL_OO(const Type, t, = known_type(env, td));
Type owner = env->class_def;
while (owner) {
if (t == owner)
}
ANN static inline Type scan0_final(const Env env, Type_Decl *td) {
- const Type t = find_type(env, td);
+ const Type t = known_type(env, td);
if(!t) ERR_O(td->pos, _("can't find parent class %s\n."), s_name(td->xid));
return t;
}
} else set_vflag(v, vflag_fglobal); // file global
} else if (GET_FLAG(decl->td, global))
SET_FLAG(v, global);
- else if(v->type != env->gwion->type[et_auto] && v->type != env->class_def) {
- type_addref(v->type);
- set_vflag(v, vflag_inner); // file global
- }
nspc_add_value(env->curr, vd->xid, v);
((Exp_Decl *)decl)->type = decl->vd.value->type;
return GW_OK;
HANDLE_SECTION_FUNC(scan1, m_bool, Env)
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->info->parent = parent));
+ const Type parent = tdef->type->info->parent;
Type t = parent;
do
if (tdef->type == t)
if (isa(parent, env->gwion->type[et_object]) < 0 &&
!(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_udef)))
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
- CHECK_BB(ensure_scan1(env, parent));
if (type_ref(parent)) ERR_B(pos, _("can't use ref type in class extend"))
return GW_OK;
}
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->info->parent;
- CHECK_BB(ensure_scan2(env, parent));
if (cdef->base.ext->array && cdef->base.ext->array->exp)
CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp));
return GW_OK;
-#! [contains] find parent
+#! [contains] unknown type
class C extends UserUGen {
var D d;
}
-#! [contains] find parent
+#! [contains] unknown type
class C extends Undefined {}
var C c;
<<< c >>>;