From: Jérémie Astor Date: Mon, 14 Dec 2020 23:44:20 +0000 (+0100) Subject: :art: Rename ref to late X-Git-Tag: nightly~1105^2~20 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a94e13bcde0f1d572e93fed0db9e558925454f40;p=gwion.git :art: Rename ref to late --- diff --git a/ast b/ast index 1f57eb48..76ba5628 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 1f57eb48c6eb8b0379b3d232cb7f3fe1ccf90d67 +Subproject commit 76ba56280e16bbef295c8496a50d079cce7fa1f9 diff --git a/examples/class_spork_exp.gw b/examples/class_spork_exp.gw index f37727a5..efd42f18 100644 --- a/examples/class_spork_exp.gw +++ b/examples/class_spork_exp.gw @@ -7,7 +7,7 @@ class C second => now; var string s; <<< "test spork exp." >>>; - } @=> ref Shred shred; + } @=> var Shred shred; } var C c; diff --git a/examples/empty_string.gw b/examples/empty_string.gw index f89e3245..7ac5532f 100644 --- a/examples/empty_string.gw +++ b/examples/empty_string.gw @@ -1,2 +1,2 @@ -"test" => ref string s; +"test" @=> var string s; <<< s >>>; diff --git a/examples/in_class_class.gw b/examples/in_class_class.gw index 6b4fe396..7505dfd1 100644 --- a/examples/in_class_class.gw +++ b/examples/in_class_class.gw @@ -5,6 +5,6 @@ class C { var C c; var C.D d; -ref C.D d_ref; +late C.D d_ref; <<< c, " ", d, d_ref >>>; diff --git a/examples/op.gw b/examples/op.gw index f6a264b0..f16849bf 100644 --- a/examples/op.gw +++ b/examples/op.gw @@ -5,7 +5,7 @@ operator void => (Object o, int i) { } class C { - ref Object ref_object; + late Object ref_object; } #!! assign object to C.ref diff --git a/examples/spork_exp.gw b/examples/spork_exp.gw index 5da1b739..13d513a0 100644 --- a/examples/spork_exp.gw +++ b/examples/spork_exp.gw @@ -9,7 +9,7 @@ class C var string s; <<< this, " test spork exp. " , s >>>; - } @=> ref Shred shred; + } @=> var Shred shred; } var C c; diff --git a/include/operator.h b/include/operator.h index f44f404f..e66dd362 100644 --- a/include/operator.h +++ b/include/operator.h @@ -66,8 +66,8 @@ ANN static inline void operator_resume(struct Op_Import *opi) { ANN static inline void set_decl_ref(const Exp e) { if(e->exp_type == ae_exp_decl) { - SET_FLAG(e->d.exp_decl.td, ref); - SET_FLAG(e->d.exp_decl.list->self->value, ref); + SET_FLAG(e->d.exp_decl.td, late); + SET_FLAG(e->d.exp_decl.list->self->value, late); } } diff --git a/src/emit/emit.c b/src/emit/emit.c index af1d0e7a..a845a8f4 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -486,7 +486,7 @@ ANN static void struct_addref(const Emitter emit, const Type type, ANN2(1) static void emit_exp_addref1(const Emitter emit, /* const */Exp exp, m_int size) { if(isa(exp->info->type, emit->gwion->type[et_object]) > 0 && (exp->info->cast_to ? isa(exp->info->cast_to, emit->gwion->type[et_object]) > 0 : 1)) { - if(exp->exp_type == ae_exp_decl && GET_FLAG(exp->d.exp_decl.td, ref) && !exp_getvar(exp)) { + if(exp->exp_type == ae_exp_decl && GET_FLAG(exp->d.exp_decl.td, late) && !exp_getvar(exp)) { const Instr instr = emit_add_instr(emit, GWOP_EXCEPT); instr->m_val = size; } @@ -775,7 +775,7 @@ ANN static m_bool emit_exp_decl_non_static(const Emitter emit, const Exp_Decl *d if(!vflag(v, vflag_member)) { v->from->offset = emit_local(emit, type); exec = (f_instr*)(allocword); - if(GET_FLAG(decl->td, ref)) { // ref or emit_var ? + if(GET_FLAG(decl->td, late)) { // ref or emit_var ? const Instr clean = emit_add_instr(emit, MemSetImm); clean->m_val = v->from->offset; } @@ -850,7 +850,7 @@ ANN static inline m_bool ensure_emit(const Emitter emit, const Type t) { ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) { const m_bool global = GET_FLAG(decl->td, global); const uint var = exp_getvar(exp_self(decl)); - const uint ref = GET_FLAG(decl->td, ref) || type_ref(decl->type); + const uint ref = GET_FLAG(decl->td, late) || type_ref(decl->type); Var_Decl_List list = decl->list; do { if(GET_FLAG(decl->td, static)) diff --git a/src/lib/array.c b/src/lib/array.c index 775fef1e..461e9c38 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -159,7 +159,7 @@ static OP_CHECK(opck_array_at) { ERR_N(exp_self(bin)->pos, _("array depths do not match.")) } if(bin->rhs->exp_type == ae_exp_decl) { - SET_FLAG(bin->rhs->d.exp_decl.td, ref); + SET_FLAG(bin->rhs->d.exp_decl.td, late);// ??? if(bin->rhs->d.exp_decl.list->self->array && bin->rhs->d.exp_decl.list->self->array->exp) ERR_N(exp_self(bin)->pos, _("do not provide array for 'xxx @=> declaration'.")) diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 01c6e4c7..3ee96890 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -34,7 +34,7 @@ static OP_CHECK(at_object) { if(opck_rassign(env, data, mut) == env->gwion->type[et_error]) return env->gwion->type[et_error]; if(bin->rhs->exp_type == ae_exp_decl) - SET_FLAG(bin->rhs->d.exp_decl.td, ref); + SET_FLAG(bin->rhs->d.exp_decl.td, late); // ??? exp_setvar(bin->rhs, 1); CHECK_BO(isa(bin->lhs->info->type , bin->rhs->info->type)) return bin->rhs->info->type; @@ -204,7 +204,7 @@ OP_EMIT(opem_object_dot) { const Instr instr = emit_add_instr(emit, RegPushImm); instr->m_val = (m_uint)value->type; } - if(GET_FLAG(value, ref)) { + if(GET_FLAG(value, late)) { const Instr instr = emit_add_instr(emit, GWOP_EXCEPT); instr->m_val = -SZ_INT; } diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index baa7462a..3050f9cb 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -83,7 +83,7 @@ ANN static inline Type check_new_td(const Env env, Type_Decl *td) { OP_CHECK(opck_new) { const Exp_Unary* unary = (Exp_Unary*)data; - SET_FLAG(unary->td, ref); + SET_FLAG(unary->td, late); DECL_ON(const Type, t, = check_new_td(env, unary->td)) if(isa(t, env->gwion->type[et_object]) < 0) ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n")) @@ -91,7 +91,7 @@ OP_CHECK(opck_new) { ERR_N(td_pos(unary->td), _("can't use 'new' on ref type '%s'\n"), t->name) if(GET_FLAG(t, abstract)) ERR_N(td_pos(unary->td), _("can't use 'new' on abstract type '%s'\n"), t->name) - UNSET_FLAG(unary->td, ref); + UNSET_FLAG(unary->td, late); if(unary->td->array) CHECK_BN(check_subscripts(env, unary->td->array, 1)) return t; @@ -100,6 +100,6 @@ OP_CHECK(opck_new) { OP_EMIT(opem_new) { const Exp_Unary* unary = (Exp_Unary*)data; CHECK_BO(emit_instantiate_object(emit, exp_self(unary)->info->type, - unary->td->array, GET_FLAG(unary->td, ref))) + unary->td->array, GET_FLAG(unary->td, late))) return emit_gc(emit, -SZ_INT); } diff --git a/src/parse/check.c b/src/parse/check.c index 47e57669..f8edca49 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -122,11 +122,11 @@ ANN static m_bool check_var_td(const Env env, const Var_Decl var, Type_Decl *con ANN static void set_late(const Gwion gwion, const Exp_Decl *decl, const Value v) { if(!exp_getvar(exp_self(decl)) && - (GET_FLAG(decl->td, ref) || is_fptr(gwion, v->type))) { - SET_FLAG(decl->td, ref); - SET_FLAG(v, ref); + (GET_FLAG(decl->td, late) || is_fptr(gwion, v->type))) { + SET_FLAG(decl->td, late); + SET_FLAG(v, late); } else - UNSET_FLAG(v, ref); + UNSET_FLAG(v, late); } ANN static m_bool check_decl(const Env env, const Exp_Decl *decl) { @@ -173,7 +173,7 @@ ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) { if(!decl->td->xid) return no_xid(env, decl); if(decl->td->xid == insert_symbol("auto")) { // should be better - SET_FLAG(decl->td, ref); + SET_FLAG(decl->td, late); CHECK_BO(scan1_exp(env, exp_self(decl))) CHECK_BO(scan2_exp(env, exp_self(decl))) } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 0d78487b..13567187 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -35,7 +35,7 @@ ANN static inline m_bool ensure_scan1(const Env env, const Type t) { ANN static Type scan1_type(const Env env, Type_Decl* td) { DECL_OO(const Type, type, = known_type(env, td)) const Type t = get_type(type); - if(!env->func && env->class_def && !GET_FLAG(td, ref)) + if(!env->func && env->class_def && !GET_FLAG(td, late)) CHECK_BO(type_cyclic(env, t, td)) CHECK_BO(ensure_scan1(env, t)) return type; @@ -85,10 +85,10 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { if(var->array->exp) CHECK_BB(scan1_exp(env, var->array->exp)) t = array_type(env, decl->type, var->array->depth); - } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, ref)) { + } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late)) { if(!(t == env->class_def && env->scope->depth)) { if(decl->td->xid == insert_symbol("auto")) - SET_FLAG(decl->td, ref); + SET_FLAG(decl->td, late); else ERR_B(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name) } @@ -105,7 +105,7 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { v->flag |= decl->td->flag; v->type = t; if(array_ref(var->array)) - SET_FLAG(decl->td, ref); + SET_FLAG(decl->td, late); if(env->class_def) { if(env->class_def->info->tuple) tuple_contains(env, v); @@ -131,7 +131,7 @@ ANN m_bool scan1_exp_decl(const Env env, const Exp_Decl* decl) { CHECK_BB(env_storage(env, decl->td->flag, exp_self(decl)->pos)) ((Exp_Decl*)decl)->type = scan1_exp_decl_type(env, (Exp_Decl*)decl); if(array_ref(decl->td->array)) - SET_FLAG(decl->td, ref); + SET_FLAG(decl->td, late); CHECK_OB(decl->type) const m_bool global = GET_FLAG(decl->td, global); if(global) { diff --git a/tests/bug/play_with_str.gw b/tests/bug/play_with_str.gw index 4e5619e8..0dd00278 100644 --- a/tests/bug/play_with_str.gw +++ b/tests/bug/play_with_str.gw @@ -1,4 +1,4 @@ -"lol" @=> ref string s; +"lol" @=> var string s; "test" => s; <<< "testmem".replace(2, 3, "UKUH") >>>; diff --git a/tests/error/UgenConnectException.gw b/tests/error/UgenConnectException.gw index 0f4cef66..75ca2dcb 100644 --- a/tests/error/UgenConnectException.gw +++ b/tests/error/UgenConnectException.gw @@ -1 +1 @@ -ref Gain g => dac; +late Gain g => dac; diff --git a/tests/fork/fork.gw b/tests/fork/fork.gw index 2b3ba86b..7bc937ac 100644 --- a/tests/fork/fork.gw +++ b/tests/fork/fork.gw @@ -3,7 +3,7 @@ fork { 12::samp => now; me.test_cancel(); <<< "stop" >>>; -} @=> ref Fork f; +} @=> var Fork f; 1 => f.set_cancel; 2::samp => now; diff --git a/tests/fork/fork_call.gw b/tests/fork/fork_call.gw index 0178f879..5a121c1b 100644 --- a/tests/fork/fork_call.gw +++ b/tests/fork/fork_call.gw @@ -2,7 +2,7 @@ fun int test() { return 12; } -fork test() @=> ref auto sh; +fork test() @=> var auto sh; <<< typeof(sh) >>>; sh.ev => now; <<< sh.retval >>>; diff --git a/tests/fork/fork_join.gw b/tests/fork/fork_join.gw index ad332af1..699826e3 100644 --- a/tests/fork/fork_join.gw +++ b/tests/fork/fork_join.gw @@ -1,3 +1,3 @@ -fork { <<< __func__ >>>; } @=> ref Fork f; +fork { <<< __func__ >>>; } @=> var Fork f; second => now; f.join(); diff --git a/tests/fork/fork_join2.gw b/tests/fork/fork_join2.gw index 146014e2..c8e1bd71 100644 --- a/tests/fork/fork_join2.gw +++ b/tests/fork/fork_join2.gw @@ -1,2 +1,2 @@ -fork { <<< __func__ >>>; minute => now; } @=> ref Fork f; +fork { <<< __func__ >>>; minute => now; } @=> var Fork f; f.join(); diff --git a/tests/new/vararg_cpy.gw b/tests/new/vararg_cpy.gw index 6a2dc204..66f04212 100644 --- a/tests/new/vararg_cpy.gw +++ b/tests/new/vararg_cpy.gw @@ -1,5 +1,5 @@ fun void test(...) { <<< vararg >>>; - <<< vararg.cpy() @=> ref Vararg new_arg >>>; + <<< vararg.cpy() @=> var Vararg new_arg >>>; } test(1); diff --git a/tests/tree/class_multi_ref_decl.gw b/tests/tree/class_multi_ref_decl.gw index 034eefcf..3e5d394a 100644 --- a/tests/tree/class_multi_ref_decl.gw +++ b/tests/tree/class_multi_ref_decl.gw @@ -1,4 +1,4 @@ class C { - ref Object i, a; + late Object i, a; } diff --git a/tests/tree/class_simple_ref_decl.gw b/tests/tree/class_simple_ref_decl.gw index bf354947..1e03df44 100644 --- a/tests/tree/class_simple_ref_decl.gw +++ b/tests/tree/class_simple_ref_decl.gw @@ -1,4 +1,4 @@ class C { - ref Object o; + late Object o; } diff --git a/tests/tree/multi_ref_decl.gw b/tests/tree/multi_ref_decl.gw index dfd21404..f00f3853 100644 --- a/tests/tree/multi_ref_decl.gw +++ b/tests/tree/multi_ref_decl.gw @@ -1,2 +1,2 @@ -ref Object i, a; +late Object i, a; <<< i, a >>>; diff --git a/tests/tree/new.gw b/tests/tree/new.gw index 38ff83ae..f46ee7c9 100644 --- a/tests/tree/new.gw +++ b/tests/tree/new.gw @@ -2,6 +2,6 @@ new Object; new Object @=> var Object refref; new Event; var Event ev; -ev @=> ref Event e; +ev @=> var Event e; new Event @=> e; ev @=> e; diff --git a/tests/tree/shredule_test.gw b/tests/tree/shredule_test.gw index 4ceb10c4..09458f0d 100644 --- a/tests/tree/shredule_test.gw +++ b/tests/tree/shredule_test.gw @@ -2,8 +2,8 @@ var Event e; spork { e => now; }; spork { samp => now; 4::samp => now;}; -spork { 5::samp => now;} @=> ref Shred s; -spork { samp => now; 4::samp => now; } @=> ref Shred t; +spork { 5::samp => now;} @=> var Shred s; +spork { samp => now; 4::samp => now; } @=> var Shred t; spork { 2::samp => now; me.exit(); }; spork { new Object; <<< "garbage collect me" >>>; 3::samp => now; }; 2::samp => now; diff --git a/tests/tree/simple_ref_decl.gw b/tests/tree/simple_ref_decl.gw index 921df645..50cbf072 100644 --- a/tests/tree/simple_ref_decl.gw +++ b/tests/tree/simple_ref_decl.gw @@ -1,2 +1,2 @@ -ref Object o; +late Object o; <<< o >>>;