Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs164_lab3_cg
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
cs164_lab3_cg
Commits
6d8a1cd4
There was an error fetching the commit references. Please try again later.
Commit
6d8a1cd4
authored
6 years ago
by
Shivane Sabharwal
Browse files
Options
Downloads
Patches
Plain Diff
started work on call_with_args
parent
7a1691c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/chocopy/pa3/CodeGenImpl.java
+16
-2
16 additions, 2 deletions
src/main/java/chocopy/pa3/CodeGenImpl.java
src/test/data/pa3/sample/call_with_args.py.s
+752
-0
752 additions, 0 deletions
src/test/data/pa3/sample/call_with_args.py.s
with
768 additions
and
2 deletions
src/main/java/chocopy/pa3/CodeGenImpl.java
+
16
−
2
View file @
6d8a1cd4
...
...
@@ -364,6 +364,7 @@ public class CodeGenImpl extends CodeGenBase {
FuncInfo
func
=
(
FuncInfo
)
globalSymbols
.
get
(
callExpr
.
function
.
name
);
for
(
Expr
e
:
callExpr
.
args
)
{
backend
.
emitADDI
(
SP
,
SP
,
-
4
,
"Increment stack ptr by 1"
);
System
.
out
.
println
(
e
.
getInferredType
());
e
.
dispatch
(
this
);
}
// Push parameters onto stack
...
...
@@ -410,9 +411,21 @@ public class CodeGenImpl extends CodeGenBase {
@Override
public
Void
analyze
(
Identifier
id
)
{
// NOT DONE
boolean
argFlag
=
false
;
int
argCtr
=
0
;
for
(
String
s
:
funcInfo
.
getParams
())
{
if
(
id
.
name
.
equals
(
s
))
{
argFlag
=
true
;
break
;
}
argCtr
++;
}
SymbolInfo
ident
=
sym
.
get
(
id
.
name
);
// global var case
if
(
ident
instanceof
GlobalVarInfo
)
{
System
.
out
.
println
(
id
.
name
);
if
(
argFlag
){
int
offset
=
argCtr
*
backend
.
getWordSize
();
backend
.
emitLW
(
A0
,
FP
,
offset
,
"Load stack argument"
);
}
else
if
(
ident
instanceof
GlobalVarInfo
)
{
// global var case
backend
.
emitLW
(
A0
,
((
GlobalVarInfo
)
ident
).
getLabel
(),
"Load identifier"
);
backend
.
emitSW
(
A0
,
SP
,
0
,
"Push to stack"
);
}
else
if
(
ident
instanceof
StackVarInfo
){
// local variable
...
...
@@ -518,6 +531,7 @@ public class CodeGenImpl extends CodeGenBase {
backend
.
emitXOR
(
T0
,
T0
,
T1
,
"== operator on BOOL/INT"
);
backend
.
emitSEQZ
(
T0
,
T0
,
"Set to 1 if XOR results in 0, they were equal"
);
backend
.
emitSW
(
T0
,
SP
,
0
,
"Push result onto stack"
);
return
null
;
}
case
"!="
:
...
...
This diff is collapsed.
Click to expand it.
src/test/data/pa3/sample/call_with_args.py.s
0 → 100644
+
752
−
0
View file @
6d8a1cd4
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