-Subproject commit 3f75322d63c10a8428e002b854a26211391474d0
+Subproject commit 2ed499104f6366ec0fbdb460e91cf31e8c5bb13e
ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
ANN m_bool type_engine_check_prog(const Env, const Ast);
ANN m_bool traverse_func_template(const Env, const Func_Def);
-ANN2(1,3) void env_err(const Env, const struct YYLTYPE *pos, const m_str fmt, ...);
+ANN2(1,3) void env_err(const Env, const loc_t pos, const m_str fmt, ...);
#endif
}
static inline m_bool _check(struct Gwion_* gwion, struct Compiler* c) {
- struct ScannerArg_ arg = { c->name, c->file, gwion->st, .ppa=gwion->ppa };
+ struct AstGetter_ arg = { c->name, c->file, gwion->st, .ppa=gwion->ppa };
CHECK_OB((c->ast = parse(&arg)))
gwion->env->name = c->name;
for(m_uint i = 0; i < vector_size(&gwion->data->passes->vec); ++i) {
#define FORK_CODE_PREFIX "fork~code:%i"
static void push_spork_code(const Emitter emit, const m_str prefix, const loc_t pos) {
- char c[strlen(SPORK_FUNC_PREFIX) + num_digit(pos->first_line) + 1];
- sprintf(c, prefix, pos->first_line);
+ char c[strlen(SPORK_FUNC_PREFIX) + num_digit(pos->first.line) + 1];
+ sprintf(c, prefix, pos->first.line);
emit_push_code(emit, c);
}
Memoize m = mp_calloc(emit->gwion->mp, Memoize);
vector_init(&m->v);
m->ret_sz = f->def->base->ret_type->size;
-// a void pure function is suspicious at least. check that
m->kind = kind;
if(!GET_FLAG(f, member))
m->arg_sz = f->def->stack_depth;
mempool_end(gwion->mp);
}
-ANN void env_err(const Env env, const struct YYLTYPE* pos, const m_str fmt, ...) {
+ANN void env_err(const Env env, const loc_t pos, const m_str fmt, ...) {
if(env->context && env->context->error)
return;
if(env->class_def)
}
ANN void gwi_set_loc(const Gwi gwi, const m_str file, const uint line) {
- gwi->loc->first_line = gwi->loc->last_line = line;
+ gwi->loc->first.line = gwi->loc->last.line = line;
gwi->gwion->env->name = file;
}
ANN m_bool type_engine_init(VM* vm, const Vector plug_dirs) {
vm->gwion->env->name = "[builtin]";
- struct YYLTYPE loc = {};
+ struct loc_t loc = {};
OperCK oper = {};
struct Gwi_ gwi = { .gwion=vm->gwion, .loc=&loc, .oper=&oper };
CHECK_BB(import_core_libs(&gwi))
}
ANN static Symbol scan0_sym(const Env env, const m_str name, const loc_t pos) {
- const size_t line_len = num_digit(pos->first_line);
- const size_t col_len = num_digit(pos->first_column);
+ const size_t line_len = num_digit(pos->first.line);
+ const size_t col_len = num_digit(pos->first.column);
char c[strlen(env->curr->name) + strlen(env->name) + line_len + col_len + strlen(name) + 6];
sprintf(c, "@%s:%s:%s:%u:%u", name, env->name, env->curr->name,
- pos->first_line, pos->first_column);
+ pos->first.line, pos->first.column);
return insert_symbol(c);
}
mp_free(gwion->mp, PlugInfo, p);
}
+struct ArgSplitter {
+ m_str str;
+ Vector v;
+ MemPool mp;
+};
+
+ANN static void _split_args(struct ArgSplitter *as) {
+ const size_t sz = strlen(as->str);
+ char buf[sz + 1], prev = '\0';
+ m_uint i = 0, j = 0;
+ char c;
+ while((c = as->str[i]) != '\0') {
+ const m_bool skip = prev == '\\';
+ const m_bool comma = c == ',';
+ if(comma) {
+ if(!skip)
+ break;
+ --j;
+ }
+ buf[j++] = (prev = c);
+ ++i;
+ }
+ buf[i] = '\0';
+ vector_add(as->v, (vtype)mstrdup(as->mp, buf));
+ if(i == sz)
+ return;
+ as->str += i + 1;
+ _split_args(as);
+}
+
ANN Vector split_args(MemPool p, const m_str str) {
- const Vector args = new_vector(p);
- m_str d = strdup(str), e = d;
- while(e)
- vector_add(args, (vtype)mstrdup(p, strsep(&e, ",")));
- xfree(d);
- return args;
+ struct ArgSplitter as = { .str=str, .v=new_vector(p), .mp=p };
+ _split_args(&as);
+ return as.v;
}
+
ANN static Vector get_arg(MemPool p, const m_str name, const Vector v) {
const size_t len = strlen(name);
for(m_uint i = vector_size(v) + 1; --i;) {