mirror of
https://github.com/irmen/prog8.git
synced 2024-10-17 10:24:55 +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 {
|
private fun labelFirstChunk(chunks: IRCodeChunks, label: String): IRCodeChunks {
|
||||||
require(chunks.isNotEmpty() && label.isNotBlank())
|
require(chunks.isNotEmpty() && label.isNotBlank())
|
||||||
val newChunks = chunks.drop(1).toMutableList()
|
val first = chunks[0]
|
||||||
val labeledFirstChunk = when(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 -> {
|
is IRCodeChunk -> {
|
||||||
val newChunk = IRCodeChunk(label, first.position, first.next)
|
val newChunk = IRCodeChunk(label, first.position, first.next)
|
||||||
newChunk.instructions += first.instructions
|
newChunk.instructions += first.instructions
|
||||||
@ -363,8 +369,7 @@ class IRCodeGen(
|
|||||||
throw AssemblyError("invalid chunk")
|
throw AssemblyError("invalid chunk")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newChunks.add(0, labeledFirstChunk)
|
return listOf(labeledFirstChunk) + chunks.drop(1)
|
||||||
return newChunks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun translate(whenStmt: PtWhen): IRCodeChunks {
|
private fun translate(whenStmt: PtWhen): IRCodeChunks {
|
||||||
|
@ -99,19 +99,16 @@ mylabel2:
|
|||||||
goto mylabel2
|
goto mylabel2
|
||||||
} until cx16.r0
|
} until cx16.r0
|
||||||
|
|
||||||
; TODO fix this for vm codegen:
|
|
||||||
repeat cx16.r0 {
|
repeat cx16.r0 {
|
||||||
mylabel3:
|
mylabel3:
|
||||||
goto mylabel3
|
goto mylabel3
|
||||||
}
|
}
|
||||||
|
|
||||||
; TODO fix this for vm codegen:
|
|
||||||
for cx16.r0L in 0 to 2 {
|
for cx16.r0L in 0 to 2 {
|
||||||
mylabel4:
|
mylabel4:
|
||||||
goto mylabel4
|
goto mylabel4
|
||||||
}
|
}
|
||||||
|
|
||||||
; TODO fix this for vm codegen:
|
|
||||||
for cx16.r0L in cx16.r1L to cx16.r2L {
|
for cx16.r0L in cx16.r1L to cx16.r2L {
|
||||||
mylabel5:
|
mylabel5:
|
||||||
goto mylabel5
|
goto mylabel5
|
||||||
|
@ -3,7 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- ir: fix unit tests
|
|
||||||
- ir: join more codechunks, before ir is written to file
|
- ir: join more codechunks, before ir is written to file
|
||||||
- ir: fix removeWeirdBranches in IR optimizer
|
- ir: fix removeWeirdBranches in IR optimizer
|
||||||
- update diagram in technical.rst?
|
- update diagram in technical.rst?
|
||||||
|
Loading…
Reference in New Issue
Block a user