Verified Commit 64c5899d authored by Recolic Keghart's avatar Recolic Keghart 🎱

return statement works

parent 06777b34
Pipeline #289 passed 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment