-Subproject commit d5d3cdd5dc857479181e9d977c32718ac743a82d
+Subproject commit 601562fc8e90d0cc4a66e1db03e78af3afbab46a
if(udef->xid) {
union_allocdata(emit->gwion->mp, udef);
Type_Decl *type_decl = new_type_decl(emit->gwion->mp,
- new_id_list(emit->gwion->mp, udef->xid, udef->pos));
+ new_id_list(emit->gwion->mp, udef->xid, loc_cpy(emit->gwion->mp, udef->pos)));
type_decl->flag = udef->flag;
const Var_Decl var_decl = new_var_decl(emit->gwion->mp, udef->xid, NULL, loc_cpy(emit->gwion->mp, udef->pos));
const Var_Decl_List var_decl_list = new_var_decl_list(emit->gwion->mp, var_decl, NULL);
base = slist;
{// build Type_List
const ID_List ilist = new_id_list(env->gwion->mp, tsym,
- loc_cpy(env->gwion->mp, pos));
+ loc_cpy(env->gwion->mp, pos)));
Type_Decl *td = new_type_decl(env->gwion->mp, ilist);
Type_List tmp_tl = new_type_list(env->gwion->mp, td, NULL);
if(tl)
Section * section = new_section_stmt_list(env->gwion->mp, base);
Class_Body body = new_class_body(env->gwion->mp, section, NULL);
const ID_List ilist = new_id_list(env->gwion->mp, insert_symbol(env->gwion->type[et_tuple]->name),
- loc_cpy(env->gwion->mp, pos));
+ loc_cpy(env->gwion->mp, loc_cpy(env->gwion->mp, pos)));
Type_Decl *td = new_type_decl(env->gwion->mp, ilist);
Class_Def cdef = new_class_def(env->gwion->mp, ae_flag_template,
sym, td, body, loc_cpy(env->gwion->mp, pos));
#include "parse.h"
#include "gwion.h"
#include "tuple.h"
+#include "context.h"
ANN static void free_type(Type a, Gwion gwion) {
if(GET_FLAG(a, template) || GET_FLAG(a, global)) {
free_decl_list(gwion->mp, a->e->def->list);
}
a->e->def->union_def = NULL;
- } else if(a->e->def)
+ } else if(a->e->def) {
+// looks like errored template get be freed for some reason
+// fix that
+ UNSET_FLAG(a->e->def, template);
+ if(a->e->ctx && a->e->ctx->error)//exit(12);
+ SET_FLAG(a->e->def, ref);
+ else
+ UNSET_FLAG(a->e->def, ref);
+ UNSET_FLAG(a->e->def, global);
free_class_def(gwion->mp, a->e->def);
+ }
}
if(a->nspc)
REM_REF(a->nspc, gwion);
Enum_Def a = mp_calloc(p, Enum_Def);
a->list = cpy_id_list(p, src->list);
a->xid = src->xid;
+ a->pos = loc_cpy(p, src->pos);
a->flag = src->flag;
vector_init(&a->values);
return a;
a->type_xid = src->type_xid; // 1
if(src->tmpl)
a->tmpl = cpy_tmpl(p, src->tmpl); // 1
+ a->pos = loc_cpy(p, src->pos);
a->flag = src->flag; // 1
return a;
}
s_name(edef->xid), v->type->name)
CHECK_BB(scan0_defined(env, edef->xid, edef->pos))
}
+// TODO: make a func
const Type t = type_copy(env->gwion->mp, env->gwion->type[et_int]);
t->xid = ++env->scope->type_xid;
- t->name = edef->xid ? s_name(edef->xid) : "int";
+ const size_t line_len = num_digit(edef->pos->first_line);
+ const size_t col_len = num_digit(edef->pos->first_column);
+// TODO: make a func also for name, used in union too
+ char name[strlen(env->curr->name) + line_len + col_len + 10]; // add pos
+ sprintf(name, "@enum:%s:%u:%u", env->curr->name, edef->pos->first_line, edef->pos->first_column);
+ const Symbol sym = insert_symbol(name);
+ t->name = edef->xid ? s_name(edef->xid) : s_name(sym);
t->e->parent = env->gwion->type[et_int];
const Nspc nspc = GET_FLAG(edef, global) ? env->global_nspc : env->curr;
t->e->owner = nspc;
if(GET_FLAG(edef, global))
context_global(env);
edef->t = t;
- if(edef->xid) {
- add_type(env, nspc, t);
- mk_class(env, t);
- }
+ add_type(env, nspc, t);
+ mk_class(env, t);
scan0_implicit_similar(env, t, env->gwion->type[et_int]);
return GW_OK;
}
env->curr : env->global_nspc;
const size_t line_len = num_digit(udef->pos->first_line);
const size_t col_len = num_digit(udef->pos->first_column);
- char name[strlen(env->name) + line_len + col_len + 10]; // add pos
- sprintf(name, "@union:%s:%u:%u", env->name, udef->pos->first_line, udef->pos->first_column);
+ char name[strlen(env->curr->name) + line_len + col_len + 10]; // add pos
+ sprintf(name, "@union:%s:%u:%u", env->curr->name, udef->pos->first_line, udef->pos->first_column);
const Symbol sym = insert_symbol(name);
const Type t = union_type(env, nspc, sym, 1);
udef->value = new_value(env->gwion->mp, t, s_name(sym));
-class C {
+class <~A~>C {
\a{};
[ 1 ];
int i,j;
int array[2];
for(auto a : array);
repeat(1);
-#! gotos ...
match i { case _:; }
enum { zero };
typedef int Int;
}
-C c;
+<~int~>C c;