From ce1efe0b087690d2dd9e32ac870aa0e613fdba3c Mon Sep 17 00:00:00 2001 From: Xun Yang <x299yang@uwaterloo.ca> Date: Sun, 12 Apr 2020 00:48:28 -0400 Subject: [PATCH] fix SIT segfault --- TypeNodes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TypeNodes.py b/TypeNodes.py index 484e80c..da61b93 100644 --- a/TypeNodes.py +++ b/TypeNodes.py @@ -315,6 +315,9 @@ class ClassNode(ClassInterNode): self.data = "" # For writeable data section # print("This is the super class: {}".format(self.superClass)) + if self.canonName == "java.lang.Object": + self.data += p("global", "I_SIT_" + self.name) + # Generate class label self.label = pLabel(name=self.name, type="class") self.data += ";START OF CLASS MEMORY LAYOUT FOR CLASS: " + self.canonName + "\n" @@ -405,18 +408,16 @@ class ClassNode(ClassInterNode): # fill in SIT self.code += "\n; Filling in SIT\n" self.code += p("mov", "eax", "I_SIT_spot_" + self.name) - if self.canonName == "java.lang.Object": - self.code += p("global", "I_SIT_" + self.name) self.code += p("mov", "[eax]", "dword I_SIT_" + self.name) for m in self.contains: if m.__class__.__name__ == "MethodNode": sm = m.getTopReplace() - if sm != m and sm.isInterM: - dlabel = "I_SIT_" + str(sm.methodOffset / 4) + if sm.typeName != m.typeName and sm.isInterM: + dlabel = "I_SIT_" + str(sm.methodOffset // 4) className = m.typeName imLabel = "M_" + className + "_" + m.name + "_" + m.paramTypes - if className != self.typeName: + if className != self.name: self.code += p("extern", imLabel) self.code += p("mov", "eax", dlabel) self.code += p("mov", "[eax]", "dword " + imLabel) -- GitLab