From: Jérémie Astor Date: Tue, 27 Apr 2021 19:36:19 +0000 (+0200) Subject: :art: uncures ERR_N X-Git-Tag: nightly~713 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3040f7904ac464dbcb3d86fab475ed991104d5e3;p=gwion.git :art: uncures ERR_N --- diff --git a/include/operator.h b/include/operator.h index 585c4185..aa82cb6e 100644 --- a/include/operator.h +++ b/include/operator.h @@ -2,7 +2,7 @@ #define __OPERATOR #define OP_ANY_TYPE (Type)1 -#define ERR_N(a, b, ...) { env_err(env, (a), (b), ## __VA_ARGS__); return env->gwion->type[et_error]; } +#define ERR_N(a, b, ...) do { env_err(env, (a), (b), ## __VA_ARGS__); return env->gwion->type[et_error]; } while(0) #define DECL_ON(decl, f, exp) decl f exp; { if(!f) return env->gwion->type[et_error]; } #define DECL_BN(decl, f, exp) decl f exp; { if(f < 0) return env->gwion->type[et_error]; } #define DECL_NN(decl, f, exp) decl f exp; { if(f == env->gwion->type[et_error]) return env->gwion->type[et_error]; } diff --git a/plug b/plug index 109a1b84..15e194f8 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 109a1b84ab2b525d475dbca811325cc6b5adf693 +Subproject commit 15e194f8060ba4b94a4d3ae5ac985a92a8f92663 diff --git a/src/lib/array.c b/src/lib/array.c index 1874ef37..fc9d3f44 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -119,7 +119,7 @@ static MFUN(vm_vector_random) { const Type l = array_base(a->type); \ const Type r = array_base(b->type); \ if(isa(r, l) < 0) \ - ERR_N(pos, _("array types do not match.")) + ERR_N(pos, _("array types do not match.")); static OP_CHECK(opck_array_at) { const Exp_Binary* bin = (Exp_Binary*)data; @@ -128,12 +128,12 @@ static OP_CHECK(opck_array_at) { if(bin->lhs->type != env->gwion->type[et_error]) { ARRAY_OPCK(bin->lhs, bin->rhs, exp_self(bin)->pos) 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 && bin->rhs->d.exp_decl.list->self->array->exp) - 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'.")); } exp_setvar(bin->rhs, 1); return bin->rhs->type; diff --git a/src/lib/engine.c b/src/lib/engine.c index 94e9f968..0464fb05 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -70,7 +70,7 @@ OP_EMIT(opem_object_dot); static OP_CHECK(opck_basic_ctor) { const Exp_Call* call = (Exp_Call*)data; - ERR_N(exp_self(call)->pos, _("can't call a non-callable value")) + ERR_N(exp_self(call)->pos, _("can't call a non-callable value")); } static INSTR(PredicateCheck) { diff --git a/src/lib/modules.c b/src/lib/modules.c index 3b293ffe..9add9a64 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -209,11 +209,11 @@ static OP_CHECK(opck_usrugen) { Exp_Binary *bin = (Exp_Binary*)data; const Arg_List arg = bin->lhs->type->info->func->def->base->args; if(!arg || arg->next) - ERR_N(exp_self(bin)->pos, _("Tick function take one and only one argument")) + ERR_N(exp_self(bin)->pos, _("Tick function take one and only one argument")); if(isa(arg->type, env->gwion->type[et_float]) < 0) - ERR_N(exp_self(bin)->pos, _("Tick functions argument must be of type float")) + ERR_N(exp_self(bin)->pos, _("Tick functions argument must be of type float")); if(isa(bin->lhs->type->info->func->def->base->ret_type, env->gwion->type[et_float]) < 0) - ERR_N(exp_self(bin)->pos, _("Tick function must return float")) + ERR_N(exp_self(bin)->pos, _("Tick function must return float")); if(bin->lhs->type->info->func->value_ref->from->owner_class) CHECK_BN(isa(bin->lhs->type->info->func->value_ref->from->owner_class, bin->rhs->type)) diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 43781586..40a1365b 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -50,8 +50,8 @@ static OP_CHECK(opck_object_cast) { const Type to = known_type(env, cast->td); if(isa(cast->exp->type, to) < 0) { if(isa(to, cast->exp->type) > 0) - ERR_N(exp_self(cast)->pos, _("can't upcast '%s' to '%s'"), cast->exp->type->name, to->name) - ERR_N(exp_self(cast)->pos, _("can't cast '%s' to '%s'"), cast->exp->type->name, to->name) + ERR_N(exp_self(cast)->pos, _("can't upcast '%s' to '%s'"), cast->exp->type->name, to->name); + ERR_N(exp_self(cast)->pos, _("can't cast '%s' to '%s'"), cast->exp->type->name, to->name); } return exp_self(cast)->type; } @@ -62,7 +62,7 @@ static Type opck_object_scan(const Env env, const struct TemplateScan *ts) { if(ts->td->types) return scan_class(env, ts->t, ts->td) ?: env->gwion->type[et_error]; Type_Decl *td = (Type_Decl*)ts->td; - ERR_N(td->pos, _("you must provide template types for type '%s'"), ts->t->name) + ERR_N(td->pos, _("you must provide template types for type '%s'"), ts->t->name); } static OP_CHECK(opck_struct_scan) { @@ -162,10 +162,10 @@ OP_CHECK(opck_object_dot) { // if(!the_base->nspc) // ERR_N(&member->base->pos, // _("type '%s' does not have members - invalid use in dot expression of %s"), -// the_base->name, str) +// the_base->name, str); if(member->xid == insert_symbol(env->gwion->st, "this") && base_static) ERR_N(exp_self(member)->pos, - _("keyword 'this' must be associated with object instance...")) + _("keyword 'this' must be associated with object instance...")); const Value value = get_value(env, member, the_base); if(!value) { const Value v = nspc_lookup_value1(env->curr, member->xid); @@ -181,14 +181,14 @@ OP_CHECK(opck_object_dot) { if(!env->class_def || isa(env->class_def, value->from->owner_class) < 0) { if(GET_FLAG(value, private)) ERR_N(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_setprot(exp_self(member), 1); } if(base_static && vflag(value, vflag_member)) ERR_N(exp_self(member)->pos, _("cannot access member '%s.%s' without object instance..."), - the_base->name, str) + the_base->name, str); if(GET_FLAG(value, const)) exp_setmeta(exp_self(member), 1); return value->type; diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 70a9fe3d..c4979b66 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -49,7 +49,7 @@ OP_CHECK(opck_const_rhs) { ERR_N(bin->rhs->pos, _("cannot assign '%s' on types '%s' and '%s'.\n" " ... (reason: --- right-side operand is %s.)"), s_name(bin->op), bin->lhs->type->name, bin->rhs->type->name, - access) + access); return bin->rhs->type; } @@ -89,7 +89,7 @@ OP_CHECK(opck_post) { const m_str access = exp_access(post->exp); if(access) ERR_N(post->exp->pos, _("post operator '%s' cannot be used on %s data-type."), - s_name(post->op), access) + s_name(post->op), access); exp_setvar(post->exp, 1); return post->exp->type; } @@ -100,11 +100,11 @@ OP_CHECK(opck_new) { const Exp_Unary* unary = (Exp_Unary*)data; DECL_ON(const Type, t, = known_type(env, unary->td)) if(isa(t, env->gwion->type[et_object]) < 0) - ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n")) + ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n")); if(type_ref(t)) - ERR_N(unary->td->pos, _("can't use 'new' on ref type '%s'\n"), t->name) + ERR_N(unary->td->pos, _("can't use 'new' on ref type '%s'\n"), t->name); if(GET_FLAG(t, abstract)) - ERR_N(unary->td->pos, _("can't use 'new' on abstract type '%s'\n"), t->name) + ERR_N(unary->td->pos, _("can't use 'new' on abstract type '%s'\n"), t->name); if(unary->td->array) CHECK_BN(check_subscripts(env, unary->td->array, 1)) return t; diff --git a/src/lib/prim.c b/src/lib/prim.c index 15ccd115..595d0262 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -66,8 +66,8 @@ static OP_CHECK(opck_##ntype##_##name) { BINARY_INT_FOLD(add, et_int, +,,) BINARY_INT_FOLD(sub, et_int, -,,) BINARY_INT_FOLD(mul, et_int, *,POWEROF2_OPT(name, <<),) -BINARY_INT_FOLD(div, et_int, /,POWEROF2_OPT(name, >>),if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) -BINARY_INT_FOLD(mod, et_int, %,, if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) +BINARY_INT_FOLD(div, et_int, /,POWEROF2_OPT(name, >>),if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) +BINARY_INT_FOLD(mod, et_int, %,, if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) BINARY_INT_FOLD(sl, et_int, <<,,) BINARY_INT_FOLD(sr, et_int, >>,,) BINARY_INT_FOLD(sand, et_int, &,,) @@ -266,7 +266,7 @@ static OP_CHECK(opck_implicit_i2f) { BINARY_INT_FLOAT_FOLD(add, et_float, +,,) BINARY_INT_FLOAT_FOLD(sub, et_float, -,,) BINARY_INT_FLOAT_FOLD(mul, et_float, *,/*POWEROF2_OPT(name, <<)*/,) -BINARY_INT_FLOAT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) +BINARY_INT_FLOAT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) BINARY_INT_FLOAT_FOLD2(gt, et_bool, >,,) BINARY_INT_FLOAT_FOLD2(ge, et_bool, >=,,) BINARY_INT_FLOAT_FOLD2(lt, et_bool, <=,,) @@ -324,7 +324,7 @@ static GWION_IMPORT(intfloat) { BINARY_FLOAT_INT_FOLD(add, et_float, +,,) BINARY_FLOAT_INT_FOLD(sub, et_float, -,,) BINARY_FLOAT_INT_FOLD(mul, et_float, *,/*POWEROF2_OPT(name, <<)*/,) -BINARY_FLOAT_INT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) +BINARY_FLOAT_INT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.num == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) BINARY_FLOAT_INT_FOLD2(gt, et_bool, >,,) BINARY_FLOAT_INT_FOLD2(ge, et_bool, >=,,) @@ -453,8 +453,8 @@ static GWION_IMPORT(time) { BINARY_FLOAT_FOLD(add, et_float, +,,) BINARY_FLOAT_FOLD(sub, et_float, -,,) BINARY_FLOAT_FOLD(mul, et_float, *,/*POWEROF2_OPT(name, <<)*/,) -BINARY_FLOAT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) -//BINARY_FLOAT_FOLD(mod, et_float, %,, if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"))) +BINARY_FLOAT_FOLD(div, et_float, /,/*POWEROF2_OPT(name, >>)*/,if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) +//BINARY_FLOAT_FOLD(mod, et_float, %,, if(bin->rhs->d.prim.d.fnum == 0)ERR_N(exp_self(bin)->pos, _("ZeroDivideException"));) BINARY_FLOAT_FOLD2(and, et_bool, &&,,) BINARY_FLOAT_FOLD2(or, et_bool, ||,,) BINARY_FLOAT_FOLD2(eq, et_bool, ==,,) diff --git a/src/lib/ptr.c b/src/lib/ptr.c index db362037..049dc80e 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -62,7 +62,7 @@ static OP_CHECK(opck_ptr_deref) { static OP_CHECK(opck_ptr_cast) { const Exp_Cast* cast = (Exp_Cast*)data; if(!cast->td->types || !cast->td->types->td) - ERR_N(exp_self(cast)->pos, "'Ptr' needs types to cast") + ERR_N(exp_self(cast)->pos, "'Ptr' needs types to cast"); DECL_ON(const Type, t, = known_type(env, cast->td)) if(t->info->cdef && !tflag(t, tflag_check)) CHECK_BN(ensure_traverse(env, t)) @@ -70,7 +70,7 @@ static OP_CHECK(opck_ptr_cast) { exp_setvar(cast->exp, 1); if(isa(cast->exp->type, to) > 0) return t; - ERR_N(exp_self(cast)->pos, "invalid pointer cast") + ERR_N(exp_self(cast)->pos, "invalid pointer cast"); } static OP_CHECK(opck_ptr_implicit) { diff --git a/src/lib/tmpl_info.c b/src/lib/tmpl_info.c index 73d86613..83ca3bf7 100644 --- a/src/lib/tmpl_info.c +++ b/src/lib/tmpl_info.c @@ -79,7 +79,7 @@ ANN static Type _tmpl_exists(const Env env, const Symbol name) { ANN Type tmpl_exists(const Env env, struct tmpl_info *const info) { if(template_match(info->list, info->td->types) < 0) // invalid template - ERR_N(info->td->pos, _("invalid template types number")) + ERR_N(info->td->pos, _("invalid template types number")); if(!info->name) { DECL_ON(const Symbol, name, = info->name = template_id(env, info)) return _tmpl_exists(env, name); diff --git a/src/lib/union.c b/src/lib/union.c index c4c46a10..b3dc30f1 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -110,7 +110,7 @@ static OP_CHECK(opck_union_ctor) { const Exp name = call->args; if(!name || !name->next || name->next->next) ERR_N(name->pos, "Union constructor takes two arguments, " - "'id' and 'value'") + "'id' and 'value'"); if(name->exp_type != ae_exp_primary || name->d.prim.prim_type != ae_prim_id) return NULL; @@ -126,7 +126,7 @@ static OP_CHECK(opck_union_ctor) { DECL_ON(const Type, t, = check_exp(env, val)) if(isa(t, v->type) < 0) { ERR_N(val->pos, "Invalid type '%s' for '%s', should be '%s'", - t->name, v->name, v->type->name) + t->name, v->name, v->type->name); } return base; }