#define OP_ANY_TYPE (Type)1
#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]; }
-#define CHECK_ON(f) { if(!f) return env->gwion->type[et_error]; }
-#define CHECK_NB(f) { if(f == env->gwion->type[et_error]) return GW_ERROR; }
-#define CHECK_NO(f) { if(f == env->gwion->type[et_error]) return NULL; }
-#define CHECK_BN(f) { if(f < 0) return env->gwion->type[et_error]; }
-#define CHECK_NN(f) { if(f == env->gwion->type[et_error]) return env->gwion->type[et_error]; }
+#define DECL_ON(decl, f, exp) decl f exp; do { if(!f) return env->gwion->type[et_error]; } while(0)
+#define DECL_BN(decl, f, exp) decl f exp; do { if(f < 0) return env->gwion->type[et_error]; } while(0)
+#define DECL_NN(decl, f, exp) decl f exp; do { if(f == env->gwion->type[et_error]) return env->gwion->type[et_error]; } while(0)
+#define CHECK_ON(f) do { if(!f) return env->gwion->type[et_error]; } while(0)
+#define CHECK_NB(f) do { if(f == env->gwion->type[et_error]) return GW_ERROR; } while(0)
+#define CHECK_NO(f) do { if(f == env->gwion->type[et_error]) return NULL; } while(0)
+#define CHECK_BN(f) do { if(f < 0) return env->gwion->type[et_error]; } while(0)
+#define CHECK_NN(f) do { if(f == env->gwion->type[et_error]) return env->gwion->type[et_error]; } while(0)
typedef Type (*opck)(const Env, void*);
typedef m_bool (*opem)(const Emitter, void*);
-Subproject commit 15e194f8060ba4b94a4d3ae5ac985a92a8f92663
+Subproject commit 7680ae9aa87eb19cf084c5aa1b83b47b08a85732
const Array_Sub array = (Array_Sub)data;
const Type t_int = env->gwion->type[et_int];
Exp e = array->exp;
- do CHECK_BN(check_implicit(env, e, t_int))
+ do CHECK_BN(check_implicit(env, e, t_int));
while((e = e->next));
const Type t = array->type->array_depth ? array->type : typedef_base(array->type);
if(t->array_depth >= array->depth)
bin->rhs->type->info->func->def->base->tmpl->call) {
struct FptrInfo info = { bin->lhs->type->info->func, bin->rhs->type->info->parent->info->func,
bin->lhs, exp_self(bin)->pos };
- CHECK_BN(fptr_do(env, &info))
+ CHECK_BN(fptr_do(env, &info));
exp_setvar(bin->rhs, 1);
return bin->rhs->type;
}
struct FptrInfo info = { bin->lhs->type->info->func, bin->rhs->type->info->func,
bin->lhs, exp_self(bin)->pos };
- CHECK_BN(fptr_do(env, &info))
+ CHECK_BN(fptr_do(env, &info));
exp_setvar(bin->rhs, 1);
return bin->rhs->type;
}
const Type t = exp_self(cast)->type;
struct FptrInfo info = { cast->exp->type->info->func, t->info->func,
cast->exp, exp_self(cast)->pos };
- CHECK_BN(fptr_do(env, &info))
+ CHECK_BN(fptr_do(env, &info));
return t;
}
struct Implicit *impl = (struct Implicit*)data;
struct FptrInfo info = { impl->e->type->info->func, impl->t->info->func,
impl->e, impl->e->pos };
- CHECK_BN(fptr_do(env, &info))
+ CHECK_BN(fptr_do(env, &info));
return impl->t;
}
static OP_CHECK(opck_op_impl){
struct Implicit *impl = (struct Implicit*)data;
const Func func = impl->t->info->func;
- CHECK_BN(op_impl_narg(env, func->def, impl->e->pos))
+ CHECK_BN(op_impl_narg(env, func->def, impl->e->pos));
op_impl_ensure_types(env, func);
const Symbol lhs_sym = insert_symbol("@lhs");
const Symbol rhs_sym = insert_symbol("@rhs");
self.d.exp_binary.op = impl->e->d.prim.d.var;
struct Op_Import opi = { .op=impl->e->d.prim.d.var, .lhs=func->def->base->args->type,
.rhs=func->def->base->args->next->type, .data=(uintptr_t)&self.d.exp_binary, .pos=impl->e->pos };
- DECL_ON(const Type, t, = op_check(env, &opi))
- CHECK_BN(isa(t, func->def->base->ret_type))
+ DECL_ON(const Type, t, = op_check(env, &opi));
+ CHECK_BN(isa(t, func->def->base->ret_type));
// Find if the function exists
Value v = nspc_lookup_value0(opi.nspc, impl->e->d.prim.d.var);
if(v) {
const m_bool ret = check_stmt(env, unary->code);
nspc_pop_value(env->gwion->mp, env->curr);
--env->scope->depth;
- CHECK_BN(ret)
+ CHECK_BN(ret);
return env->gwion->type[unary->op == insert_symbol("spork") ? et_shred : et_fork];
}
ERR_O(exp_self(unary)->pos, _("only function calls can be sporked..."))
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))
+ bin->rhs->type));
return bin->rhs->type;
}
if(bin->rhs->exp_type == ae_exp_decl)
SET_FLAG(bin->rhs->d.exp_decl.list->self->value, late);
exp_setvar(bin->rhs, 1);
- CHECK_BN(isa(bin->lhs->type , bin->rhs->type))
+ CHECK_BN(isa(bin->lhs->type , bin->rhs->type));
return bin->rhs->type;
}
did_you_mean_type(the_base, str);
return env->gwion->type[et_error];
}
- CHECK_BN(not_from_owner_class(env, the_base, value, exp_self(member)->pos))
+ CHECK_BN(not_from_owner_class(env, the_base, value, exp_self(member)->pos));
if(!env->class_def || isa(env->class_def, value->from->owner_class) < 0) {
if(GET_FLAG(value, private))
ERR_N(exp_self(member)->pos,
.type=f->value_ref->type };
struct Op_Import opi = { .op=insert_symbol("@func_check"),
.rhs=f->value_ref->type, .pos=imp->e->pos, .data=(uintptr_t)&call };
- CHECK_NN(op_check(env, &opi))
+ CHECK_NN(op_check(env, &opi));
}
}
*/
OP_CHECK(opck_new) {
const Exp_Unary* unary = (Exp_Unary*)data;
- DECL_ON(const Type, t, = known_type(env, unary->td))
+ 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"));
if(type_ref(t))
if(GET_FLAG(t, abstract))
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))
+ CHECK_BN(check_subscripts(env, unary->td->array, 1));
return t;
}
const Type t = env->gwion->type[TYPE]; \
if(!exp_self(unary)->pos.first.line || !func(unary->exp)) \
return t; \
- CHECK_NN(opck_unary_meta(env, data))\
+ CHECK_NN(opck_unary_meta(env, data)); \
const ctype num = OP unary->exp->d.prim.d.member; \
exp_self(unary)->exp_type = ae_exp_primary; \
exp_self(unary)->d.prim.prim_type = exptype; \
static OP_CHECK(opck_now) {
const Exp_Binary* bin = (Exp_Binary*)data;
if(!is_now(env, bin->rhs))
- CHECK_NN(opck_const_rhs(env, data))
+ CHECK_NN(opck_const_rhs(env, data));
exp_setvar(bin->rhs, 1);
return bin->rhs->type;
}
static OP_CHECK(opck_ptr_assign) {
const Exp_Binary* bin = (Exp_Binary*)data;
- CHECK_BN(ptr_access(env, bin->lhs))
- CHECK_BN(ptr_access(env, bin->rhs))
+ CHECK_BN(ptr_access(env, bin->lhs));
+ CHECK_BN(ptr_access(env, bin->rhs));
exp_setvar(bin->lhs, 1);
exp_setvar(bin->rhs, 1);
Type t = bin->lhs->type;
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");
- DECL_ON(const Type, t, = known_type(env, cast->td))
+ DECL_ON(const Type, t, = known_type(env, cast->td));
if(t->info->cdef && !tflag(t, tflag_check))
- CHECK_BN(ensure_traverse(env, t))
+ CHECK_BN(ensure_traverse(env, t));
const Type to = known_type(env, cast->td->types->td);
exp_setvar(cast->exp, 1);
if(isa(cast->exp->type, to) > 0)
static OP_CHECK(opck_implicit_similar) {
const struct Implicit *imp = (struct Implicit*)data;
- CHECK_BN(ref_access(env, imp->e))
+ CHECK_BN(ref_access(env, imp->e));
exp_setvar(imp->e, 1);
return imp->t;
}
if(template_match(info->list, info->td->types) < 0) // invalid template
ERR_N(info->td->pos, _("invalid template types number"));
if(!info->name) {
- DECL_ON(const Symbol, name, = info->name = template_id(env, info))
+ DECL_ON(const Symbol, name, = info->name = template_id(env, info));
return _tmpl_exists(env, name);
}
return _tmpl_exists(env, info->name);
static OP_CHECK(opck_none) {
Exp_Binary *bin = (Exp_Binary*)data;
- CHECK_NN(opck_rassign(env, data))
+ CHECK_NN(opck_rassign(env, data));
exp_setvar(bin->rhs, 1);
return bin->rhs->type;
}
free_exp(env->gwion->mp, exp_func);
free_exp(env->gwion->mp, exp_args);
e->d.exp_binary.op = insert_symbol(env->gwion->st, "==");
- CHECK_ON(check_exp(env, e))
+ CHECK_ON(check_exp(env, e));
return e->type;
}
}
name->d.prim.prim_type = ae_prim_num;
name->d.prim.d.num = i;
name->type = env->gwion->type[et_int];
- DECL_ON(const Type, t, = check_exp(env, val))
+ 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);
const Exp e = exp_self(exp);
struct Op_Import opi = { .op=insert_symbol("@func_check"),
.rhs=t, .pos=e->pos, .data=(uintptr_t)e };
- CHECK_NB(op_check(env, &opi)) // doesn't really return NULL
+ CHECK_NB(op_check(env, &opi)); // doesn't really return NULL
if(e->exp_type != ae_exp_call)
return 0;
return e->type != env->gwion->type[et_error] ?