mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 04:30:03 +00:00
ir: fix overwriting chunk label
This commit is contained in:
parent
0eda7ac498
commit
5b6569d0f9
@ -346,8 +346,14 @@ class IRCodeGen(
|
||||
|
||||
private fun labelFirstChunk(chunks: IRCodeChunks, label: String): IRCodeChunks {
|
||||
require(chunks.isNotEmpty() && label.isNotBlank())
|
||||
val newChunks = chunks.drop(1).toMutableList()
|
||||
val labeledFirstChunk = when(val first=chunks[0]) {
|
||||
val first = chunks[0]
|
||||
if(first.label!=null) {
|
||||
if(first.label==label)
|
||||
return chunks
|
||||
val newFirst = IRCodeChunk(label, first.position, first)
|
||||
return listOf(newFirst) + chunks
|
||||
}
|
||||
val labeledFirstChunk = when(first) {
|
||||
is IRCodeChunk -> {
|
||||
val newChunk = IRCodeChunk(label, first.position, first.next)
|
||||
newChunk.instructions += first.instructions
|
||||
@ -363,8 +369,7 @@ class IRCodeGen(
|
||||
throw AssemblyError("invalid chunk")
|
||||
}
|
||||
}
|
||||
newChunks.add(0, labeledFirstChunk)
|
||||
return newChunks
|
||||
return listOf(labeledFirstChunk) + chunks.drop(1)
|
||||
}
|
||||
|
||||
private fun translate(whenStmt: PtWhen): IRCodeChunks {
|
||||
|
@ -99,19 +99,16 @@ mylabel2:
|
||||
goto mylabel2
|
||||
} until cx16.r0
|
||||
|
||||
; TODO fix this for vm codegen:
|
||||
repeat cx16.r0 {
|
||||
mylabel3:
|
||||
goto mylabel3
|
||||
}
|
||||
|
||||
; TODO fix this for vm codegen:
|
||||
for cx16.r0L in 0 to 2 {
|
||||
mylabel4:
|
||||
goto mylabel4
|
||||
}
|
||||
|
||||
; TODO fix this for vm codegen:
|
||||
for cx16.r0L in cx16.r1L to cx16.r2L {
|
||||
mylabel5:
|
||||
goto mylabel5
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- ir: fix unit tests
|
||||
- ir: join more codechunks, before ir is written to file
|
||||
- ir: fix removeWeirdBranches in IR optimizer
|
||||
- update diagram in technical.rst?
|
||||
|
Loading…
x
Reference in New Issue
Block a user