From 56404e2e8ec09ebd082ee459aba8f05d525e3783 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Tue, 26 Mar 2019 16:20:21 +0100 Subject: [PATCH] :art: '::' as an operator --- ast | 2 +- include/parse.h | 2 +- src/emit/emit.c | 7 ------- src/lib/prim.c | 4 ++++ src/parse/check.c | 18 +----------------- src/parse/scan1.c | 5 ----- src/parse/scan2.c | 5 ----- util | 2 +- 8 files changed, 8 insertions(+), 37 deletions(-) diff --git a/ast b/ast index d5bb4217..aad27af2 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit d5bb42177b8cc84c6fa225c93a79b84cb9c75840 +Subproject commit aad27af27cd58925dfde26a7c9d6cfad3a9594b3 diff --git a/include/parse.h b/include/parse.h index 245d483f..28a2d1ae 100644 --- a/include/parse.h +++ b/include/parse.h @@ -22,7 +22,7 @@ static const _exp_func exp_func[] = { (_exp_func)prefix##_exp_decl, (_exp_func)prefix##_exp_binary, (_exp_func)prefix##_exp_unary, \ (_exp_func)prefix##_exp_primary, (_exp_func)prefix##_exp_cast, (_exp_func)prefix##_exp_post, \ (_exp_func)prefix##_exp_call, (_exp_func)prefix##_exp_array, (_exp_func)prefix##_exp_if, \ - (_exp_func)prefix##_exp_dot, (_exp_func)prefix##_exp_dur, (_exp_func)prefix##_exp_lambda \ + (_exp_func)prefix##_exp_dot, (_exp_func)prefix##_exp_lambda \ }; #define DECL_SECTION_FUNC(prefix) \ diff --git a/src/emit/emit.c b/src/emit/emit.c index 72abcc84..eeac008d 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -694,13 +694,6 @@ ANN static m_bool emit_exp_post(const Emitter emit, const Exp_Postfix* post) { G return op_emit(emit, &opi); } -ANN static m_bool emit_exp_dur(const Emitter emit, const Exp_Dur* dur) { GWDEBUG_EXE - CHECK_BB(emit_exp(emit, dur->base, 0)) - CHECK_BB(emit_exp(emit, dur->unit, 0)) - emit_add_instr(emit, FloatTimes); - return GW_OK; -} - ANN static m_bool is_special(const Type t) { if(isa(t, t_complex) > 0 || isa(t, t_polar) > 0 || isa(t, t_vec3) > 0 || isa(t, t_vec4) > 0 || diff --git a/src/lib/prim.c b/src/lib/prim.c index 15f1764c..155ba89c 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -272,6 +272,10 @@ static GWION_IMPORT(float) { CHECK_FF(not, unary_meta, not) CHECK_BB(gwi_oper_ini(gwi, NULL, "dur", "int")) CHECK_FF(not, unary_meta, not) + CHECK_BB(gwi_oper_ini(gwi, "int", "dur", "dur")) + CHECK_BB(gwi_oper_end(gwi, op_coloncolon, int_float_mul)) + CHECK_BB(gwi_oper_ini(gwi, "float", "dur", "dur")) + CHECK_BB(gwi_oper_end(gwi, op_coloncolon, FloatTimes)) return GW_OK; } diff --git a/src/parse/check.c b/src/parse/check.c index e2308522..cd74ccf1 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -635,22 +635,6 @@ ANN static Type check_exp_post(const Env env, const Exp_Postfix* post) { GWDEBUG OP_RET(post, "postfix"); } -ANN static Type check_exp_dur(const Env env, const Exp_Dur* exp) { GWDEBUG_EXE - CHECK_OO(check_exp(env, exp->base)) - CHECK_OO(check_exp(env, exp->unit)) - if(isa(exp->base->type, t_float) < 0) { - if(isa(exp->base->type, t_int) > 0) - exp->base->cast_to = t_float; - else - ERR_O(exp->base->pos, "invalid type '%s' in prefix of dur expression...\n" - " (must be of type 'int' or 'float')", exp->base->type->name) - } - if(isa(exp->unit->type, t_dur) < 0) - ERR_O(exp->unit->pos, "invalid type '%s' in postfix of dur expression...\n" - " (must be of type 'dur')", exp->base->type->name) - return exp->unit->type; -} - ANN static Type check_exp_call(const Env env, Exp_Call* exp) { GWDEBUG_EXE if(exp->tmpl) { CHECK_OO(check_exp(env, exp->func)) @@ -737,7 +721,7 @@ static const _type_func exp_func[] = { (_type_func)check_exp_decl, (_type_func)check_exp_binary, (_type_func)check_exp_unary, (_type_func)check_exp_primary, (_type_func)check_exp_cast, (_type_func)check_exp_post, (_type_func)check_exp_call, (_type_func)check_exp_array, (_type_func)check_exp_if, - (_type_func)check_exp_dot, (_type_func)check_exp_dur, (_type_func)check_exp_lambda + (_type_func)check_exp_dot, (_type_func)check_exp_lambda }; ANN static inline Type check_exp(const Env env, const Exp exp) { GWDEBUG_EXE diff --git a/src/parse/scan1.c b/src/parse/scan1.c index c5b4ed7f..344f6180 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -117,11 +117,6 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { GWDEB " on non-mutable data-type...", op2str(post->op)); } -ANN static inline m_bool scan1_exp_dur(const Env env, const Exp_Dur* dur) { GWDEBUG_EXE - CHECK_BB(scan1_exp(env, dur->base)) - return scan1_exp(env, dur->unit); -} - ANN static m_bool scan1_exp_call(const Env env, const Exp_Call* exp_call) { GWDEBUG_EXE if(exp_call->tmpl) return GW_OK; diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 67fb1f48..c4818740 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -184,11 +184,6 @@ ANN static inline m_bool scan2_exp_post(const Env env, const Exp_Postfix* post) return scan2_exp(env, post->exp); } -ANN static inline m_bool scan2_exp_dur(const Env env, const Exp_Dur* dur) { GWDEBUG_EXE - CHECK_BB(scan2_exp(env, dur->base)) - return scan2_exp(env, dur->unit); -} - ANN2(1,2) static inline m_bool scan2_exp_call1(const Env env, const restrict Exp func, const restrict Exp args) { GWDEBUG_EXE CHECK_BB(scan2_exp(env, func)) diff --git a/util b/util index a25a0c0e..1e9a605a 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit a25a0c0e88bfdf69041c658ff14f7992d78ddcb4 +Subproject commit 1e9a605aeb73cef2853972984b90e6dc43324d84 -- 2.43.0