From: fennecdjay Date: Mon, 24 Oct 2022 17:58:13 +0000 (+0200) Subject: :art: array and range/slice access X-Git-Tag: nightly~207^2~122 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e1824abfd87eba374f08d3bd46f3bb0c24b8b14e;p=gwion.git :art: array and range/slice access --- diff --git a/plug b/plug index f69bdbee..a9eaca11 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit f69bdbeee0f878c46de0a1e44c2236cacc332fe3 +Subproject commit a9eaca11c2bf2408316968cad2619a9161f204b5 diff --git a/src/emit/emit.c b/src/emit/emit.c index bbce4f15..dc978ff2 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -657,10 +657,10 @@ ANN static m_bool emit_prim_range(const Emitter emit, Range **data) { Range *range = *data; CHECK_BB(emit_range(emit, range)); const Exp e = range->start ?: range->end; - const Symbol sym = insert_symbol("@range"); + const Symbol sym = insert_symbol("[:]"); assert(e); struct Op_Import opi = {.op = sym, - .rhs = e->type, + .lhs = e->type, .pos = e->pos, .data = (uintptr_t)prim_exp(data)}; CHECK_BB(op_emit(emit, &opi)); @@ -724,7 +724,7 @@ ANN m_bool emit_array_access(const Emitter emit, if (tflag(info->array.type, tflag_typedef)) info->array.type = typedef_base(info->array.type); // look mum no pos - struct Op_Import opi = {.op = insert_symbol("@array"), + struct Op_Import opi = {.op = insert_symbol("[]"), .lhs = info->array.exp->type, .rhs = info->array.type, .data = (uintptr_t)info}; @@ -748,7 +748,7 @@ ANN static m_bool emit_exp_array(const Emitter emit, const Exp_Array *array) { ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice *range) { CHECK_BB(emit_exp(emit, range->base)); CHECK_BB(emit_range(emit, range->range)); - const Symbol sym = insert_symbol("@slice"); + const Symbol sym = insert_symbol("[:]"); const Exp e = range->range->start ?: range->range->end; assert(e); struct Op_Import opi = {.op = sym, diff --git a/src/import/import_prim.c b/src/import/import_prim.c index 4afdbd23..7a99ff82 100644 --- a/src/import/import_prim.c +++ b/src/import/import_prim.c @@ -119,7 +119,7 @@ static OP_CHECK(opck_bit_access) { ANN static void scan_prim_op(const Env env, const Type t){ struct Op_Func opfunc = { .ck = opck_bit_access, .em = opem_bit_access }; struct Op_Import opi = { - .op = insert_symbol(env->gwion->st, "@array"), + .op = insert_symbol(env->gwion->st, "[]"), .lhs = env->gwion->type[et_int], .rhs = t, .func = &opfunc diff --git a/src/lib/array.c b/src/lib/array.c index bb4ea30c..7276fa77 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -972,11 +972,11 @@ GWION_IMPORT(array) { GWI_BB(gwi_oper_ini(gwi, "int", "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)) + GWI_BB(gwi_oper_end(gwi, "[:]", NULL)) GWI_BB(gwi_oper_ini(gwi, "int", "Array", NULL)) GWI_BB(gwi_oper_add(gwi, opck_array)) GWI_BB(gwi_oper_emi(gwi, opem_array_access)) - GWI_BB(gwi_oper_end(gwi, "@array", NULL)) + GWI_BB(gwi_oper_end(gwi, "[]", NULL)) GWI_BB(gwi_oper_ini(gwi, "Array", NULL, "void")) GWI_BB(gwi_oper_emi(gwi, opem_array_each_init)) GWI_BB(gwi_oper_end(gwi, "@each_init", NULL)) diff --git a/src/lib/dict.c b/src/lib/dict.c index c055dfe0..b242a1d3 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -650,7 +650,7 @@ static OP_CHECK(opck_dict_scan) { set_tflag(t, tflag_dtor); } struct Op_Func opfunc = { .ck = opck_dict_access, .em = opem_dict_access }; - struct Op_Import opi = { .lhs = key, .rhs = t, .ret = val, .op = insert_symbol("@array"), .func = &opfunc }; + struct Op_Import opi = { .lhs = key, .rhs = t, .ret = val, .op = insert_symbol("[]"), .func = &opfunc }; add_op(env->gwion, &opi); opi.op = insert_symbol("~~"); opfunc.em = opem_dict_remove; diff --git a/src/lib/prim.c b/src/lib/prim.c index c1cf7acd..ae2be81c 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -230,10 +230,10 @@ static GWION_IMPORT(int_unary) { GWI_BB(gwi_oper_end(gwi, "--", int_pre_dec)) GWI_BB(gwi_oper_add(gwi, opck_int_cmp)) GWI_BB(gwi_oper_end(gwi, "~", int_cmp)) - GWI_BB(gwi_oper_ini(gwi, NULL, "int", NULL)) + GWI_BB(gwi_oper_ini(gwi, "int", NULL, NULL)) GWI_BB(gwi_oper_add(gwi, opck_int_range)) GWI_BB(gwi_oper_emi(gwi, opem_int_range)) - GWI_BB(gwi_oper_end(gwi, "@range", NULL)) + GWI_BB(gwi_oper_end(gwi, "[:]", NULL)) GWI_BB(gwi_oper_ini(gwi, "int", NULL, "int")) GWI_BB(gwi_oper_add(gwi, opck_post)) GWI_BB(gwi_oper_end(gwi, "++", int_post_inc)) diff --git a/src/lib/string.c b/src/lib/string.c index ae32cd96..b61f5b11 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -573,7 +573,7 @@ GWION_IMPORT(string) { GWI_BB(gwi_oper_ini(gwi, "int", "string", NULL)) GWI_BB(gwi_oper_add(gwi, opck_string_access)) GWI_BB(gwi_oper_emi(gwi, opem_string_access)) - GWI_BB(gwi_oper_end(gwi, "@array", NULL)) + GWI_BB(gwi_oper_end(gwi, "[]", NULL)) GWI_BB(gwi_oper_ini(gwi, "string", "string", "bool")) GWI_BB(gwi_oper_add(gwi, opck_string_eq)) @@ -582,7 +582,7 @@ GWION_IMPORT(string) { GWI_BB(gwi_oper_end(gwi, "!=", String_neq)) GWI_BB(gwi_oper_ini(gwi, "int", "string", "string")) - GWI_BB(gwi_oper_end(gwi, "@slice", StringSlice)) + GWI_BB(gwi_oper_end(gwi, "[:]", StringSlice)) struct SpecialId_ file_spid = { .ck = check_filepp, .is_const = 1}; diff --git a/src/parse/check.c b/src/parse/check.c index 7561c990..2117b113 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -233,9 +233,9 @@ ANN static Type check_prim_range(const Env env, Range **data) { env_weight(env, 1); const Exp e = range->start ?: range->end; assert(e); - const Symbol sym = insert_symbol("@range"); + const Symbol sym = insert_symbol("[:]"); struct Op_Import opi = {.op = sym, - .rhs = e->type, + .lhs = e->type, .pos = e->pos, .data = (uintptr_t)prim_exp(data)}; return op_check(env, &opi); @@ -449,7 +449,7 @@ ANN static Type check_prim(const Env env, Exp_Primary *prim) { } ANN Type check_array_access(const Env env, const Array_Sub array) { - const Symbol sym = insert_symbol("@array"); + const Symbol sym = insert_symbol("[]"); struct Op_Import opi = {.op = sym, .lhs = array->exp->type, .rhs = array->type, @@ -468,7 +468,7 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice *range) { CHECK_OO(check_exp(env, range->base)); CHECK_BO(check_range(env, range->range)); env_weight(env, 1); - const Symbol sym = insert_symbol("@slice"); + const Symbol sym = insert_symbol("[:]"); const Exp e = range->range->start ?: range->range->end; assert(e); struct Op_Import opi = {.op = sym,