]> Nishi Git Mirror - gwion.git/commitdiff
:art: ArrayTop
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 10 Mar 2019 23:03:23 +0000 (00:03 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 10 Mar 2019 23:03:23 +0000 (00:03 +0100)
include/instr.h
include/lang_private.h
include/opcode.h
opcode.txt
src/emit/emit.c
src/lib/array.c
src/lib/object.c
src/vm/vm.c

index f794bacd733affff9b0406b385496dcaee0a7ace..ec5baff37ff0295a1df7b9f623cf43dd74051adf 100644 (file)
@@ -45,7 +45,6 @@ INSTR(ComplexImag);
 INSTR(DtorReturn);
 
 /* array */
-INSTR(ArrayTop);
 INSTR(ArrayBottom);
 INSTR(ArrayPost);
 INSTR(ArrayInit);
index 116b2a6197eb0debeead480a2c6e52d8e5f71bcf..f7bb22fe2676f05038666dde48b794654a611c90 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __LANG_PRIVATE
 #define __LANG_PRIVATE
-ANN m_bool import_int(const Gwi gwi);
-ANN m_bool import_float(const Gwi gwi);
+ANN m_bool import_prim(const Gwi gwi);
 ANN m_bool import_complex(const Gwi gwi);
 ANN m_bool import_vec3(const Gwi gwi);
 ANN m_bool import_vec4(const Gwi gwi);
index 04f8bb2707c25dcfc87dc9965681944458f49915..d43d3c18129b5c139e970cd81441bd2945cc3985 100644 (file)
@@ -139,6 +139,7 @@ enum {
   eBranchNeqFloat,
   eDecIntAddr,
   eInitLoopCounter,
+  eArrayTop,
   eObjectInstantiate,
   eRegAddRef,
   eObjectAssign,
@@ -301,6 +302,7 @@ enum {
 #define  BranchNeqFloat      (f_instr)eBranchNeqFloat
 #define  DecIntAddr          (f_instr)eDecIntAddr
 #define  InitLoopCounter     (f_instr)eInitLoopCounter
+#define  ArrayTop            (f_instr)eArrayTop
 #define  ObjectInstantiate   (f_instr)eObjectInstantiate
 #define  RegAddRef           (f_instr)eRegAddRef
 #define  ObjectAssign        (f_instr)eObjectAssign
index d31f84bedd5fbd9cecb2d750453ebc1a85fdd971..92d958b38bc95bf33f5a900b3e41a9f53765cb06 100644 (file)
@@ -136,6 +136,7 @@ BranchEqFloat
 BranchNeqFloat
 DecIntAddr
 InitLoopCounter
+ArrayTop
 ObjectInstantiate
 RegAddRef
 ObjectAssign
index be2fac75486ea7a99bcdd19da95e60b32bded09f..420e2b90a65d7a87eb08bbaface2959145e4df75 100644 (file)
@@ -214,7 +214,7 @@ ANN2(1,2) m_bool emit_instantiate_object(const Emitter emit, const Type type,
     info->is_ref = !!is_ref;
   } else if(!is_ref) {
     const Instr instr = emit_add_instr(emit, ObjectInstantiate);
-    instr->m_val = (m_uint)type;
+    instr->m_val2 = (m_uint)type;
     emit_pre_ctor(emit, type);
   }
   return GW_OK;
@@ -720,13 +720,13 @@ ANN static Type_List tmpl_tl(const Env env, const m_str name) {
 }
 
 ANN m_bool traverse_dot_tmpl(const Emitter emit, const struct dottmpl_ *dt) {
-  const m_uint scope = env_push_type(emit->env, dt->owner);
+  const m_uint scope = emit_push_type(emit, dt->owner);
   m_bool ret = GW_ERROR;
   if(traverse_func_template(emit->env, dt->def, dt->tl) > 0) {
     ret = emit_func_def(emit, dt->def);
     nspc_pop_type(emit->env->curr);
   }
-  env_pop(emit->env, scope);
+  emit_pop(emit, scope);
   return ret;
 }
 
index 7793b9cdd2203d441f440da2f265190a97c7276b..51e8bc70dd799bd528a6bf0ee5980c280a97bd73 100644 (file)
@@ -229,13 +229,6 @@ GWION_IMPORT(array) {
   return GW_OK;
 }
 
-INSTR(ArrayTop) { GWDEBUG_EXE
-  if(*(m_uint*)REG(-SZ_INT * 2) < *(m_uint*)REG(-SZ_INT))
-    instantiate_object(shred, (Type)instr->m_val2);
-  else
-    shred->pc = instr->m_val;
-}
-
 INSTR(ArrayBottom) { GWDEBUG_EXE
   POP_REG(shred, SZ_INT);
   const M_Object obj = *(M_Object*)REG(0);
index e84be8f013b8668b0375279e95dab7b3aa7dffa2..5c4c7e68570af1cceafee20a7d50ece7c1458462 100644 (file)
@@ -49,7 +49,8 @@ M_Object new_string2(const VM_Shred shred, const m_str str) {
 }
 
 ANN void instantiate_object(const VM_Shred shred, const Type type) {
-  const M_Object object = new_object(NULL, type);
+//  const M_Object object = new_object(NULL, type);
+  const M_Object object = new_object(shred, type);
   *(M_Object*)REG(0) =  object;
   PUSH_REG(shred, SZ_INT);
 }
index e456afde46008338195c09e9cd05334847ddba4e..17d0dc479f018c59454b9a08aa2bba37a33b6d51 100644 (file)
@@ -264,7 +264,7 @@ ANN void vm_run(const VM* vm) { /* lgtm [cpp/use-of-goto] */
     &&sporkini, &&sporkfunc, &&sporkthis, &&sporkexp, &&sporkend,
     &&brancheqint, &&branchneint, &&brancheqfloat, &&branchnefloat,
     &&decintaddr, &&initloop,
-    &&newobj,
+    &&arraytop, &&newobj,
     &&addref, &&assign, &&remref,
     &&except, &&allocmemberaddr, &&dotmember, &&dotfloat, &&dotother, &&dotaddr,
     &&staticint, &&staticfloat, &&staticother,
@@ -646,8 +646,13 @@ initloop:
   reg -= SZ_INT;
   (*(m_uint*)instr->m_val) = labs(*(m_int*)reg);
   DISPATCH()
+arraytop:
+    if(*(m_uint*)(reg - SZ_INT * 2) < *(m_uint*)(reg-SZ_INT))
+      goto newobj;
+  else
+    goto _goto;
 newobj:
-  *(M_Object*)reg = new_object(shred, (Type)instr->m_val);
+  *(M_Object*)reg = new_object(shred, (Type)instr->m_val2);
   reg += SZ_INT;
   DISPATCH()
 addref: