From 88d8389c42a651ddcc820871570633fed293f634 Mon Sep 17 00:00:00 2001
From: pycsham <shampuiyanchloe@gmail.com>
Date: Sun, 12 Apr 2020 16:12:19 -0400
Subject: [PATCH] fixed some issues with Array. Now works on basic tests

---
 AstBuilding.py      | 15 ++++++++++-----
 ExprPrimaryNodes.py |  2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/AstBuilding.py b/AstBuilding.py
index 25a7d04..74bec92 100644
--- a/AstBuilding.py
+++ b/AstBuilding.py
@@ -83,14 +83,14 @@ def arrayClassMemory(types):
         code += "section .text\n" + \
                 "; Function to initialize class memory layout\n" + \
                 pLabel(name=t+"_arrayMemoryInitialize", type="helper") + \
-                p(instruction="mov", arg1="eax", arg2="I_SIT_spot_"+t+ "_array") + \
+                p(instruction="mov", arg1="eax", arg2="dword I_SIT_spot_"+t+ "_array") + \
                 p(instruction="extern", arg1="I_SIT_Object") + \
-                p(instruction="mov", arg1="[eax]", arg2="I_SIT_Object", comment="Points to the SIT column of java.lang.Object")
+                p(instruction="mov", arg1="[eax]", arg2="dword I_SIT_Object", comment="Points to the SIT column of java.lang.Object")
 
         for m in methods:
             code += p(instruction="extern", arg1=m) + \
-                    p(instruction="mov", arg1="eax", arg2="V_"+t+"_"+m+"_array") + \
-                    p(instruction="mov", arg1="[eax]", arg2=m, comment="points to method implementation")
+                    p(instruction="mov", arg1="eax", arg2="dword V_"+t+"_"+m+"_array") + \
+                    p(instruction="mov", arg1="[eax]", arg2="dword "+m, comment="points to method implementation")
         code += p(instruction="ret", arg1="")
         code += "; End of function to initialize class memory layout\n"
 
@@ -128,7 +128,12 @@ def codeGenPrep(ASTs):
 
 
 def codeGen(ASTs, output="output"):
-    ASTs = ASTs[:1] # TOREMOVE: don't compile stdlib for now
+    # ASTs = ASTs[:1] # TOREMOVE: don't compile stdlib for now
+    rASTs = []
+    for index,t in enumerate(ASTs):
+        if index == 0 or t[0] == "stdlib/5.0/java/lang/Object.java":
+            rASTs.append(t)
+    ASTs = rASTs
     arrayClassMemory = codeGenPrep(ASTs)
     for t in ASTs:
         t[1].codeGen()
diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py
index 11e60a1..eb7c71c 100644
--- a/ExprPrimaryNodes.py
+++ b/ExprPrimaryNodes.py
@@ -200,7 +200,7 @@ class ArrayAccessNode(ASTNode):
         if hasattr(self, "code"):
             return
         self.code = "; Array access\n" + \
-                    self.addr + \
+                    self.addr() + \
                     p(instruction="mov", arg1="eax", arg2="[eax]", comment="eax now contains a[i]") +\
                     "; End of array access\n"
 
-- 
GitLab