From: fennecdjay Date: Mon, 15 Aug 2022 00:23:19 +0000 (+0200) Subject: :art: rename Types X-Git-Tag: nightly~264^2~39 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=7faf5196ac428272245b80974a1d97aa1b9cdc15;p=gwion.git :art: rename Types --- diff --git a/ast b/ast index 0572c7f6..c405f31e 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 0572c7f619a0b3377efa07a77a3f3b369b2c6e39 +Subproject commit c405f31eb2ffaf5a26b4ae92165d14784b2f2287 diff --git a/src/emit/emit.c b/src/emit/emit.c index b981760a..762d837b 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2363,7 +2363,7 @@ ANN static m_bool emit_enum_def(const Emitter emit NUSED, const Enum_Def edef) { const Value v = (Value)vector_at(&edef->values, i); *(m_uint *)(v->from->owner->class_data + v->from->offset) = i; } - set_tflag(edef->t, tflag_emit); + set_tflag(edef->type, tflag_emit); return GW_OK; } diff --git a/src/import/import_enum.c b/src/import/import_enum.c index aac406b2..f2f87d5b 100644 --- a/src/import/import_enum.c +++ b/src/import/import_enum.c @@ -85,7 +85,7 @@ ANN Type gwi_enum_end(const Gwi gwi) { lint_indent(gwi->lint); lint_enum_def(gwi->lint, edef); } - const Type t = ret > 0 ? edef->t : NULL; + const Type t = ret > 0 ? edef->type : NULL; if (edef->values.ptr) vector_release(&edef->values); free_enum_def(gwion->mp, edef); vector_release(&gwi->ck->v); diff --git a/src/lib/engine.c b/src/lib/engine.c index 98d633a7..e0cf45a3 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -125,10 +125,10 @@ ANN static m_bool import_core_libs(const Gwi gwi) { GWI_BB(gwi_oper_add(gwi, opck_new)) GWI_BB(gwi_oper_emi(gwi, opem_new)) GWI_BB(gwi_oper_end(gwi, "new", NULL)) + GWI_BB(import_ref(gwi)) GWI_BB(import_string(gwi)) GWI_BB(import_shred(gwi)) GWI_BB(import_modules(gwi)) - GWI_BB(import_ref(gwi)) gwidoc(gwi, "allow member access."); GWI_BB(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL)) diff --git a/src/lib/string.c b/src/lib/string.c index fc9a69da..130b01b3 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -398,15 +398,26 @@ static MFUN(string_atof) { const m_str str = STRING(obj); *(m_float*)RETURN = (m_float)atof(str); } -/* + #include static MFUN(string_atoi2) { const M_Object obj = *(M_Object*)MEM(0); const m_str str = STRING(obj); - char *endptr; - *(m_int*)RETURN = strtol(str, &endptr, 10); +puts(str); + char *endptr = NULL; + if(!(*(m_int*)RETURN = strtol(str, &endptr, 10))) { +printf("lkjlk j %i\n", errno); + if(errno == EINVAL) { + handle(shred, "ErrorInvalidValue"); + return; + } + if(errno == ERANGE) { + handle(shred, "ValueOutOfRange"); + return; + } + } +printf("ret: %li\n", *(m_int*)RETURN); **(m_uint**)MEM(SZ_INT) = endptr - str; } -*/ ANN Type check_array_access(const Env env, const Array_Sub array); @@ -553,6 +564,10 @@ GWION_IMPORT(string) { gwi_func_ini(gwi, "int", "atoi"); GWI_BB(gwi_func_end(gwi, string_atoi, ae_flag_none)) + gwi_func_ini(gwi, "int", "atoi2"); + gwi_func_arg(gwi, "&int", "offset"); + GWI_BB(gwi_func_end(gwi, string_atoi2, ae_flag_none)) + gwi_func_ini(gwi, "float", "atof"); GWI_BB(gwi_func_end(gwi, string_atof, ae_flag_none)) diff --git a/src/parse/check.c b/src/parse/check.c index 7dc6ce27..857e7e21 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1248,14 +1248,14 @@ ANN Type check_exp(const Env env, const Exp exp) { } ANN m_bool check_enum_def(const Env env, const Enum_Def edef) { - const m_uint scope = env_push_type(env, edef->t); + const m_uint scope = env_push_type(env, edef->type); ID_List list = edef->list; for(uint32_t i = 0; i < list->len; i++) { Symbol xid = *mp_vector_at(list, Symbol, i); decl_static(env, nspc_lookup_value0(env->curr, xid)); } env_pop(env, scope); - nspc_allocdata(env->gwion->mp, edef->t->nspc); + nspc_allocdata(env->gwion->mp, edef->type->nspc); return GW_OK; } @@ -1839,21 +1839,22 @@ ANN m_bool check_func_def(const Env env, const Func_Def fdef) { ANN bool check_trait_requests(const Env env, const Type t, const ID_List list, const ValueFrom *from); ANN static m_bool check_extend_def(const Env env, const Extend_Def xdef) { + const Type t = xdef->type; ValueFrom from = { .filename = env->name, .loc=xdef->td->pos, .ctx=env->context, .owner = env->curr, .owner_class = env->class_def }; - const bool ret = check_trait_requests(env, xdef->t, xdef->traits, &from); + const bool ret = check_trait_requests(env, t, xdef->traits, &from); if(ret) { - if(!xdef->t->info->traits) { - xdef->t->info->traits = new_mp_vector(env->gwion->mp, Symbol, xdef->traits->len); + if(!t->info->traits) { + t->info->traits = new_mp_vector(env->gwion->mp, Symbol, xdef->traits->len); for(uint32_t i = 0; i < xdef->traits->len; i++) { - const Symbol sym = *mp_vector_at(xdef->t->info->traits, Symbol, i); - mp_vector_set(xdef->t->info->traits, Symbol, i, sym); + const Symbol sym = *mp_vector_at(t->info->traits, Symbol, i); + mp_vector_set(t->info->traits, Symbol, i, sym); } } else { for(uint32_t i = 0; i < xdef->traits->len; i++) { - const Symbol sym = *mp_vector_at(xdef->t->info->traits, Symbol, i); - mp_vector_add(env->gwion->mp, &xdef->t->info->traits, Symbol, sym); + const Symbol sym = *mp_vector_at(t->info->traits, Symbol, i); + mp_vector_add(env->gwion->mp, &t->info->traits, Symbol, sym); } } return GW_OK; diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 88eb7ee2..23c44409 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -247,7 +247,7 @@ ANN m_bool scan0_enum_def(const Env env, const Enum_Def edef) { CHECK_BB(env_storage(env, edef->flag, edef->pos)); CHECK_BB(scan0_defined(env, edef->xid, edef->pos)); CHECK_BB(scan0_global(env, edef->flag, edef->pos)); - edef->t = enum_type(env, edef); + edef->type = enum_type(env, edef); vector_init(&edef->values); if (GET_FLAG(edef, global)) context_global(env); return GW_OK; @@ -460,7 +460,7 @@ ANN static m_bool scan0_extend_def(const Env env, const Extend_Def xdef) { } } } - xdef->t = t; + xdef->type = t; return GW_OK; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index caa6b272..8196dc96 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -364,18 +364,19 @@ ANN static inline m_bool scan1_stmt_exp(const Env env, const Stmt_Exp stmt) { } ANN m_bool scan1_enum_def(const Env env, const Enum_Def edef) { - edef->t->nspc = new_nspc(env->gwion->mp, edef->t->name); - const m_uint scope = env_push_type(env, edef->t); + const Type t = edef->type; + t->nspc = new_nspc(env->gwion->mp, t->name); + const m_uint scope = env_push_type(env, t); ID_List list = edef->list; for(uint32_t i = 0; i < list->len; i++) { Symbol xid = *mp_vector_at(list, Symbol, i); - const Value v = new_value(env, edef->t, s_name(xid), edef->pos); + const Value v = new_value(env, t, s_name(xid), edef->pos); valuefrom(env, v->from); nspc_add_value(env->curr, xid, v); if (env->class_def) { SET_FLAG(v, static); SET_ACCESS(edef, v) - SET_ACCESS(edef, edef->t) + SET_ACCESS(edef, t) } else set_vflag(v, vflag_builtin); SET_FLAG(v, const);