From 710b3a871667dbddc56139aa9c769bd9c8a7ebbd Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 8 Jan 2021 11:24:14 +0100 Subject: [PATCH] :art: Finish removing typeof --- ast | 2 +- src/clean.c | 4 +--- src/emit/emit.c | 9 --------- src/parse/check.c | 7 ------- src/parse/scan1.c | 5 ++--- src/parse/scan2.c | 3 +-- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/ast b/ast index 59dea1d3..a7f4b203 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 59dea1d3bdabeb2ed1d69944e45bb0c83b12435b +Subproject commit a7f4b203839d44366733b76e74feac7dab7b2a06 diff --git a/src/clean.c b/src/clean.c index 94e09afc..b4591701 100644 --- a/src/clean.c +++ b/src/clean.c @@ -46,9 +46,7 @@ ANN static void clean_type_decl(Clean *a, Type_Decl *b) { } ANN static void clean_prim(Clean *a, Exp_Primary *b) { - if(b->prim_type == ae_prim_hack || - b->prim_type == ae_prim_typeof || - b->prim_type == ae_prim_interp) + if(b->prim_type == ae_prim_hack || b->prim_type == ae_prim_interp) clean_exp(a, b->d.exp); else if(b->prim_type == ae_prim_array) clean_array_sub(a, b->d.array); diff --git a/src/emit/emit.c b/src/emit/emit.c index 310655c1..46f6e18a 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -623,15 +623,6 @@ ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { #define emit_prim_nil (void*)dummy_func -ANN static m_bool emit_prim_typeof(const Emitter emit, const Exp *exp) { - const Exp e = *exp; - if(!e->type->array_depth) - regpushi(emit, (m_uint)(actual_type(emit->gwion, e->type))); - else - regpushi(emit, (m_uint)e->type); - return GW_OK; -} - ANN static void interp_multi(const Emitter emit, const Exp e) { Var_Decl_List list = e->d.exp_decl.list; const int emit_var = exp_getvar(e); diff --git a/src/parse/check.c b/src/parse/check.c index 4fcb436f..fb2a0cfa 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -334,13 +334,6 @@ ANN static Type check_prim_id(const Env env, const Symbol *data) { return prim_id_non_res(env, data); } -ANN static Type check_prim_typeof(const Env env, const Exp *exp) { - const Exp e = *exp; - DECL_OO(const Type, t, = check_exp(env, e)) - CHECK_BO(inferable(env, t, (*exp)->pos)) - return type_class(env->gwion, t); -} - ANN static Type check_prim_interp(const Env env, const Exp* exp) { CHECK_OO(check_exp(env, *exp)) return env->gwion->type[et_string]; diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 5625bef6..14ac1bd3 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -62,7 +62,7 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) { } static inline m_bool scan1_defined(const Env env, const Var_Decl var) { - if(var->value) // from a `typeof` declaration + if(var->value) // from an auto declaration return GW_OK; if(((!env->class_def || !GET_FLAG(env->class_def, final) || env->scope->depth) ? nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->xid)) ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), @@ -195,8 +195,7 @@ ANN static m_bool scan1_range(const Env env, Range *range) { } ANN static inline m_bool scan1_prim(const Env env, const Exp_Primary* prim) { - if(prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_typeof || - prim->prim_type == ae_prim_interp) + if(prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_interp) return scan1_exp(env, prim->d.exp); if(prim->prim_type == ae_prim_array && prim->d.array->exp) return scan1_exp(env, prim->d.array->exp); diff --git a/src/parse/scan2.c b/src/parse/scan2.c index f5286ac4..af5ed0fc 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -105,8 +105,7 @@ ANN static m_bool scan2_range(const Env env, Range *range) { } ANN static inline m_bool scan2_prim(const Env env, const Exp_Primary* prim) { - if(prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_typeof || - prim->prim_type == ae_prim_interp) + if(prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_interp) CHECK_BB(scan2_exp(env, prim->d.exp)) /* else if(prim->prim_type == ae_prim_id) { const Value v = prim_value(env, prim->d.var); -- 2.43.0