mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
decided
This commit is contained in:
parent
24b77fb5a5
commit
3626828ceb
@ -227,8 +227,9 @@ open class VarDecl(val type: VarDeclType,
|
||||
}
|
||||
|
||||
override fun replaceChildNode(node: Node, replacement: Node) {
|
||||
// TODO the check that node===value is too strict sometimes, but leaving it out allows for bugs to creep through ... :( Perhaps check when adding the replace if there is already a replace on the same node?
|
||||
require(replacement is Expression)
|
||||
require(replacement is Expression && node===value)
|
||||
// NOTE: ideally you also want to check that node===value but this sometimes crashes the optimizer when queueing multiple node replacements
|
||||
// just accept the risk of having the wrong node specified in the IAstModification object...
|
||||
value = replacement
|
||||
replacement.parent = this
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ interface IAstModification {
|
||||
}
|
||||
}
|
||||
|
||||
class ReplaceNode(private val node: Node, private val replacement: Node, private val parent: Node) :
|
||||
class ReplaceNode(val node: Node, private val replacement: Node, private val parent: Node) :
|
||||
IAstModification {
|
||||
override fun perform() {
|
||||
parent.replaceChildNode(node, replacement)
|
||||
@ -158,9 +158,19 @@ abstract class AstWalker {
|
||||
open fun after(whileLoop: WhileLoop, parent: Node): Iterable<IAstModification> = emptyList()
|
||||
|
||||
private val modifications = mutableListOf<Triple<IAstModification, Node, Node>>()
|
||||
// private val modificationsReplacedNodes = mutableSetOf<Pair<Node, Position>>()
|
||||
|
||||
private fun track(mods: Iterable<IAstModification>, node: Node, parent: Node) {
|
||||
for (it in mods) modifications += Triple(it, node, parent)
|
||||
for (it in mods) {
|
||||
// if(it is IAstModification.ReplaceNode) {
|
||||
// val replaceKey = Pair(it.node, it.node.position)
|
||||
// if(replaceKey in modificationsReplacedNodes)
|
||||
// throw FatalAstException("there already is a node replacement for $replaceKey - optimizer can't deal with multiple replacements for same node yet. Split the ast modification?")
|
||||
// else
|
||||
// modificationsReplacedNodes.add(replaceKey)
|
||||
// }
|
||||
modifications += Triple(it, node, parent)
|
||||
}
|
||||
}
|
||||
|
||||
fun applyModifications(): Int {
|
||||
@ -169,6 +179,7 @@ abstract class AstWalker {
|
||||
}
|
||||
val amount = modifications.size
|
||||
modifications.clear()
|
||||
// modificationsReplacedNodes.clear()
|
||||
return amount
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,24 @@
|
||||
%target cx16
|
||||
;%target cx16
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
txt.print("hello")
|
||||
|
||||
str filename = "titlescreen.bin"
|
||||
ubyte success = cx16.vload(filename, 8, 0, $0000)
|
||||
if success {
|
||||
txt.print("load ok")
|
||||
cx16.VERA_DC_HSCALE = 64
|
||||
cx16.VERA_DC_VSCALE = 64
|
||||
cx16.VERA_L1_CONFIG = %00011111 ; 256c bitmap mode
|
||||
cx16.VERA_L1_MAPBASE = 0
|
||||
cx16.VERA_L1_TILEBASE = 0
|
||||
} else {
|
||||
txt.print("load fail")
|
||||
}
|
||||
; str filename = "titlescreen.bin"
|
||||
; ubyte success = cx16.vload(filename, 8, 0, $0000)
|
||||
; if success {
|
||||
; txt.print("load ok")
|
||||
; cx16.VERA_DC_HSCALE = 64
|
||||
; cx16.VERA_DC_VSCALE = 64
|
||||
; cx16.VERA_L1_CONFIG = %00011111 ; 256c bitmap mode
|
||||
; cx16.VERA_L1_MAPBASE = 0
|
||||
; cx16.VERA_L1_TILEBASE = 0
|
||||
; } else {
|
||||
; txt.print("load fail")
|
||||
; }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user