This commit is contained in:
Irmen de Jong 2021-11-28 14:06:12 +01:00
parent d6abd72e55
commit 960b60cd2d
3 changed files with 13 additions and 4 deletions

View File

@ -378,6 +378,11 @@ internal class StatementReorderer(val program: Program,
}
private fun replaceCallSubStatementWithGosub(function: Subroutine, call: FunctionCallStatement, parent: Node): Iterable<IAstModification> {
if(function.parameters.isEmpty()) {
// 0 params -> just GoSub
return listOf(IAstModification.ReplaceNode(call, GoSub(null, call.target, null, call.position), parent))
}
val assignParams =
function.parameters.zip(call.args).map {
var argumentValue = it.second

View File

@ -307,12 +307,10 @@ class GlobalNamespace(val modules: Iterable<Module>): Node, INameScope {
}
}
object BuiltinFunctionScopePlaceholder : INameScope {
internal object BuiltinFunctionScopePlaceholder : INameScope {
override val name = "<<builtin-functions-scope-placeholder>>"
override val position = Position("<<placeholder>>", 0, 0, 0)
override var statements = mutableListOf<Statement>()
override var parent: Node = ParentSentinel
override fun linkParents(parent: Node) {}
}

View File

@ -16,7 +16,7 @@ main {
word @shared ww
byte @shared bb
push(-bb)
push(ub+1)
pop(ub)
txt.print_ub(ub)
txt.nl()
@ -25,6 +25,8 @@ main {
txt.print_uw(uw)
txt.nl()
single(ub+1)
; uw=10000
; routines(44,uw+123)
; routines2(44,uw+123)
@ -39,6 +41,10 @@ main {
}
sub single(ubyte num) {
num++
}
sub routine(uword num, ubyte a1, ubyte a2, ubyte switch, byte a3) {
txt.print_uw(num)
txt.spc()