From: fennecdjay Date: Tue, 18 Jun 2019 22:17:38 +0000 (+0200) Subject: :art: Start internationalization X-Git-Tag: nightly~2440^2 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=4e322c73ce84324cac568d12effa986ec64638cd;p=gwion.git :art: Start internationalization --- diff --git a/ast b/ast index 595dd5ed..c43f0ae6 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 595dd5edbd94984c3b2eebc352d38476472f1a93 +Subproject commit c43f0ae616811b5a927a4bcd0bd552037a7c09c9 diff --git a/help/test.sh b/help/test.sh index 84146808..0f5889d2 100644 --- a/help/test.sh +++ b/help/test.sh @@ -181,9 +181,9 @@ test_gw(){ vlog=${GWION_TEST_DIR}/${GWION_TEST_PREFIX}$(printf "%04i" "$n").valgrind.log rlog=${GWION_TEST_DIR}/${GWION_TEST_PREFIX}$(printf "%04i" "$n").log if [ "$VALGRIND" == "NO_VALGRIND" ] - then ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: + then LANG=C ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: else - "$VALGRIND" --suppressions=help/supp --log-file="$vlog" \ + LANG=C "$VALGRIND" --suppressions=help/supp --log-file="$vlog" \ ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: fi ret=$? diff --git a/opt/fold.c b/opt/fold.c index 47ec95c6..26633fba 100644 --- a/opt/fold.c +++ b/opt/fold.c @@ -30,7 +30,7 @@ describe_xxx_exp(float, m_float, float, fnum) #define CASE(op_op, l, op, r) case op_##op_op: ret = l op r; break; #define DIV_BY_ZERO(l, op, r) if(r) ret = l op r; else \ - ERR_B(bin->rhs->pos, "ZeroDivideException") + ERR_B(bin->rhs->pos, _("Division by zero")) #define COMMON_CASE(l, r) \ CASE(add, l, +, r) \ diff --git a/src/compile.c b/src/compile.c index ce19f335..9bb3ecf6 100644 --- a/src/compile.c +++ b/src/compile.c @@ -74,7 +74,7 @@ static inline m_bool compiler_open(MemPool p, struct Compiler* c) { strcpy(name, c->name); if(_compiler_open(c) < 0) { compiler_error(p, c); - gw_err("'%s': no such file\n", name); + gw_err(_("'%s': no such file\n"), name); return GW_ERROR; } return GW_OK; @@ -97,7 +97,7 @@ static m_uint compile(struct Gwion_* gwion, struct Compiler* c) { compiler_name(gwion->mp, c); MUTEX_LOCK(gwion->data->mutex); if(check(gwion, c) < 0 || !(code = emit_ast(gwion->emit, c->ast))) - gw_err("while compiling file '%s'\n", c->base); + gw_err(_("while compiling file '%s'\n"), c->base); else { const VM_Shred shred = new_vm_shred(gwion->mp, code); shred->info->args = c->args; diff --git a/src/emit/emit.c b/src/emit/emit.c index 42d2fb5e..741cf278 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -498,7 +498,7 @@ ANN static m_bool prim_gack(const Emitter emit, const Exp_Primary* primary) { } while((e = e->next)); if(emit_exp(emit, exp, 0) < 0) { free_vector(emit->gwion->mp, v); - ERR_B(exp->pos, " ... in 'gack' expression.") + ERR_B(exp->pos, _(" ... in 'gack' expression.")) } const Instr instr = emit_add_instr(emit, Gack); instr->m_val = offset; @@ -1279,15 +1279,15 @@ ANN static m_bool emit_stmt_jump(const Emitter emit, const Stmt_Jump stmt) { if(switch_inside(emit->env, stmt_self(stmt)->pos) > 0 && !strcmp(s_name(stmt->name), "default")) return switch_default(emit->env, emit_code_size(emit), stmt_self(stmt)->pos); if(!stmt->data.v.ptr) - ERR_B(stmt_self(stmt)->pos, "illegal case") + ERR_B(stmt_self(stmt)->pos, _("illegal case")) const m_uint size = vector_size(&stmt->data.v); if(!size) - ERR_B(stmt_self(stmt)->pos, "label '%s' defined but not used.", s_name(stmt->name)) + ERR_B(stmt_self(stmt)->pos, _("label '%s' defined but not used."), s_name(stmt->name)) LOOP_OPTIM for(m_uint i = size + 1; --i;) { const Stmt_Jump label = (Stmt_Jump)vector_at(&stmt->data.v, i - 1); if(!label->data.instr) - ERR_B(stmt_self(label)->pos, "you are trying to use a upper label.") + ERR_B(stmt_self(label)->pos, _("you are trying to use a upper label.")) label->data.instr->m_val = emit_code_size(emit); } } @@ -1552,20 +1552,20 @@ ANN static m_bool emit_vararg(const Emitter emit, const Exp_Dot* member) { } if(!strcmp(str, "start")) { if(get_variadic(emit)) - ERR_B(exp_self(member)->pos, "vararg.start already used. this is an error") + ERR_B(exp_self(member)->pos, _("vararg.start already used. this is an error")) emit_vararg_start(emit, offset); return GW_OK; } if(!strcmp(str, "end")) { if(!get_variadic(emit)) - ERR_B(exp_self(member)->pos, "vararg.start not used before vararg.end. this is an error") + ERR_B(exp_self(member)->pos, _("vararg.start not used before vararg.end. this is an error")) emit_vararg_end(emit, offset); return GW_OK; } if(!get_variadic(emit)) - ERR_B(exp_self(member)->pos, "vararg.%s used before vararg.start. this is an error", s_name(member->xid)) + ERR_B(exp_self(member)->pos, _("vararg.%s used before vararg.start. this is an error"), s_name(member->xid)) if(GET_FLAG(emit->env->func, empty)) - ERR_B(exp_self(member)->pos, "vararg.%s used after vararg.end. this is an error", s_name(member->xid)) + ERR_B(exp_self(member)->pos, _("vararg.%s used after vararg.end. this is an error"), s_name(member->xid)) const Instr instr = emit_add_instr(emit, VarargMember); instr->m_val = offset; instr->m_val2 = exp_self(member)->type->size; @@ -1700,9 +1700,9 @@ ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def fdef) { CHECK_BB(_fdef_body(emit, fdef)) if(GET_FLAG(fdef, variadic)) { if(!get_variadic(emit)) - ERR_B(fdef->pos, "invalid variadic use") + ERR_B(fdef->pos, _("invalid variadic use")) if(!GET_FLAG(fdef->base->func, empty)) - ERR_B(fdef->pos, "invalid variadic use") + ERR_B(fdef->pos, _("invalid variadic use")) } return GW_OK; } diff --git a/src/emit/escape.c b/src/emit/escape.c index 697e5361..68a32cbb 100644 --- a/src/emit/escape.c +++ b/src/emit/escape.c @@ -26,7 +26,7 @@ char* escape_table(void) { static int get_escape(const Emitter emit, const char c, const loc_t pos) { if(emit->escape[(int)c]) return emit->escape[(int)c]; - env_err(emit->env, pos, "unrecognized escape sequence '\\%c'", c); + env_err(emit->env, pos, _("unrecognized escape sequence '\\%c'"), c); return GW_ERROR; } @@ -37,7 +37,7 @@ m_bool escape_str(const Emitter emit, const m_str base, const loc_t pos) { if(*str_lit == '\\') { ++str_lit; if(*str_lit == '\0') { - env_err(emit->env, pos, "invalid: string ends with escape charactor '\\'"); + env_err(emit->env, pos, _("invalid: string ends with escape charactor '\\'")); return GW_ERROR; } const unsigned char c = *(str_lit); @@ -51,7 +51,7 @@ m_bool escape_str(const Emitter emit, const m_str base, const loc_t pos) { *str++ = (char)((c-'0') * 64 + (c2-'0') * 8 + (c3-'0')); str_lit += 2; } else { - env_err(emit->env, pos, "malformed octal escape sequence '\\%c%c%c'", c, c2, c3); + env_err(emit->env, pos, _("malformed octal escape sequence '\\%c%c%c'"), c, c2, c3); return GW_ERROR; } } @@ -63,7 +63,7 @@ m_bool escape_str(const Emitter emit, const m_str base, const loc_t pos) { *str++ = (char)((c1-'0') * 16 + (c3-'0')); ++str_lit; } else { - env_err(emit->env, pos, "malformed hex escape sequence '\\%c%c'", c1, c3); + env_err(emit->env, pos, _("malformed hex escape sequence '\\%c%c'"), c1, c3); return GW_ERROR; } } else diff --git a/src/gwion.c b/src/gwion.c index ba957def..b6d62bce 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -107,9 +107,9 @@ ANN void gwion_end(const Gwion gwion) { ANN void env_err(const Env env, const struct YYLTYPE* pos, const m_str fmt, ...) { if(env->class_def) - gw_err("in class: '%s'\n", env->class_def->name); + gw_err(_("in class: '%s'\n"), env->class_def->name); if(env->func) - gw_err("in function: '%s'\n", env->func->name); + gw_err(_("in function: '%s'\n"), env->func->name); loc_header(pos, env->name); va_list arg; va_start(arg, fmt); diff --git a/src/lib/array.c b/src/lib/array.c index 7fe5036e..45548935 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -147,17 +147,17 @@ ANN static Type get_array_type(Type t) { const Type l = get_array_type(bin->lhs->type); \ const Type r = get_array_type(bin->rhs->type); \ if(isa(l, r) < 0) \ - ERR_N(exp_self(bin)->pos, "array types do not match.") + ERR_N(exp_self(bin)->pos, _("array types do not match.")) static OP_CHECK(opck_array_at) { ARRAY_OPCK if(opck_const_rhs(env, data) == t_null) return t_null; if(bin->lhs->type->array_depth != bin->rhs->type->array_depth) - ERR_N(exp_self(bin)->pos, "array depths do not match.") + ERR_N(exp_self(bin)->pos, _("array depths do not match.")) if(bin->rhs->exp_type == ae_exp_decl) { if(bin->rhs->d.exp_decl.list->self->array) - ERR_N(exp_self(bin)->pos, "do not provide array for 'xxx @=> declaration'.") + ERR_N(exp_self(bin)->pos, _("do not provide array for 'xxx @=> declaration'.")) } bin->rhs->emit_var = 1; return bin->rhs->type; diff --git a/src/lib/func.c b/src/lib/func.c index d93ce1db..7f212721 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -29,7 +29,7 @@ static INSTR(LambdaAssign) { static OP_CHECK(opck_func_call) { Exp_Binary* bin = (Exp_Binary*)data; if(bin->rhs->exp_type == ae_exp_decl) - ERR_N(bin->rhs->pos, "calling fptr decl, this is forbidden.") + ERR_N(bin->rhs->pos, _("calling fptr decl, this is forbidden.")) Exp_Call call = { .func=bin->rhs, .args=bin->lhs }; Exp e = exp_self(bin); e->exp_type = ae_exp_call; @@ -101,17 +101,17 @@ ANN static m_bool fptr_check(const Env env, struct FptrInfo *info) { const Type l_type = info->lhs->value_ref->owner_class; const Type r_type = info->rhs->value_ref->owner_class; if(!r_type && l_type) - ERR_B(info->pos, "can't assign member function to non member function pointer") + ERR_B(info->pos, _("can't assign member function to non member function pointer")) else if(!l_type && r_type) { if(!GET_FLAG(info->rhs, global)) - ERR_B(info->pos, "can't assign non member function to member function pointer") + ERR_B(info->pos, _("can't assign non member function to member function pointer")) } else if(l_type && isa(r_type, l_type) < 0) - ERR_B(info->pos, "can't assign member function to a pointer of an other class") + ERR_B(info->pos, _("can't assign member function to a pointer of an other class")) if(GET_FLAG(info->rhs, member)) { if(!GET_FLAG(info->lhs, member)) - ERR_B(info->pos, "can't assign static function to member function pointer") + ERR_B(info->pos, _("can't assign static function to member function pointer")) } else if(GET_FLAG(info->lhs, member)) - ERR_B(info->pos, "can't assign member function to static function pointer") + ERR_B(info->pos, _("can't assign member function to static function pointer")) return GW_OK; } @@ -161,7 +161,7 @@ ANN2(1,3,4) m_bool check_lambda(const Env env, const Type owner, arg = arg->next; } if(base || arg) - ERR_B(exp_self(l)->pos, "argument number does not match for lambda") + ERR_B(exp_self(l)->pos, _("argument number does not match for lambda")) l->def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, def->base->td, l->name, l->args), l->code, def->flag, loc_cpy(env->gwion->mp, def->pos)); @@ -248,8 +248,8 @@ ANN Type check_exp_unary_spork(const Env env, const Stmt code); static OP_CHECK(opck_spork) { const Exp_Unary* unary = (Exp_Unary*)data; if(unary->op == op_fork && !unary->fork_ok) - ERR_O(exp_self(unary)->pos, "forks must be stored in a value:\n" - "fork xxx @=> Fork f") + ERR_O(exp_self(unary)->pos, _("forks must be stored in a value:\n" + "fork xxx @=> Fork f")) if(unary->exp && unary->exp->exp_type == ae_exp_call) return unary->op == op_spork ? t_shred : t_fork; else if(unary->code) { @@ -261,7 +261,7 @@ static OP_CHECK(opck_spork) { CHECK_BO(ret) return unary->op == op_spork ? t_shred : t_fork; } else - ERR_O(exp_self(unary)->pos, "only function calls can be sporked...") + ERR_O(exp_self(unary)->pos, _("only function calls can be sporked...")) return NULL; } diff --git a/src/lib/import.c b/src/lib/import.c index 3f6efaf8..64999711 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -77,7 +77,7 @@ ANN static void dl_func_func_arg(DL_Func* a, const restrict m_str t, const restr ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n) { if(gwi->func.narg == DLARG_MAX - 1) - GWI_ERR_B("too many arguments for function '%s'.", gwi->func.name) + GWI_ERR_B(_("too many arguments for function '%s'."), gwi->func.name) dl_func_func_arg(&gwi->func, t, n); return GW_OK; } @@ -104,16 +104,16 @@ ANN static m_bool name_valid(const Gwi gwi, const m_str a) { } if(c == ',') { if(!lvl) - GWI_ERR_B("illegal use of ',' outside of templating in name '%s'.", a) + GWI_ERR_B(_("illegal use of ',' outside of templating in name '%s'."), a) continue; } if(c == '>') { if(!lvl) - GWI_ERR_B("illegal templating in name '%s'.", a) + GWI_ERR_B(_("illegal templating in name '%s'."), a) lvl--; continue; } - GWI_ERR_B("illegal character '%c' in name '%s'.", c, a) + GWI_ERR_B(_("illegal character '%c' in name '%s'."), c, a) } return !lvl ? 1 : -1; } @@ -132,7 +132,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) { - env_err(env, &p->loc, "illegal character '%c' in path '%s'.", c, p->path); + env_err(env, &p->loc, _("illegal character '%c' in path '%s'."), c, p->path); return GW_ERROR; } if(c == '.' || i == 1) { @@ -142,7 +142,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, loc_cpy(env->gwion->mp, &p->loc)); memset(p->curr, 0, p->len + 1); } else { - env_err(env, &p->loc, "path '%s' must not ini or end with '.'.", p->path); + env_err(env, &p->loc, _("path '%s' must not ini or end with '.'."), p->path); return GW_ERROR; } } @@ -217,7 +217,7 @@ ANN2(1,2) static void import_class_ini(const Env env, const Type type, ANN2(1,2) m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_ctor, const f_xtor dtor) { if(type->nspc) - GWI_ERR_B("during import: class '%s' already imported.", type->name) + GWI_ERR_B(_("during import: class '%s' already imported."), type->name) if(gwi->templater.n) { const ID_List types = templater_def(gwi->gwion->st, gwi); type->e->def = new_class_def(gwi->gwion->mp, 0, insert_symbol(gwi->gwion->st, type->name), NULL, NULL, loc_cpy(gwi->gwion->mp, gwi->loc)); @@ -233,13 +233,13 @@ ANN2(1,2) m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_c ANN m_int gwi_class_ext(const Gwi gwi, Type_Decl* td) { if(!gwi->gwion->env->class_def) - GWI_ERR_B("gwi_class_ext invoked before gwi_class_ini") + GWI_ERR_B(_("gwi_class_ext invoked before gwi_class_ini")) const VM_Code ctor = gwi->gwion->env->class_def->nspc->pre_ctor; if(gwi->gwion->env->class_def->e->parent || (gwi->gwion->env->class_def->e->def && gwi->gwion->env->class_def->e->def->base.ext)) - GWI_ERR_B("class extend already set") + GWI_ERR_B(_("class extend already set")) if(td->array && !td->array->exp) - GWI_ERR_B("class extend array can't be empty") + GWI_ERR_B(_("class extend array can't be empty")) if(!gwi->gwion->env->class_def->e->def) { DECL_OB(const Type, t, = known_type(gwi->gwion->env, td)) if(td->array) @@ -265,7 +265,7 @@ ANN m_int gwi_class_ext(const Gwi gwi, Type_Decl* td) { ANN m_int gwi_class_end(const Gwi gwi) { if(!gwi->gwion->env->class_def) - GWI_ERR_B("import: too many class_end called.") + GWI_ERR_B(_("import: too many class_end called.")) nspc_allocdata(gwi->gwion->mp, gwi->gwion->env->class_def->nspc); env_pop(gwi->gwion->env, 0); return GW_OK; @@ -300,7 +300,7 @@ ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, const restrict DL_Var* v = &gwi->var; memset(v, 0, sizeof(DL_Var)); if(!(v->t.xid = str2list(gwi->gwion->env, type, &v->array_depth))) - GWI_ERR_B(" ... during var import '%s.%s'.", gwi->gwion->env->class_def->name, name) + GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->class_def->name, name) v->var.xid = insert_symbol(gwi->gwion->st, name); return GW_OK; } @@ -335,6 +335,8 @@ ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr v->exp.pos = gwi->loc; CHECK_BB(traverse_decl(gwi->gwion->env, &v->exp.d.exp_decl)) SET_FLAG(v->var.value, builtin); +if(v->var.value->type->array_depth) +ADD_REF(v->var.value->type); dl_var_release(gwi->gwion->mp, v); return (m_int)v->var.value->offset; } @@ -392,7 +394,7 @@ ANN static Arg_List make_dll_arg_list(const Gwi gwi, DL_Func * dl_fun) { if(!(type_decl = str2decl(env, arg->type, &array_depth))) { if(arg_list) free_arg_list(env->gwion->mp, arg_list); - GWI_ERR_O(" ... at argument '%i'", i + 1) + GWI_ERR_O(_(" ... at argument '%i'"), i + 1) } if((type_path2 = str2list(env, arg->name, &array_depth2))) free_id_list(env->gwion->mp, type_path2); @@ -400,7 +402,7 @@ ANN static Arg_List make_dll_arg_list(const Gwi gwi, DL_Func * dl_fun) { free_type_decl(env->gwion->mp, type_decl); if(arg_list) free_arg_list(env->gwion->mp, arg_list); - GWI_ERR_O("array subscript specified incorrectly for built-in module"); + GWI_ERR_O(_("array subscript specified incorrectly for built-in module")); } const Array_Sub array_sub = make_dll_arg_list_array(env->gwion->mp, NULL, &array_depth, array_depth2); const Var_Decl var_decl = new_var_decl(env->gwion->mp, insert_symbol(env->gwion->st, arg->name), array_sub, loc_cpy(gwi->gwion->mp, gwi->loc)); @@ -432,7 +434,7 @@ ANN static Func_Def make_dll_as_fun(const Gwi gwi, DL_Func * dl_fun, ae_flag fla flag |= ae_flag_builtin; Type_Decl* type_decl = import_td(gwi, dl_fun->type); if(!type_decl) - GWI_ERR_O(" ... during @ function import '%s' (type).", dl_fun->name) + GWI_ERR_O(_(" ... during @ function import '%s' (type)."), dl_fun->name) const m_str name = dl_fun->name; const Arg_List arg_list = make_dll_arg_list(gwi, dl_fun); const Func_Def func_def = new_func_def(mp, new_func_base(mp, type_decl, insert_symbol(gwi->gwion->st, name), arg_list), @@ -529,7 +531,7 @@ ANN static Stmt import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) { flag |= ae_flag_builtin; if(!(type_path = str2list(env, dl_fun->type, &array_depth)) || !(type_decl = new_type_decl(env->gwion->mp, type_path, 0))) - GWI_ERR_O(" ... during fptr import '%s' (type).", dl_fun->name); + GWI_ERR_O(_(" ... during fptr import '%s' (type)."), dl_fun->name); struct Func_Base_ *base = new_func_base(env->gwion->mp, type_decl, insert_symbol(env->gwion->st, dl_fun->name), args); return new_stmt_fptr(env->gwion->mp, base, flag); } @@ -555,7 +557,7 @@ ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restri ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) { Type_Decl* td = import_td(gwi, gwi->val.type); if(!td) - GWI_ERR_O("'%s' : invalid type"); + GWI_ERR_O(_("'%s' : invalid type")); td->flag |= flag; const Symbol sym = insert_symbol(gwi->gwion->st, gwi->val.name); const Stmt stmt = new_stmt_type(gwi->gwion->mp, td, sym); @@ -600,7 +602,7 @@ ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type, const restrict ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { if(!gwi->union_data.list) - GWI_ERR_O("union is empty"); + GWI_ERR_O(_("union is empty")); const Stmt stmt = new_stmt_union(gwi->gwion->mp, gwi->union_data.list, loc_cpy(gwi->gwion->mp, gwi->loc)); stmt->d.stmt_union.flag = flag; CHECK_BO(traverse_stmt_union(gwi->gwion->env, &stmt->d.stmt_union)) diff --git a/src/lib/object.c b/src/lib/object.c index 54a08159..89246da3 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -106,7 +106,7 @@ static OP_CHECK(at_object) { if(bin->rhs->exp_type == ae_exp_decl) SET_FLAG(bin->rhs->d.exp_decl.td, ref); if(l != t_null && isa(l, r) < 0) { - env_err(env, exp_self(bin)->pos, "'%s' @=> '%s': not allowed", l->name, r->name); + env_err(env, exp_self(bin)->pos, _("'%s' @=> '%s': not allowed"), l->name, r->name); return t_null; } bin->rhs->emit_var = 1; diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index df756db1..dc17e417 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -29,8 +29,8 @@ OP_EMIT(opem_basic_cast) { OP_CHECK(opck_const_rhs) { const Exp_Binary* bin = (Exp_Binary*)data; if(bin->rhs->meta != ae_meta_var) - ERR_N(exp_self(bin)->pos, "cannot assign '%s' on types '%s' and '%s'.\n" - " ... (reason: --- right-side operand is %s.)", + ERR_N(exp_self(bin)->pos, _("cannot assign '%s' on types '%s' and '%s'.\n" + " ... (reason: --- right-side operand is %s.)"), op2str(bin->op), bin->lhs->type->name, bin->rhs->type->name, access(bin->rhs->meta)) return bin->rhs->type; @@ -67,7 +67,7 @@ OP_CHECK(opck_unary_meta2_uniq) { CHECK_OO(opck_unary_meta2(env, data)) if(unary->exp->next) ERR_N(exp_self(unary)->pos, - "'%s' must be applied to a unique expression", op2str(unary->op)) + _("'%s' must be applied to a unique expression"), op2str(unary->op)) return t_int; } @@ -75,7 +75,7 @@ OP_CHECK(opck_unary) { const Exp_Unary* unary = (Exp_Unary*)data; if(unary->exp->meta != ae_meta_var) ERR_N(unary->exp->pos, - "unary operator '%s' cannot be used on %s data-types.", + _("unary operator '%s' cannot be used on %s data-types."), op2str(unary->op), access(unary->exp->meta)) unary->exp->emit_var = 1; exp_self(unary)->meta = ae_meta_value; @@ -85,7 +85,7 @@ OP_CHECK(opck_unary) { OP_CHECK(opck_post) { const Exp_Postfix* post = (Exp_Postfix*)data; if(post->exp->meta != ae_meta_var) - ERR_N(post->exp->pos, "post operator '%s' cannot be used on %s data-type.", + ERR_N(post->exp->pos, _("post operator '%s' cannot be used on %s data-type."), op2str(post->op), access(post->exp->meta)) post->exp->emit_var = 1; exp_self(post)->meta = ae_meta_value; diff --git a/src/lib/prim.c b/src/lib/prim.c index e33e05c0..06e3dcd1 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -130,7 +130,7 @@ static GWION_IMPORT(values) { static OP_CHECK(opck_chuck_now) { Exp_Binary* bin = (Exp_Binary*)data; - ERR_O(exp_self(bin)->pos, "can't assign 'now' to 'now'") + ERR_O(exp_self(bin)->pos, _("can't assign 'now' to 'now'")) return NULL; } diff --git a/src/lib/ptr.c b/src/lib/ptr.c index c8dd80c6..34733335 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -17,7 +17,7 @@ static OP_CHECK(opck_ptr_assign) { const Exp_Binary* bin = (Exp_Binary*)data; if(bin->lhs->meta != ae_meta_var) - ERR_N(exp_self(bin)->pos, "left side operand is constant"); + ERR_N(exp_self(bin)->pos, _("left side operand is constant")); bin->lhs->emit_var = 1; Type t = bin->lhs->type; do if(!strcmp(t->name, get_type_name(env, bin->rhs->type->name, 1))) @@ -43,7 +43,7 @@ static OP_CHECK(opck_implicit_ptr) { const Exp e = (Exp)imp->e; if(!strcmp(get_type_name(env, imp->t->name, 1), e->type->name)) { if(e->meta == ae_meta_value) - ERR_N(e->pos, "can't cast constant to Ptr"); + ERR_N(e->pos, _("can't cast constant to Ptr")); e->cast_to = imp->t; e->emit_var = 1; return imp->t; diff --git a/src/main.c b/src/main.c index af1af971..7d7ede36 100644 --- a/src/main.c +++ b/src/main.c @@ -16,8 +16,6 @@ //static struct Gwion_ gwion; static void sig(int unused NUSED) { -// gwion.vm->bbq->is_running = 0; -// longjmp(jmp, 1); #ifdef BUILD_ON_WINDOWS exit(EXIT_FAILURE); #else @@ -26,8 +24,16 @@ static void sig(int unused NUSED) { } int main(int argc, char** argv) { -// setlocale(LC_ALL,""); -// bindtextdomain ("bison-runtime", "/usr/share/locale"); +// setlocale(LC_ALL, NULL); +//puts( +// bindtextdomain ("bison-runtime", "/usr/share/locale") +//); +// bindtextdomain ("bison-runtime", NULL); +//puts( + bindtextdomain ("gwion_ast", "ast/po"); + bindtextdomain ("gwion_util", "util/po"); + bindtextdomain ("gwion", "po"); +//); Arg arg = { .argc=argc, .argv=argv, .loop=-1 }; signal(SIGINT, sig); signal(SIGTERM, sig); diff --git a/src/oo/env.c b/src/oo/env.c index 04536574..17d48164 100644 --- a/src/oo/env.c +++ b/src/oo/env.c @@ -95,6 +95,7 @@ ANN void env_add_type(const Env env, const Type type) { SET_FLAG(type, builtin); nspc_add_type(env->curr, insert_symbol(type->name), type); // map_set(&env->curr->info->type->map, insert_symbol(type->name), type); +// map_set(vector_back(&env->curr->info->type->ptr), insert_symbol(type->name), type); const Value v = new_value(env->gwion->mp, v_type, type->name); SET_FLAG(v, checked | ae_flag_const | ae_flag_global | ae_flag_builtin); nspc_add_value(env->curr, insert_symbol(type->name), v); diff --git a/src/oo/env_utils.c b/src/oo/env_utils.c index c7453bad..49512631 100644 --- a/src/oo/env_utils.c +++ b/src/oo/env_utils.c @@ -23,13 +23,13 @@ ANN Nspc env_nspc(const Env env) { ANN m_bool env_access(const Env env, const ae_flag flag, const loc_t pos) { if(env->scope->depth) { if(GET(flag, ae_flag_global)) - ERR_B(pos, "'global' can only be used at %s scope.", + ERR_B(pos, _("'global' can only be used at %s scope."), GET(flag, ae_flag_global) && !env->class_def ? "file" : "class") } if((GET(flag, ae_flag_static) || GET(flag, ae_flag_private) || GET(flag, ae_flag_protect)) && (!env->class_def || env->scope->depth)) - ERR_B(pos, "static/private/protect can only be used at class scope.") + ERR_B(pos, _("static/private/protect can only be used at class scope.")) return GW_OK; } @@ -66,7 +66,7 @@ ANN Type find_type(const Env env, ID_List path) { type = type->e->parent; } if(!t) - ERR_O(path->pos, "...(cannot find class '%s' in nspc '%s')", s_name(xid), nspc->name) + ERR_O(path->pos, _("...(cannot find class '%s' in nspc '%s')"), s_name(xid), nspc->name) type = t; } nspc = type->nspc; @@ -80,7 +80,7 @@ ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos) { if(!v || isa(v->type, t_class) > 0) return GW_OK; env_err(env, pos, - "'%s' already declared as variable of type '%s'.", s_name(s), v->type->name); + _("'%s' already declared as variable of type '%s'."), s_name(s), v->type->name); return GW_ERROR; } diff --git a/src/oo/nspc.c b/src/oo/nspc.c index 4ecba648..a30f3627 100644 --- a/src/oo/nspc.c +++ b/src/oo/nspc.c @@ -32,9 +32,13 @@ ANN static void free_nspc_value(const Nspc a, Gwion gwion) { Value v; if(!a->is_union) { while(scope_iter(&iter, &v) > 0) { +const Type t = (GET_FLAG(v, builtin) && v->type->array_depth) ? + v->type : NULL; if(isa(v->type, t_object) > 0) nspc_release_object(a, v, gwion); REM_REF(v, gwion); +if(t) + REM_REF(t, gwion); } } free_scope(gwion->mp, a->info->value); diff --git a/src/oo/switch.c b/src/oo/switch.c index 888f12a0..89375fc7 100644 --- a/src/oo/switch.c +++ b/src/oo/switch.c @@ -77,7 +77,7 @@ ANN m_bool switch_decl(const Env env, const loc_t pos) { const Switch sw = (Switch)(VLEN(&env->scope->swi->map) ? VVAL(&env->scope->swi->map, VLEN(&env->scope->swi->map) - 1): 0); if(sw && sw->depth == env->scope->depth) - ERR_B(pos, "Declaration in switch is prohibited.") + ERR_B(pos, _("Declaration in switch is prohibited.")) return GW_OK; } @@ -115,13 +115,13 @@ ANN Exp switch_expget(const Env env) { ANN m_bool switch_inside(const Env env, const loc_t pos) { if(!VLEN(env->scope->swi)) - ERR_B(pos, "case found outside switch statement.") + ERR_B(pos, _("case found outside switch statement.")) return GW_OK; } ANN m_bool switch_dup(const Env env, const m_int value, const loc_t pos) { const Switch sw = (Switch)_scope_back(env->scope->swi); if(map_get(sw->cases, (vtype)value)) - ERR_B(pos, "duplicated cases value %i", value) + ERR_B(pos, _("duplicated cases value %i"), value) sw->ok = 1; return GW_OK; } @@ -143,10 +143,10 @@ ANN m_bool switch_dyn(const Env env) { ANN m_bool switch_default(const Env env, const m_uint pc, const loc_t pos) { if(!VLEN(env->scope->swi)) - ERR_B(pos, "'default'case found outside switch statement.") + ERR_B(pos, _("'default'case found outside switch statement.")) const Switch sw = (Switch)_scope_back(env->scope->swi); if(sw->default_case_index) - ERR_B(pos, "default case already defined") + ERR_B(pos, _("default case already defined")) sw->default_case_index = pc; return GW_OK; } @@ -178,7 +178,7 @@ ANN m_bool switch_end(const Env env, const loc_t pos) { const vtype index = VKEY(&env->scope->swi->map, VLEN(&env->scope->swi->map) - 1); // sw->ok = 1; if(!VLEN(sw->cases) && !VLEN(&sw->exp)) - ERR_B(pos, "switch statement with no cases.") + ERR_B(pos, _("switch statement with no cases.")) map_remove(&env->scope->swi->map, index); free_switch(env->gwion->mp, sw); return GW_OK; diff --git a/src/parse/check.c b/src/parse/check.c index f7237760..1b9055d4 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -25,7 +25,7 @@ ANN m_bool check_class_def(const Env env, const Class_Def class_def); ANN m_bool check_exp_array_subscripts(Env env, Exp exp) { CHECK_OB(check_exp(env, exp)) do if(isa(exp->type, t_int) < 0) - ERR_B(exp->pos, "incompatible array subscript type '%s' ...", exp->type->name) + ERR_B(exp->pos, _("incompatible array subscript type '%s' ..."), exp->type->name) while((exp = exp->next)); return GW_OK; } @@ -34,7 +34,7 @@ ANN static inline m_bool check_exp_decl_parent(const Env env, const Var_Decl var const Value value = find_value(env->class_def->e->parent, var->xid); if(value) ERR_B(var->pos, - "in class '%s': '%s' has already been defined in parent class '%s' ...", + _("in class '%s': '%s' has already been defined in parent class '%s' ..."), env->class_def->name, s_name(var->xid), value->owner_class->name) return GW_OK; } @@ -55,12 +55,12 @@ ANN static m_bool check_fptr_decl(const Env env, const Var_Decl var) { if(!env->class_def) { if(!type || GET_FLAG(func, global)) return GW_OK; - ERR_B(var->pos, "can't use non public typedef at global scope.") + ERR_B(var->pos, _("can't use non public typedef at global scope.")) } if(isa(type, env->class_def) < 0 && !GET_FLAG(func, global)) - ERR_B(var->pos, "can't use non global fptr of other class.") + ERR_B(var->pos, _("can't use non global fptr of other class.")) if(GET_FLAG(func, member) && GET_FLAG(v, static)) - ERR_B(var->pos, "can't use static variables for member function.") + ERR_B(var->pos, _("can't use static variables for member function.")) return GW_OK; } @@ -70,8 +70,8 @@ ANN Type check_td(const Env env, Type_Decl *td) { CHECK_OO(check_exp(env, td->exp)) const Type t = actual_type(td->exp->type); if(!t || (isa(td->exp->type, t_class) < 0 && t == t_class)) - ERR_O(td->exp->pos, "Expression must be of type '%s', not '%s'\n" - "maybe you meant typeof(Expression)", t_class->name, td->exp->type->name); + ERR_O(td->exp->pos, _("Expression must be of type '%s', not '%s'\n" + "maybe you meant typeof(Expression)"), t_class->name, td->exp->type->name); m_uint depth; td->xid = str2list(env, t->name, &depth); @@ -98,10 +98,10 @@ ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { CHECK_BO(scan1_exp(env, exp_self(decl))) CHECK_BO(scan2_exp(env, exp_self(decl))) if(decl->type == t_auto) - ERR_O(td_pos(decl->td), "can't infer type."); + ERR_O(td_pos(decl->td), _("can't infer type.")); } if(!decl->type) // TODO: remove when scan passes are complete - ERR_O(td_pos(decl->td), "can't infer type."); + ERR_O(td_pos(decl->td), _("can't infer type.")); if(GET_FLAG(decl->type , template)) { /*if(!GET_FLAG(decl->type, checked))*/ if(!GET_FLAG(decl->type, scan2)) @@ -140,7 +140,7 @@ ANN static m_bool prim_array_inner(const Env env, const Type t, Type type, const e->cast_to = type; return GW_OK; } - ERR_B(e->pos, "array init [...] contains incompatible types ...") + ERR_B(e->pos, _("array init [...] contains incompatible types ...")) } ANN static inline Type prim_array_match(const Env env, Exp e) { @@ -154,7 +154,7 @@ ANN static Type prim_array(const Env env, const Exp_Primary* primary) { const Array_Sub array = primary->d.array; const Exp e = array->exp; if(!e) - ERR_O(exp_self(primary)->pos, "must provide values/expressions for array [...]") + ERR_O(exp_self(primary)->pos, _("must provide values/expressions for array [...]")) CHECK_OO(check_exp(env, e)) return (array->type = prim_array_match(env, e)); } @@ -165,12 +165,12 @@ ANN static Value check_non_res_value(const Env env, const Exp_Primary* primary) const Value v = value ? value : find_value(env->class_def, primary->d.var); if(v && SAFE_FLAG(env->func, static) && GET_FLAG(v, member)) ERR_O(exp_self(primary)->pos, - "non-static member '%s' used from static function.", s_name(primary->d.var)) + _("non-static member '%s' used from static function."), s_name(primary->d.var)) return v; } else if(env->func && GET_FLAG(env->func->def, global)) { if(!SAFE_FLAG(value, abstract) && !SAFE_FLAG(value, arg)) ERR_O(exp_self(primary)->pos, - "non-global variable '%s' used from global function.", s_name(primary->d.var)) + _("non-global variable '%s' used from global function."), s_name(primary->d.var)) } return value; } @@ -179,7 +179,7 @@ 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)) { env_err(env, exp_self(primary)->pos, - "variable %s not legit at this point.", s_name(primary->d.var)); + _("variable %s not legit at this point."), s_name(primary->d.var)); if(v && v->owner_class) did_you_mean_type(v->owner_class, s_name(primary->d.var)); else @@ -197,9 +197,9 @@ ANN static Type prim_id_non_res(const Env env, const Exp_Primary* primary) { ANN static Type check_exp_prim_this(const Env env, const Exp_Primary* primary) { if(!env->class_def) - ERR_O(exp_self(primary)->pos, "keyword 'this' can be used only inside class definition...") + ERR_O(exp_self(primary)->pos, _("keyword 'this' can be used only inside class definition...")) if(env->func && !GET_FLAG(env->func, member)) - ERR_O(exp_self(primary)->pos, "keyword 'this' cannot be used inside static functions...") + ERR_O(exp_self(primary)->pos, _("keyword 'this' cannot be used inside static functions...")) exp_self(primary)->meta = ae_meta_value; return env->class_def; } @@ -221,8 +221,8 @@ ANN static m_bool vec_value(const Env env, Exp e, const m_str s) { if(isa(t, t_int) > 0) e->cast_to = t_float; else - ERR_B(e->pos, "invalid type '%s' in %s value #%d...\n" - " (must be of type 'int' or 'float')", t->name, s, count) + ERR_B(e->pos, _("invalid type '%s' in %s value #%d...\n" + " (must be of type 'int' or 'float')"), t->name, s, count) } ++count; } while((e = e->next)); @@ -257,7 +257,7 @@ ANN static Type prim_vec(const Env env, const Exp_Primary* primary) { struct VecInfo info = { .n=vec->dim }; vec_info(t, &info); if(vec->dim > info.n) - ERR_O(vec->exp->pos, "extraneous component of %s value...", info.s) + ERR_O(vec->exp->pos, _("extraneous component of %s value..."), info.s) CHECK_BO(vec_value(env, vec->exp, info.s)) return info.t; } @@ -296,11 +296,11 @@ ANN Type check_exp_array(const Env env, const Exp_Array* array) { m_uint depth = 0; do { if(isa(e->type, t_int) < 0) - ERR_O(e->pos, "array index %i must be of type 'int', not '%s'", + ERR_O(e->pos, _("array index %i must be of type 'int', not '%s'"), depth, e->type->name) } while(++depth && (e = e->next)); if(depth != array->array->depth) - ERR_O(exp_self(array)->pos, "invalid array acces expression.") + ERR_O(exp_self(array)->pos, _("invalid array acces expression.")) while(t_base && array->array->depth > t_base->array_depth) { depth -= t_base->array_depth; @@ -308,7 +308,7 @@ ANN Type check_exp_array(const Env env, const Exp_Array* array) { t_base = t_base->e->parent; else ERR_O(exp_self(array)->pos, - "array subscripts (%i) exceeds defined dimension (%i)", + _("array subscripts (%i) exceeds defined dimension (%i)"), array->array->depth, t_base->array_depth) } return depth == t_base->array_depth ? array_base(t_base) : @@ -398,7 +398,7 @@ ANN2(1, 2) static Func find_func_match(const Env env, const Func up, const Exp e ANN static m_bool check_call(const Env env, const Exp_Call* exp) { ae_exp_t et = exp->func->exp_type; if(et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast) - ERR_B(exp->func->pos, "invalid expression for function call.") + ERR_B(exp->func->pos, _("invalid expression for function call.")) CHECK_OB(check_exp(env, exp->func)) return exp->args ? !!check_exp(env, exp->args) : GW_OK; } @@ -525,11 +525,11 @@ ANN Func find_template_match(const Env env, const Value value, const Exp_Call* e t = t->e->parent; } assert(exp_self(exp)); - ERR_O(exp_self(exp)->pos, "arguments do not match for template call") + ERR_O(exp_self(exp)->pos, _("arguments do not match for template call")) } ANN static void print_current_args(Exp e) { - gw_err("and not\n "); + gw_err(_("and not\n ")); do gw_err(" \033[32m%s\033[0m", e->type->name); while((e = e->next) && gw_err(",")); gw_err("\n"); @@ -542,7 +542,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 loc_t pos){ - env_err(env, 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->e->d.func; do { gw_err("(%s) ", up->name); @@ -550,7 +550,7 @@ ANN2(1) static void* function_alternative(const Env env, const Type f, const Exp e ? print_arg(e) : (void)gw_err("\033[32mvoid\033[0m"); gw_err("\n"); } while((up = up->next)); - args ? print_current_args(args) : (void)gw_err("and not:\n \033[32mvoid\033[0m\n"); + args ? print_current_args(args) : (void)gw_err(_("and not:\n \033[32mvoid\033[0m\n")); return NULL; } @@ -572,8 +572,8 @@ ANN static Func get_template_func(const Env env, const Exp_Call* func, const Val ((Exp_Call*)func)->tmpl = NULL; assert(exp_self(func)); ERR_O(exp_self(func)->pos, - "function is template. automatic type guess not fully implemented yet.\n" - " please provide template types. eg: ''") + _("function is template. automatic type guess not fully implemented yet.\n" + " please provide template types. eg: ''")) } ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { @@ -603,7 +603,7 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { list = list->next; } if(args_number < type_number) - ERR_O(call->pos, "not able to guess types for template call.") + ERR_O(call->pos, _("not able to guess types for template call.")) Tmpl tmpl = { .call=tl[0] }; ((Exp_Call*)exp)->tmpl = &tmpl; const Func func = get_template_func(env, exp, value); @@ -612,9 +612,9 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { ANN static m_bool check_exp_call1_check(const Env env, const Exp exp) { if(!check_exp(env, exp)) - ERR_B(exp->pos, "function call using a non-existing function") + ERR_B(exp->pos, _("function call using a non-existing function")) if(isa(exp->type, t_function) < 0) - ERR_B(exp->pos, "function call using a non-function value") + ERR_B(exp->pos, _("function call using a non-function value")) return GW_OK; } @@ -630,7 +630,7 @@ ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { e = e->next; } if(arg || e) - ERR_O(exp_self(exp)->pos, "argument number does not match for lambda") + ERR_O(exp_self(exp)->pos, _("argument number does not match for lambda")) l->def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, NULL, l->name, l->args), l->code, 0, loc_cpy(env->gwion->mp, exp_self(exp)->pos)); CHECK_BO(traverse_func_def(env, l->def)) @@ -692,11 +692,11 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { const Type t = actual_type(exp->func->type); const Value v = nspc_lookup_value1(t->e->owner, insert_symbol(t->name)); if(!v) - ERR_O(exp_self(exp)->pos, " template call of non-existant function.") + ERR_O(exp_self(exp)->pos, _(" template call of non-existant function.")) if(!GET_FLAG(v, func)) - ERR_O(exp_self(exp)->pos, "template call of non-function value.") + ERR_O(exp_self(exp)->pos, _("template call of non-function value.")) if(!v->d.func_ref->def->base->tmpl) - ERR_O(exp_self(exp)->pos, "template call of non-template function.") + ERR_O(exp_self(exp)->pos, _("template call of non-template function.")) const Func ret = find_template_match(env, v, exp); CHECK_OO((exp->m_func = ret)) return ret->def->base->ret_type; @@ -721,11 +721,11 @@ ANN static Type check_exp_if(const Env env, const Exp_If* exp_if) { DECL_OO(const Type, else_exp, = check_exp(env, exp_if->else_exp)) if(isa(cond, t_int) < 0 && isa(cond, t_float) < 0 && isa(cond, t_object) < 0) ERR_O(exp_self(exp_if)->pos, - "Invalid type '%s' in if expression condition.", cond->name) + _("Invalid type '%s' in if expression condition."), cond->name) const Type ret = find_common_anc(if_exp, else_exp); if(!ret) ERR_O(exp_self(exp_if)->pos, - "incompatible types '%s' and '%s' in if expression...", + _("incompatible types '%s' and '%s' in if expression..."), if_exp->name, else_exp->name) return ret; } @@ -737,15 +737,15 @@ ANN static Type check_exp_dot(const Env env, Exp_Dot* member) { const Type the_base = base_static ? member->t_base->e->d.base_type : member->t_base; if(!the_base->nspc) ERR_O(member->base->pos, - "type '%s' does not have members - invalid use in dot expression of %s", + _("type '%s' does not have members - invalid use in dot expression of %s"), the_base->name, str) if(member->xid == insert_symbol("this") && base_static) ERR_O(exp_self(member)->pos, - "keyword 'this' must be associated with object instance...") + _("keyword 'this' must be associated with object instance...")) const Value value = find_value(the_base, member->xid); if(!value) { env_err(env, member->base->pos, - "class '%s' has no member '%s'", the_base->name, str); + _("class '%s' has no member '%s'"), the_base->name, str); if(member->t_base->nspc) did_you_mean_type(member->t_base, str); return NULL; @@ -753,13 +753,13 @@ ANN static Type check_exp_dot(const Env env, Exp_Dot* member) { if(!env->class_def || isa(env->class_def, value->owner_class) < 0) { if(GET_FLAG(value, private)) ERR_O(exp_self(member)->pos, - "can't access private '%s' outside of class...", value->name) + _("can't access private '%s' outside of class..."), value->name) else if(GET_FLAG(value, protect)) exp_self(member)->meta = ae_meta_protect; } if(base_static && GET_FLAG(value, member)) ERR_O(exp_self(member)->pos, - "cannot access member '%s.%s' without object instance...", + _("cannot access member '%s.%s' without object instance..."), the_base->name, str) if(GET_FLAG(value, const) || GET_FLAG(value, enum)) exp_self(member)->meta = ae_meta_value; @@ -814,7 +814,7 @@ ANN static m_bool check_flow(const Env env, const Exp exp, const m_str orig) { if(isa(exp->type, t_object) > 0 || isa(exp->type, t_int) > 0 || isa(exp->type, t_float) > 0 || isa(exp->type, t_dur) > 0 || isa(exp->type, t_time) > 0) return GW_OK; - ERR_B(exp->pos, "invalid type '%s' (in '%s' condition)", exp->type->name, orig) + ERR_B(exp->pos, _("invalid type '%s' (in '%s' condition)"), exp->type->name, orig) } ANN static m_bool check_breaks(const Env env, const Stmt a, const Stmt b) { @@ -833,9 +833,9 @@ ANN static m_bool check_conts(const Env env, const Stmt a, const Stmt b) { ANN static inline m_bool for_empty(const Env env, const Stmt_For stmt) { if(!stmt->c2 || !stmt->c2->d.stmt_exp.val) - ERR_B(stmt_self(stmt)->pos, "empty for loop condition...", - "...(note: explicitly use 'true' if it's the intent)", - "...(e.g., 'for(; true;){ /*...*/ }')") + ERR_B(stmt_self(stmt)->pos, _("empty for loop condition..." + "...(note: explicitly use 'true' if it's the intent)" + "...(e.g., 'for(; true;){ /*...*/ }')")) return GW_OK; } @@ -846,8 +846,8 @@ ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { if(GET_FLAG(t, typedef)) t = t->e->parent; if(!t || !ptr || isa(t, t_array) < 0) - ERR_B(stmt_self(stmt)->pos, "type '%s' is not array.\n" - " This is not allowed in auto loop", stmt->exp->type->name) + ERR_B(stmt_self(stmt)->pos, _("type '%s' is not array.\n" + " This is not allowed in auto loop"), stmt->exp->type->name) if(stmt->is_ptr) { struct ID_List_ id0, id; struct Type_List_ tl; @@ -882,7 +882,7 @@ ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { ANN static m_bool cond_type(const Env env, const Exp e) { if(e->next) - ERR_B(e->pos, "conditional must be a single expression") + ERR_B(e->pos, _("conditional must be a single expression")) const Type t = e->type; if(isa(t, t_int) > 0) return GW_OK; @@ -890,7 +890,7 @@ ANN static m_bool cond_type(const Env env, const Exp e) { e->cast_to = t_int; return GW_OK; } - ERR_B(e->pos, "conditional must be of type 'int'...") + ERR_B(e->pos, _("conditional must be of type 'int'...")) } #define stmt_func_xxx(name, type, prolog, exp) describe_stmt_func(check, name, type, prolog, exp) stmt_func_xxx(if, Stmt_If,, !(!check_exp(env, stmt->cond) || @@ -918,13 +918,13 @@ stmt_func_xxx(auto, Stmt_Auto,, do_stmt_auto(env, stmt)) ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { if(!env->func) - ERR_B(stmt_self(stmt)->pos, "'return' statement found outside function definition") + ERR_B(stmt_self(stmt)->pos, _("'return' statement found outside function definition")) DECL_OB(const Type, ret_type, = stmt->val ? check_exp(env, stmt->val) : t_void) if(env->func->value_ref->type == t_lambda) { if(env->func->def->base->ret_type && isa(ret_type, env->func->def->base->ret_type) < 0 && isa(env->func->def->base->ret_type, ret_type) < 0) - ERR_B(stmt_self(stmt)->pos, "return types do not match for lambda expression") + ERR_B(stmt_self(stmt)->pos, _("return types do not match for lambda expression")) env->func->value_ref->type = ret_type; return GW_OK; } @@ -932,7 +932,7 @@ ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { isa(env->func->def->base->ret_type, t_object) > 0) return GW_OK; if(env->func->def->base->ret_type && isa(ret_type, env->func->def->base->ret_type) < 0) - ERR_B(stmt_self(stmt)->pos, "invalid return type '%s' -- expecting '%s'", + ERR_B(stmt_self(stmt)->pos, _("invalid return type '%s' -- expecting '%s'"), ret_type->name, env->func->def->base->ret_type->name) else //! set default return type for lambdas env->func->def->base->ret_type = ret_type; @@ -942,7 +942,7 @@ ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { #define describe_check_stmt_stack(stack, name) \ ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) {\ if(!vector_size(&env->scope->stack)) \ - ERR_B(stmt->pos, "'"#name"' found outside of for/while/until...") \ + ERR_B(stmt->pos, _("'"#name"' found outside of for/while/until...")) \ return GW_OK; \ } describe_check_stmt_stack(conts, continue) @@ -953,12 +953,12 @@ ANN static m_bool check_stmt_case(const Env env, const Stmt_Exp stmt) { CHECK_BB(switch_inside(env, stmt_self(stmt)->pos)); DECL_OB(const Type, t, = check_exp(env, stmt->val)) if(isa(t, t_int) < 0) - ERR_B(stmt_self(stmt)->pos, "invalid type '%s' case expression. should be 'int'", t->name) + ERR_B(stmt_self(stmt)->pos, _("invalid type '%s' case expression. should be 'int'"), t->name) const Value v = case_value(stmt->val); if(!v) return GW_OK; if(!GET_FLAG(v, const)) - ERR_B(stmt->val->pos, "'%s' is not constant.", v->name) + ERR_B(stmt->val->pos, _("'%s' is not constant."), v->name) if(!GET_FLAG(v, builtin) && !GET_FLAG(v, enum)) switch_expset(env, stmt->val); return GW_OK; @@ -972,10 +972,10 @@ ANN static m_bool check_stmt_jump(const Env env, const Stmt_Jump stmt) { (m_uint*)env->class_def : (m_uint*)env->func; const Map m = label->ptr ? (Map)map_get(label, (vtype)key) : NULL; if(!m) - ERR_B(stmt_self(stmt)->pos, "label '%s' used but not defined", s_name(stmt->name)) + ERR_B(stmt_self(stmt)->pos, _("label '%s' used but not defined"), s_name(stmt->name)) const Stmt_Jump ref = (Stmt_Jump)map_get(m, (vtype)stmt->name); if(!ref) - ERR_B(stmt_self(stmt)->pos, "label '%s' used but not defined", s_name(stmt->name)) + ERR_B(stmt_self(stmt)->pos, _("label '%s' used but not defined"), s_name(stmt->name)) vector_add(&ref->data.v, (vtype)stmt); return GW_OK; } @@ -1000,7 +1000,7 @@ ANN m_bool check_stmt_union(const Env env, const Stmt_Union stmt) { CHECK_OB(check_exp(env, l->self)) if(isa(l->self->type, t_object) > 0) { if(!GET_FLAG(l->self->d.exp_decl.td, ref) && !GET_FLAG(stmt->type, template)) - ERR_B(l->self->pos, "In union, Objects must be declared as reference (use '@')") + ERR_B(l->self->pos, _("In union, Objects must be declared as reference (use '@')")) // SET_FLAG(l->self->d.exp_decl.td, ref); Var_Decl_List list = l->self->d.exp_decl.list; do SET_FLAG(list->self->value, pure); @@ -1042,8 +1042,8 @@ ANN static m_bool check_signature_match(const Env env, const Func_Def fdef, cons const m_str p_name = parent->value_ref->owner_class->name; const m_str f_name = s_name(fdef->base->xid); ERR_B(td_pos(fdef->base->td), - "function '%s.%s' ressembles '%s.%s' but cannot override...\n" - " ...(reason: '%s.%s' is declared as 'static')", + _("function '%s.%s' ressembles '%s.%s' but cannot override...\n" + " ...(reason: '%s.%s' is declared as 'static')"), c_name, f_name, p_name, c_name, GET_FLAG(fdef, static) ? c_name : p_name, f_name) } @@ -1096,8 +1096,8 @@ ANN static m_bool check_func_overload(const Env env, const Func_Def fdef) { for(m_uint j = i + 1; f1 && j <= v->offset; ++j) { const Func f2 = get_overload(env, fdef, j); if(f2 && compat_func(f1->def, f2->def) > 0) - ERR_B(td_pos(f2->def->base->td), "global function '%s' already defined" - " for those arguments", s_name(fdef->base->xid)) + ERR_B(td_pos(f2->def->base->td), _("global function '%s' already defined" + " for those arguments"), s_name(fdef->base->xid)) } } return GW_OK; @@ -1109,8 +1109,8 @@ ANN static m_bool check_func_def_override(const Env env, const Func_Def fdef) { const Value override = find_value(env->class_def->e->parent, fdef->base->xid); if(override && override->owner_class && isa(override->type, t_function) < 0) ERR_B(fdef->pos, - "function name '%s' conflicts with previously defined value...\n" - " from super class '%s'...", + _("function name '%s' conflicts with previously defined value...\n" + " from super class '%s'..."), s_name(fdef->base->xid), override->owner_class->name) } if(func->value_ref->offset && (!fdef->base->tmpl || !fdef->base->tmpl->base)) diff --git a/src/parse/did_you_mean.c b/src/parse/did_you_mean.c index aacc629c..15495cb7 100644 --- a/src/parse/did_you_mean.c +++ b/src/parse/did_you_mean.c @@ -55,7 +55,7 @@ ANN void did_you_mean_nspc(Nspc nspc, const char* name) { do ressembles(&v, nspc, name); while((nspc = nspc->parent)); for(m_uint i = 0; i < vector_size(&v); ++i) - gw_err(" (did you mean '%s'?)\n", (m_str)vector_at(&v, i)); + gw_err(_(" (did you mean '%s'?)\n"), (m_str)vector_at(&v, i)); vector_release(&v); } @@ -66,7 +66,7 @@ ANN void did_you_mean_type(Type type, const char* name) { do ressembles(&v, t->nspc, name); while((t = t->e->parent) && t->nspc); for(m_uint i = 0; i < vector_size(&v); ++i) - gw_err(" (did you mean '%s'?)\n", (m_str)vector_at(&v, i)); + gw_err(_(" (did you mean '%s'?)\n"), (m_str)vector_at(&v, i)); did_you_mean_nspc(type->nspc, name); vector_release(&v); } diff --git a/src/parse/operator.c b/src/parse/operator.c index fe2ffe91..2c60537f 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -76,7 +76,7 @@ ANN m_bool add_op(const Gwion gwion, const Nspc nspc, const struct Op_Import* op continue; const Vector v = (Vector)map_get(&n->info->op_map, (vtype)opi->op); if(v && (mo = operator_find(v, opi->lhs, opi->rhs))) { - env_err(gwion->env, opi->pos, "operator '%s', for type '%s' and '%s' already imported", + env_err(gwion->env, opi->pos, _("operator '%s', for type '%s' and '%s' already imported"), op2str(opi->op), opi->lhs ? opi->lhs->name : NULL, opi->rhs ? opi->rhs->name : NULL); return GW_ERROR; @@ -154,7 +154,7 @@ ANN Type op_check(const Env env, struct Op_Import* opi) { nspc = nspc->parent; } while(nspc); if(opi->op == op_cast || (ret != t_null && opi->op != op_impl)) - env_err(env, opi->pos, "%s %s %s: no match found for operator", + env_err(env, opi->pos, _("%s %s %s: no match found for operator"), type_name(opi->lhs), op2str(opi->op), type_name(opi->rhs)); return NULL; } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 4d6dda9d..463e22e2 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -29,7 +29,7 @@ ANN static Value mk_class(const Env env, const Type base) { ANN static inline m_bool scan0_defined(const Env env, const Symbol s, const loc_t pos) { if(nspc_lookup_type0(env->curr, s)) - ERR_B(pos, "type '%s' already defined", s_name(s)); + ERR_B(pos, _("type '%s' already defined"), s_name(s)); return already_defined(env, s, pos); } @@ -80,7 +80,7 @@ ANN m_bool scan0_stmt_enum(const Env env, const Stmt_Enum stmt) { if(stmt->xid) { const Value v = nspc_lookup_value1(env->curr, stmt->xid); if(v) - ERR_B(stmt_self(stmt)->pos, "'%s' already declared as variable of type '%s'.", + ERR_B(stmt_self(stmt)->pos, _("'%s' already declared as variable of type '%s'."), s_name(stmt->xid), v->type->name) CHECK_BB(scan0_defined(env, stmt->xid, stmt_self(stmt)->pos)) } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 834b14d4..5ad18b66 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -18,7 +18,7 @@ ANN static Type void_type(const Env env, const Type_Decl* td) { DECL_OO(const Type, t, = known_type(env, td)) if(t->size) return t; - ERR_O(td_pos(td), "cannot declare variables of size '0' (i.e. 'void')...") + ERR_O(td_pos(td), _("cannot declare variables of size '0' (i.e. 'void')...")) } @@ -27,20 +27,16 @@ ANN static inline Type get_base_type(const Env env, const Type t) { return nspc_lookup_type1(env->curr, insert_symbol(decl_name)); } -ANN static inline void contains(const Type base, const Type t) { - if(vector_find(&base->e->contains, (vtype)t) == GW_ERROR) { - vector_add(&base->e->contains, (vtype)t); +ANN static inline void type_contains(const Type base, const Type t) { + const Vector v = &base->e->contains; + if(!v->ptr) + vector_init(v); + if(vector_find(v, (vtype)t) == GW_ERROR) { + vector_add(v, (vtype)t); ADD_REF(t); } } -ANN static inline void type_contains(const Type base, const Type t) { - if(!base->e->contains.ptr) - vector_init(&base->e->contains); -printf("%s => %s\n", t->name, base->name); - contains(base, t); -} - ANN static m_bool type_recursive(const Env env, Exp_Decl* decl, const Type t) { const Type decl_base = get_base_type(env, t); const Type base = get_base_type(env, env->class_def); @@ -50,7 +46,7 @@ ANN static m_bool type_recursive(const Env env, Exp_Decl* decl, const Type t) { if(decl_base->e->contains.ptr) { for(m_uint i = 0; i < vector_size(&t->e->contains); ++i) { if(env->class_def == (Type)vector_at(&t->e->contains, i) && !GET_FLAG(decl->td, ref)) - ERR_B(exp_self(decl)->pos, "%s declared inside %s\n. (make it a ref ?)", + ERR_B(exp_self(decl)->pos, _("%s declared inside %s\n. (make it a ref ?)"), decl_base->name, decl_base == base ? "itself" : base->name); } } @@ -69,11 +65,11 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) { SET_FLAG(decl->td, member); } if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, ref)) - ERR_O(exp_self(decl)->pos, "Type '%s' is abstract, declare as ref. (use @)", t->name) + ERR_O(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name) if(GET_FLAG(t, private) && t->e->owner != env->curr) - ERR_O(exp_self(decl)->pos, "can't use private type %s", t->name) + ERR_O(exp_self(decl)->pos, _("can't use private type %s"), t->name) if(GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0)) - ERR_O(exp_self(decl)->pos, "can't use protected type %s", t->name) + ERR_O(exp_self(decl)->pos, _("can't use protected type %s"), t->name) decl->base = t->e->def; return decl->type = t; } @@ -93,13 +89,13 @@ ANN m_bool scan1_exp_decl(const Env env, const Exp_Decl* decl) { const Value former = nspc_lookup_value0(env->curr, var->xid); if(former && !decl->td->exp && (!env->class_def || !(GET_FLAG(env->class_def, template) || GET_FLAG(env->class_def, scan1)))) - ERR_B(var->pos, "variable %s has already been defined in the same scope...", + ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), s_name(var->xid)) if(var->array) { if(var->array->exp) { if(GET_FLAG(decl->td, ref)) - ERR_B(td_pos(decl->td), "ref array must not have array expression.\n" - "e.g: int @my_array[];\nnot: @int my_array[2];") + ERR_B(td_pos(decl->td), _("ref array must not have array expression.\n" + "e.g: int @my_array[];\nnot: @int my_array[2];")) CHECK_BB(scan1_exp(env, var->array->exp)) } t = array_type(env, decl->type, var->array->depth); @@ -148,8 +144,8 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { CHECK_BB(scan1_exp(env, post->exp)) if(post->exp->meta == ae_meta_var) return GW_OK; - ERR_B(post->exp->pos, "post operator '%s' cannot be used" - " on non-mutable data-type...", op2str(post->op)); + ERR_B(post->exp->pos, _("post operator '%s' cannot be used" + " on non-mutable data-type..."), op2str(post->op)); } ANN static m_bool scan1_exp_call(const Env env, const Exp_Call* exp_call) { @@ -333,7 +329,7 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) { if(tmpl_base(fdef->base->tmpl)) return GW_OK; if(GET_FLAG(fdef, dtor) && !env->class_def) - ERR_B(td_pos(fdef->base->td), "dtor must be in class def!!") + ERR_B(td_pos(fdef->base->td), _("dtor must be in class def!!")) if(GET_FLAG(fdef, op) && env->class_def) SET_FLAG(fdef, static); struct Func_ fake = { .name=s_name(fdef->base->xid) }, *const former = env->func; @@ -359,14 +355,14 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { Type t = parent; do { if(cdef->base.type == t) - ERR_B(pos, "recursive (%s <= %s) class declaration.", cdef->base.type->name, t->name); + ERR_B(pos, _("recursive (%s <= %s) class declaration."), cdef->base.type->name, t->name); } while((t = t->e->parent)); if(isa(parent, t_object) < 0) - ERR_B(pos, "cannot extend primitive type '%s'", parent->name) + ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name) if(parent->e->def) CHECK_BB(scanx_parent(parent, scan1_class_def, env)) if(type_ref(parent)) - ERR_B(pos, "can't use ref type in class extend") + ERR_B(pos, _("can't use ref type in class extend")) return GW_OK; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index a3e56c75..b09ce505 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -158,7 +158,7 @@ ANN static inline m_bool scan2_exp_array(const Env env, const Exp_Array* array) ANN static m_bool multi_decl(const Env env, const Exp e, const Operator op) { if(e->exp_type == ae_exp_decl) { if(e->d.exp_decl.list->next) - ERR_B(e->pos, "cant '%s' from/to a multi-variable declaration.", op2str(op)) + ERR_B(e->pos, _("cant '%s' from/to a multi-variable declaration."), op2str(op)) SET_FLAG(e->d.exp_decl.list->self->value, used); } return GW_OK; @@ -263,7 +263,7 @@ ANN static m_bool scan2_stmt_jump(const Env env, const Stmt_Jump stmt) { if(stmt->is_label) { const Map m = scan2_label_map(env); if(map_get(m, (vtype)stmt->name)) - ERR_B(stmt_self(stmt)->pos, "label '%s' already defined", s_name(stmt->name)) + ERR_B(stmt_self(stmt)->pos, _("label '%s' already defined"), s_name(stmt->name)) map_set(m, (vtype)stmt->name, (vtype)stmt); vector_init(&stmt->data.v); } @@ -305,10 +305,10 @@ ANN static m_bool scan2_func_def_overload(const Env env, const Func_Def f, const const m_bool tmpl = GET_FLAG(overload, template); if(isa(overload->type, t_function) < 0 || isa(overload->type, t_fptr) > 0) { if(isa(actual_type(overload->type), t_function) < 0) - ERR_B(f->pos, "function name '%s' is already used by another value", overload->name) + ERR_B(f->pos, _("function name '%s' is already used by another value"), overload->name) } if((!tmpl && base) || (tmpl && !base && !GET_FLAG(f, template))) - ERR_B(f->pos, "must overload template function with template") + ERR_B(f->pos, _("must overload template function with template")) return GW_OK; } @@ -498,8 +498,8 @@ ANN2(1,2) static m_str func_name(const Env env, const Func_Def f, const Value v) } -ANN m_bool scan2_fdef(const Env env, const Func_Def f, const Value overload) { - const m_str name = func_name(env, f, overload); +ANN2(1,2) m_bool scan2_fdef(const Env env, const Func_Def f, const Value overload) { + const m_str name = func_name(env, f, overload ?: NULL); if((m_int)name <= GW_OK) return (m_bool)(m_uint)name; const Func base = get_func(env, f); @@ -524,7 +524,7 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { const Value overload = nspc_lookup_value0(env->curr, f->base->xid); const Value res = nspc_lookup_value1(env->global_nspc, f->base->xid); if(res) - ERR_B(f->pos, "'%s' already declared as type", s_name(f->base->xid)) + ERR_B(f->pos, _("'%s' already declared as type"), s_name(f->base->xid)) f->stack_depth = (env->class_def && !GET_FLAG(f, static) && !GET_FLAG(f, global)) ? SZ_INT : 0; if(GET_FLAG(f, variadic)) f->stack_depth += SZ_INT; diff --git a/src/parse/template.c b/src/parse/template.c index 51805843..aac48450 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -154,9 +154,9 @@ ANN Type scan_type(const Env env, const Type t, const Type_Decl* type) { return t; if(!type->types) ERR_O(t->e->def->pos, - "you must provide template types for type '%s'", t->name) + _("you must provide template types for type '%s'"), t->name) if(template_match(t->e->def->base.tmpl->list, type->types) < 0) - ERR_O(type->xid->pos, "invalid template types number") + ERR_O(type->xid->pos, _("invalid template types number")) DECL_OO(const Class_Def, a, = template_class(env, t->e->def, type->types)) SET_FLAG(a, ref); if(a->base.type) @@ -188,6 +188,6 @@ ANN Type scan_type(const Env env, const Type t, const Type_Decl* type) { return a->base.type; } else if(type->types) ERR_O(type->xid->pos, - "type '%s' is not template. You should not provide template types", t->name) + _("type '%s' is not template. You should not provide template types"), t->name) return t; } diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index f648dd55..c3ec7d0a 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -58,14 +58,14 @@ ANEW ANN m_str tl2str(const Env env, Type_List tl) { ANN static inline void* type_unknown(const Env env, const ID_List id) { char path[id_list_len(id)]; type_path(path, id); - env_err(env, id->pos, "unknown type '%s'", path); + env_err(env, id->pos, _("unknown type '%s'"), path); did_you_mean_nspc(env->curr, s_name(id->xid)); return NULL; } ANN static inline Type prim_ref(const Env env, const Type t, const Type_Decl* td) { if(GET_FLAG(td, ref) && isa(t, t_object) < 0 && isa(t, t_class) < 0) - ERR_O(td->xid->pos, "primitive types cannot be used as reference (@)...\n") + ERR_O(td->xid->pos, _("primitive types cannot be used as reference (@)...\n")) return t; } diff --git a/src/parse/type_utils.c b/src/parse/type_utils.c index d27414a8..4474cf19 100644 --- a/src/parse/type_utils.c +++ b/src/parse/type_utils.c @@ -12,7 +12,7 @@ ANN m_bool isres(const Env env, const Symbol xid, const loc_t pos) { if(vector_find(&env->gwion->data->reserved, (vtype)xid) > -1) - ERR_B(pos, "%s is reserved.", s_name(xid)); + ERR_B(pos, _("%s is reserved."), s_name(xid)); return GW_OK; } diff --git a/src/plug.c b/src/plug.c index 3f76968f..9dea63a7 100644 --- a/src/plug.c +++ b/src/plug.c @@ -66,7 +66,7 @@ ANN static void plug_get(MemPool p, PlugInfo* pi, const m_str c) { map_set(&pi->drv, (vtype)str(), (vtype)drv); } } else - gw_err("error in %s.", DLERROR()); + gw_err(_("error in %s."), DLERROR()); } ANN PlugInfo* new_plug(MemPool p, const Vector list) { @@ -151,4 +151,4 @@ void plug_run(const Gwion gwion, const Vector args) { free_vector(gwion->mp, arg); } } -} \ No newline at end of file +} diff --git a/src/vm/vm.c b/src/vm/vm.c index e50854f3..d7d18216 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -664,8 +664,8 @@ arrayaccess: { const m_int idx = *(m_int*)(reg + SZ_INT * instr->m_val); if(idx < 0 || (m_uint)idx >= m_vector_size(ARRAY(a.obj))) { - gw_err(" ... at index [%" INT_F "]\n", idx); - gw_err(" ... at dimension [%" INT_F "]\n", instr->m_val); + gw_err(_(" ... at index [%" INT_F "]\n"), idx); + gw_err(_(" ... at dimension [%" INT_F "]\n"), instr->m_val); shred->code = code; shred->mem = mem; exception(shred, "ArrayOutofBounds"); diff --git a/tests/sh/plugin.sh b/tests/sh/plugin.sh index fdd53b80..1cc461fb 100644 --- a/tests/sh/plugin.sh +++ b/tests/sh/plugin.sh @@ -14,13 +14,14 @@ export GWION_ADD_DIR test_plugin() { export NAME=$"$1" + export PRG=$"../../gwion" make if [ -f "$NAME.gw" ] then GWOPT=-p. test_gw "$NAME.gw" "$n" else GWOPT=-p. test_gw "/dev/null" "$n" fi make clean - N=$(printf "% 4i" "$n") + N=$(printf "% 4i" "$n") echo "ok $N plugin test: '$NAME'" n=$((n+1)) } diff --git a/tests/sh/test.sh b/tests/sh/test.sh index fdc2f7a8..7e1fa70b 100644 --- a/tests/sh/test.sh +++ b/tests/sh/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +# [test] #0 : "${PRG:=gwion}" : "${VALGRIND:=valgrind}" @@ -181,9 +182,9 @@ test_gw(){ vlog=${GWION_TEST_DIR}/${GWION_TEST_PREFIX}$(printf "%04i" "$n").valgrind.log rlog=${GWION_TEST_DIR}/${GWION_TEST_PREFIX}$(printf "%04i" "$n").log if [ "$VALGRIND" == "NO_VALGRIND" ] - then ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: + then LANG=C ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: else - "$VALGRIND" --suppressions=help/supp --log-file="$vlog" \ + LANG=C "$VALGRIND" --suppressions=help/supp --log-file="$vlog" \ ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: fi ret=$? diff --git a/util b/util index 512600b2..c82bc41a 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 512600b2403a7f31454245f3957866ab8cbde070 +Subproject commit c82bc41a6bca03493bdebad1cc29a775b28bd9d2