From: fennecdjay Date: Fri, 22 Nov 2019 14:14:44 +0000 (+0100) Subject: :art: Update X-Git-Tag: nightly~2092 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d78e54914a37afc6e2282fa3ad79b284ce028c53;p=gwion.git :art: Update --- diff --git a/ast b/ast index 3f75322d..2ed49910 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 3f75322d63c10a8428e002b854a26211391474d0 +Subproject commit 2ed499104f6366ec0fbdb460e91cf31e8c5bb13e diff --git a/include/env/env.h b/include/env/env.h index c9072067..89e60847 100644 --- a/include/env/env.h +++ b/include/env/env.h @@ -50,5 +50,5 @@ ANN Type find_type(const Env, ID_List); 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 diff --git a/src/compile.c b/src/compile.c index a6fcbec4..52b0b5c0 100644 --- a/src/compile.c +++ b/src/compile.c @@ -80,7 +80,7 @@ static inline m_bool compiler_open(MemPool p, struct Compiler* c) { } 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) { diff --git a/src/emit/emit.c b/src/emit/emit.c index 3671f589..ca32d9a4 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1038,8 +1038,8 @@ static m_bool scoped_stmt(const Emitter emit, const Stmt stmt, const m_bool pop) #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); } diff --git a/src/emit/memoize.c b/src/emit/memoize.c index 30ac5e33..3abeccb9 100644 --- a/src/emit/memoize.c +++ b/src/emit/memoize.c @@ -44,7 +44,6 @@ Memoize memoize_ini(const Emitter emit, const Func f, const enum Kind kind) { 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; diff --git a/src/gwion.c b/src/gwion.c index 6f067f55..f37f86a2 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -123,7 +123,7 @@ ANN void gwion_end(const Gwion gwion) { 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) diff --git a/src/import/special.c b/src/import/special.c index 87133f8b..e047257f 100644 --- a/src/import/special.c +++ b/src/import/special.c @@ -38,7 +38,7 @@ ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId spid) { } 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; } diff --git a/src/lib/engine.c b/src/lib/engine.c index 75a7ba31..1fb5e552 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -147,7 +147,7 @@ ANN static m_bool import_core_libs(const Gwi gwi) { 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)) diff --git a/src/parse/scan0.c b/src/parse/scan0.c index dfd0912f..33e7f7a1 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -168,11 +168,11 @@ ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) { } 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); } diff --git a/src/plug.c b/src/plug.c index bd34041e..baa3d3b5 100644 --- a/src/plug.c +++ b/src/plug.c @@ -166,15 +166,43 @@ void free_plug(const struct Gwion_ *gwion) { 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;) {