#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]; }
-Subproject commit 109a1b84ab2b525d475dbca811325cc6b5adf693
+Subproject commit 15e194f8060ba4b94a4d3ae5ac985a92a8f92663
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;
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;
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) {
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))
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;
}
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) {
// 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);
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;
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;
}
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;
}
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;
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, &,,)
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, <=,,)
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, >=,,)
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, ==,,)
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))
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) {
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);
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;
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;
}