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
75570697
There was an error fetching the commit references. Please try again later.
Commit
75570697
authored
6 years ago
by
Vedaank
Browse files
Options
Downloads
Patches
Plain Diff
negate done 15 pass
parent
90f6645f
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
Makefile
+1
-1
1 addition, 1 deletion
Makefile
src/main/java/chocopy/pa3/CodeGenImpl.java
+21
-0
21 additions, 0 deletions
src/main/java/chocopy/pa3/CodeGenImpl.java
with
22 additions
and
1 deletion
Makefile
+
1
−
1
View file @
75570697
CLEAN
=
mvn clean package
TEST
=
java
-cp
"chocopy-ref.jar:target/assignment.jar"
chocopy.ChocoPy
--pass
=
..s
--run
--dir
src/test/data/pa3/sample/
--test
FILE
=
None
FILE
=
op_logical
clean
:
$(
CLEAN
)
test
:
...
...
This diff is collapsed.
Click to expand it.
src/main/java/chocopy/pa3/CodeGenImpl.java
+
21
−
0
View file @
75570697
...
...
@@ -464,6 +464,27 @@ public class CodeGenImpl extends CodeGenBase {
return
null
;
}
@Override
public
Void
analyze
(
UnaryExpr
unaryExpr
)
{
switch
(
unaryExpr
.
operator
)
{
case
"-"
:
if
(
unaryExpr
.
getInferredType
().
equals
(
SymbolType
.
INT_TYPE
))
{
backend
.
emitADDI
(
SP
,
SP
,
-
4
,
"Increment stack ptr for first operand"
);
unaryExpr
.
operand
.
dispatch
(
this
);
backend
.
emitLW
(
T0
,
SP
,
0
,
"Load operand 2 into t0"
);
backend
.
emitADDI
(
SP
,
SP
,
4
,
"Decrement stack ptr for first operand"
);
backend
.
emitSUB
(
T0
,
ZERO
,
T0
,
"Subtract operands"
);
backend
.
emitSW
(
T0
,
SP
,
0
,
"Push result onto stack"
);
return
null
;
}
}
return
null
;
}
@Override
public
Void
analyze
(
AssignStmt
assignStmt
)
{
return
null
;
...
...
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