From 834292f156331baa178a4bef298f1901a315e9a0 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 14 Nov 2019 12:00:37 +0100 Subject: [PATCH] :art: Massive primary renaming --- ast | 2 +- src/emit/emit.c | 30 +++++++++++++++--------------- src/lib/string.c | 2 +- src/lib/tuple.c | 8 ++++---- src/parse/check.c | 26 +++++++++++++------------- src/parse/scan1.c | 10 +++++----- src/parse/scan2.c | 10 +++++----- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/ast b/ast index 71015548..353d33a3 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 710155485a0128816f915ad328572e0b88b85278 +Subproject commit 353d33a37749f7509d43f477283a84cf350f462d diff --git a/src/emit/emit.c b/src/emit/emit.c index 184b292c..3671f589 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -299,7 +299,7 @@ static const f_instr allocmember[] = { RegPushImm, RegPushImm2, RegPushImm3, Al 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; @@ -314,7 +314,7 @@ ANN static inline Exp dot_this_exp(const Emitter emit, const Symbol *data, const 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); @@ -456,9 +456,9 @@ ANN void emit_except(const Emitter emit, const Type t) { 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); @@ -507,9 +507,9 @@ ANN static m_bool emit_exp_array(const Emitter emit, const Exp_Array* array) { } 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) { @@ -599,8 +599,8 @@ ANN static m_bool emit_prim_unpack(const Emitter emit NUSED, const Tuple *tuple) #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) { @@ -784,8 +784,8 @@ ANN static m_uint pop_exp_size(const Emitter emit, Exp e) { 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 ? @@ -1476,7 +1476,7 @@ ANN static m_bool emit_case_body(const Emitter emit, const struct Stmt_Match_* s } 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); @@ -1490,12 +1490,12 @@ ANN static m_bool case_value(const Emitter emit, const Exp base, const Exp e) { #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; } diff --git a/src/lib/string.c b/src/lib/string.c index 61aa3c30..829a73c1 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -172,7 +172,7 @@ static CTOR(string_ctor) { 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); diff --git a/src/lib/tuple.c b/src/lib/tuple.c index 832474ec..a4b85e8b 100644 --- a/src/lib/tuple.c +++ b/src/lib/tuple.c @@ -131,8 +131,8 @@ static OP_CHECK(opck_at_object_tuple) { 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) { @@ -214,10 +214,10 @@ static OP_CHECK(opck_impl_tuple) { 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); diff --git a/src/parse/check.c b/src/parse/check.c index 1e63334b..ca18dd83 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -292,11 +292,11 @@ struct VecInfo { }; 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"; @@ -308,7 +308,7 @@ ANN static void vec_info(const Env env, const ae_prim_t t, struct VecInfo* v) { } 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) @@ -337,7 +337,7 @@ ANN static Type check_prim_tuple(const Env env, const Tuple *tuple) { } #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]) @@ -350,8 +350,8 @@ describe_prim_xxx(unpack, env->gwion->type[et_tuple]) #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); @@ -359,9 +359,9 @@ ANN static Type tuple_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); @@ -1159,13 +1159,13 @@ ANN static Value match_value(const Env env, const Exp_Primary* prim, const m_uin 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; } } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 5dde97f6..5a04f013 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -122,14 +122,14 @@ ANN static inline m_bool scan1_exp_binary(const Env env, const Exp_Binary* bin) 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; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index c90145f0..247d47f1 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -101,16 +101,16 @@ ANN static inline Value prim_value(const Env env, const Symbol s) { 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; } -- 2.43.0