]> Nishi Git Mirror - gwion.git/commitdiff
:art: set_decl_ref
authorfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 8 Oct 2019 22:45:11 +0000 (00:45 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 8 Oct 2019 22:45:11 +0000 (00:45 +0200)
22 files changed:
include/operator.h
src/emit/emit.c
src/lib/array.c
src/lib/complex.c
src/lib/engine.c
src/lib/event.c
src/lib/gack.c
src/lib/instr.c
src/lib/modules.c
src/lib/prim.c
src/lib/ptr.c
src/lib/shred.c
src/lib/string.c
src/lib/tuple.c
src/lib/ugen.c
src/lib/vararg.c
src/lib/vec.c
src/oo/env.c
src/pass.c
src/plug.c
src/vm/vm.c
src/vm/vm_code.c

index 309693378197cfd0ff1d912fb53ef611dc090f04..a0466b5eaba957b7a03479689016e942ac8ad7b9 100644 (file)
@@ -32,4 +32,11 @@ ANN Type   op_check(const Env, struct Op_Import*);
 ANN struct Instr_* op_emit(const Emitter, const struct Op_Import*);
 ANN m_bool operator_set_func(const struct Op_Import*);
 ANN void free_op_map(Map map, struct Gwion_* gwion);
+
+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);
+  }
+}
 #endif
index 085c6dc49d7cf7ab6899bf3eaa30482f9e310700..a3b8b166ad071535c9455a2078e4727e1247015a 100644 (file)
@@ -1893,7 +1893,7 @@ ANN static m_bool emit_class_def(const Emitter emit, const Class_Def cdef) {
     CHECK_BB(emit_array_extend(emit, type->e->parent, cdef->base.ext->array->exp))
   if(cdef->body)
     CHECK_BB(scanx_body(emit->env, cdef, (_exp_func)emit_section, emit))
-  emit_class_finish(emit, type->nspc);
+  emit_class_finish(emit, nspc);
   SET_FLAG(type, emit);
   return GW_OK;
 }
index 862041fdf8ad42dec209eb13035faeeb49667462..d16810c3275f0a814823b2327d844abf9983f4d8 100644 (file)
@@ -11,6 +11,7 @@
 #include "object.h"
 #include "array.h"
 #include "emit.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "traverse.h"
index 0762985697bd8e238dc08ff031903c57979dfbc9..1ed8f00e8660a6825ee96f99d3f8fcb48b2973ca 100644 (file)
@@ -8,6 +8,7 @@
 #include "instr.h"
 #include "object.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 
index 6fd67801531c70abb85ba84077bc9e10b2be3847..d29ef4cc6ae663ffc458bac8a6dc6ebd48a6cd38 100644 (file)
@@ -12,6 +12,7 @@
 #include "env.h"
 #include "vm.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
index 99f79bebec97cfdbf97318f4ab554f4f6b161e47..1ca394dff179722ae3b39099f7d72ed762d40cff 100644 (file)
@@ -7,6 +7,7 @@
 #include "type.h"
 #include "instr.h"
 #include "object.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
index 4d07a03cf3285a8c0e37817510ae0c294ee8cbca..f610ad1bf975b62943f450134392e9aaaa7b50d9 100644 (file)
@@ -11,6 +11,7 @@
 #include "object.h"
 #include "instr.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gack.h"
index 3ee791f7698d6ced86688073d3ad75e942aabb94..66d305c6f0959b150969103f803471c119b64efa 100644 (file)
@@ -13,6 +13,7 @@
 #include "nspc.h"
 #include "shreduler_private.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "cpy_ast.h"
index 3cf3af3f9ac7b6e6cbff90dbb8d0b559188e708d..71dd15d6e669c0a087507cbccecf3fc9695b5529 100644 (file)
@@ -9,6 +9,7 @@
 #include "type.h"
 #include "instr.h"
 #include "object.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "ugen.h"
index d1a3232e335b16c766c087d4b6b79fd9ee08d979..f7085b690bd1f77ccc41e9a192956609fcfcf492 100644 (file)
@@ -8,6 +8,7 @@
 #include "instr.h"
 #include "object.h"
 #include "emit.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
index 59a0d4771c3f7b10a467c67374d29c365b32d21b..fd8188cab760fc85b54d54b0c399006f9cbcf28d 100644 (file)
@@ -10,6 +10,7 @@
 #include "nspc.h"
 #include "instr.h"
 #include "object.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "emit.h"
index 41aeed37486bf1154149de47184b53b800df68ee..8ab294244fe592e8de54e93cfaae889bfb5b0851 100644 (file)
@@ -10,6 +10,7 @@
 #include "object.h"
 #include "shreduler_private.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "emit.h"
index 0562c3c95e7a607d98a8110505e0fd19059e75d6..9805a95b499915c7b087662937681670758918aa 100644 (file)
@@ -11,6 +11,7 @@
 #include "instr.h"
 #include "object.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "emit.h"
