mirror of
https://github.com/irmen/prog8.git
synced 2026-04-21 17:16:33 +00:00
IRFileReader parses the p8ir file with xml parser
This commit is contained in:
@@ -291,12 +291,7 @@ class IRCodeGen(
|
||||
}
|
||||
is PtConditionalBranch -> translate(node)
|
||||
is PtInlineAssembly -> listOf(IRInlineAsmChunk(null, node.assembly, node.isIR, null))
|
||||
is PtIncludeBinary -> {
|
||||
val data = node.file.readBytes()
|
||||
.drop(node.offset?.toInt() ?: 0)
|
||||
.take(node.length?.toInt() ?: Int.MAX_VALUE)
|
||||
listOf(IRInlineBinaryChunk(null, data.map { it.toUByte() }, null))
|
||||
}
|
||||
is PtIncludeBinary -> listOf(IRInlineBinaryChunk(null, readBinaryData(node), null))
|
||||
is PtAddressOf,
|
||||
is PtContainmentCheck,
|
||||
is PtMemoryByte,
|
||||
@@ -327,6 +322,13 @@ class IRCodeGen(
|
||||
return chunks
|
||||
}
|
||||
|
||||
private fun readBinaryData(node: PtIncludeBinary): Collection<UByte> {
|
||||
return node.file.readBytes()
|
||||
.drop(node.offset?.toInt() ?: 0)
|
||||
.take(node.length?.toInt() ?: Int.MAX_VALUE)
|
||||
.map { it.toUByte() }
|
||||
}
|
||||
|
||||
private fun translate(branch: PtConditionalBranch): IRCodeChunks {
|
||||
val result = mutableListOf<IRCodeChunkBase>()
|
||||
val elseLabel = createLabelName()
|
||||
@@ -1106,8 +1108,8 @@ class IRCodeGen(
|
||||
child.name,
|
||||
child.address,
|
||||
child.clobbers,
|
||||
child.parameters.map { Pair(it.first.type, it.second) }, // note: the name of the asmsub param is not used anymore.
|
||||
child.returnTypes.zip(child.retvalRegisters),
|
||||
child.parameters.map { IRAsmSubroutine.IRAsmParam(it.second, it.first.type) }, // note: the name of the asmsub param is not used anymore.
|
||||
child.returnTypes.zip(child.retvalRegisters).map { IRAsmSubroutine.IRAsmParam(it.second, it.first) },
|
||||
asmChunk,
|
||||
child.position
|
||||
)
|
||||
@@ -1116,6 +1118,9 @@ class IRCodeGen(
|
||||
is PtInlineAssembly -> {
|
||||
irBlock += IRInlineAsmChunk(null, child.assembly, child.isIR, null)
|
||||
}
|
||||
is PtIncludeBinary -> {
|
||||
irBlock += IRInlineBinaryChunk(null, readBinaryData(child), null)
|
||||
}
|
||||
else -> TODO("weird child node $child")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user