From: fennecdjay Date: Tue, 9 Apr 2019 22:10:55 +0000 (+0200) Subject: :art: gwion_err => env_err X-Git-Tag: nightly~2538 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=b76b4732f2fac5a3079eacc24535317203409e73;p=gwion.git :art: gwion_err => env_err --- diff --git a/ast b/ast index 86c07142..b032c950 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 86c07142d6942990d228ed1cd4d584e898cfe90f +Subproject commit b032c9500ff15c8b20a01f3abcb3e1751d4b465f diff --git a/include/env.h b/include/env.h index cc5d0932..11ce53bc 100644 --- a/include/env.h +++ b/include/env.h @@ -59,4 +59,5 @@ ANN m_bool type_engine_check_prog(const Env, const Ast); ANN Func get_func(const Env, const Func_Def); ANN m_bool traverse_func_template(const Env env, const Func_Def def, const Type_List types); ANN ID_List str2list(const Env, const m_str path, m_uint* array_depth); +ANN void env_err(const Env, const uint pos, const m_str fmt, ...); #endif diff --git a/include/gwion.h b/include/gwion.h index a557c92a..97766423 100644 --- a/include/gwion.h +++ b/include/gwion.h @@ -19,5 +19,4 @@ ANN m_bool gwion_ini(const Gwion, struct Arg_*); ANN VM* gwion_cpy(const VM*); ANN void gwion_run(const Gwion gwion); ANN void gwion_end(const Gwion gwion); -ANN void gwion_err(const Gwion gwion, const uint pos, const m_str fmt, ...); #endif diff --git a/include/parse.h b/include/parse.h index fb68ae88..02ac871d 100644 --- a/include/parse.h +++ b/include/parse.h @@ -5,9 +5,9 @@ #define insert_symbol(a) insert_symbol(env->gwion->st, (a)) #undef ERR_B -#define ERR_B(a, b, ...) { gwion_err(env->gwion, (a), (b), ## __VA_ARGS__); return GW_ERROR; } +#define ERR_B(a, b, ...) { env_err(env, (a), (b), ## __VA_ARGS__); return GW_ERROR; } #undef ERR_O -#define ERR_O(a, b, ...) { gwion_err(env->gwion, (a), (b), ## __VA_ARGS__); return NULL; } +#define ERR_O(a, b, ...) { env_err(env, (a), (b), ## __VA_ARGS__); return NULL; } #define RET_NSPC(exp) \ ++env->scope->depth; \ diff --git a/src/emit/emit.c b/src/emit/emit.c index 9acef143..81fdbf9c 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -27,9 +27,9 @@ #define insert_symbol(a) insert_symbol(emit->env->gwion->st, (a)) #undef ERR_B -#define ERR_B(a, b, ...) { gwion_err(emit->gwion, (a), (b), ## __VA_ARGS__); return GW_ERROR; } +#define ERR_B(a, b, ...) { env_err(emit->env, (a), (b), ## __VA_ARGS__); return GW_ERROR; } #undef ERR_O -#define ERR_O(a, b, ...) { gwion_err(emit->gwion, (a), (b), ## __VA_ARGS__); return NULL; } +#define ERR_O(a, b, ...) { env_err(emit->env, (a), (b), ## __VA_ARGS__); return NULL; } typedef struct Local_ { m_uint size; diff --git a/src/gwion.c b/src/gwion.c index 45f1503f..f1888826 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -100,8 +100,7 @@ ANN void gwion_end(const Gwion gwion) { mempool_end(gwion->p); } -ANN void gwion_err(const Gwion gwion, const uint pos, const m_str fmt, ...) { - const Env env = gwion->env; +ANN void env_err(const Env env, const uint pos, const m_str fmt, ...) { gw_err("in file: '%s'\n", env->name); if(env->class_def) gw_err("in class: '%s'\n", env->class_def->name); diff --git a/src/lib/engine.c b/src/lib/engine.c index c3f05af7..6773a708 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -105,4 +105,4 @@ ANN m_bool type_engine_init(VM* vm, const Vector plug_dirs) { env_reset(gwi.gwion->env); } return GW_OK; -} +} \ No newline at end of file diff --git a/src/lib/import.c b/src/lib/import.c index a40bb9bd..536b25d4 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -97,20 +97,20 @@ ANN static m_bool name_valid(Env env, const m_str a) { } if(c == ',') { if(!lvl) { - gwion_err(env->gwion, 0, "illegal use of ',' outside of templating in name '%s'.", a); + env_err(env, 0, "illegal use of ',' outside of templating in name '%s'.", a); return GW_ERROR; } continue; } if(c == '>') { if(!lvl) { - gwion_err(env->gwion, 0, "illegal templating in name '%s'.", a); + env_err(env, 0, "illegal templating in name '%s'.", a); return GW_ERROR; } lvl--; continue; } - gwion_err(env->gwion, 0, "illegal character '%c' in name '%s'.", c, a); + env_err(env, 0, "illegal character '%c' in name '%s'.", c, a); return GW_ERROR; } return !lvl ? 1 : -1; @@ -130,7 +130,7 @@ ANN static m_bool path_valid(const Env env,ID_List* list, const struct Path* p) for(m_uint i = p->len + 1; --i;) { const char c = p->path[i - 1]; if(c != '.' && check_illegal(p->curr, c, i) < 0) { - gwion_err(env->gwion, 0, "illegal character '%c' in path '%s'.", c, p->path); + env_err(env, 0, "illegal character '%c' in path '%s'.", c, p->path); return GW_ERROR; } if(c == '.' || i == 1) { @@ -140,7 +140,7 @@ ANN static m_bool path_valid(const Env env,ID_List* list, const struct Path* p) *list = prepend_id_list(env->gwion->st->p, insert_symbol(env->gwion->st, p->curr), *list, 0); memset(p->curr, 0, p->len + 1); } else { - gwion_err(env->gwion, 0, "path '%s' must not ini or end with '.'.", p->path); + env_err(env, 0, "path '%s' must not ini or end with '.'.", p->path); return GW_ERROR; } } diff --git a/src/main.c b/src/main.c index d136974b..7201af6f 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,11 @@ #include "gwion.h" #include "arg.h" +#ifdef __linux__ +#include +#include +#endif + static jmp_buf jmp; static struct Gwion_ gwion; @@ -16,6 +21,8 @@ static void sig(int unused NUSED) { } int main(int argc, char** argv) { +// setlocale(LC_ALL,""); +// bindtextdomain ("bison-runtime", "/usr/share/locale"); Arg arg = { .argc=argc, .argv=argv, .loop=-1 }; signal(SIGINT, sig); signal(SIGTERM, sig); diff --git a/src/parse/check.c b/src/parse/check.c index fd569458..f367286c 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -180,7 +180,7 @@ ANN static Value check_non_res_value(const Env env, const Exp_Primary* primary) ANN static Type prim_id_non_res(const Env env, const Exp_Primary* primary) { const Value v = check_non_res_value(env, primary); if(!v || !GET_FLAG(v, checked)) { - gwion_err(env->gwion, exp_self(primary)->pos, + env_err(env, exp_self(primary)->pos, "variable %s not legit at this point.", s_name(primary->d.var)); did_you_mean(env->gwion->st, s_name(primary->d.var)); return NULL; @@ -487,7 +487,7 @@ ANN static void print_arg(Arg_List e) { } ANN2(1) static void* function_alternative(const Env env, const Type f, const Exp args, const uint pos){ - gwion_err(env->gwion, pos, "argument type(s) do not match for function. should be :"); + env_err(env, pos, "argument type(s) do not match for function. should be :"); Func up = f->d.func; do { gw_err("(%s)\t", up->name);