From 8fb87901aeaa64ede6a0b2793d27d72d7b534d5c Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 5 Jul 2019 19:57:47 +0200 Subject: [PATCH] :art: Operators as symbols --- ast | 2 +- include/gwi.h | 3 +- include/import.h | 4 +- include/operator.h | 2 +- src/emit/emit.c | 10 +- src/lib/array.c | 6 +- src/lib/complex.c | 36 +++---- src/lib/engine.c | 2 +- src/lib/event.c | 2 +- src/lib/func.c | 18 ++-- src/lib/import.c | 5 +- src/lib/object.c | 24 ++--- src/lib/opfunc.c | 8 +- src/lib/prim.c | 234 +++++++++++++++++++++---------------------- src/lib/ptr.c | 6 +- src/lib/string.c | 58 +++++------ src/lib/ugen.c | 8 +- src/lib/vararg.c | 4 +- src/lib/vec.c | 52 +++++----- src/parse/check.c | 9 +- src/parse/operator.c | 42 ++++---- src/parse/scan1.c | 4 +- src/parse/scan2.c | 9 +- util | 2 +- 24 files changed, 274 insertions(+), 276 deletions(-) diff --git a/ast b/ast index e44ed608..288d889c 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit e44ed608c3017151511c1ec23db9a4fd97007729 +Subproject commit 288d889c1479bc51f413836bbebeb63031742215 diff --git a/include/gwi.h b/include/gwi.h index 23389900..7bd75d85 100644 --- a/include/gwi.h +++ b/include/gwi.h @@ -22,11 +22,10 @@ typedef struct { } DL_Func; typedef struct { - Operator op; + Symbol op; m_str ret, lhs, rhs; Type (*ck)(Env, void*, m_bool*); m_bool (*em)(Emitter, void*); - m_bool mut; } DL_Oper; typedef struct { diff --git a/include/import.h b/include/import.h index 91de84f4..0864ff38 100644 --- a/include/import.h +++ b/include/import.h @@ -22,7 +22,7 @@ typedef struct Gwi_* Gwi; #define ALLOC_PTR(p, a, b, c) b* a = (b*)_mp_calloc(p, sizeof(b)); *a = (b)c #define _CHECK_OP(op, check, func)\ CHECK_BB(gwi_oper_add(gwi, opck_##check))\ - CHECK_BB(gwi_oper_end(gwi, op_##op, func)) + CHECK_BB(gwi_oper_end(gwi, op, func)) #define GWI_LOC new_loc(gwi->gwion->mp, __LINE__) @@ -61,7 +61,7 @@ ANN m_int gwi_func_end(const Gwi gwi, const ae_flag flag); ANN2(1) m_int gwi_oper_ini(const Gwi gwi, const m_str l, const m_str r, const m_str t); ANN m_int gwi_oper_add(const Gwi gwi, opck); ANN m_int gwi_oper_emi(const Gwi gwi, opem); -ANN2(1) m_int gwi_oper_end(const Gwi gwi, const Operator op, const f_instr f); +ANN2(1) m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f); ANN Type_Decl* str2decl(const Env, const m_str, m_uint* depth); diff --git a/include/operator.h b/include/operator.h index a54b8d10..3fb4c4bd 100644 --- a/include/operator.h +++ b/include/operator.h @@ -13,7 +13,7 @@ struct Op_Import { opem em; uintptr_t data; loc_t pos; - Operator op; + Symbol op; }; struct Implicit { diff --git a/src/emit/emit.c b/src/emit/emit.c index a50ac62f..df309a90 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -731,7 +731,7 @@ ANN static m_bool emit_exp_binary(const Emitter emit, const Exp_Binary* bin) { } ANN static m_bool emit_exp_cast(const Emitter emit, const Exp_Cast* cast) { - struct Op_Import opi = { .op=op_cast, .lhs=cast->exp->type, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast}; + struct Op_Import opi = { .op=insert_symbol("$"), .lhs=cast->exp->type, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast}; CHECK_BB(emit_exp(emit, cast->exp, 0)) (void)op_emit(emit, &opi); return GW_OK; @@ -955,7 +955,7 @@ ANN static m_bool spork_func(const Emitter emit, const Exp_Call* exp) { } ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { - const m_bool is_spork = unary->op == op_spork; + const m_bool is_spork = unary->op == insert_symbol("spork"); const Func f = !unary->code ? unary->exp->d.exp_call.m_func : NULL; if(!f) { emit_add_instr(emit, RegPushImm); @@ -969,7 +969,7 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { CHECK_BB(spork_func(emit, &unary->exp->d.exp_call)) } const VM_Code code = finalyze(emit); - const Instr ini = emit_add_instr(emit, unary->op == op_spork ? SporkIni : ForkIni); + const Instr ini = emit_add_instr(emit, unary->op == insert_symbol("spork") ? SporkIni : ForkIni); ini->m_val = (m_uint)code; ini->m_val2 = is_spork; if(!f) { @@ -1004,7 +1004,7 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) { struct Op_Import opi = { .op=unary->op, .data=(uintptr_t)unary }; - if(unary->op != op_spork && unary->op != op_fork && unary->exp) { + if(unary->op != insert_symbol("spork") && unary->op != insert_symbol("fork") && unary->exp) { CHECK_BB(emit_exp(emit, unary->exp, 1)) opi.rhs = unary->exp->type; } @@ -1014,7 +1014,7 @@ ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) { ANN static m_bool emit_implicit_cast(const Emitter emit, const restrict Exp from, const restrict Type to) { const struct Implicit imp = { from, to }; - struct Op_Import opi = { .op=op_impl, .lhs=from->type, .rhs=to, .data=(m_uint)&imp }; + struct Op_Import opi = { .op=insert_symbol("@implicit"), .lhs=from->type, .rhs=to, .data=(m_uint)&imp }; return op_emit(emit, &opi); } diff --git a/src/lib/array.c b/src/lib/array.c index da46685d..a96fcfe8 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -222,14 +222,14 @@ GWION_IMPORT(array) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "@Array", (m_str)OP_ANY_TYPE, NULL)) CHECK_BB(gwi_oper_add(gwi, opck_array_at)) - CHECK_BB(gwi_oper_end(gwi, op_ref, ObjectAssign)) + CHECK_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) CHECK_BB(gwi_oper_add(gwi, opck_array_shift)) CHECK_BB(gwi_oper_emi(gwi, opem_array_shift)) - CHECK_BB(gwi_oper_end(gwi, op_shl, NULL)) + CHECK_BB(gwi_oper_end(gwi, "<<", NULL)) CHECK_BB(gwi_oper_ini(gwi, "@Array", "Array", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_array_cast)) CHECK_BB(gwi_oper_emi(gwi, opem_basic_cast)) - CHECK_BB(gwi_oper_end(gwi, op_cast, NULL)) + CHECK_BB(gwi_oper_end(gwi, "$", NULL)) register_freearg(gwi, ArrayAlloc, freearg_array); return GW_OK; } diff --git a/src/lib/complex.c b/src/lib/complex.c index 167aefda..54bd3897 100644 --- a/src/lib/complex.c +++ b/src/lib/complex.c @@ -127,34 +127,34 @@ GWION_IMPORT(complex) { CHECK_BB(gwi_item_end(gwi, ae_flag_member, NULL)) CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "complex", "complex", "complex")) - CHECK_BB(gwi_oper_end(gwi, op_add, ComplexAdd)) - CHECK_BB(gwi_oper_end(gwi, op_sub, ComplexSub)) - CHECK_BB(gwi_oper_end(gwi, op_mul, ComplexMul)) - CHECK_BB(gwi_oper_end(gwi, op_div, ComplexDiv)) + CHECK_BB(gwi_oper_end(gwi, "+", ComplexAdd)) + CHECK_BB(gwi_oper_end(gwi, "-", ComplexSub)) + CHECK_BB(gwi_oper_end(gwi, "*", ComplexMul)) + CHECK_BB(gwi_oper_end(gwi, "/", ComplexDiv)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, ComplexRAssign)) + CHECK_BB(gwi_oper_end(gwi, "=>", ComplexRAssign)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_radd, ComplexRAdd)) + CHECK_BB(gwi_oper_end(gwi, "+=>", ComplexRAdd)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rsub, ComplexRSub)) + CHECK_BB(gwi_oper_end(gwi, "-=>", ComplexRSub)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rmul, ComplexRMul)) + CHECK_BB(gwi_oper_end(gwi, "*=>", ComplexRMul)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rdiv, ComplexRDiv)) + CHECK_BB(gwi_oper_end(gwi, "/=>", ComplexRDiv)) CHECK_BB(gwi_oper_ini(gwi, "polar", "polar", "polar")) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, ComplexRAssign)) - CHECK_BB(gwi_oper_end(gwi, op_add, PolarAdd)) - CHECK_BB(gwi_oper_end(gwi, op_sub, PolarSub)) - CHECK_BB(gwi_oper_end(gwi, op_mul, PolarMul)) - CHECK_BB(gwi_oper_end(gwi, op_div, PolarDiv)) + CHECK_BB(gwi_oper_end(gwi, "=>", ComplexRAssign)) + CHECK_BB(gwi_oper_end(gwi, "+", PolarAdd)) + CHECK_BB(gwi_oper_end(gwi, "-", PolarSub)) + CHECK_BB(gwi_oper_end(gwi, "*", PolarMul)) + CHECK_BB(gwi_oper_end(gwi, "/", PolarDiv)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_radd, PolarRAdd)) + CHECK_BB(gwi_oper_end(gwi, "+=>", PolarRAdd)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rsub, PolarRSub)) + CHECK_BB(gwi_oper_end(gwi, "-=>", PolarRSub)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rmul, PolarRMul)) + CHECK_BB(gwi_oper_end(gwi, "*=>", PolarRMul)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_rdiv, PolarRDiv)) + CHECK_BB(gwi_oper_end(gwi, "/=>", PolarRDiv)) return GW_OK; } diff --git a/src/lib/engine.c b/src/lib/engine.c index 7b6655c8..4a629e6a 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -79,7 +79,7 @@ ANN static m_bool import_core_libs(const Gwi gwi) { CHECK_BB(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL)) CHECK_BB(gwi_oper_add(gwi, opck_new)) CHECK_BB(gwi_oper_emi(gwi, opem_new)) - CHECK_BB(gwi_oper_end(gwi, op_new, NULL)) + CHECK_BB(gwi_oper_end(gwi, "new", NULL)) CHECK_BB(import_prim(gwi)) CHECK_BB(import_complex(gwi)) CHECK_BB(import_vec3(gwi)) diff --git a/src/lib/event.c b/src/lib/event.c index 09f15d41..77931069 100644 --- a/src/lib/event.c +++ b/src/lib/event.c @@ -66,6 +66,6 @@ GWION_IMPORT(event) { CHECK_BB(gwi_func_end(gwi, 0)) CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "Event", "@now", "int")) - _CHECK_OP(chuck, eventwait, EventWait) + _CHECK_OP("=>", eventwait, EventWait) return GW_OK; } diff --git a/src/lib/func.c b/src/lib/func.c index cc85de4e..4d06af67 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -248,11 +248,11 @@ ANN Type check_exp_unary_spork(const Env env, const Stmt code); static OP_CHECK(opck_spork) { const Exp_Unary* unary = (Exp_Unary*)data; - if(unary->op == op_fork && !unary->fork_ok) + if(unary->op == insert_symbol("fork") && !unary->fork_ok) ERR_O(exp_self(unary)->pos, _("forks must be stored in a value:\n" "fork xxx @=> Fork f")) if(unary->exp && unary->exp->exp_type == ae_exp_call) - return unary->op == op_spork ? t_shred : t_fork; + return unary->op == insert_symbol("spork") ? t_shred : t_fork; else if(unary->code) { ++env->scope->depth; nspc_push_value(env->gwion->mp, env->curr); @@ -260,7 +260,7 @@ static OP_CHECK(opck_spork) { nspc_pop_value(env->gwion->mp, env->curr); --env->scope->depth; CHECK_BO(ret) - return unary->op == op_spork ? t_shred : t_fork; + return unary->op == insert_symbol("spork") ? t_shred : t_fork; } else ERR_O(exp_self(unary)->pos, _("only function calls can be sporked...")) return NULL; @@ -284,24 +284,24 @@ static FREEARG(freearg_dottmpl) { GWION_IMPORT(func) { CHECK_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "@function", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_func_call)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, NULL)) + CHECK_BB(gwi_oper_end(gwi, "=>", NULL)) CHECK_BB(gwi_oper_ini(gwi, "@function", "@func_ptr", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_fptr_at)) CHECK_BB(gwi_oper_emi(gwi, opem_func_assign)) - CHECK_BB(gwi_oper_end(gwi, op_ref, NULL /*FuncAssign*/)) + CHECK_BB(gwi_oper_end(gwi, "@=>", NULL /*FuncAssign*/)) CHECK_BB(gwi_oper_add(gwi, opck_fptr_cast)) CHECK_BB(gwi_oper_emi(gwi, opem_fptr_cast)) - CHECK_BB(gwi_oper_end(gwi, op_cast, NULL)) + CHECK_BB(gwi_oper_end(gwi, "$", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_fptr_impl)) CHECK_BB(gwi_oper_emi(gwi, opem_fptr_impl)) - CHECK_BB(gwi_oper_end(gwi, op_impl, NULL)) + CHECK_BB(gwi_oper_end(gwi, "@implicit", NULL)) CHECK_BB(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL)) CHECK_BB(gwi_oper_add(gwi, opck_spork)) CHECK_BB(gwi_oper_emi(gwi, opem_spork)) - CHECK_BB(gwi_oper_end(gwi, op_spork, NULL)) + CHECK_BB(gwi_oper_end(gwi, "spork", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_spork)) CHECK_BB(gwi_oper_emi(gwi, opem_spork)) - CHECK_BB(gwi_oper_end(gwi, op_fork, NULL)) + CHECK_BB(gwi_oper_end(gwi, "fork", NULL)) register_freearg(gwi, SporkIni, freearg_xork); register_freearg(gwi, ForkIni, freearg_xork); register_freearg(gwi, DotTmpl, freearg_dottmpl); diff --git a/src/lib/import.c b/src/lib/import.c index 15c8bb3a..56ecdfd9 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -489,7 +489,6 @@ ANN2(1,2) static int import_op(const Gwi gwi, const DL_Oper* op, ANN2(1) m_int gwi_oper_ini(const Gwi gwi, const restrict m_str l, const restrict m_str r, const restrict m_str t) { - gwi->oper.mut = 0; gwi->oper.ret = t; gwi->oper.rhs = r; gwi->oper.lhs = l; @@ -506,8 +505,8 @@ ANN m_int gwi_oper_emi(const Gwi gwi, m_bool (*em)(Emitter, void*)) { return GW_OK; } -ANN m_int gwi_oper_end(const Gwi gwi, const Operator op, const f_instr f) { - gwi->oper.op = op; +ANN m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f) { + gwi->oper.op = insert_symbol(gwi->gwion->st, op); const m_bool ret = import_op(gwi, &gwi->oper, f); gwi->oper.ck = NULL; gwi->oper.em = NULL; diff --git a/src/lib/object.c b/src/lib/object.c index bc41aab2..436231ca 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -154,30 +154,30 @@ GWION_IMPORT(object) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "@null", "Object", "Object")) CHECK_BB(gwi_oper_add(gwi, at_object)) - CHECK_BB(gwi_oper_end(gwi, op_ref, ObjectAssign)) + CHECK_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) CHECK_BB(gwi_oper_ini(gwi, "Object", "Object", NULL)) CHECK_BB(gwi_oper_add(gwi, at_object)) - CHECK_BB(gwi_oper_end(gwi, op_ref, ObjectAssign)) + CHECK_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) CHECK_BB(gwi_oper_ini(gwi, "Object", "Object", "int")) - CHECK_BB(gwi_oper_end(gwi, op_eq, EqObject)) - CHECK_BB(gwi_oper_end(gwi, op_ne, NeqObject)) + CHECK_BB(gwi_oper_end(gwi, "==", EqObject)) + CHECK_BB(gwi_oper_end(gwi, "!=", NeqObject)) CHECK_BB(gwi_oper_add(gwi, opck_object_cast)) CHECK_BB(gwi_oper_emi(gwi, opem_basic_cast)) - CHECK_BB(gwi_oper_end(gwi, op_cast, NULL)) + CHECK_BB(gwi_oper_end(gwi, "$", NULL)) CHECK_BB(gwi_oper_ini(gwi, "@null", "Object", "int")) - CHECK_BB(gwi_oper_end(gwi, op_eq, EqObject)) - CHECK_BB(gwi_oper_end(gwi, op_ne, NeqObject)) + CHECK_BB(gwi_oper_end(gwi, "==", EqObject)) + CHECK_BB(gwi_oper_end(gwi, "!=", NeqObject)) CHECK_BB(gwi_oper_add(gwi, opck_basic_cast)) CHECK_BB(gwi_oper_emi(gwi, opem_basic_cast)) - CHECK_BB(gwi_oper_end(gwi, op_cast, NULL)) + CHECK_BB(gwi_oper_end(gwi, "$", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_implicit_null2obj)) - CHECK_BB(gwi_oper_end(gwi, op_impl, NULL)) + CHECK_BB(gwi_oper_end(gwi, "@implicit", NULL)) CHECK_BB(gwi_oper_ini(gwi, "Object", "@null", "int")) - CHECK_BB(gwi_oper_end(gwi, op_eq, EqObject)) - CHECK_BB(gwi_oper_end(gwi, op_ne, NeqObject)) + CHECK_BB(gwi_oper_end(gwi, "==", EqObject)) + CHECK_BB(gwi_oper_end(gwi, "!=", NeqObject)) CHECK_BB(gwi_oper_ini(gwi, NULL, "Object", "int")) CHECK_BB(gwi_oper_add(gwi, opck_unary_meta2)) - CHECK_BB(gwi_oper_end(gwi, op_not, IntNot)) + CHECK_BB(gwi_oper_end(gwi, "!", IntNot)) gwi_item_ini(gwi, "@null", "null"); gwi_item_end(gwi, 0, NULL); gwi_reserve(gwi, "this"); diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 9175a4f4..3f2f7522 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -31,7 +31,7 @@ OP_CHECK(opck_const_rhs) { if(bin->rhs->meta != ae_meta_var) ERR_N(bin->rhs->pos, _("cannot assign '%s' on types '%s' and '%s'.\n" " ... (reason: --- right-side operand is %s.)"), - op2str(bin->op), bin->lhs->type->name, bin->rhs->type->name, + s_name(bin->op), bin->lhs->type->name, bin->rhs->type->name, access(bin->rhs->meta)) return bin->rhs->type; } @@ -67,7 +67,7 @@ OP_CHECK(opck_unary_meta2_uniq) { CHECK_OO(opck_unary_meta2(env, data, mut)) if(unary->exp->next) ERR_N(exp_self(unary)->pos, - _("'%s' must be applied to a unique expression"), op2str(unary->op)) + _("'%s' must be applied to a unique expression"), s_name(unary->op)) return t_int; } @@ -76,7 +76,7 @@ OP_CHECK(opck_unary) { if(unary->exp->meta != ae_meta_var) ERR_N(unary->exp->pos, _("unary operator '%s' cannot be used on %s data-types."), - op2str(unary->op), access(unary->exp->meta)) + s_name(unary->op), access(unary->exp->meta)) unary->exp->emit_var = 1; exp_self(unary)->meta = ae_meta_value; return unary->exp->type; @@ -86,7 +86,7 @@ OP_CHECK(opck_post) { const Exp_Postfix* post = (Exp_Postfix*)data; if(post->exp->meta != ae_meta_var) ERR_N(post->exp->pos, _("post operator '%s' cannot be used on %s data-type."), - op2str(post->op), access(post->exp->meta)) + s_name(post->op), access(post->exp->meta)) post->exp->emit_var = 1; exp_self(post)->meta = ae_meta_value; return post->exp->type; diff --git a/src/lib/prim.c b/src/lib/prim.c index 24e30591..2a6f973c 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -19,57 +19,57 @@ GWION_IMPORT(int_op) { CHECK_BB(gwi_oper_ini(gwi, "int", "int", "int")) - CHECK_BB(gwi_oper_end(gwi, op_add, int_plus)) - CHECK_BB(gwi_oper_end(gwi, op_sub, int_minus)) - CHECK_BB(gwi_oper_end(gwi, op_mul, int_mul)) - CHECK_BB(gwi_oper_end(gwi, op_div, int_div)) - return gwi_oper_end(gwi, op_mod, int_modulo); + CHECK_BB(gwi_oper_end(gwi, "+", int_plus)) + CHECK_BB(gwi_oper_end(gwi, "-", int_minus)) + CHECK_BB(gwi_oper_end(gwi, "*", int_mul)) + CHECK_BB(gwi_oper_end(gwi, "/", int_div)) + return gwi_oper_end(gwi, "%", int_modulo); } static GWION_IMPORT(int_logical) { - CHECK_BB(gwi_oper_end(gwi, op_and, int_and)) - CHECK_BB(gwi_oper_end(gwi, op_or, int_or)) - CHECK_BB(gwi_oper_end(gwi, op_eq, int_eq)) - CHECK_BB(gwi_oper_end(gwi, op_ne, int_neq)) - CHECK_BB(gwi_oper_end(gwi, op_gt, int_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, int_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, int_lt)) - CHECK_BB(gwi_oper_end(gwi, op_le, int_le)) - CHECK_BB(gwi_oper_end(gwi, op_shr, int_sr)) - CHECK_BB(gwi_oper_end(gwi, op_shl, int_sl)) - CHECK_BB(gwi_oper_end(gwi, op_sand, int_sand)) - CHECK_BB(gwi_oper_end(gwi, op_sor, int_sor)) - return gwi_oper_end(gwi, op_sxor, int_xor); + CHECK_BB(gwi_oper_end(gwi, "&&", int_and)) + CHECK_BB(gwi_oper_end(gwi, "||", int_or)) + CHECK_BB(gwi_oper_end(gwi, "==", int_eq)) + CHECK_BB(gwi_oper_end(gwi, "!=", int_neq)) + CHECK_BB(gwi_oper_end(gwi, ">", int_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", int_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", int_lt)) + CHECK_BB(gwi_oper_end(gwi, "<=", int_le)) + CHECK_BB(gwi_oper_end(gwi, ">>", int_sr)) + CHECK_BB(gwi_oper_end(gwi, "<<", int_sl)) + CHECK_BB(gwi_oper_end(gwi, "&", int_sand)) + CHECK_BB(gwi_oper_end(gwi, "|", int_sor)) + return gwi_oper_end(gwi, "^", int_xor); } static GWION_IMPORT(int_r) { - CHECK_OP(chuck, rassign, r_assign) - CHECK_OP(radd, rassign, r_plus) - CHECK_OP(rsub, rassign, r_minus) - CHECK_OP(rmul, rassign, r_mul) - CHECK_OP(rdiv, rassign, r_div) - CHECK_OP(rmod, rassign, r_modulo) - CHECK_OP(rsl, rassign, r_sl) - CHECK_OP(rsr, rassign, r_sr) - CHECK_OP(rsand, rassign, r_sand) - CHECK_OP(rsor, rassign, r_sor) - CHECK_OP(rsxor, rassign, r_sxor) + CHECK_OP("=>", rassign, r_assign) + CHECK_OP("+=>", rassign, r_plus) + CHECK_OP("-=>", rassign, r_minus) + CHECK_OP("*=>", rassign, r_mul) + CHECK_OP("/=>", rassign, r_div) + CHECK_OP("%=>", rassign, r_modulo) + CHECK_OP("<<=>", rassign, r_sl) + CHECK_OP(">>=>", rassign, r_sr) + CHECK_OP("&=>", rassign, r_sand) + CHECK_OP("|=>", rassign, r_sor) + CHECK_OP("^=>", rassign, r_sxor) return GW_OK; } static GWION_IMPORT(int_unary) { CHECK_BB(gwi_oper_ini(gwi, NULL, "int", "int")) CHECK_BB(gwi_oper_add(gwi, opck_unary_meta)) - CHECK_BB(gwi_oper_end(gwi, op_sub, int_negate)) + CHECK_BB(gwi_oper_end(gwi, "-", int_negate)) CHECK_BB(gwi_oper_add(gwi, opck_unary_meta2_uniq)) - CHECK_BB(gwi_oper_end(gwi, op_not, IntNot)) - CHECK_OP(inc, unary, pre_inc) - CHECK_OP(dec, unary, pre_dec) - CHECK_BB(gwi_oper_end(gwi, op_cmp, int_cmp)) + CHECK_BB(gwi_oper_end(gwi, "!", IntNot)) + CHECK_OP("++", unary, pre_inc) + CHECK_OP("--", unary, pre_dec) + CHECK_BB(gwi_oper_end(gwi, "~", int_cmp)) CHECK_BB(gwi_oper_ini(gwi, "int", NULL, "int")) - CHECK_OP(inc, post, post_inc) + CHECK_OP("++", post, post_inc) CHECK_BB(gwi_oper_add(gwi, opck_post)) - CHECK_BB(gwi_oper_end(gwi, op_dec, int_post_dec)) + CHECK_BB(gwi_oper_end(gwi, "--", int_post_dec)) return GW_OK; } @@ -160,125 +160,125 @@ static OP_EMIT(opem_f2i) { static GWION_IMPORT(intfloat) { CHECK_BB(gwi_oper_ini(gwi, "int", "float", "int")) - CHECK_BB(gwi_oper_end(gwi, op_and, int_float_and)) - CHECK_BB(gwi_oper_end(gwi, op_or, int_float_or)) - CHECK_BB(gwi_oper_end(gwi, op_eq, int_float_eq)) - CHECK_BB(gwi_oper_end(gwi, op_ne, int_float_neq)) - CHECK_BB(gwi_oper_end(gwi, op_gt, int_float_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, int_float_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, int_float_lt)) - CHECK_BB(gwi_oper_end(gwi, op_le, int_float_le)) + CHECK_BB(gwi_oper_end(gwi, "&&", int_float_and)) + CHECK_BB(gwi_oper_end(gwi, "||", int_float_or)) + CHECK_BB(gwi_oper_end(gwi, "==", int_float_eq)) + CHECK_BB(gwi_oper_end(gwi, "!=", int_float_neq)) + CHECK_BB(gwi_oper_end(gwi, ">", int_float_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", int_float_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", int_float_lt)) + CHECK_BB(gwi_oper_end(gwi, "<=", int_float_le)) CHECK_BB(gwi_oper_ini(gwi, "int", "float", "float")) - CHECK_BB(gwi_oper_end(gwi, op_add, int_float_plus)) - CHECK_BB(gwi_oper_end(gwi, op_mul, int_float_mul)) - CHECK_BB(gwi_oper_end(gwi, op_sub, int_float_minus)) - CHECK_BB(gwi_oper_end(gwi, op_div, int_float_div)) - CHECK_IF(chuck, rassign, r_assign) - CHECK_IF(radd, rassign, r_plus) - CHECK_IF(rsub, rassign, r_minus) - CHECK_IF(rmul, rassign, r_mul) - CHECK_IF(rdiv, rassign, r_div) + CHECK_BB(gwi_oper_end(gwi, "+", int_float_plus)) + CHECK_BB(gwi_oper_end(gwi, "*", int_float_mul)) + CHECK_BB(gwi_oper_end(gwi, "-", int_float_minus)) + CHECK_BB(gwi_oper_end(gwi, "/", int_float_div)) + CHECK_IF("=>", rassign, r_assign) + CHECK_IF("+=>", rassign, r_plus) + CHECK_IF("-=>", rassign, r_minus) + CHECK_IF("*=>", rassign, r_mul) + CHECK_IF("/=>", rassign, r_div) CHECK_BB(gwi_oper_emi(gwi, opem_i2f)) - _CHECK_OP(cast, basic_cast, CastI2F) - _CHECK_OP(impl, implicit_i2f, CastI2F) + _CHECK_OP("$", basic_cast, CastI2F) + _CHECK_OP("@implicit", implicit_i2f, CastI2F) return GW_OK; } static GWION_IMPORT(floatint) { CHECK_BB(gwi_oper_ini(gwi, "float", "int", "float")) - CHECK_BB(gwi_oper_end(gwi, op_add, float_int_plus)) - CHECK_BB(gwi_oper_end(gwi, op_sub, float_int_minus)) - CHECK_BB(gwi_oper_end(gwi, op_mul, float_int_mul)) - CHECK_BB(gwi_oper_end(gwi, op_div, float_int_div)) + CHECK_BB(gwi_oper_end(gwi, "+", float_int_plus)) + CHECK_BB(gwi_oper_end(gwi, "-", float_int_minus)) + CHECK_BB(gwi_oper_end(gwi, "*", float_int_mul)) + CHECK_BB(gwi_oper_end(gwi, "/", float_int_div)) CHECK_BB(gwi_oper_ini(gwi, "float", "int", "int")) - CHECK_BB(gwi_oper_end(gwi, op_and, float_int_and)) - CHECK_BB(gwi_oper_end(gwi, op_or, float_int_or)) - CHECK_BB(gwi_oper_end(gwi, op_eq, float_int_eq)) - CHECK_BB(gwi_oper_end(gwi, op_ne, float_int_neq)) - CHECK_BB(gwi_oper_end(gwi, op_gt, float_int_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, float_int_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, float_int_lt)) - CHECK_BB(gwi_oper_end(gwi, op_le, float_int_le)) - CHECK_FI(chuck, rassign, r_assign) - CHECK_FI(radd, rassign, r_plus) - CHECK_FI(rsub, rassign, r_minus) - CHECK_FI(rmul, rassign, r_mul) - CHECK_FI(rdiv, rassign, r_div) + CHECK_BB(gwi_oper_end(gwi, "&&", float_int_and)) + CHECK_BB(gwi_oper_end(gwi, "||", float_int_or)) + CHECK_BB(gwi_oper_end(gwi, "==", float_int_eq)) + CHECK_BB(gwi_oper_end(gwi, "!=", float_int_neq)) + CHECK_BB(gwi_oper_end(gwi, ">", float_int_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", float_int_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", float_int_lt)) + CHECK_BB(gwi_oper_end(gwi, "<=", float_int_le)) + CHECK_FI("=>", rassign, r_assign) + CHECK_FI("+=>", rassign, r_plus) + CHECK_FI("-=>", rassign, r_minus) + CHECK_FI("*=>", rassign, r_mul) + CHECK_FI("/=>", rassign, r_div) CHECK_BB(gwi_oper_emi(gwi, opem_f2i)) - _CHECK_OP(cast, basic_cast, CastF2I) - _CHECK_OP(impl, implicit_f2i, CastF2I) + _CHECK_OP("$", basic_cast, CastF2I) + _CHECK_OP("@implicit", implicit_f2i, CastF2I) return GW_OK; } static GWION_IMPORT(dur) { CHECK_BB(gwi_oper_ini(gwi, "dur", "dur", "dur")) - CHECK_FF(chuck, rassign, r_assign) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatPlus)) - CHECK_BB(gwi_oper_end(gwi, op_sub, FloatMinus)) - CHECK_BB(gwi_oper_end(gwi, op_mul, FloatTimes)) + CHECK_FF("=>", rassign, r_assign) + CHECK_BB(gwi_oper_end(gwi, "+", FloatPlus)) + CHECK_BB(gwi_oper_end(gwi, "-", FloatMinus)) + CHECK_BB(gwi_oper_end(gwi, "*", FloatTimes)) CHECK_BB(gwi_oper_ini(gwi, "dur", "dur", "float")) - CHECK_BB(gwi_oper_end(gwi, op_div, FloatDivide)) + CHECK_BB(gwi_oper_end(gwi, "/", FloatDivide)) CHECK_BB(gwi_oper_ini(gwi, "dur", "dur", "int")) - CHECK_BB(gwi_oper_end(gwi, op_gt, float_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, float_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, float_lt)) - return gwi_oper_end(gwi, op_le, float_le); + CHECK_BB(gwi_oper_end(gwi, ">", float_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", float_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", float_lt)) + return gwi_oper_end(gwi, "<=", float_le); } static GWION_IMPORT(time) { CHECK_BB(gwi_oper_ini(gwi, "time", "time", "time")) - CHECK_FF(chuck, rassign, r_assign) + CHECK_FF("=>", rassign, r_assign) CHECK_BB(gwi_oper_ini(gwi, "time", "dur", "time")) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatPlus)) + CHECK_BB(gwi_oper_end(gwi, "+", FloatPlus)) CHECK_BB(gwi_oper_ini(gwi, "dur", "time", "time")) - CHECK_FF(chuck, rassign, r_assign) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatPlus)) + CHECK_FF("=>", rassign, r_assign) + CHECK_BB(gwi_oper_end(gwi, "+", FloatPlus)) CHECK_BB(gwi_oper_ini(gwi, "dur", "@now", "time")) - _CHECK_OP(chuck, rhs_emit_var, Time_Advance) + _CHECK_OP("=>", rhs_emit_var, Time_Advance) CHECK_BB(gwi_oper_ini(gwi, "@now", "@now", NULL)) - _CHECK_OP(chuck, chuck_now, NULL) + _CHECK_OP("=>", chuck_now, NULL) CHECK_BB(gwi_oper_ini(gwi, NULL, "@now", NULL)) - CHECK_BB(gwi_oper_end(gwi, op_not, NULL)) + CHECK_BB(gwi_oper_end(gwi, "!", NULL)) CHECK_BB(gwi_oper_ini(gwi, "time", "time", "int")) - CHECK_BB(gwi_oper_end(gwi, op_gt, float_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, float_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, float_lt)) - return gwi_oper_end(gwi, op_le, float_le); + CHECK_BB(gwi_oper_end(gwi, ">", float_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", float_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", float_lt)) + return gwi_oper_end(gwi, "<=", float_le); } static GWION_IMPORT(float) { CHECK_BB(gwi_oper_ini(gwi, "float", "float", "float")) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatPlus)) - CHECK_BB(gwi_oper_end(gwi, op_sub, FloatMinus)) - CHECK_BB(gwi_oper_end(gwi, op_mul, FloatTimes)) - CHECK_BB(gwi_oper_end(gwi, op_div, FloatDivide)) - CHECK_FF(chuck, rassign, r_assign) - CHECK_FF(radd, rassign, r_plus) - CHECK_FF(rsub, rassign, r_minus) - CHECK_FF(rmul, rassign, r_mul) - CHECK_FF(rdiv, rassign, r_div) + CHECK_BB(gwi_oper_end(gwi, "+", FloatPlus)) + CHECK_BB(gwi_oper_end(gwi, "-", FloatMinus)) + CHECK_BB(gwi_oper_end(gwi, "*", FloatTimes)) + CHECK_BB(gwi_oper_end(gwi, "/", FloatDivide)) + CHECK_FF("=>", rassign, r_assign) + CHECK_FF("+=>", rassign, r_plus) + CHECK_FF("-=>", rassign, r_minus) + CHECK_FF("*=>", rassign, r_mul) + CHECK_FF("/=>", rassign, r_div) CHECK_BB(gwi_oper_ini(gwi, "float", "float", "int")) - CHECK_BB(gwi_oper_end(gwi, op_and, float_and)) - CHECK_BB(gwi_oper_end(gwi, op_or, float_or)) - CHECK_BB(gwi_oper_end(gwi, op_eq, float_eq)) - CHECK_BB(gwi_oper_end(gwi, op_ne, float_neq)) - CHECK_BB(gwi_oper_end(gwi, op_gt, float_gt)) - CHECK_BB(gwi_oper_end(gwi, op_ge, float_ge)) - CHECK_BB(gwi_oper_end(gwi, op_lt, float_lt)) - CHECK_BB(gwi_oper_end(gwi, op_le, float_le)) + CHECK_BB(gwi_oper_end(gwi, "&&", float_and)) + CHECK_BB(gwi_oper_end(gwi, "||", float_or)) + CHECK_BB(gwi_oper_end(gwi, "==", float_eq)) + CHECK_BB(gwi_oper_end(gwi, "!=", float_neq)) + CHECK_BB(gwi_oper_end(gwi, ">", float_gt)) + CHECK_BB(gwi_oper_end(gwi, ">=", float_ge)) + CHECK_BB(gwi_oper_end(gwi, "<", float_lt)) + CHECK_BB(gwi_oper_end(gwi, "<=", float_le)) CHECK_BB(gwi_oper_ini(gwi, NULL, "float", "float")) - CHECK_FF(sub, unary_meta, negate) + CHECK_FF("-", unary_meta, negate) CHECK_BB(gwi_oper_ini(gwi, NULL, "float", "int")) - CHECK_FF(not, unary_meta2_uniq, not) + CHECK_FF("!", unary_meta2_uniq, not) CHECK_BB(gwi_oper_ini(gwi, NULL, "time", "int")) - CHECK_FF(not, unary_meta2_uniq, not) + CHECK_FF("!", unary_meta2_uniq, not) CHECK_BB(gwi_oper_ini(gwi, NULL, "dur", "int")) - CHECK_FF(not, unary_meta2_uniq, not) + CHECK_FF("!", unary_meta2_uniq, 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_end(gwi, "::", int_float_mul)) CHECK_BB(gwi_oper_ini(gwi, "float", "dur", "dur")) - CHECK_BB(gwi_oper_end(gwi, op_coloncolon, FloatTimes)) + CHECK_BB(gwi_oper_end(gwi, "::", FloatTimes)) return GW_OK; } diff --git a/src/lib/ptr.c b/src/lib/ptr.c index f6e1fc42..ffe626ed 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -85,12 +85,12 @@ GWION_IMPORT(ptr) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Ptr", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_ptr_assign)) - CHECK_BB(gwi_oper_end(gwi, op_trig, instr_ptr_assign)) + CHECK_BB(gwi_oper_end(gwi, "]=>", instr_ptr_assign)) CHECK_BB(gwi_oper_add(gwi, opck_implicit_ptr)) - CHECK_BB(gwi_oper_end(gwi, op_impl, Cast2Ptr)) + CHECK_BB(gwi_oper_end(gwi, "@implicit", Cast2Ptr)) CHECK_BB(gwi_oper_ini(gwi, NULL, "Ptr", NULL)) CHECK_BB(gwi_oper_add(gwi, opck_ptr_deref)) CHECK_BB(gwi_oper_emi(gwi, opem_ptr_deref)) - CHECK_BB(gwi_oper_end(gwi, op_mul, instr_ptr_deref)) + CHECK_BB(gwi_oper_end(gwi, "*", instr_ptr_deref)) return GW_OK; } diff --git a/src/lib/string.c b/src/lib/string.c index 3426d745..578e7108 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -179,70 +179,70 @@ GWION_IMPORT(string) { CHECK_BB(gwi_oper_ini(gwi, "string", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, String_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", String_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "string", "string", "int")) - CHECK_BB(gwi_oper_end(gwi, op_eq, String_eq)) - CHECK_BB(gwi_oper_end(gwi, op_ne, String_neq)) + CHECK_BB(gwi_oper_end(gwi, "==", String_eq)) + CHECK_BB(gwi_oper_end(gwi, "!=", String_neq)) CHECK_BB(gwi_oper_ini(gwi, "int", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Int_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Int_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Int_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Int_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Int_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Int_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "float", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Float_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Float_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Float_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Float_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Float_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Float_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "complex", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Complex_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Complex_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Complex_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Complex_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Complex_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Complex_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "polar", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Polar_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Polar_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Polar_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Polar_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Polar_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Polar_String_Plus)) CHECK_BB(gwi_oper_ini(gwi,"Vec3", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Vec3_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec3_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Vec3_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec3_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Vec3_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Vec3_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "Vec4", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Vec4_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec4_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Vec4_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec4_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Vec4_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Vec4_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "Object", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Object_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Object_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Object_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Object_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Object_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Object_String_Plus)) CHECK_BB(gwi_oper_ini(gwi, "@null", "string", "string")) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Object_String_Assign)) - CHECK_BB(gwi_oper_end(gwi, op_add, Object_String)) + CHECK_BB(gwi_oper_end(gwi, "=>", Object_String_Assign)) + CHECK_BB(gwi_oper_end(gwi, "+", Object_String)) CHECK_BB(gwi_oper_add(gwi, opck_const_rhs)) - CHECK_BB(gwi_oper_end(gwi, op_radd, Object_String_Plus)) + CHECK_BB(gwi_oper_end(gwi, "+=>", Object_String_Plus)) gwi_item_ini(gwi, "string", "__func__"); gwi_item_end(gwi, ae_flag_const, NULL); diff --git a/src/lib/ugen.c b/src/lib/ugen.c index dc1cfdb6..582670f1 100644 --- a/src/lib/ugen.c +++ b/src/lib/ugen.c @@ -355,9 +355,9 @@ GWION_IMPORT(ugen) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "UGen", "UGen", "UGen")) - _CHECK_OP(chuck, chuck_ugen, UgenConnect) - _CHECK_OP(unchuck, chuck_ugen, UgenDisconnect) - _CHECK_OP(trig, chuck_ugen, TrigConnect) - _CHECK_OP(untrig, chuck_ugen, TrigDisconnect) + _CHECK_OP("=>", chuck_ugen, UgenConnect) + _CHECK_OP("=<", chuck_ugen, UgenDisconnect) + _CHECK_OP("]=>", chuck_ugen, TrigConnect) + _CHECK_OP("}=<", chuck_ugen, TrigDisconnect) return import_global_ugens(gwi); } diff --git a/src/lib/vararg.c b/src/lib/vararg.c index 67c3613b..b5c5cc2b 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -108,10 +108,10 @@ GWION_IMPORT(vararg) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "VarObject", "Object", NULL)) CHECK_BB(gwi_oper_add(gwi, at_varobj)) - CHECK_BB(gwi_oper_end(gwi, op_ref, VarargAssign)) + CHECK_BB(gwi_oper_end(gwi, "@=>", VarargAssign)) CHECK_BB(gwi_oper_ini(gwi, "Object", "VarObject", NULL)) CHECK_BB(gwi_oper_add(gwi, at_varobj)) - CHECK_BB(gwi_oper_end(gwi, op_ref, VarargAssign)) + CHECK_BB(gwi_oper_end(gwi, "@=>", VarargAssign)) register_freearg(gwi, VarargIni, freearg_vararg); gwi_reserve(gwi, "vararg"); return GW_OK; diff --git a/src/lib/vec.c b/src/lib/vec.c index 4b37423c..1bf4a484 100644 --- a/src/lib/vec.c +++ b/src/lib/vec.c @@ -197,22 +197,22 @@ GWION_IMPORT(vec3) { CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "Vec3", "Vec3", "Vec3")) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec3Add)) - CHECK_BB(gwi_oper_end(gwi, op_sub, Vec3Sub)) - CHECK_BB(gwi_oper_end(gwi, op_mul, Vec3Mul)) - CHECK_BB(gwi_oper_end(gwi, op_div, Vec3Div)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec3Add)) + CHECK_BB(gwi_oper_end(gwi, "-", Vec3Sub)) + CHECK_BB(gwi_oper_end(gwi, "*", Vec3Mul)) + CHECK_BB(gwi_oper_end(gwi, "/", Vec3Div)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Vec3RAssign)) + CHECK_BB(gwi_oper_end(gwi, "=>", Vec3RAssign)) CHECK_BB(gwi_oper_ini(gwi, "Vec3", "float", "Vec3")) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec3AddFloat)) - CHECK_BB(gwi_oper_end(gwi, op_sub, Vec3SubFloat)) - CHECK_BB(gwi_oper_end(gwi, op_mul, Vec3MulFloat)) - CHECK_BB(gwi_oper_end(gwi, op_div, Vec3DivFloat)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec3AddFloat)) + CHECK_BB(gwi_oper_end(gwi, "-", Vec3SubFloat)) + CHECK_BB(gwi_oper_end(gwi, "*", Vec3MulFloat)) + CHECK_BB(gwi_oper_end(gwi, "/", Vec3DivFloat)) CHECK_BB(gwi_oper_ini(gwi, "float", "Vec3", "Vec3")) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatAddVec3)) - CHECK_BB(gwi_oper_end(gwi, op_sub, FloatSubVec3)) - CHECK_BB(gwi_oper_end(gwi, op_mul, FloatMulVec3)) - CHECK_BB(gwi_oper_end(gwi, op_div, FloatDivVec3)) + CHECK_BB(gwi_oper_end(gwi, "+", FloatAddVec3)) + CHECK_BB(gwi_oper_end(gwi, "-", FloatSubVec3)) + CHECK_BB(gwi_oper_end(gwi, "*", FloatMulVec3)) + CHECK_BB(gwi_oper_end(gwi, "/", FloatDivVec3)) return GW_OK; } @@ -315,20 +315,20 @@ GWION_IMPORT(vec4) { CHECK_BB(gwi_func_end(gwi, 0)) CHECK_BB(gwi_class_end(gwi)) CHECK_BB(gwi_oper_ini(gwi, "Vec4", "Vec4", "Vec4")) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec4Add)) - CHECK_BB(gwi_oper_end(gwi, op_sub, Vec4Sub)) - CHECK_BB(gwi_oper_end(gwi, op_mul, Vec4Mul)) - CHECK_BB(gwi_oper_end(gwi, op_div, Vec4Div)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec4Add)) + CHECK_BB(gwi_oper_end(gwi, "-", Vec4Sub)) + CHECK_BB(gwi_oper_end(gwi, "*", Vec4Mul)) + CHECK_BB(gwi_oper_end(gwi, "/", Vec4Div)) CHECK_BB(gwi_oper_add(gwi, opck_rassign)) - CHECK_BB(gwi_oper_end(gwi, op_chuck, Vec4RAssign)) + CHECK_BB(gwi_oper_end(gwi, "=>", Vec4RAssign)) CHECK_BB(gwi_oper_ini(gwi, "Vec4", "float", "Vec4")) - CHECK_BB(gwi_oper_end(gwi, op_add, Vec4AddFloat)) - CHECK_BB(gwi_oper_end(gwi, op_sub, Vec4SubFloat)) - CHECK_BB(gwi_oper_end(gwi, op_mul, Vec4MulFloat)) - CHECK_BB(gwi_oper_end(gwi, op_div, Vec4DivFloat)) + CHECK_BB(gwi_oper_end(gwi, "+", Vec4AddFloat)) + CHECK_BB(gwi_oper_end(gwi, "-", Vec4SubFloat)) + CHECK_BB(gwi_oper_end(gwi, "*", Vec4MulFloat)) + CHECK_BB(gwi_oper_end(gwi, "/", Vec4DivFloat)) CHECK_BB(gwi_oper_ini(gwi, "float", "Vec4", "Vec4")) - CHECK_BB(gwi_oper_end(gwi, op_add, FloatAddVec4)) - CHECK_BB(gwi_oper_end(gwi, op_sub, FloatSubVec4)) - CHECK_BB(gwi_oper_end(gwi, op_mul, FloatMulVec4)) - return (m_bool)gwi_oper_end(gwi, op_div, FloatDivVec4); + CHECK_BB(gwi_oper_end(gwi, "+", FloatAddVec4)) + CHECK_BB(gwi_oper_end(gwi, "-", FloatSubVec4)) + CHECK_BB(gwi_oper_end(gwi, "*", FloatMulVec4)) + return (m_bool)gwi_oper_end(gwi, "/", FloatDivVec4); } diff --git a/src/parse/check.c b/src/parse/check.c index 1f860e96..e9e1b89d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -348,7 +348,7 @@ ANN static m_bool func_match_inner(const Env env, const Exp e, const Type t, } if(implicit) { const struct Implicit imp = { e, t }; - struct Op_Import opi = { .op=op_impl, .lhs=e->type, .rhs=t, .data=(m_uint)&imp, .pos=e->pos }; + struct Op_Import opi = { .op=insert_symbol("@implicit"), .lhs=e->type, .rhs=t, .data=(m_uint)&imp, .pos=e->pos }; return op_check(env, &opi) ? 1 : -1; } } @@ -660,7 +660,7 @@ ANN Type check_exp_call1(const Env env, const Exp_Call *exp) { } ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { - if(bin->lhs->exp_type == ae_exp_unary && bin->lhs->d.exp_unary.op == op_fork && + if(bin->lhs->exp_type == ae_exp_unary && bin->lhs->d.exp_unary.op == insert_symbol("fork") && bin->rhs->exp_type == ae_exp_decl) bin->lhs->d.exp_unary.fork_ok = 1; CHECK_OO(check_exp(env, bin->lhs)) @@ -675,7 +675,7 @@ ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) { DECL_OO(const Type, t, = check_exp(env, cast->exp)) CHECK_OO((exp_self(cast)->type = cast->td->xid ? known_type(env, cast->td) : check_td(env, cast->td))) - struct Op_Import opi = { .op=op_cast, .lhs=t, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast, .pos=exp_self(cast)->pos }; + struct Op_Import opi = { .op=insert_symbol("$"), .lhs=t, .rhs=exp_self(cast)->type, .data=(uintptr_t)cast, .pos=exp_self(cast)->pos }; return op_check(env, &opi); } @@ -1129,8 +1129,7 @@ ANN static void operator_func(const Func f) { const m_bool is_unary = GET_FLAG(f->def, unary); const Type l = is_unary ? NULL : a->type; const Type r = is_unary ? a->type : a->next ? a->next->type : NULL; - const Operator op = name2op(s_name(f->def->base->xid)); - struct Op_Import opi = { .op=op, .lhs=l, .rhs=r, .data=(m_uint)f, .pos=f->def->pos }; + struct Op_Import opi = { .op=f->def->base->xid, .lhs=l, .rhs=r, .data=(m_uint)f, .pos=f->def->pos }; operator_set_func(&opi); } diff --git a/src/parse/operator.c b/src/parse/operator.c index c73f5142..6dd1bfdf 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -100,9 +100,10 @@ ANN static m_bool _op_exist(const struct OpChecker* ock, const Nspc n) { const Vector v = (Vector)map_get(&n->info->op_map, (vtype)ock->opi->op); if(!v || !operator_find(v, ock->opi->lhs, ock->opi->rhs)) return GW_OK; - env_err(ock->env, ock->opi->pos, _("operator '%s', for type '%s' and '%s' already imported"), - op2str(ock->opi->op), ock->opi->lhs ? ock->opi->lhs->name : NULL, - ock->opi->rhs ? ock->opi->rhs->name : NULL); +// TODO: get me back +// env_err(ock->env, ock->opi->pos, _("operator '%s', for type '%s' and '%s' already imported"), +// s_name(ock->opi->op), ock->opi->lhs ? ock->opi->lhs->name : NULL, +// ock->opi->rhs ? ock->opi->rhs->name : NULL); return GW_ERROR; } @@ -125,17 +126,17 @@ ANN m_bool add_op(const Gwion gwion, const struct Op_Import* opi) { return GW_OK; } -ANN static void set_nspc(struct Op_Import* opi, const Nspc nspc) { - if(opi->op == op_impl)return; - if(opi->op == op_cast) - ((Exp_Cast*)opi->data)->nspc = nspc; - if(opi->lhs) { - if(opi->rhs) - ((Exp_Binary*)opi->data)->nspc = nspc; +ANN static void set_nspc(struct OpChecker* ock, const Nspc nspc) { + if(ock->opi->op == insert_symbol(ock->env->gwion->st, "@implicit"))return; + if(ock->opi->op == insert_symbol(ock->env->gwion->st, "$")) + ((Exp_Cast*)ock->opi->data)->nspc = nspc; + if(ock->opi->lhs) { + if(ock->opi->rhs) + ((Exp_Binary*)ock->opi->data)->nspc = nspc; else - ((Exp_Postfix*)opi->data)->nspc = nspc; + ((Exp_Postfix*)ock->opi->data)->nspc = nspc; } else - ((Exp_Unary*)opi->data)->nspc = nspc; + ((Exp_Unary*)ock->opi->data)->nspc = nspc; } ANN static Type op_check_inner(struct OpChecker* ock) { @@ -171,22 +172,23 @@ ANN Type op_check(const Env env, struct Op_Import* opi) { if(ret == t_null) break; if(!ock.mut) - set_nspc(opi, nspc); + set_nspc(&ock, nspc);// TODO check me return ret; } } while(l && (l = op_parent(env, l))); } nspc = nspc->parent; } while(nspc); - if(opi->op == op_cast || (ret != t_null && opi->op != op_impl)) + if(opi->op == insert_symbol(env->gwion->st, "$") || + (ret != t_null && opi->op != insert_symbol(env->gwion->st, "@implicit"))) env_err(env, opi->pos, _("%s %s %s: no match found for operator"), - type_name(opi->lhs), op2str(opi->op), type_name(opi->rhs)); + type_name(opi->lhs), s_name(opi->op), type_name(opi->rhs)); return NULL; } ANN m_bool operator_set_func(const struct Op_Import* opi) { const Nspc nspc = ((Func)opi->data)->value_ref->owner; - const Vector v = (Vector)map_get(&nspc->info->op_map, opi->op); + const Vector v = (Vector)map_get(&nspc->info->op_map, (vtype)opi->op); DECL_OB(M_Operator*, mo, = operator_find(v, opi->lhs, opi->rhs)) mo->func = (Func)opi->data; return GW_OK; @@ -202,10 +204,10 @@ ANN static m_bool handle_instr(const Emitter emit, const M_Operator* mo) { return GW_OK; } -ANN static Nspc get_nspc(const struct Op_Import* opi) { - if(opi->op == op_impl) +ANN static Nspc get_nspc(SymTable *st, const struct Op_Import* opi) { + if(opi->op == insert_symbol(st, "@implicit")) return opi->rhs->e->owner; - if(opi->op == op_cast) + if(opi->op == insert_symbol(st, "$")) return ((Exp_Cast*)opi->data)->nspc; if(opi->lhs) { if(opi->rhs) @@ -217,7 +219,7 @@ ANN static Nspc get_nspc(const struct Op_Import* opi) { } ANN m_bool op_emit(const Emitter emit, const struct Op_Import* opi) { - Nspc nspc = get_nspc(opi); + Nspc nspc = get_nspc(emit->gwion->st, opi); do { Type l = opi->lhs; do { diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 8730b02a..9eb17791 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -146,7 +146,7 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix* post) { if(post->exp->meta == ae_meta_var) return GW_OK; ERR_B(post->exp->pos, _("post operator '%s' cannot be used" - " on non-mutable data-type..."), op2str(post->op)); + " on non-mutable data-type..."), s_name(post->op)); } ANN static m_bool scan1_exp_call(const Env env, const Exp_Call* exp_call) { @@ -168,7 +168,7 @@ ANN static m_bool scan1_exp_if(const Env env, const Exp_If* exp_if) { } ANN static inline m_bool scan1_exp_unary(const restrict Env env, const Exp_Unary *unary) { - if((unary->op == op_spork || unary->op == op_fork) && unary->code) + if((unary->op == insert_symbol("spork") || unary->op == insert_symbol("fork")) && unary->code) { RET_NSPC(scan1_stmt(env, unary->code)) } return unary->exp ? scan1_exp(env, unary->exp) : GW_OK; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 576ac8a9..b4593d14 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -155,10 +155,10 @@ ANN static inline m_bool scan2_exp_array(const Env env, const Exp_Array* array) } -ANN static m_bool multi_decl(const Env env, const Exp e, const Operator op) { +ANN static m_bool multi_decl(const Env env, const Exp e, const Symbol op) { if(e->exp_type == ae_exp_decl) { if(e->d.exp_decl.list->next) - ERR_B(e->pos, _("cant '%s' from/to a multi-variable declaration."), op2str(op)) + ERR_B(e->pos, _("cant '%s' from/to a multi-variable declaration."), s_name(op)) SET_FLAG(e->d.exp_decl.list->self->value, used); } return GW_OK; @@ -200,7 +200,7 @@ ANN static inline m_bool scan2_exp_if(const Env env, const Exp_If* exp_if) { } ANN static m_bool scan2_exp_unary(const Env env, const Exp_Unary * unary) { - if((unary->op == op_spork || unary->op == op_fork) && unary->code) { + if((unary->op == insert_symbol("spork") || unary->op == insert_symbol("fork")) && unary->code) { RET_NSPC(scan2_stmt(env, unary->code)) } else if(unary->exp) return scan2_exp(env, unary->exp); @@ -406,12 +406,11 @@ ANN static m_bool scan2_func_def_builtin(MemPool p, const Func func, const m_str ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { assert(f->base->args); - const Operator op = name2op(s_name(f->base->xid)); const Type l = GET_FLAG(f, unary) ? NULL : f->base->args->var_decl->value->type; const Type r = GET_FLAG(f, unary) ? f->base->args->var_decl->value->type : f->base->args->next ? f->base->args->next->var_decl->value->type : NULL; - struct Op_Import opi = { .op=op, .lhs=l, .rhs=r, .ret=f->base->ret_type, .pos=f->pos }; + struct Op_Import opi = { .op=f->base->xid, .lhs=l, .rhs=r, .ret=f->base->ret_type, .pos=f->pos }; CHECK_BB(add_op(env->gwion, &opi)) return GW_OK; } diff --git a/util b/util index 5e175eff..dc6040ef 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 5e175eff5cc60ef509ede0378891850feee1cc13 +Subproject commit dc6040ef47f0e9b03c3a2d4dbf4c551c54a299eb -- 2.43.0