Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Reichenbach
EDAP15-exercise-3
Commits
82e28d9d
Commit
82e28d9d
authored
Dec 04, 2020
by
Christoph Reichenbach
Browse files
Suppress unneeded return null
parent
7d00ba2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/teal0/backend/IRGen.jrag
View file @
82e28d9d
...
...
@@ -168,7 +168,19 @@ aspect IRGen {
return BB;
}
// same effect as startBB() except for hasBB()
public void endBB() {
BB = null;
}
public boolean hasBB() {
return BB != null;
}
public IRCodeBB getCurrentBB() {
if (BB == null) {
startBB();
}
return BB;
}
...
...
@@ -324,7 +336,7 @@ aspect IRGen {
getBody().genCode(fctx);
if (fctx.getCurrentBB().getIRCodeExit() == null) {
if (
fctx.hasBB() &&
fctx.getCurrentBB().getIRCodeExit() == null) {
// no exit here
fctx.addInsn(new IRConstantInsn().setDst(new IRVarRef(fctx.getReturnVar()))
.setSrc(new IRNull()));
...
...
@@ -454,9 +466,9 @@ aspect IRGen {
ctx.addInsn(new IRCopyInsn(new IRVarRef(ctx.getReturnVar()), retVal));
IRCodeBB currentBB = ctx.getCurrentBB();
currentBB.setIRCodeExit(new IRReturn(new IRVarRef(ctx.getReturnVar())));
// start a new basic block to hold the translation
// of any (unreachable) statements following the return.
ctx.
start
BB();
//
ctx will auto-
start a new basic block to hold the translation
// of any (unreachable) statements following the return
if needed
.
ctx.
end
BB();
}
syn IRVar VarDecl.genIR() = new IRVar(getIdDecl().genIR(), variableType().genIRTypeRef());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment