]> Nishi Git Mirror - gwion.git/commitdiff
:art: Manually merge Fix branch
authorfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 14 Dec 2018 00:24:00 +0000 (01:24 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 14 Dec 2018 00:24:00 +0000 (01:24 +0100)
34 files changed:
.travis.yml
examples/array_lit.gw
examples/class.gw
examples/class_enum.gw
examples/class_spork_exp.gw
examples/complex/event.gw
examples/decl.gw
examples/dtor.gw
examples/in_class_class.gw
examples/typeof.gw
examples/union.gw
include/emit.h
src/emit/emit.c
tests/bug/float2.gw
tests/bug/object_string.gw
tests/error/decl_res.gw
tests/error/no_cast.gw
tests/error/union_object_ref.gw
tests/fptr/class_ptr3.gw
tests/tree/array_empty.gw
tests/tree/ast_doc.gw
tests/tree/auto_ptr.gw
tests/tree/cast_test.gw
tests/tree/fptr_class.gw
tests/tree/gc1.gw
tests/tree/multi_decl.gw
tests/tree/multi_ref_decl.gw
tests/tree/named_union_private_static.gw
tests/tree/object_func.gw
tests/tree/private_access.gw
tests/tree/private_func.gw
tests/tree/simple_decl.gw
tests/tree/simple_ref_decl.gw
tests/tree/template_class_ref.gw

index d5dda08029d29cfb1cc0c1058f2f7aa28ab88e88..c450fe2b6ff23d099cf698d63b53d6f6b2e186f8 100644 (file)
@@ -1,6 +1,5 @@
-dist: xenial
 language: c
-#sudo: required
+sudo: required
 os:
   - linux
   - osx
@@ -16,12 +15,12 @@ addons:
   apt:
     sources:
     - ubuntu-toolchain-r-test
-#    - llvm-toolchain-trusty-7.0
+    - llvm-toolchain-trusty-6.0
     packages:
     - valgrind
     - lcov
     - gcc-8
-#    - clang-7.0
+    - clang-6.0
 env:
   global:
   - CC_TEST_REPORTER_ID=1ef7168aff2b8902922b345c8b1b9be3fd2442fa4f2096634b42235bcbaa2c47
@@ -36,9 +35,9 @@ env:
 matrix:
   fast_finish: true
   allow_failures:
-    - os: osx
-    - compiler: gcc
-    - env: USE_DOUBLE=1
+   - os: osx
+   - compiler: clang
+
 compiler:
   - gcc
   - clang
@@ -46,10 +45,10 @@ compiler:
 install:
 - if [ $TRAVIS_JOB_NUMBER = ${TRAVIS_BUILD_NUMBER}.1  ]; then gem install coveralls-lcov; fi
 
-#      elif [ $CC = clang ]; then export CC=clang-7.0;
 before_script:
   - if [ $(uname) = Linux ]; then
       if [ $CC = gcc ]; then export CC=gcc-8;
+      elif [ $CC = clang ]; then export CC=clang-6.0;
       fi;
     fi;
   - git submodule update --init util ast
index c0ee67798193421992c14a276a80555c8cf7a95d..2c18fce61af30428cb5f2fb2f3e31731c1fcaf93 100644 (file)
@@ -12,6 +12,8 @@ Object t[2][12][3][4][5];
 int k[1][1];
 
 
+<<<i, j, o, p, r, q, s, t, k>>>;
+
 [ 1.0, 2, 3, 4, 5 ];
 [ #(0.0, 0.0) ];
 [ @(0.0, 0.0, 0.0) ];
index fc5ff090632920f90458e9404d192960c1dc1ae5..cd171521a6a63418d29940916519a4d3659fa00f 100644 (file)
@@ -5,3 +5,4 @@ class C
 }
 
 C c;
+<<<c>>>;
index 492fb6a9a0582a5a7ccbf584d7a665b42fc3ad7f..de47bbbe0a93300467bcd54ba8e92c39f8ecb857 100644 (file)
@@ -8,3 +8,4 @@ class C {
   <<<zero, " ", one, " ", two, " ", three>>>;
 }
 C c;
+<<<c>>>;
index 9ed4f1be2adae6e4029b9edfb03e546b818ec06b..1b539b07842d8aeaa81cb4fb4273582c90d91d9e 100644 (file)
@@ -11,5 +11,6 @@ class C
 }
 
 C c;
+<<<c>>>;
 me.yield();
 second => now;
index 35e1c0340d20ec060d22c900b01119a99810ed65..ab60daea8cb859ab69b142115605b863a75e4962 100644 (file)
@@ -1,5 +1,5 @@
 Event e;
-//spork {second => now; e.broadcast(); };
+spork {second => now; e.broadcast(); };
 //2::second => now;
 .2::second => now;
