From: Jérémie Astor Date: Wed, 6 May 2020 15:56:55 +0000 (+0200) Subject: :bug: Fix range operator X-Git-Tag: nightly~1657 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=496e6c790582daf72684e642312d0fed37060c10;p=gwion.git :bug: Fix range operator --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 050cc97b..db4fb657 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -430,8 +430,8 @@ ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice* range) { CHECK_BB(emit_range(emit, range->range)) const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; - struct Op_Import opi = { .op=sym, .lhs=range->base->info->type, .rhs=e->info->type, - .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp }; + struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type, + .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp }; CHECK_OB(op_emit(emit, &opi)) return GW_OK; } diff --git a/src/lib/array.c b/src/lib/array.c index dd78610f..c9b3b239 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -190,7 +190,7 @@ static OP_CHECK(opck_array_cast) { static OP_CHECK(opck_array_slice) { const Exp e = (Exp)data; - return e->d.exp_slice.base->info->type; + return e->info->type; } static inline m_bool bounds(const M_Vector v, const m_int i) { @@ -339,7 +339,7 @@ GWION_IMPORT(array) { GWI_BB(gwi_oper_ini(gwi, "@Array", "@Array", NULL)) GWI_BB(gwi_oper_add(gwi, opck_array_cast)) GWI_BB(gwi_oper_end(gwi, "$", NULL)) - GWI_BB(gwi_oper_ini(gwi, "nonnull @Array", "int", "int")) + GWI_BB(gwi_oper_ini(gwi, "int", "nonnull @Array", "int")) GWI_BB(gwi_oper_add(gwi, opck_array_slice)) GWI_BB(gwi_oper_emi(gwi, opem_array_slice)) GWI_BB(gwi_oper_end(gwi, "@slice", NULL)) diff --git a/src/lib/string.c b/src/lib/string.c index b26017d0..4c493a6f 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -94,7 +94,7 @@ GWION_IMPORT(string) { GWI_BB(gwi_item_end(gwi, ae_flag_const, NULL)) GWI_BB(gwi_class_end(gwi)) - GWI_BB(gwi_oper_ini(gwi, "string", "nonnull string", "string")) + GWI_BB(gwi_oper_ini(gwi, "string", "nonnull string", "nonnull string")) GWI_BB(gwi_oper_add(gwi, opck_const_rhs)) GWI_BB(gwi_oper_end(gwi, "=>", String_Assign)) @@ -102,7 +102,7 @@ GWION_IMPORT(string) { GWI_BB(gwi_oper_end(gwi, "==", String_eq)) GWI_BB(gwi_oper_end(gwi, "!=", String_neq)) - GWI_BB(gwi_oper_ini(gwi, "nonnull string", "int", "string")) + GWI_BB(gwi_oper_ini(gwi, "int", "nonnull string", "nonnull string")) GWI_BB(gwi_oper_end(gwi, "@slice", StringSlice)) struct SpecialId_ spid = { .ck=check_funcpp, .exec=RegPushMe, .is_const=1 }; diff --git a/src/parse/check.c b/src/parse/check.c index 34e2beeb..8a196dc0 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -356,8 +356,8 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice* range) { CHECK_BO(check_range(env, range->range)) const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; - struct Op_Import opi = { .op=sym, .lhs=range->base->info->type, .rhs=e->info->type, - .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp }; + struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type, + .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp }; return op_check(env, &opi); }