allow goto to take any expression, not only an integer or an identifier (part 1)

This commit is contained in:
Irmen de Jong
2024-12-14 00:56:11 +01:00
parent 697d54e10a
commit cc59069876
18 changed files with 122 additions and 119 deletions

View File

@@ -68,12 +68,7 @@ fun printAst(root: PtNode, skipLibraries: Boolean, output: (text: String) -> Uni
"%asm {{ ...${node.assembly.length} characters... }}"
}
is PtJump -> {
if(node.identifier!=null)
"goto ${node.identifier.name}"
else if(node.address!=null)
"goto ${node.address.toHex()}"
else
"???"
"goto ${txt(node.target)}"
}
is PtAsmSub -> {
val params = node.parameters.joinToString(", ") {

View File

@@ -116,11 +116,9 @@ class PtIfElse(position: Position) : PtNode(position) {
}
class PtJump(val identifier: PtIdentifier?, // note: even ad-hoc labels are wrapped as an Identifier to simplify code. Just use dummy type and position.
val address: UInt?,
position: Position) : PtNode(position) {
class PtJump(val target: PtExpression, position: Position) : PtNode(position) {
init {
identifier?.let {it.parent = this }
target.parent = this
}
}