-//e => now;
+e => now;
index 048f715b4656f388eaeddede94b3808a59a3a95e..271009cb226ceaa7c0eff2f8b9e14d6ae1d0cf02 100644 (file)
@@ -1 +1,2 @@
 int i;
+<<<i>>>;
index c349e4912b9aa5386dd796e1f2621b1520f04412..61bb92d2709a2112fec69000f49a4374005d4183 100644 (file)
@@ -7,3 +7,4 @@ C c;
 C d;
 //me.yield();
 <<<"end of dtor test.">>>;
+<<<c," ", d>>>;
index f8e815c065f99d58641a0bf0b467639f01f390a2..734d74061b890776f55d7e8c29b740e4d3b15d19 100644 (file)
@@ -9,4 +9,4 @@ C c;
 <C.D> d;
 <C.D> @d_ref;
 
-<<< c, " ", d >>>;
+<<< c, " ", d, d_ref >>>;
index 8bad5c0d8f553b96f9c0f1cb34986a6c3edb7108..b4c5593f8cead8873f75cdf10047b5bd3075eea1 100644 (file)
@@ -15,3 +15,4 @@ C c;
 typeof(c.f) d;
 <<<d>>>;
 
+<<<i," ", c>>>;
index 67a3b72b84e4e2efdfcc14d6abc636fb24f990fa..3cbdefb65fe638f94975b355542d95ffd468b63b 100644 (file)
@@ -4,3 +4,4 @@ union
        Object @ o;
 
 };
+<<<i, " ", o>>>;
index 2c83dacab90f64b35bf294f135b4b15cf45f1549..cfa84658cab23d2060ebfacd8887d69e66918982 100644 (file)
@@ -26,7 +26,7 @@ ANN void free_emitter(Emitter);
 ANEW ANN VM_Code emit_code(const Emitter);
 ANN VM_Code emit_ast(const Emitter emit, Ast ast);
 ANN m_bool emit_exp_call1(const Emitter, const Func);
-ANEW ANN2(1) Instr emit_add_instr(const Emitter, const f_instr);
+ANN2(1) Instr emit_add_instr(const Emitter, const f_instr) __attribute__((returns_nonnull));
 ANN Code* emit_class_code(const Emitter, const m_str);
 ANN m_bool emit_array_extend(const Emitter, const Type, const Exp);
 ANN void emit_class_finish(const Emitter, const Nspc);
index 6032eca0671af72f00219623f3982333fa8c9dac..25d6203efc3a690bea9832b4d57c2734b3a530b1 100644 (file)
@@ -92,7 +92,8 @@ ANN void free_emitter(Emitter a) {
   xfree(a);
 }
 