index 8af9b3d8d659027ee4fed7405cb5cdf06dc4f2a1..7cab9c003e2ea43ec8e773e6f467ab540a38402c 100644 (file)
@@ -11,6 +11,7 @@
 #include "env.h"
 #include "vm.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
@@ -162,6 +163,7 @@ static OP_CHECK(opck_at_tuple_object) {
   if(tuple_match(env, bin->rhs->type, bin->lhs->type) < 0)
     return env->gwion->type[et_null];
   bin->rhs->emit_var = 1;
+  set_decl_ref(bin->rhs);
   return bin->rhs->type;
 }
 
@@ -173,10 +175,9 @@ static OP_CHECK(opck_cast_tuple_object) {
 }
 
 static INSTR(Tuple2Object) {
-//  const M_Object o = *(M_Object*)(shred->reg - SZ_INT*2);
   const M_Object o = *(M_Object*)(shred->reg - instr->m_val2);
   const Type t = (Type)instr->m_val;
-  if(isa(o->type_ref, t) < 0)
+  if(o && isa(o->type_ref, t) < 0)
   // TODO: pass position by m_val2
 //    Except(shred, "can't cast %s to %s\n", o->type_ref->name, t->name);
     Except(shred, _("can't cast\n"));
@@ -191,12 +192,15 @@ static OP_EMIT(opem_##name##_tuple_object) {              \
   instr->m_val2 = SZ_INT;                                 \
   return instr;                                           \
 }
-static OP_EMIT(opem_at_tuple_object) {                    \
-  const Exp_Binary *bin = (Exp_Binary*)data;              \
-  const Instr instr = emit_add_instr(emit, Tuple2Object); \
-  instr->m_val = (m_uint)bin->rhs->type;                  \
-  instr->m_val2 = SZ_INT*2;                               \
-  return emit_add_instr(emit, ObjectAssign);              \
+static OP_EMIT(opem_at_tuple_object) {                     \
+  const Exp_Binary *bin = (Exp_Binary*)data;               \
+  const Instr instr = emit_add_instr(emit, Tuple2Object);  \
+  instr->m_val = (m_uint)bin->rhs->type;                   \
+  instr->m_val2 = SZ_INT*2;                                \
+
+  const Instr assign = emit_add_instr(emit, ObjectAssign); \
+
+return assign;
 }
 mk_opem_tuple2object(cast, Exp_Cast *, exp_self(exp)->type)
 
index 1fec7ae699f24da59fa4d8e00c619df0ca4f300b..51220b7c5c39c5b876fc5203ac0fc2126691ac55 100644 (file)
@@ -8,6 +8,7 @@
 #include "type.h"
 #include "instr.h"
 #include "object.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
index 35d0fca7e3b95a89dd37d3333a2fdd0315c5fe61..250823ce515a13d49316f74992bbe98aa6208802 100644 (file)
@@ -11,6 +11,7 @@
 #include "object.h"
 #include "vararg.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "gwi.h"
index 205970420b7c5cfa3a682783c53290de53205fe5..a2848c998c2b08a63e2ef8931c32ae1f6c464574 100644 (file)
@@ -7,6 +7,7 @@
 #include "instr.h"
 #include "object.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "driver.h"
index 870d591316ef6db24a2a89025c5eb2178a1a5210..1ca4259033a340c30dde92030df7bc53ecc210fc 100644 (file)
@@ -5,6 +5,7 @@
 #include "vm.h"
 #include "env.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "value.h"
 #include "traverse.h"
index 9a2434cb5a3241290c7e3ce6e31b859a111d17a2..9c2684f8a7c60640122db53491fa2b6dc677030b 100644 (file)
@@ -25,7 +25,7 @@ ANN m_bool pass_set(const Gwion gwion, const Vector passes) {
     const Symbol sym = insert_symbol(gwion->st, name);
     const compilation_pass pass = (compilation_pass)map_get(&gwion->data->pass_map, (vtype)sym);
     if(!pass) {
-      gw_err("Failed to set compilation passes, back to default");
+      gw_err("Failed to set compilation passes, back to default\n");
       pass_default(gwion);
       return GW_ERROR;
     }
index c0dd2193af3a8f4301a6c3586660934309035652..dd11e1aa8cc6bcef4e91e7312ad365d7b66c3128 100644 (file)
@@ -11,6 +11,7 @@
 #include "env.h"
 #include "vm.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "instr.h"
 #include "object.h"
index 51742e90a0a1f12d084fc8aba0819ffd1f902d54..5eb145ffeadb5d3ac128ae006c15b186b04e881c 100644 (file)
@@ -15,6 +15,7 @@
 #include "shreduler_private.h"
 #include "emit.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"
 #include "map_private.h"
index 3335c0e6d6a77f9c8327c41e2c60725a252e0506..597007f5c97467615787debd17211f45f9856276 100644 (file)
@@ -12,6 +12,7 @@
 #include "array.h"
 #include "memoize.h"
 #include "gwion.h"
+#include "value.h"
 #include "operator.h"
 #include "import.h"