From: Jérémie Astor Date: Sat, 6 Jun 2020 09:31:32 +0000 (+0200) Subject: :bug: Fix @now const X-Git-Tag: nightly~1486 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2358ab5aa57af2861e0658c788d51b28e50f3039;p=gwion.git :bug: Fix @now const --- diff --git a/include/import.h b/include/import.h index 6c9056a7..eab366a8 100644 --- a/include/import.h +++ b/include/import.h @@ -47,7 +47,6 @@ OP_CHECK(opck_unary_meta2); OP_CHECK(opck_unary); OP_CHECK(opck_post); OP_CHECK(opck_rassign); -OP_CHECK(opck_rhs_emit_var); OP_CHECK(opck_basic_cast); OP_CHECK(opck_usr_implicit); OP_CHECK(opck_new); diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 9868d64e..5f98c8fb 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -33,12 +33,6 @@ OP_CHECK(opck_const_rhs) { return bin->rhs->info->type; } -OP_CHECK(opck_rhs_emit_var) { - const Exp_Binary* bin = (Exp_Binary*)data; - exp_setvar(bin->rhs, 1); - return bin->rhs->info->type; -} - OP_CHECK(opck_rassign) { const Exp_Binary* bin = (Exp_Binary*)data; if(opck_const_rhs(env, data, mut) == env->gwion->type[et_null]) diff --git a/src/lib/prim.c b/src/lib/prim.c index e8deb93c..49eb2126 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -221,6 +221,21 @@ static GWION_IMPORT(dur) { return gwi_oper_end(gwi, "<=", float_le); } + +static inline int is_now(const Env env, const Exp exp) { + return exp->exp_type == ae_exp_primary && + exp->d.prim.prim_type == ae_prim_id && + exp->d.prim.d.var == insert_symbol("now"); +} + +static OP_CHECK(opck_now) { + const Exp_Binary* bin = (Exp_Binary*)data; + if(!is_now(env, bin->rhs)) + CHECK_NN(opck_const_rhs(env, data, mut)) + exp_setvar(bin->rhs, 1); + return bin->rhs->info->type; +} + static GWION_IMPORT(time) { GWI_BB(gwi_oper_cond(gwi, "time", BranchEqFloat, BranchNeqFloat)) GWI_BB(gwi_oper_ini(gwi, "time", "time", "time")) @@ -231,7 +246,7 @@ static GWION_IMPORT(time) { CHECK_FF("=>", rassign, r_assign) GWI_BB(gwi_oper_end(gwi, "+", FloatPlus)) GWI_BB(gwi_oper_ini(gwi, "dur", "@now", "time")) - _CHECK_OP("=>", rhs_emit_var, Time_Advance) + _CHECK_OP("=>", now, Time_Advance) GWI_BB(gwi_oper_ini(gwi, "time", "time", "int")) GWI_BB(gwi_oper_end(gwi, ">", float_gt)) GWI_BB(gwi_oper_end(gwi, ">=", float_ge))