-Subproject commit d87fc045c20a0ae0eb83527b374eca08300f841b
+Subproject commit 9c119d73b5482d11487ad1cc6c48dd47bda896ee
-Iutil/include
-Iast/include
+-Iast/libprettyerr/src
-Iinclude
-Ifmt/include
-Subproject commit c2c3ab9f1aa60c61729ce6345a516ffdc2087dcc
+Subproject commit bee2f7b0dc9942e804aa12d2cf3c29914c38b834
#define describe_lookups(A, b) \
describe_lookup0(A, b) describe_lookup1(A, b) describe_lookup2(A, b)
-#define describe_nspc_func(A, b) \
- static inline ANN void nspc_add_##b(const Nspc n, const Symbol s, \
+#define describe_nspc_func(A, b, prefix) \
+ static inline ANN void prefix##nspc_add_##b(const Nspc n, const Symbol s, \
const A a) { \
scope_add(n->info->b, (vtype)s, (vtype)a); \
} \
- static inline ANN void nspc_add_##b##_front(const Nspc n, const Symbol s, \
+ static inline ANN void prefix##nspc_add_##b##_front(const Nspc n, const Symbol s, \
const A a) { \
map_set(&n->info->b->map, (vtype)s, (vtype)a); \
} \
} \
describe_lookups(A, b)
-describe_nspc_func(Value, value) describe_nspc_func(Type, type)
- describe_nspc_func(Func, func) describe_nspc_func(Trait, trait)
+typedef void (*nspc_add_value_t)(const Nspc n, const Symbol s, const Value a);
+ANN void nspc_add_value(const Nspc n, const Symbol s, const Value a);
+ANN void nspc_add_value_front(const Nspc n, const Symbol s, const Value a);
+ANN void nspc_add_value_set_func(nspc_add_value_t add, nspc_add_value_t front);
+describe_nspc_func(Value, value,_)
+describe_nspc_func(Type, type,)
+describe_nspc_func(Func, func,)
+describe_nspc_func(Trait, trait,)
/* howere there is no need for lookup_func0, push_func, pop_func */
ANN void did_you_mean_nspc(const Nspc, const char *);
ANN void did_you_mean_type(const Type, const char *);
ANN static inline void valid_value(const Env env, const Symbol xid, const Value v) {
set_vflag(v, vflag_valid);
- nspc_add_value(env->curr, xid, v);
+ _nspc_add_value(env->curr, xid, v);
}
#endif
}
ANN static inline void declared_here(const Value v) {
- gwerr_secondary_from("declared here", v->from);
+ gwerr_secondary_from((m_str)"declared here", v->from);
}
#endif
#ifndef __GWIONPASS
#define __GWIONPASS
-typedef union __attribute__((__transparent_union__)) {
- Ast *ast;
- m_bool * ret;
-} PassArg;
-
struct Passes_ {
struct Map_ map;
struct Vector_ vec;
};
// change this to gwion ?
-typedef m_bool (*compilation_pass)(const Env, PassArg);
+typedef m_bool (*compilation_pass)(const Env, Ast*);
ANEW ANN struct Passes_ *new_passes(const Gwion);
ANN void free_passes(MemPool mp, struct Passes_ *);
-Subproject commit c08c81a8f29a441c94ee4ebb6b7c2e7efd0e074a
+Subproject commit bbd7aa68843338c277b4a0b453c0da3181657bd1
return ret;
}
+static pos_t pos = { 1 , 1 };
+void gwion_set_default_pos(const pos_t _pos) {
+ pos = _pos;
+}
ANN static inline m_bool _check(struct Gwion_ *gwion, struct Compiler *c) {
struct AstGetter_ arg = {c->name, c->file, gwion->st, .ppa = gwion->ppa};
- CHECK_OB((c->ast = parse(&arg)));
+ CHECK_OB((c->ast = parse_pos(&arg, pos)));
gwion->env->name = c->name;
const m_bool ret = passes(gwion, c);
return ret;
if (!decl->args && !exp_getvar(exp_self(decl)) && GET_FLAG(array_base_simple(v->type), abstract) && !GET_FLAG(decl->td, late) &&
GET_FLAG(v, late) && late_array(decl->td)
&& GET_FLAG(v->type, abstract)) {
- env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use {+G}late{0} instead of {G+}%s{0}"),
+ env_err(emit->env, decl->td->pos, _("Type '%s' is abstract, use {+G}late{0} instead of {G+}%s{0}"),
v->type->name, !GET_FLAG(decl->td, const) ? "var" : "const");
if(v->type->nspc->vtable.ptr) {
const Vector vec = &v->type->nspc->vtable;
}
}
}
+ return GW_ERROR;
}
if(GET_FLAG(v, late) && exp_getuse(exp_self(decl)))
emit_add_instr(emit, GWOP_EXCEPT);
const Value value = arg->var_decl.value;
vector_add(v, value->from->offset);
value->from->offset = emit_local(emit, value->type);
- nspc_add_value(emit->env->curr, arg->var_decl.xid, value);
+ _nspc_add_value(emit->env->curr, arg->var_decl.xid, value);
}
emit_regmove(emit, -f->code->stack_depth);
emit_regtomem4(emit, f->code->stack_depth, start_offset);
emit_memsetimm(emit, key_offset, -1);
stmt->v->from->offset = val_offset;
//value_addref(stmt->v);
-nspc_add_value(emit->env->curr, stmt->sym, stmt->v);
+_nspc_add_value(emit->env->curr, stmt->sym, stmt->v);
emit_debug(emit, stmt->v);
if (stmt->idx) {
stmt->idx->v->from->offset = key_offset;
-nspc_add_value(emit->env->curr, stmt->idx->sym, stmt->idx->v);
+_nspc_add_value(emit->env->curr, stmt->idx->sym, stmt->idx->v);
//value_addref(stmt->idx->v);
emit_debug(emit, stmt->idx->v);
}
emit->code->stack_depth += type->size;
arg->var_decl.value->from->offset = emit_localn(emit, type);
emit_debug(emit, arg->var_decl.value);
- nspc_add_value(emit->env->curr, insert_symbol(arg->var_decl.value->name), arg->var_decl.value);
+ _nspc_add_value(emit->env->curr, insert_symbol(arg->var_decl.value->name), arg->var_decl.value);
}
}
if (v) return v;
const Value value =
new_value(env, env->gwion->type[et_string], s_name(sym), loc);
- nspc_add_value_front(env->global_nspc, sym, value);
+ _nspc_add_value_front(env->global_nspc, sym, value);
return value;
}
a->ref = 1;
return a;
}
+
+static nspc_add_value_t _add = _nspc_add_value;
+static nspc_add_value_t _front = _nspc_add_value_front;
+ANN void nspc_add_value(const Nspc n, const Symbol s, const Value a) {
+ _add(n, s, a);
+}
+ANN void nspc_add_value_front(const Nspc n, const Symbol s, const Value a) {
+ _front(n, s, a);
+}
+
+ANN void nspc_add_value_set_func(nspc_add_value_t add, nspc_add_value_t front) {
+ _add = add;
+ _front = front;
+}
+
ANEW ANN m_str type2str(const Gwion gwion, const Type t,
const loc_t pos NUSED) {
- GwText text = {.mp = gwion->mp};
+ GwText text;
+ text_init(&text, gwion->mp);
td_fullname(gwion->env, &text, t);
return text.str;
}
ANEW ANN m_str tl2str(const Gwion gwion, const Type_List tl,
const loc_t pos NUSED) {
- struct td_info info = {.tl = tl, {.mp = gwion->mp}};
+ struct td_info info = {.tl = tl};
+ text_init(&info.text, gwion->mp);
CHECK_BO(td_info_run(gwion->env, &info));
return info.text.str;
}
ANN static m_bool run_with_doc(const Gwi gwi, m_bool (*f)(const Gwi)) {
struct LintState ls = {.builtin = true, .nindent = 4};
+ text_init(&ls.text, gwi->gwion->mp);
Lint linter = {.mp = gwi->gwion->mp, .ls = &ls };
lint_indent(&linter);
lint(&linter, "{-}#!+ %s{0}\n", gwi->gwion->env->name);
gwi->lint = &linter;
- return f(gwi);
+ const m_bool ret = f(gwi);
+ fprintf(stdout, "%s", ls.text.str);
+ return ret;
}
ANN m_bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi)) {
if (td->array && td->array->exp)
CHECK_BB(check_subscripts(env, td->array, 1));
CHECK_BB(ensure_traverse(env, parent));
+ if(GET_FLAG(parent, abstract))
+ SET_FLAG(cdef->base.type, abstract);
return GW_OK;
}
} else if (GET_FLAG(decl->td, global))
SET_FLAG(v, global);
else if(env->context)
- set_vflag(v, vflag_fglobal); // file global
+ set_vflag(v, vflag_fglobal); // file global
} else if (GET_FLAG(decl->td, global))
SET_FLAG(v, global);
nspc_add_value(env->curr, vd->xid, v);
!(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_udef)))
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
if (type_ref(parent)) ERR_B(pos, _("can't use ref type in class extend"))
- if (GET_FLAG(parent, abstract)) SET_FLAG(cdef->base.type, abstract);
return GW_OK;
}
const Type t = decl->type;
CHECK_BB(ensure_scan2(env, t));
const Var_Decl vd = decl->vd;
- nspc_add_value(env->curr, vd.xid, vd.value);
+ _nspc_add_value(env->curr, vd.xid, vd.value);
return GW_OK;
}
name)
const Symbol sym =
func_symbol(env, env->curr->name, name, "template", ff->def->vt_index);
- nspc_add_value(env->curr, sym, value);
+ _nspc_add_value(env->curr, sym, value);
if (!overload) nspc_add_value(env->curr, f->base->xid, value);
nspc_add_func(env->curr, sym, func);
func->def->vt_index = ff->def->vt_index;
} 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);
+ _nspc_add_value(env->curr, sym, value);
nspc_add_func(env->curr, sym, func);
if (!overload) nspc_add_value(env->curr, f->base->xid, value);
else func->def->vt_index = ++overload->from->offset;
nspc_add_func(env->curr, insert_symbol(func->name), func);
const Value v = func_value(env, func, overload);
scan2_func_def_flag(env, f);
- nspc_add_value(env->curr, insert_symbol(func->name), v);
+ _nspc_add_value(env->curr, insert_symbol(func->name), v);
return v;
}
}
ANN static Symbol symname(const Env env, Func_Base *const base, bool *global) {
- GwText text = { .mp = env->gwion->mp };
+ GwText text;
+ text_init(&text, env->gwion->mp);
text_add(&text, "(");
DECL_OO(const Type, t, = known_type(env, base->td));
DECL_OO(const m_str, name, = type2str(env->gwion, t, base->td->pos));
-INC = -I../../include -I../../util/include -I../../util/libtermcolor/include -I../../ast/include -I../../fmt/include
+INC = -I../../include -I../../util/include -I../../ast/libprettyerr/src -I../../ast/include -I../../fmt/include
CC ?= gcc
NAME := ${NAME}
-INC = -I../../include -I../../util/include -I../../util/libtermcolor/include -I../../ast/include -I../../fmt/include
+INC = -I../../include -I../../util/include -I../../ast/libprettyerr/src -I../../ast/include -I../../fmt/include
CC ?= gcc
NAME := ${NAME}
-INC = -I../../include -I../../util/include -I../../util/libtermcolor/include -I../../ast/include -I../../fmt/include
+INC = -I../../include -I../../util/include -I../../ast/libprettyerr/src -I../../ast/include -I../../fmt/include
CC ?= gcc
NAME := ${NAME}
-Subproject commit 08e7ba7e688452ba2a827b8a3f9e2a4fa3157759
+Subproject commit d4b4d45ac7f64e3a42076a0aca35ab29b57817e4