mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
code generator: add a return (RTS) to empty subroutines. Fixes #67
This commit is contained in:
parent
41e40cad03
commit
85956b5828
@ -120,13 +120,13 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: I
|
|||||||
// and if an assembly block doesn't contain a rts/rti, and some other situations.
|
// and if an assembly block doesn't contain a rts/rti, and some other situations.
|
||||||
val mods = mutableListOf<IAstModification>()
|
val mods = mutableListOf<IAstModification>()
|
||||||
val returnStmt = Return(null, subroutine.position)
|
val returnStmt = Return(null, subroutine.position)
|
||||||
if (subroutine.asmAddress == null
|
if (subroutine.asmAddress == null && !subroutine.inline) {
|
||||||
&& !subroutine.inline
|
if(subroutine.statements.isEmpty() ||
|
||||||
&& subroutine.statements.isNotEmpty()
|
(subroutine.amountOfRtsInAsm() == 0
|
||||||
&& subroutine.amountOfRtsInAsm() == 0
|
|
||||||
&& subroutine.statements.lastOrNull { it !is VarDecl } !is Return
|
&& subroutine.statements.lastOrNull { it !is VarDecl } !is Return
|
||||||
&& subroutine.statements.last() !is Subroutine) {
|
&& subroutine.statements.last() !is Subroutine)) {
|
||||||
mods += IAstModification.InsertLast(returnStmt, subroutine)
|
mods += IAstModification.InsertLast(returnStmt, subroutine)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// precede a subroutine with a return to avoid falling through into the subroutine from code above it
|
// precede a subroutine with a return to avoid falling through into the subroutine from code above it
|
||||||
|
Loading…
Reference in New Issue
Block a user