return GW_OK;
}
+ANN Symbol case_basic_op(const Env env, const Type base, const Exp e);
#define CASE_PASS (Symbol)1
ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e,
const Vector vec, const uint n) {
}
}
}
- if (!n) return insert_symbol("?=");
+ if (!n) return case_basic_op(emit->env, base->type, e);
regpush(emit, SZ_INT);
CHECK_BO(emit_exp(emit, e));
const Exp_Binary bin = {.lhs = base, .rhs = e, .op = insert_symbol("?=")};
-#include <string.h>
#include "gwion_util.h"
#include "gwion_ast.h"
#include "gwion_env.h"
// get members of a type, starting from parents
static void compound_get_member(const Env env, const Type t, const Vector v) {
- if(t->info->parent && t->info->parent->nspc)
+ const Type parent = t->info->parent && t->info->parent->nspc
+ ? t->info->parent : NULL;
+ if(parent)
compound_get_member(env, t->info->parent, v);
type_get_member(env->gwion, t, v);
}
const Vector l, const Vector r) {
const m_uint lsz = vector_size(l),
rsz = vector_size(r);
-// if(lsz && rsz >= lsz) {
if(rsz >= lsz) {
for(m_uint i = 0; i < lsz; i++) {
const Value lval = (Value)vector_at(l, i),
static OP_CHECK(opck_deep_equal) {
Exp_Binary *const bin = data;
+ const Symbol base_op = !strcmp(s_name(bin->op), "?=")
+ ? insert_symbol(env->gwion->st, "==") : insert_symbol(env->gwion->st, "!=");
+ struct Op_Import opi = {.op = base_op,
+ .lhs = bin->lhs->type,
+ .rhs = bin->rhs->type,
+ .data = (uintptr_t)bin,
+ .pos = exp_self(bin)->pos};
+ if(op_get(env, &opi)) {
+ bin->op = base_op;
+ return op_check(env, &opi);
+ }
struct Vector_ l, r;
check_deep_equal_exp(env, bin->lhs, &l);
check_deep_equal_exp(env, bin->rhs, &r);
vector_release(&r);
if(ret) return env->gwion->type[et_bool];
const Symbol op = bin->op;
- bin->op = !strcmp(s_name(bin->op), "?=")
- ? insert_symbol(env->gwion->st, "==") : insert_symbol(env->gwion->st, "!=");
+ bin->op = base_op;
env_set_error(env, true);
const Type ret_type = check_exp(env, exp_self(bin));
env_set_error(env, false);
return v;
}
+ANN Symbol case_basic_op(const Env env, const Type base, const Exp e) {
+ const Symbol _op = insert_symbol("==");
+ struct Op_Import opi = {.op = _op,
+ .lhs = base,
+ .rhs = e->type,
+ .data = (uintptr_t)NULL,
+ .pos = e->pos};
+ return op_get(env, &opi)
+ ? insert_symbol("==")
+ : insert_symbol("?=");
+}
+
ANN static Symbol case_op(const Env env, const Type base, const Exp e) {
if (e->exp_type == ae_exp_primary) {
if (e->d.prim.prim_type == ae_prim_id) {
}
}
}
- return insert_symbol("?=");
+ return case_basic_op(env, base, e);
}
ANN static m_bool match_case_exp(const Env env, Exp e) {
CHECK_OB(t);
Exp_Binary bin = {.lhs = cpy_exp(env->gwion->mp, base), .rhs = cpy_exp(env->gwion->mp, e), .op = op};
struct Exp_ ebin = {.d = {.exp_binary = bin}, .exp_type = ae_exp_binary, .pos = e->pos };
- struct Op_Import opi = {.op = op,
- .lhs = base->type,
- .rhs = e->type,
- .data = (uintptr_t)&ebin.d.exp_binary,
- .pos = e->pos};
- traverse_exp(env, &ebin);
- const Type ret = op_check(env, &opi);
+ CHECK_BB(traverse_exp(env, &ebin));
+ const Type ret = ebin.type;
if(ebin.exp_type == ae_exp_binary) {
free_exp(env->gwion->mp, bin.lhs);
free_exp(env->gwion->mp, bin.rhs);