-Subproject commit 595dd5edbd94984c3b2eebc352d38476472f1a93
+Subproject commit c43f0ae616811b5a927a4bcd0bd552037a7c09c9
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=$?
#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) \
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;
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;
} 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;
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);
}
}
}
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;
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;
}
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;
}
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);
*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;
}
}
*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
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);
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;
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;
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;
}
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));
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) {
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;
}
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;
}
}
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;
}
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) {
*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;
}
}
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));
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)
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;
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;
}
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;
}
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);
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));
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),
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);
}
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);
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))
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;
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;
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;
}
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;
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;
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;
}
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)))
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;
//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
}
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);
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);
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;
}
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;
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;
}
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);
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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);
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))
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) {
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));
}
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;
}
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
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;
}
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));
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;
}
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;
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) :
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;
}
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");
}
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);
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;
}
((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: '<type1, type2, ...>'")
+ _("function is template. automatic type guess not fully implemented yet.\n"
+ " please provide template types. eg: '<type1, type2, ...>'"))
}
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);
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;
}
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))
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;
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;
}
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;
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;
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) {
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;
}
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;
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;
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) ||
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;
}
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;
#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)
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;
(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;
}
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);
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)
}
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;
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))
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);
}
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);
}
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;
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;
}
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);
}
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))
}
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')..."))
}
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);
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);
}
}
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;
}
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);
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) {
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;
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;
}
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;
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);
}
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;
}
}
-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);
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;
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)
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;
}
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;
}
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;
}
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) {
free_vector(gwion->mp, arg);
}
}
-}
\ No newline at end of file
+}
{
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");
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))
}
#!/bin/bash
+# [test] #0
: "${PRG:=gwion}"
: "${VALGRIND:=valgrind}"
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=$?
-Subproject commit 512600b2403a7f31454245f3957866ab8cbde070
+Subproject commit c82bc41a6bca03493bdebad1cc29a775b28bd9d2