-ANEW ANN2(1) Instr emit_add_instr(const Emitter emit, const f_instr f) {
+__attribute__((returns_nonnull))
+ANN2(1) Instr emit_add_instr(const Emitter emit, const f_instr f) {
   const Instr instr = mp_alloc(Instr);
   instr->execute = f;
   vector_add(&emit->code->instr, (vtype)instr);
@@ -253,11 +254,12 @@ static const f_instr dotmember[]  = { DotMember, DotMember2, DotMember3, DotMemb
 static const f_instr allocmember[]  = { PushNull, PushNull2, PushNull3, AllocMember4 };
 static const f_instr allocword[]  = { AllocWord, AllocWord2, AllocWord3, AllocWord4 };
 
-ANN static m_bool emit_symbol_owned(const Emitter emit, const Exp_Primary* prim) {
+ANN static m_bool emit_symbol_owned(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
   const Value v = prim->value;
   const Exp exp = new_exp_prim_id(insert_symbol("this"), prim->self->pos);
   const Exp dot = new_exp_dot(exp, prim->d.var);
-  exp->type = dot->d.exp_dot.t_base = v->owner_class;
+  exp->type = v->owner_class;
+  dot->d.exp_dot.t_base = v->owner_class;
   dot->type = v->type;
   dot->emit_var = prim->self->emit_var;
   const m_bool ret = emit_exp_dot(emit, &dot->d.exp_dot);
@@ -265,7 +267,7 @@ ANN static m_bool emit_symbol_owned(const Emitter emit, const Exp_Primary* prim)
   return ret;
 }
 
-ANN static m_bool emit_symbol_builtin(const Emitter emit, const Exp_Primary* prim) {
+ANN static m_bool emit_symbol_builtin(const Emitter emit, const Exp_Primary* prim) { GWDEBUG_EXE
   const Value v = prim->value;
   if(GET_FLAG(v, func)) {
     const Instr instr = emit_add_instr(emit, RegPushImm);
@@ -576,12 +578,24 @@ ANN static m_bool emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_c
   return GW_OK;
 }
 
-ANN static m_bool prepare_call(const Emitter emit, const Exp_Call* exp_call) {
+ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
   if(exp_call->args)
     CHECK_BB(emit_exp(emit, exp_call->args, 1))
   if(GET_FLAG(exp_call->m_func->def, variadic))
     CHECK_BB(emit_func_arg_vararg(emit, exp_call))
+  return GW_OK;
+}
+
+ANN static m_bool prepare_call(const Emitter emit, const Exp_Call* exp_call) { GWDEBUG_EXE
+  if(exp_call->args)
+    CHECK_BB(emit_func_args(emit, exp_call))
   CHECK_BB(emit_exp(emit, exp_call->func, 0))
+  if(GET_FLAG(exp_call->m_func->def, variadic) && !exp_call->args) {
+    // handle empty call to variadic functions
+    const Instr mk = emit_add_instr(emit, VarargIni);
+    *(m_uint*)mk->ptr = 1;
+    emit_add_instr(emit, PushNull);
+  }
   return GW_OK;
 }
 
@@ -598,7 +612,7 @@ ANN static m_bool emit_exp_call_template(const Emitter emit, const Exp_Call* exp
   if(emit->env->func && emit->env->func == exp_call->m_func)
     return prepare_call(emit, exp_call);
   m_int scope = push_tmpl_func(emit, exp_call->m_func, exp_call->tmpl->types);
-  CHECK_BB(scope)
+  CHECK_BB(scope);
   CHECK_BB(prepare_call(emit, exp_call))
   emit_pop_type(emit);
   emit_pop(emit, (m_uint)scope);
@@ -710,7 +724,8 @@ ANN static m_bool spork_exp(const Emitter emit, const Exp_Call* exp) { GWDEBUG_E
   op->m_val = emit->code->stack_depth;
   CHECK_BB(emit_exp_call1(emit, exp->m_func))
   const VM_Code code = finalyze(emit);
-  const m_uint size = exp->m_func->def->stack_depth - (GET_FLAG(exp->m_func, member) ? SZ_INT : 0);
+  const m_uint size = exp->m_func->def->stack_depth - (GET_FLAG(exp->m_func,
+    member) ? SZ_INT : 0);
   return emit_exp_spork_finish(emit, code, NULL, size, 0);
 }
 
@@ -1088,7 +1103,7 @@ ANN static m_bool emit_stmt_switch(const Emitter emit, const Stmt_Switch stmt) {
   if(dyn) {
     const Map m = (Map)push->m_val2, map = emit->env->sw->cases;
     for(m_uint i = map_size(map) + 1; --i;)
-      map_set(m, VKEY(map, i), VVAL(map, i - 1));
+      map_set(m, VKEY(map, i), VVAL(map, i -1));
   }
   *(m_uint*)instr->ptr = dyn ? SZ_INT : 0;
   pop_vector(&emit->code->stack_break, emit_code_size(emit));
@@ -1580,8 +1595,8 @@ ANN static m_bool emit_class_def(const Emitter emit, const Class_Def class_def)
 
 ANN static void emit_free_code(Code* code) {
   LOOP_OPTIM
-  for(m_uint i = vector_size(&code->instr) + 1; --i;)
-    mp_free(Instr, (Instr)vector_at(&code->instr, i - 1));
+  for(m_uint j = vector_size(&code->instr) + 1; --j;)
+    mp_free(Instr, (Instr)vector_at(&code->instr, j - 1));
   free_code(code);
 }
 
index 4506f7adfde46e4a0a7356d4af89f9b51251498b..a88cbeccb47296154c0d05c1fd9da67c2c14e995 100644 (file)
@@ -79,3 +79,4 @@ float f,g;
 <<< 1.0 >=  i>>>;
 <<< 1.0 <   i>>>;
 <<< 1.0 <=  i>>>;
+<<<g>>>;
index fd09ff7dbd7b457f5b6a1e5e00c168fc6c674179..d5a6390fae6c03819b2ef87fa6b4fa526cd54c9b 100644 (file)
@@ -1,3 +1,3 @@
 Object o;
 "Object: " => string s;
-//<<<s + (o + "")>>>;
+<<<s + (o + "")>>>;
index 2aa3bb831514aaa2818d1baa5cfc32664871d809..1c4f171616e9c7f94960d14b03e08cdcc80e8c11 100644 (file)
@@ -1,2 +1,3 @@
 // [skip]  in variable declaration
 int now;
+<<<now>>>;
index 8214acfeaecc89e85c017d09125a9893f456b8ca..b790243f08ddba9c07f2ef8c46d2f7ea08d1e173 100644 (file)
@@ -4,4 +4,5 @@ class D{}
 
 C c;
 D d;
-c $ D;
+<<<c $ D>>>;
+<<<d>>>;
index 5916fe9725975ba84d3950ab1770e5772944bb00..c0437706f0e38c6a8f916e6545886a8f6ff32e86 100644 (file)
@@ -5,3 +5,4 @@ union
        Object o;
 
 };
+<<<i, " ", o>>>;
index bcf066cbbd03723ea30c03a1f3122fa4f0c61f3b..f8976b717ebbe7b6d9d428ac33a9df97a0d41cb7 100644 (file)
@@ -8,3 +8,4 @@ class C {
   p(1);
 }
 C c;
+<<<c>>>;
index 9ef78efec6cca3d4777b00fe37ff7c9e9e6f9587..1985cb20ed6586939eb8a8d47d252216fe3c4046 100644 (file)
@@ -1 +1,2 @@
 int i[][][];
+<<<i>>>;
index 1b8a09711ea26e702b86a744de078f756c1075e6..4ca5e1976ef312070410bf755a778ef5d9b2210a 100644 (file)
@@ -1,2 +1,3 @@
 int i;
+<<<i>>>;
 //! document the AST
index d63d5d91a25638d57939c5edc69200e93ef8aaae..b94cf26184029bdd2dcd1de706f741072773f530 100644 (file)
@@ -2,3 +2,4 @@
 int i[4];
 for(auto@ a : i)
   <<<*a>>>;
+<<<ptr>>>;
index a7ef1aa970534df26626cb06a5956ff1fe4eeed1..3eecbf2afe541538baebeccdbde4092b2967cd40 100644 (file)
@@ -12,3 +12,4 @@ G g;
 //<<<f $ D>>>;
 <<< [ f, g ] >>>;
 <<<maybe ? f : D>>>;
+<<<c, " ", d, " ", e, " ", g>>>;
index 6261f75366fb6cca8ce1d5cc2c75890d4c53b464..4b158a4fcf8904d78343e68663a0a810fb9737d0 100644 (file)
@@ -8,3 +8,4 @@ class C {
   p(1);
 }
 C c;
+<<<c>>>;
index 632b9907462bcbdeeb15abec93c266e65a4fcba7..93dfbf3b3779f7935fc42c619f2843afd23fbb48 100644 (file)
@@ -1,2 +1,3 @@
 Object o;
+<<<o>>>;
 me.exit();
index 832c9fc3eeca1f23c7e92f818c6b520ba9a748fa..062fc59b06951aa200a3231efe6d23b58a9dee85 100644 (file)
@@ -1 +1,2 @@
 int i, j;
+<<<i, " ", j>>>;
index 0cfe15e238bdfb2a18b6ad7848bb7e29d3f8393f..c65d2581a7995ad79b3cfe66ab2ff1059a6f5e84 100644 (file)
@@ -1 +1,2 @@
 Object @ i, a;
+<<<i, a>>>;
index dbdc7cdb4f6f85f1cf3d0648809bf9751f234497..8787d183fc00c6b4ba24a53bc26683574a0376bf 100644 (file)
@@ -1,3 +1,4 @@
 class C { union private static { int i; } u;<<<this, " ", u, " ", this.u.i>>>;  
 }
 C c;
+<<<c>>>;
index 79649395567b3ff7a635a770788a11f363b8dd6a..9a0ac9340fd11ff95b8119585db2a1529d664e2c 100644 (file)
@@ -1,2 +1,2 @@
-function Object test(){ Object o; return new Object; }
+function Object test(){ Object o; <<<o>>>; return new Object; }
 test();
index 9a2e811cca42d8e2828e5617ea64998ab510b14f..981e10e86472e47e5a0ad75e55f9f44d78cc186e 100644 (file)
@@ -1,2 +1,3 @@
 class C { private int i; <<<i>>>; }
 C c;
+<<<c>>>;
index 0b50bdd879f47566a2221f722406828e36d3ee01..00a75fd0bf14c00eeed873f10a07d4f2d5f403a5 100644 (file)
@@ -4,3 +4,4 @@ class C {
 }
 
 C c;
+<<<c>>>;
index 048f715b4656f388eaeddede94b3808a59a3a95e..271009cb226ceaa7c0eff2f8b9e14d6ae1d0cf02 100644 (file)
@@ -1 +1,2 @@
 int i;
+<<<i>>>;
index 6ed759dc31d22bee9c9d2528481d17068a35e104..384ac16a4eb3bf61b4bd259a5a357a9c8f6638c5 100644 (file)
@@ -1 +1,2 @@
 Object @ o;
+<<<o>>>;
index 6321c7237a2c676de67fe159b14787b74cc96c7c..683bda0102dca931e5946a57abca118bb98fa3c6 100644 (file)
@@ -2,3 +2,4 @@ template“A”
 class C {}
 
 “int”C ref;
+<<<ref>>>;