m_bool nonnull = GET_FLAG(info->exp->info->type, nonnull);
CHECK_BB(fptr_check(env, info))
DECL_OB(const Type, t, = fptr_type(env, info))
- info->exp->info->type = !nonnull ? t : type_nonnull(env, t);
+ info->exp->info->type = !nonnull ? t : nonnul_type(env, t);
return GW_OK;
}
Exp_Lambda *l = &info->exp->d.exp_lambda;
static ID_CHECK(idck_vararg) {
if(env->func && GET_FLAG(env->func->def, variadic))
- return type_nonnull(env, exp_self(prim)->info->type);
+ return nonnul_type(env, exp_self(prim)->info->type);
ERR_O(exp_self(prim)->pos, _("'vararg' must be used inside variadic function"))
}
--- /dev/null
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "gwion_env.h"
+#include "vm.h"
+#include "instr.h"
+#include "object.h"
+#include "gwion.h"
+#include "operator.h"
+
+ANN void func_operator(const Func_Def fdef, struct Op_Import *opi) {
+ opi->op =fdef->base->xid;
+ const m_str str = s_name(fdef->base->xid);
+ const uint is_unary = GET_FLAG(fdef, unary) +
+ (!strcmp(str, "@conditionnal") || !strcmp(str, "@unconditionnal"));
+ const Arg_List args = fdef->base->args;
+ opi->lhs = is_unary ? NULL :
+ args ? args->var_decl->value->type : NULL;
+ opi->rhs = args ? is_unary ? args->var_decl->value->type :
+ args->next ? args->next->var_decl->value->type :
+ fdef->base->ret_type : NULL;
+}
#define STR_NONNULL ":nonnull"
#define STRLEN_NONNULL strlen(STR_NONNULL)
-ANN Type type_nonnull(const Env env, const Type base) {
+ANN Type nonnul_type(const Env env, const Type base) {
char c[strlen(base->name) + 9];
sprintf(c, "%s%s", base->name, STR_NONNULL);
const Symbol sym = insert_symbol(c);
ERR_O(td_pos(td), _("void types can't be nonnull."))
if(isa(ret, env->gwion->type[et_object]) < 0 && isa(ret, env->gwion->type[et_fptr]) < 0)
return ret;
- return type_nonnull(env, ret);
+ return nonnul_type(env, ret);
}
return ret;
}