Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs444
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xun Yang
cs444
Commits
687b9695
Commit
687b9695
authored
4 years ago
by
Xun Yang
Browse files
Options
Downloads
Patches
Plain Diff
comment out super class stuff for marmoset submit
parent
7b75fe21
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MemberNodes.py
+8
-8
8 additions, 8 deletions
MemberNodes.py
TypeNodes.py
+15
-12
15 additions, 12 deletions
TypeNodes.py
with
23 additions
and
20 deletions
MemberNodes.py
+
8
−
8
View file @
687b9695
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
TypeNodes.py
+
15
−
12
View file @
687b9695
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment