mirror of https://github.com/tbklang/tlang.git
DGen
- Handle `ReturnInstruction` with no expression Test cases - Added `simple_return_expressionless.t`
This commit is contained in:
parent
5f81ac41db
commit
301a6615ad
|
@ -392,10 +392,18 @@ public final class DCodeEmitter : CodeEmitter
|
|||
Context context = returnInstruction.getContext();
|
||||
assert(context);
|
||||
|
||||
/* Get the return expression instruction */
|
||||
Value returnExpressionInstr = returnInstruction.getReturnExpInstr();
|
||||
|
||||
emmmmit = "return "~transform(returnExpressionInstr)~";";
|
||||
/* If there is an expression returned */
|
||||
if(returnInstruction.hasReturnExpInstr())
|
||||
{
|
||||
/* Get the return expression instruction */
|
||||
Value returnExpressionInstr = returnInstruction.getReturnExpInstr();
|
||||
emmmmit = "return "~transform(returnExpressionInstr)~";";
|
||||
}
|
||||
/* Expression-less return */
|
||||
else
|
||||
{
|
||||
emmmmit = "return;";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* If statements (IfStatementInstruction)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
module simple_return_expressionless;
|
||||
|
||||
void func()
|
||||
{
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue