Skip to content
Snippets Groups Projects
Verified Commit 64c5899d authored by Recolic Keghart's avatar Recolic Keghart
Browse files

return statement works

parent 06777b34
No related branches found
No related tags found
No related merge requests found
Pipeline #289 passed with warnings with stages
in 8 minutes and 52 seconds
......@@ -352,8 +352,9 @@ public class CodeGenImpl extends CodeGenBase {
stmt.dispatch(stmtAnalyzer);
}
backend.emitMV(A0, ZERO, "Returning None implicitly");
betterBackend.emitFunctionEnd(funcInfo.getFuncName(), stmtAnalyzer.regMgr, "BEGIN FUNCTION");
// the following instructions are ignored.
// backend.emitMV(A0, ZERO, "Returning None implicitly");
backend.emitLocalLabel(stmtAnalyzer.epilogue, "Epilogue");
// FIXME: {... reset fp etc. ...}
......@@ -424,8 +425,12 @@ public class CodeGenImpl extends CodeGenBase {
// this is wrong, and you'll have to fix it.
// This is here just to demonstrate how to emit a
// RISC-V instruction.
backend.emitMV(ZERO, ZERO, "No-op");
return null;
RiscVBackend.Register returnValReg = node.value.dispatch(this);
if(returnValReg == null)
return null;
backend.emitMV(A0, returnValReg, "put return value!");
regMgr.returnOne(returnValReg);
return null; // Statement always return null.
}
// FIXME: More, of course.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment