From: fennecdjay Date: Thu, 15 Jun 2023 12:08:09 +0000 (+0200) Subject: :art: use gwint X-Git-Tag: nightly~147 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=72fed49e3ab678b0fe01b37dd31e7be5f213b435;p=gwion.git :art: use gwint --- diff --git a/ast b/ast index f80e75e3..fc8943f0 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit f80e75e38b2616b68e2cc764d598a8e74123a1d7 +Subproject commit fc8943f0e05aecd74cc36c4912cb399f5b68bf40 diff --git a/fmt b/fmt index c980939e..c4da9693 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit c980939e8fe7bb574b2a555dde1bbffc216d012f +Subproject commit c4da96931dd1b011c37eec8c0acba23f087cef9b diff --git a/include/env/value.h b/include/env/value.h index 67d24b39..9e285a39 100644 --- a/include/env/value.h +++ b/include/env/value.h @@ -23,7 +23,7 @@ enum vflag { } __attribute__((packed)); union value_data { - m_int num; + m_int num; m_float fnum; m_uint * ptr; struct M_Object_ *obj; diff --git a/include/parse.h b/include/parse.h index b0b75621..9cfed325 100644 --- a/include/parse.h +++ b/include/parse.h @@ -113,7 +113,7 @@ ANN static inline bool is_hole(const Env env, const Exp exp) { static inline bool exp_is_zero(const Exp exp) { return exp->exp_type == ae_exp_primary && exp->d.prim.prim_type == ae_prim_num && - !exp->d.prim.d.num; + !exp->d.prim.d.gwint.num; } ANN static inline bool not_upvalue(const Env env, const Value v) { diff --git a/plug b/plug index 21f9f3d2..799c5a69 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 21f9f3d2a5e0eb5627abf2eaede8f54f3beaab72 +Subproject commit 799c5a69162c0bb51454d3b1281c6f7d9e71f291 diff --git a/src/emit/emit.c b/src/emit/emit.c index 9eb533a3..4da51eff 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1981,7 +1981,7 @@ ANN2(1) /*static */ m_bool emit_exp(const Emitter emit, /* const */ Exp e) { } ANN static m_bool emit_if_const(const Emitter emit, const Stmt_If stmt) { - if (stmt->cond->d.prim.d.num) return emit_stmt(emit, stmt->if_body); + if (stmt->cond->d.prim.d.gwint.num) return emit_stmt(emit, stmt->if_body); return stmt->else_body ? emit_stmt(emit, stmt->else_body) : GW_OK; } @@ -2122,8 +2122,8 @@ ANN static m_bool _emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt, (void)emit_add_instr(emit, run_always); } op = _flow(emit, stmt->cond, NULL, is_while); - } else if ((!is_while && stmt->cond->d.prim.d.num) || - (is_while && !stmt->cond->d.prim.d.num)) + } else if ((!is_while && stmt->cond->d.prim.d.gwint.num) || + (is_while && !stmt->cond->d.prim.d.gwint.num)) return GW_OK; } CHECK_BB(scoped_stmt(emit, stmt->body)); @@ -2131,8 +2131,8 @@ ANN static m_bool _emit_stmt_flow(const Emitter emit, const Stmt_Flow stmt, if (!is_const) { CHECK_OB((op = _flow(emit, stmt->cond, NULL, !is_while))); op->m_val = index; - } else if ((is_while && stmt->cond->d.prim.d.num) || - (!is_while && !stmt->cond->d.prim.d.num)) { + } else if ((is_while && stmt->cond->d.prim.d.gwint.num) || + (!is_while && !stmt->cond->d.prim.d.gwint.num)) { const Instr goto_ = emit_add_instr(emit, Goto); goto_->m_val = index; } diff --git a/src/import/import_enum.c b/src/import/import_enum.c index f7e05469..7d6adf9a 100644 --- a/src/import/import_enum.c +++ b/src/import/import_enum.c @@ -32,7 +32,7 @@ ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type) { ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) { CHECK_BB(ck_ok(gwi, ck_edef)); DECL_OB(const Symbol, xid, = gwi_str2sym(gwi, name)); - const EnumValue ev = { .xid = xid, .num = i, .set = true}; + const EnumValue ev = { .xid = xid, .gwint = { .num = i }, .set = true}; mp_vector_add(gwi->gwion->mp, &gwi->ck->tmpl, EnumValue, ev); return GW_OK; } diff --git a/src/import/import_prim.c b/src/import/import_prim.c index 987f701d..7678ae01 100644 --- a/src/import/import_prim.c +++ b/src/import/import_prim.c @@ -83,7 +83,7 @@ static OP_EMIT(opem_bit_access) { instr->m_val = info->array.type->size; } else emit_add_instr(emit, bit_set); } else { - const m_uint offset = info->array.exp->d.prim.d.num; + const m_uint offset = info->array.exp->d.prim.d.gwint.num; if(!info->is_var) { const Instr instr = emit_add_instr(emit, bit_get_fast); instr->m_val = info->type->size; @@ -109,7 +109,7 @@ static OP_CHECK(opck_bit_access) { const Exp e = array->exp; if(e->next) ERR_N(e->next->pos, "too many expressions for bit access"); if(is_prim_int(e)) { - m_int idx = e->d.prim.d.num; + m_int idx = e->d.prim.d.gwint.num; if(idx < 0 || idx >= (m_int)array->type->size * CHAR_BIT) ERR_N(e->pos, "bit access out of bound"); } @@ -217,7 +217,7 @@ ANN Type mk_primitive(const Env env, const m_str name, const m_uint size) { ANN m_bool gwi_primitive(const Gwi gwi, const m_str name, const m_uint size, const ae_flag flag) { const Env env = gwi->gwion->env; const Prim_Def pdef = new_prim_def(gwi->gwion->mp, insert_symbol(gwi->gwion->st, name), size, gwi->loc, flag); - if(gwi->gwion->data->cdoc)gwfmt_prim_def(gwi->gwfmt, pdef); + if(gwi->gwion->data->cdoc) gwfmt_prim_def(gwi->gwfmt, pdef); if(!env->class_def || !tflag(env->class_def, tflag_tmpl)) { const m_bool ret = scan0_prim_def(gwi->gwion->env, pdef); free_prim_def(gwi->gwion->mp, pdef); diff --git a/src/lib/prim.c b/src/lib/prim.c index 08471962..1eb024b5 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -65,11 +65,11 @@ #define BINARY_INT_FOLD(name, TYPE, OP, pre) \ BINARY_FOLD(int, name, TYPE, OP, pre, is_prim_int, is_prim_int, m_int, \ - ae_prim_num, num, num, num) + ae_prim_num, gwint.num, gwint.num, gwint.num) #define BINARY_INT_FOLD_Z(name, TYPE, OP, pre) \ BINARY_FOLD_Z(int, name, TYPE, OP, pre, is_prim_int, is_prim_int, m_int, \ - ae_prim_num, num, num, num) + ae_prim_num, gwint.num, gwint.num, gwint.num) BINARY_INT_FOLD(add, et_int, +,) BINARY_INT_FOLD(sub, et_int, -,) @@ -103,7 +103,7 @@ static OP_EMIT(opem_##type##_##name) { \ return GW_OK; \ } -#define BINARY_INT_EMIT(name) BINARY_OP_EMIT(name, int, num, m_val) +#define BINARY_INT_EMIT(name) BINARY_OP_EMIT(name, int, gwint.num, m_val) BINARY_INT_EMIT(add) BINARY_INT_EMIT(sub) BINARY_INT_EMIT(mul) @@ -208,14 +208,14 @@ static OP_EMIT(opem_int_range) { const Type t = env->gwion->type[TYPE]; \ CHECK_NN(opck_unary_meta(env, data)); \ if (!func(unary->exp)) return t; \ - const ctype num = OP unary->exp->d.prim.d.member; \ - exp_self(unary)->exp_type = ae_exp_primary; \ - exp_self(unary)->d.prim.prim_type = exptype; \ - exp_self(unary)->d.prim.d.num = num; \ + const ctype num = OP unary->exp->d.prim.d.member; \ + exp_self(unary)->exp_type = ae_exp_primary; \ + exp_self(unary)->d.prim.prim_type = exptype; \ + exp_self(unary)->d.prim.d.gwint.num = num; \ return t; \ } #define UNARY_INT_FOLD(name, TYPE, OP) \ - UNARY_FOLD(int, name, TYPE, OP, is_prim_int, m_int, ae_prim_num, num) + UNARY_FOLD(int, name, TYPE, OP, is_prim_int, m_int, ae_prim_num, gwint.num) UNARY_INT_FOLD(negate, et_int, -) UNARY_INT_FOLD(cmp, et_int, ~) UNARY_INT_FOLD(not, et_bool, !) @@ -297,7 +297,7 @@ static OP_CHECK(opck_cast_f2i) { Exp e = exp_self(cast); e->exp_type = ae_exp_primary; e->d.prim.prim_type = ae_prim_num; - e->d.prim.d.num = f; + e->d.prim.d.gwint.num = f; } return env->gwion->type[et_int]; } @@ -311,7 +311,7 @@ ANN static void tofloat(Exp e, const m_int i) { static OP_CHECK(opck_cast_i2f) { Exp_Cast *cast = (Exp_Cast*)data; if(is_prim_int(cast->exp)) { - const m_int i = cast->exp->d.prim.d.num; + const m_int i = cast->exp->d.prim.d.gwint.num; free_type_decl(env->gwion->mp, cast->td); free_exp(env->gwion->mp, cast->exp); Exp e = exp_self(cast); @@ -333,13 +333,13 @@ static OP_CHECK(opck_implicit_i2f) { #define BINARY_INT_FLOAT_FOLD(name, TYPE, OP, pre) \ BINARY_FOLD(int_float, name, TYPE, OP, pre, is_prim_int, \ - is_prim_float, m_float, ae_prim_float, num, fnum, fnum) + is_prim_float, m_float, ae_prim_float, gwint.num, fnum, fnum) #define BINARY_INT_FLOAT_FOLD_Z(name, TYPE, OP, pre) \ BINARY_FOLD_Z(int_float, name, TYPE, OP, pre, is_prim_int, \ - is_prim_float, m_float, ae_prim_float, num, fnum, fnum) + is_prim_float, m_float, ae_prim_float, gwint.num, fnum, fnum) #define BINARY_INT_FLOAT_FOLD2(name, TYPE, OP, pre) \ BINARY_FOLD(int_float, name, TYPE, OP, pre, is_prim_int, \ - is_prim_float, m_float, ae_prim_num, num, fnum, num) + is_prim_float, m_float, ae_prim_num, gwint.num, fnum, gwint.num) BINARY_INT_FLOAT_FOLD(add, et_float, +,) BINARY_INT_FLOAT_FOLD(sub, et_float, -,) @@ -394,15 +394,15 @@ static GWION_IMPORT(intfloat) { #define BINARY_FLOAT_INT_FOLD(name, TYPE, OP, pre) \ BINARY_FOLD(float_int, name, TYPE, OP, pre, is_prim_float, \ - is_prim_int, m_float, ae_prim_float, fnum, num, fnum) + is_prim_int, m_float, ae_prim_float, fnum, gwint.num, fnum) #define BINARY_FLOAT_INT_FOLD_Z(name, TYPE, OP, pre) \ BINARY_FOLD_Z(float_int, name, TYPE, OP, pre, is_prim_float, \ - is_prim_int, m_float, ae_prim_float, fnum, num, fnum) + is_prim_int, m_float, ae_prim_float, fnum, gwint.num, fnum) #define BINARY_FLOAT_INT_FOLD2(name, TYPE, OP, pre) \ BINARY_FOLD(float_int, name, TYPE, OP, pre, is_prim_float, \ - is_prim_int, m_int, ae_prim_num, fnum, num, num) + is_prim_int, m_int, ae_prim_num, fnum, gwint.num, gwint.num) BINARY_FLOAT_INT_FOLD(add, et_float, +,) BINARY_FLOAT_INT_FOLD(sub, et_float, -,) @@ -535,7 +535,7 @@ static GWION_IMPORT(time) { #define BINARY_FLOAT_FOLD2(name, TYPE, OP, pre) \ BINARY_FOLD(float, name, TYPE, OP, pre, is_prim_float, is_prim_float, \ - m_int, ae_prim_num, fnum, fnum, num) + m_int, ae_prim_num, fnum, fnum, gwint.num) BINARY_FLOAT_FOLD(add, et_float, +,) BINARY_FLOAT_FOLD(sub, et_float, -,) diff --git a/src/lib/string.c b/src/lib/string.c index 86b0489e..a4b45207 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -42,7 +42,7 @@ describe_string_logical(eq, (!strcmp(STRING(lhs), STRING(rhs)))) const Exp e = exp_self(bin); \ e->exp_type = ae_exp_primary; \ e->d.prim.prim_type = ae_prim_num; \ - e->d.prim.d.num = ret; \ + e->d.prim.d.gwint.num = ret; \ return env->gwion->type[et_bool]; \ } @@ -74,7 +74,7 @@ ID_CHECK(check_funcpp) { ID_CHECK(check_linepp) { ((Exp_Primary *)prim)->prim_type = ae_prim_num; - ((Exp_Primary *)prim)->d.num = prim_pos(prim).first.line; + ((Exp_Primary *)prim)->d.gwint.num = prim_pos(prim).first.line; return env->gwion->type[et_int]; } diff --git a/src/lib/union.c b/src/lib/union.c index 992e4891..68605fc8 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -126,10 +126,10 @@ static OP_CHECK(opck_union_new) { for (m_uint i = 0; i < map_size(map); ++i) { if (VKEY(map, i) == (m_uint)name->d.prim.d.var) { - const Value v = (Value)VVAL(map, i); - name->d.prim.prim_type = ae_prim_num; - name->d.prim.d.num = i; - name->type = env->gwion->type[et_int]; + const Value v = (Value)VVAL(map, i); + name->d.prim.prim_type = ae_prim_num; + name->d.prim.d.gwint.num = i; + name->type = env->gwion->type[et_int]; if(!val && v->type == env->gwion->type[et_none]) { const Exp e = new_prim_int(env->gwion->mp, SZ_INT, name->pos); e->next = name; diff --git a/src/parse/check.c b/src/parse/check.c index ccd578dd..8274b15d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1868,7 +1868,7 @@ ANN static m_bool check_ctor(const Env env, const Func func) { if(!func->def->builtin && !GET_FLAG(func, const)) { const Type_Decl *td = env->class_def->info->cdef->base.ext; const m_uint depth = !td || !td->array - ? 1 : td->array->exp->d.prim.d.num; + ? 1 : td->array->exp->d.prim.d.gwint.num; if(depth) { // check if size is 0 const Type parent = env->class_def->info->parent; const Value v = nspc_lookup_value0(parent->nspc, insert_symbol("new")); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index befa0d8a..95eef097 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -397,11 +397,11 @@ ANN m_bool scan1_enum_def(const Env env, const Enum_Def edef) { t->nspc = new_nspc(env->gwion->mp, t->name); const m_uint scope = env_push_type(env, t); ID_List list = edef->list; - m_uint last = 0; + m_int last = 0; for(uint32_t i = 0; i < list->len; i++) { EnumValue ev = *mp_vector_at(list, EnumValue, i); const Value v = new_value(env, t, s_name(ev.xid), edef->pos); - v->d.num = (ev.set ? ev.num : last); + v->d.num = (ev.set ? ev.gwint.num : last); last = v->d.num + 1; valuefrom(env, v->from); nspc_add_value(env->curr, ev.xid, v);