Browse Source

* fixed writing to global variables

git-svn-id: branches/wasm@47169 -
nickysn 4 years ago
parent
commit
5128c07e68
1 changed files with 7 additions and 3 deletions
  1. 7 3
      compiler/wasm32/hlcgcpu.pas

+ 7 - 3
compiler/wasm32/hlcgcpu.pas

@@ -1033,9 +1033,13 @@ implementation
         exit;
         exit;
 
 
       // setting up memory offset
       // setting up memory offset
-      if assigned(ref.symbol) then begin
-        //list.Concat(taicpu.op_sym(a_get_global, ref.symbol));
-      end else if ref.index <> NR_NO then // array access
+      if assigned(ref.symbol) then
+        begin
+          list.Concat(taicpu.op_const(a_i32_const,0));
+          incstack(list,1);
+          result:=1;
+        end
+      else if ref.index <> NR_NO then // array access
       begin
       begin
         // it's just faster to sum two of those together
         // it's just faster to sum two of those together
         list.Concat(taicpu.op_reg(a_get_local, ref.base));
         list.Concat(taicpu.op_reg(a_get_local, ref.base));