#define OP_ANY_TYPE (Type)1
#define ERR_N(a, b, ...) { env_err(env, (a), (b), ## __VA_ARGS__); return env->gwion->type[et_null]; }
+#define DECL_ON(decl, f, exp) decl f exp; { if(!f) return env->gwion->type[et_null]; }
+#define DECL_BN(decl, f, exp) decl f exp; { if(f < 0) return env->gwion->type[et_null]; }
+#define DECL_NN(decl, f, exp) decl f exp; { if(f == env->gwion->type[et_null) return env->gwion->type[et_null]; }
+#define CHECK_ON(f) { if(!f) return env->gwion->type[et_null]; }
+#define CHECK_BN(f) { if(f < 0) return env->gwion->type[et_null]; }
+#define CHECK_NN(f) { if(f == env->gwion->type[et_null] return env->gwion->type[et_null]; }
typedef Type (*opck)(const Env, void*, m_bool*);
typedef struct Instr_* (*opem)(const Emitter, void*);
OP_CHECK(opck_new) {
const Exp_Unary* unary = (Exp_Unary*)data;
SET_FLAG(unary->td, ref);
- DECL_OO(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 && isa(t, env->gwion->type[et_function]) < 0)
- ERR_O(exp_self(unary)->pos, _("primitive types cannot be used as reference (@)...\n"))
+ ERR_N(exp_self(unary)->pos, _("primitive types cannot be used as reference (@)...\n"))
if(type_ref(t))
ERR_N(td_pos(unary->td), _("can't use 'new' on ref type '%s'\n"), t->name)
UNSET_FLAG(unary->td, ref);
if(unary->td->array)
- CHECK_BO(check_subscripts(env, unary->td->array))
+ CHECK_BN(check_subscripts(env, unary->td->array))
return t;
}