Skip to content
Snippets Groups Projects
Commit 687b9695 authored by Xun Yang's avatar Xun Yang
Browse files

comment out super class stuff for marmoset submit

parent 7b75fe21
No related branches found
No related tags found
No related merge requests found
......@@ -264,14 +264,14 @@ class MethodNode(ASTNode):
vars[i].offset = i * 4 + 16
bodyCode += p("push", 0)
# call parent constructor
if myClass.superClass:
suLabel = "M_" + myClass.superClass.name + "_"
bodyCode += importHelper(myClass.superClass.name, self.typeName, suLabel)
bodyCode += p("mov", "eax", "[ebp - " + str(thisLoc) + "]")
bodyCode += p("push", "eax", None, "# Pass THIS as argument to superClass.")
bodyCode += p("call", suLabel)
bodyCode += p("add", "esp", "4") # pop object off stack
# # call parent constructor
# if myClass.superClass:
# suLabel = "M_" + myClass.superClass.name + "_"
# bodyCode += importHelper(myClass.superClass.name, self.typeName, suLabel)
# bodyCode += p("mov", "eax", "[ebp - " + str(thisLoc) + "]")
# bodyCode += p("push", "eax", None, "# Pass THIS as argument to superClass.")
# bodyCode += p("call", suLabel)
# bodyCode += p("add", "esp", "4") # pop object off stack
# init fields
......
......@@ -305,7 +305,7 @@ class ClassNode(ClassInterNode):
return
self.code = "" # For read-only section
self.code = "" # For read-only section
self.data = "" # For writeable data section
# print("This is the super class: {}".format(self.superClass))
......@@ -355,8 +355,8 @@ class ClassNode(ClassInterNode):
self.methodOffset[(method.name, method.paramTypes)] = lastMethodOffset
self.data += pLabel(name=self.name + "_" + method.name + "_" + method.paramTypes, type="vtable")
self.data += p(instruction="dd", arg1=64) # just declaring a memory segment with a random number
# Adding inherited method to the methodDict
# Adding inherited method to the methodDict
for i in self.inherits:
if isinstance(i, MethodNode):
key = (i.name, i.paramTypes)
......@@ -381,10 +381,13 @@ class ClassNode(ClassInterNode):
mLabel = "M_" + className + "_" + key[0] + "_" + key[1] # method implementation
# First need to import method implementation labels
if className != self.name:
self.code += p(instruction="extern", arg1=mLabel, comment="importing method implementation label")
self.code += p(instruction="mov", arg1="eax", arg2=vLabel, comment="Filling in class memory segment for method " + mLabel)
self.code += p(instruction="mov", arg1="[eax]", arg2="dword " + mLabel)
# if className != self.name:
# self.code += p(instruction="extern", arg1=mLabel, comment="importing method implementation label")
# self.code += p(instruction="mov", arg1="eax", arg2=vLabel, comment="Filling in class memory segment for method " + mLabel)
# self.code += p(instruction="mov", arg1="[eax]", arg2="dword " + mLabel)
if className == self.name:
self.code += p(instruction="mov", arg1="eax", arg2=vLabel, comment="Filling in class memory segment for method " + mLabel)
self.code += p(instruction="mov", arg1="[eax]", arg2="dword " + mLabel)
self.code += p(instruction="ret", arg1="")
self.code += "; End of function for filling in class memory layout\n"
......@@ -395,22 +398,22 @@ class ClassNode(ClassInterNode):
###########################################################
# Generating a function that allocates and initializes all static fields
# Note: 1. saving and restoring ebx, a callee-save register
# Generating a function that allocates and initializes all static fields
# Note: 1. saving and restoring ebx, a callee-save register
# 2. static fields are intialized in the order of declaration within the class and has to be intialized
# before the test() method is being called
self.code += "; Function for filling allocating space and initializing static fields for class " + self.name + "\n"
self.code += pLabel(name=self.name + "_" + "staticFieldMemoryInit", type="helper")
self.code += p(instruction="push", arg1="ebx", comment="saving ebx")
self.code += p(instruction="push", arg1="ebx", comment="saving ebx")
for field in self.fields:
if not hasattr(field, "code"):
field.codeGen()
self.code += field.code
self.data += field.data
self.code += p(instruction="pop", arg1="ebx", comment="restoring ebx")
self.code += p(instruction="pop", arg1="ebx", comment="restoring ebx")
self.code += p(instruction="ret", arg1="")
self.code += "; End of function for filling allocating space and initializing static fields for class " + self.name + "\n"
# Generating a function that calls both the class memory init and static field init functions
self.code += "; Function that calls staticFieldMemoryInit and classMemoryInit \n"
self.code += pLabel(name=self.name + "_" + "classAndStaticFieldInit", type="helper")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment