mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
added exit function to astvm simulator
This commit is contained in:
parent
64d682bfde
commit
0422ad080a
@ -1054,6 +1054,8 @@ internal class AstChecker(private val program: Program,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO warn about unreachable code following a return statement???
|
||||
}
|
||||
|
||||
private fun checkFunctionOrLabelExists(target: IdentifierReference, statement: Statement): Statement? {
|
||||
|
@ -588,6 +588,8 @@ internal class StatementOptimizer(private val program: Program) : IAstModifyingV
|
||||
statements.removeAt(statements.lastIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO remove all statements following a 'return' statement ???
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -996,6 +996,11 @@ class AstVm(val program: Program, compilationTarget: String) {
|
||||
else -> RuntimeValueNumeric(DataType.BYTE, 1)
|
||||
}
|
||||
}
|
||||
"exit" -> {
|
||||
val rv = args.single().numericValue()
|
||||
dialog.canvas.printAsciiText("\n<program ended with exit($rv)>")
|
||||
throw VmTerminationException("program ended with exit($rv)")
|
||||
}
|
||||
else -> TODO("astvm implement builtin function $name")
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ main {
|
||||
sub sub2() {
|
||||
c64scr.print("sp2:")
|
||||
print_stackpointer()
|
||||
exit(65)
|
||||
sub3()
|
||||
sub3()
|
||||
return
|
||||
sub3() ; TODO warning about unreachable code
|
||||
sub3() ; TODO remove statements after a return
|
||||
sub3()
|
||||
sub3()
|
||||
sub3()
|
||||
@ -40,9 +40,6 @@ main {
|
||||
}
|
||||
|
||||
sub print_stackpointer() {
|
||||
%asm {{
|
||||
tsx
|
||||
}}
|
||||
c64scr.print_ub(X) ; prints stack pointer
|
||||
c64.CHROUT('\n')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user