Skip to content

Commit

Permalink
🔥 few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Jan 31, 2024
1 parent 6ecdb45 commit 0188110
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/lib/object_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ OP_EMIT(opem_object_dot) {
emit_member(emit, value, exp_getvar(exp_self(member)));
else
emit_struct_data(emit, value, exp_getvar(exp_self(member)));
} else if (GET_FLAG(value, static))
} else {
assert(GET_FLAG(value, static));
emit_dot_static_import_data(emit, value, exp_getvar(exp_self(member)));
else exit(3); //emit_pushimm(emit, (m_uint)value->type);
}
if(isa(value->type, emit->gwion->type[et_object]) > 0 &&
!exp_getvar(exp_self(member)) &&
(GET_FLAG(value, static) || GET_FLAG(value, late)))
Expand Down
2 changes: 1 addition & 1 deletion src/parse/scan0.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ ANN static Type cdef_parent(const Env env, const Class_Def cdef) {
}
if (tmpl_base(cdef->base.tmpl)) return get_parent_base(env, cdef->base.ext);
const bool tmpl = !!cdef->base.tmpl;
if (tmpl) template_push_types(env, cdef->base.tmpl);
if (tmpl) CHECK_BO(template_push_types(env, cdef->base.tmpl));
const Type t = scan0_final(env, cdef->base.ext);
if (tmpl) nspc_pop_type(env->gwion->mp, env->curr);
return t;
Expand Down
9 changes: 4 additions & 5 deletions src/parse/spread.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ANN m_bool spread_ast(const Env env, const Spread_Def spread, const Tmpl *tmpl)
for(uint32_t i = tmpl->list->len - 1; i < tmpl->call->len; i++) {
fseek(f, 0, SEEK_SET);
const TmplArg targ = *mp_vector_at(tmpl->call, TmplArg, i);
// skip or error on const?
// or do smth else?
// post spread const expression won't reach here
assert(targ.type == tmplarg_td);
DECL_OB(const Type, t, = known_type(env, targ.d.td));
struct AstGetter_ arg = {env->name, f, env->gwion->st, .ppa = env->gwion->ppa};
const m_str type = type2str(env->gwion, t, targ.d.td->tag.loc);
Expand Down Expand Up @@ -75,8 +75,8 @@ ANN Ast spread_class(const Env env, const Ast body) {
{
++offset;
break;
}
mp_vector_add(env->gwion->mp, &new_body, Section, section);
}
mp_vector_add(env->gwion->mp, &new_body, Section, section);
}
} else {
if(!acc)
Expand Down Expand Up @@ -112,7 +112,6 @@ ANN Stmt_List spread_func(const Env env, const Stmt_List body) {
const Stmt stmt = *mp_vector_at(list, Stmt, j);
mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt);
}
break;
}
} else {
mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt);
Expand Down
16 changes: 9 additions & 7 deletions src/parse/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,16 @@ static ANN bool is_single_variadic(const MP_Vector *v) {
return !strcmp(s_name(spec->tag.sym), "...");
}


ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t loc, const bool is_spread) {
if (!sl || sl->len > tl->len || (tl->len != sl->len && !is_spread))
ERR_B(loc, "invalid template type number");
for (uint32_t i = 0; i < sl->len; i++) {
TmplArg *arg = mp_vector_at(tl, TmplArg, i);
TmplArg *targ = mp_vector_at(tl, TmplArg, i);
Specialized *spec = mp_vector_at(sl, Specialized, i);
if(arg->type == tmplarg_td) {
if(targ->type == tmplarg_td) {
if(spec->td) {
Type_Decl *base = arg->d.td;
Type_Decl *base = targ->d.td;
Type_Decl *next = base;
Type_Decl *last = next->next;
while(next && last) {
Expand All @@ -186,9 +187,9 @@ ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Speciali
next->next = NULL;
const Type t = known_type(env, base);
if(t) {
arg->type = tmplarg_exp;
targ->type = tmplarg_exp;
Exp* e = new_exp_td(env->gwion->mp, base, base->tag.loc);
arg->d.exp = new_exp_dot(env->gwion->mp, e, last->tag.sym, base->tag.loc);
targ->d.exp = new_exp_dot(env->gwion->mp, e, last->tag.sym, base->tag.loc);
free_type_decl(env->gwion->mp, last);
i--;
continue;
Expand All @@ -199,7 +200,7 @@ ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Speciali
spec->td ? "constant" : "type");
}

DECL_OB(const Type, t, = known_type(env, arg->d.td));
DECL_OB(const Type, t, = known_type(env, targ->d.td));
if(spec->traits) {
Symbol missing = miss_traits(t, spec);
if (missing) {
Expand Down Expand Up @@ -246,7 +247,8 @@ ANN static Type _scan_type(const Env env, const Type t, Type_Decl *td) {
Specialized_List sl = tmpl
? tmpl->list : NULL;
const bool is_spread = is_spread_tmpl(tmpl);
if(!single_variadic) CHECK_BO(check_tmpl(env, tl, sl, td->tag.loc, is_spread));
if(!single_variadic)
CHECK_BO(check_tmpl(env, tl, sl, td->tag.loc, is_spread));
struct Op_Import opi = {.op = insert_symbol("class"),
.lhs = t,
.data = (uintptr_t)&ts,
Expand Down
2 changes: 1 addition & 1 deletion tests/new/ref.gw
Original file line number Diff line number Diff line change
@@ -1 +1 @@
new Object => var Object? o;
new Object :=> var Object? o;
2 changes: 1 addition & 1 deletion tests/spread/spread_error.gw
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class C:[...] {

... T : arg {
zvar T arg;
var T arg;
}...


Expand Down

0 comments on commit 0188110

Please sign in to comment.