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
7b75fe21
Commit
7b75fe21
authored
5 years ago
by
Xun Yang
Browse files
Options
Downloads
Patches
Plain Diff
minor fixes to constructor and iffalse
parent
5043df70
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CodeGenUtils.py
+10
-4
10 additions, 4 deletions
CodeGenUtils.py
MemberNodes.py
+3
-2
3 additions, 2 deletions
MemberNodes.py
with
13 additions
and
6 deletions
CodeGenUtils.py
+
10
−
4
View file @
7b75fe21
...
...
@@ -86,9 +86,15 @@ def genMethodInvoke(method):
return
(
pro
,
epi
)
# generates shorter code for constant value conditionals and comparison conditionals
# cond is either literalNode or ExprNode
# cond is either literalNode or ExprNode
or NameNode
def
iffalse
(
cond
,
label
):
result
=
""
if
cond
.
__class__
.
__name__
==
"
NameNode
"
:
cond
.
codeGen
()
result
+=
cond
.
code
result
+=
p
(
"
jz
"
,
label
)
return
result
val
=
cond
.
getConstant
()
if
val
!=
None
:
if
val
==
True
:
...
...
@@ -102,7 +108,7 @@ def iffalse(cond, label):
return
result
# Generates generic (not specific to class) helper functions
# Generates generic (not specific to class) helper functions
def
genericHelperFunctions
():
code
=
""
...
...
@@ -137,9 +143,9 @@ def globalImport(genGlobalFunction=False):
if
not
genGlobalFunction
:
code
+=
p
(
instruction
=
"
extern
"
,
arg1
=
"
G__Zero
"
)
+
\
p
(
instruction
=
"
extern
"
,
arg1
=
"
H__Throw_Exception
"
)
+
\
p
(
instruction
=
"
extern
"
,
arg1
=
"
H__Null_Check
"
)
p
(
instruction
=
"
extern
"
,
arg1
=
"
H__Null_Check
"
)
code
+=
"
; End of importing helper functions and constants
\n
"
code
+=
"
; End of importing helper functions and constants
\n
"
return
code
# Helper function for importation of label (only import if it's not already inside the same .s file)
...
...
This diff is collapsed.
Click to expand it.
MemberNodes.py
+
3
−
2
View file @
7b75fe21
...
...
@@ -105,6 +105,7 @@ class MethodNode(ASTNode):
self
.
typeName
=
typeName
self
.
order
=
order
self
.
myType
=
None
# self.SIToffset for methods that implements interface method
# get method name
nameNodes
=
getParseTreeNodes
([
'
ID
'
],
parseTree
,
[
'
params
'
,
'
type
'
,
'
methodBody
'
])
...
...
@@ -241,7 +242,7 @@ class MethodNode(ASTNode):
self
.
code
+=
genProcedure
(
bodyCode
,
"
method definition for
"
+
self
.
name
)
else
:
self
.
code
+=
(
"
mov
"
,
"
eax
"
,
"
0
"
)
self
.
code
+=
p
(
"
mov
"
,
"
eax
"
,
"
0
"
)
self
.
code
+=
p
(
"
ret
"
,
""
)
# This method is called instead of codeGen if this is a constructor
...
...
@@ -292,7 +293,7 @@ class MethodNode(ASTNode):
for
i
in
range
(
len
(
vars
)):
bodyCode
+=
p
(
"
pop
"
,
"
edx
"
)
else
:
bodyCode
+=
(
"
mov
"
,
"
eax
"
,
"
0
"
)
bodyCode
+=
p
(
"
mov
"
,
"
eax
"
,
"
0
"
)
self
.
code
+=
genProcedure
(
bodyCode
,
"
Constructor definition for
"
+
self
.
name
+
"
"
+
self
.
paramTypes
)
...
...
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