-Subproject commit 710155485a0128816f915ad328572e0b88b85278
+Subproject commit 353d33a37749f7509d43f477283a84cf350f462d
static const f_instr allocword[] = { AllocWord, AllocWord2, AllocWord3, RegPushMem4 };
ANN static inline Exp this_exp(const Emitter emit, const Type t, const loc_t pos) {
- const Exp exp = new_exp_prim_id(emit->gwion->mp, insert_symbol("this"),
+ const Exp exp = new_prim_id(emit->gwion->mp, insert_symbol("this"),
loc_cpy(emit->gwion->mp, pos));
exp->type = t;
return exp;
ANN static inline Exp dot_static_exp(const Emitter emit, const Symbol *data, const Type t) {
const Symbol s = insert_symbol(t->name);
- const Exp e = new_exp_prim_id(emit->gwion->mp, s,
+ const Exp e = new_prim_id(emit->gwion->mp, s,
loc_cpy(emit->gwion->mp, prim_pos(data)));
const Value val = nspc_lookup_value1(t->nspc->parent, s);
const Exp dot = new_exp_dot(emit->gwion->mp, e, *data);
ANN static inline m_bool tuple_index(const Emitter emit, struct ArrayAccessInfo *const info) {
assert(isa(info->array.type, emit->gwion->type[et_tuple]) > 0);
- const m_uint idx = info->array.exp->d.exp_primary.d.num;
+ const m_uint idx = info->array.exp->d.prim.d.num;
emit_except(emit, info->array.type);
- tuple_access(emit, info->array.exp->d.exp_primary.d.num, (info->array.depth -1)? 0 : info->is_var);
+ tuple_access(emit, info->array.exp->d.prim.d.num, (info->array.depth -1)? 0 : info->is_var);
if(!info->array.exp->next)
return GW_OK;
const Type type = (Type)vector_at(&info->array.type->e->tuple->types, idx);
}
ANN static m_bool emit_prim_vec(const Emitter emit, const Vec *vec) {
- const ae_prim_t t = prim_self(vec)->primary_type;
+ const ae_prim_t t = prim_self(vec)->prim_type;
CHECK_BB(emit_exp(emit, vec->exp, 0));
- m_int n = (m_int)((t == ae_primary_vec ? 3 : 2) - vec->dim + 1);
+ m_int n = (m_int)((t == ae_prim_vec ? 3 : 2) - vec->dim + 1);
while(--n > 0)
emit_add_instr(emit, RegPushImm2);
if(prim_exp(vec)->emit_var) {
#define emit_prim_nil (void*)dummy_func
DECL_PRIM_FUNC(emit, m_bool , Emitter);
-ANN static m_bool emit_exp_primary(const Emitter emit, Exp_Primary *const prim) {
- return prim_func[prim->primary_type](emit, &prim->d);
+ANN static m_bool emit_prim(const Emitter emit, Exp_Primary *const prim) {
+ return prim_func[prim->prim_type](emit, &prim->d);
}
ANN static m_bool emit_dot_static_data(const Emitter emit, const Value v, const uint emit_var) {
m_uint size = 0;
do {
if(e->exp_type == ae_exp_primary &&
- e->d.exp_primary.primary_type == ae_primary_hack) {
- size += pop_exp_size(emit, e->d.exp_primary.d.exp);
+ e->d.prim.prim_type == ae_prim_hack) {
+ size += pop_exp_size(emit, e->d.prim.d.exp);
continue;
}
size += (e->exp_type == ae_exp_decl ?
}
ANN static m_bool case_value(const Emitter emit, const Exp base, const Exp e) {
- const Value v = e->d.exp_primary.value;
+ const Value v = e->d.prim.value;
v->from->offset = emit_local(emit, base->type->size, isa(base->type, emit->gwion->type[et_object]) > 0);
CHECK_BB(emit_exp(emit, base, 1))
regpop(emit, base->type->size);
#define CASE_PASS (Symbol)1
ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e) {
if(e->exp_type == ae_exp_primary) {
- if(e->d.exp_primary.primary_type == ae_primary_unpack)
+ if(e->d.prim.prim_type == ae_prim_unpack)
return insert_symbol("@=>");
- if(e->d.exp_primary.primary_type == ae_primary_id) {
- if(e->d.exp_primary.d.var == insert_symbol("_"))
+ if(e->d.prim.prim_type == ae_prim_id) {
+ if(e->d.prim.d.var == insert_symbol("_"))
return CASE_PASS;
- if(!nspc_lookup_value1(emit->env->curr, e->d.exp_primary.d.var)) {
+ if(!nspc_lookup_value1(emit->env->curr, e->d.prim.d.var)) {
CHECK_BO(case_value(emit, base, e))
return CASE_PASS;
}
ANN Type check_prim_str(const Env, const m_str *);
ID_CHECK(check_funcpp) {
- ((Exp_Primary*)prim)->primary_type = ae_primary_str;
+ ((Exp_Primary*)prim)->prim_type = ae_prim_str;
((Exp_Primary*)prim)->d.str = env->func ? env->func->name : env->class_def ?
env->class_def->name : env->name;
return check_prim_str(env, &prim->d.str);
static OP_CHECK(opck_at_tuple) {
const Exp_Binary *bin = (Exp_Binary*)data;
if(bin->rhs->exp_type == ae_exp_primary &&
- bin->rhs->d.exp_primary.primary_type == ae_primary_unpack) {
- Exp e = bin->rhs->d.exp_primary.d.tuple.exp;
+ bin->rhs->d.prim.prim_type == ae_prim_unpack) {
+ Exp e = bin->rhs->d.prim.d.tuple.exp;
int i = 0;
do {
if(e->exp_type == ae_exp_decl) {
static OP_EMIT(opem_at_tuple) {
const Exp_Binary *bin = (Exp_Binary*)data;
if(!(bin->rhs->exp_type == ae_exp_primary &&
- bin->rhs->d.exp_primary.primary_type == ae_primary_unpack)) {
+ bin->rhs->d.prim.prim_type == ae_prim_unpack)) {
return emit_add_instr(emit, ObjectAssign);
}
- const Exp e = bin->rhs->d.exp_primary.d.tuple.exp;
+ const Exp e = bin->rhs->d.prim.d.tuple.exp;
const Vector v = &bin->lhs->type->e->tuple->types;
struct TupleEmit te = { .e=e, .v=v };
emit_unpack_instr(emit, &te);
};
ANN static void vec_info(const Env env, const ae_prim_t t, struct VecInfo* v) {
- if(t == ae_primary_complex) {
+ if(t == ae_prim_complex) {
v->s = "complex";
v->t = env->gwion->type[et_complex];
v->n = 2;
- } else if(t == ae_primary_vec) {
+ } else if(t == ae_prim_vec) {
v->t = env->gwion->type[v->n == 4 ? et_vec4 : et_vec3];
v->n = 4;
v->s = "vector";
}
ANN static Type check_prim_vec(const Env env, const Vec *vec) {
- const ae_prim_t t = prim_self(vec)->primary_type;
+ const ae_prim_t t = prim_self(vec)->prim_type;
struct VecInfo info = { .n=vec->dim };
vec_info(env, t, &info);
if(vec->dim > info.n)
}
#define describe_prim_xxx(name, type) \
-ANN static Type check##_prim_##name(const Env env NUSED, const union exp_primary_data* data NUSED) {\
+ANN static Type check##_prim_##name(const Env env NUSED, const union prim_data* data NUSED) {\
return type; \
}
describe_prim_xxx(num, env->gwion->type[et_int])
#define check_prim_char check_prim_num
DECL_PRIM_FUNC(check, Type, Env);
-ANN static Type check_exp_primary(const Env env, Exp_Primary *primary) {
- return exp_self(primary)->type = prim_func[primary->primary_type](env, &primary->d);
+ANN static Type check_prim(const Env env, Exp_Primary *prim) {
+ return exp_self(prim)->type = prim_func[prim->prim_type](env, &prim->d);
}
ANN static Type at_depth(const Env env, const Array_Sub array);
const Vector v = &array->type->e->tuple->types;
const Exp exp = array->exp;
if(exp->exp_type != ae_exp_primary ||
- exp->d.exp_primary.primary_type != ae_primary_num)
+ exp->d.prim.prim_type != ae_prim_num)
ERR_O(exp->pos, _("tuple subscripts must be litteral"))
- const m_uint idx = exp->d.exp_primary.d.num;
+ const m_uint idx = exp->d.prim.d.num;
if(idx >= vector_size(v))
ERR_O(exp->pos, _("tuple subscripts too big"))
const Type type = (Type)vector_at(v, idx);
ANN static Symbol case_op(const Env env, const Exp e, const m_uint i) {
if(e->exp_type == ae_exp_primary) {
- if(e->d.exp_primary.primary_type == ae_primary_unpack)
+ if(e->d.prim.prim_type == ae_prim_unpack)
return insert_symbol("@=>");
- else if(e->d.exp_primary.primary_type == ae_primary_id) {
- if(e->d.exp_primary.d.var == insert_symbol("_"))
+ else if(e->d.prim.prim_type == ae_prim_id) {
+ if(e->d.prim.d.var == insert_symbol("_"))
return NULL;
- if(!nspc_lookup_value1(env->curr, e->d.exp_primary.d.var)) {
- e->d.exp_primary.value = match_value(env, &e->d.exp_primary, i);
+ if(!nspc_lookup_value1(env->curr, e->d.prim.d.var)) {
+ e->d.prim.value = match_value(env, &e->d.prim, i);
return NULL;
}
}
return scan1_exp(env, bin->rhs);
}
-ANN static inline m_bool scan1_exp_primary(const Env env, const Exp_Primary* prim) {
- if(prim->primary_type == ae_primary_hack)
+ANN static inline m_bool scan1_prim(const Env env, const Exp_Primary* prim) {
+ if(prim->prim_type == ae_prim_hack)
return scan1_exp(env, prim->d.exp);
- if(prim->primary_type == ae_primary_array && prim->d.array->exp)
+ if(prim->prim_type == ae_prim_array && prim->d.array->exp)
return scan1_exp(env, prim->d.array->exp);
- if(prim->primary_type == ae_primary_tuple)
+ if(prim->prim_type == ae_prim_tuple)
return scan1_exp(env, prim->d.tuple.exp);
-// if(prim->primary_type == ae_primary_unpack)
+// if(prim->prim_type == ae_prim_unpack)
// return scan1_exp(env, prim->d.tuple.exp);
return GW_OK;
}
return value;
}
-ANN static inline m_bool scan2_exp_primary(const Env env, const Exp_Primary* prim) {
- if(prim->primary_type == ae_primary_hack)
+ANN static inline m_bool scan2_prim(const Env env, const Exp_Primary* prim) {
+ if(prim->prim_type == ae_prim_hack)
CHECK_BB(scan2_exp(env, prim->d.exp))
- else if(prim->primary_type == ae_primary_id) {
+ else if(prim->prim_type == ae_prim_id) {
const Value v = prim_value(env, prim->d.var);
if(v)
SET_FLAG(v, used);
- } else if(prim->primary_type == ae_primary_array && prim->d.array->exp)
+ } else if(prim->prim_type == ae_prim_array && prim->d.array->exp)
return scan2_exp(env, prim->d.array->exp);
- if(prim->primary_type == ae_primary_tuple)
+ if(prim->prim_type == ae_prim_tuple)
return scan2_exp(env, prim->d.tuple.exp);
return GW_OK;
}