mirror of
https://github.com/irmen/prog8.git
synced 2024-10-09 13:55:19 +00:00
fix assembly generation error when pipe character is part of string literal
This commit is contained in:
parent
a9fe6472d9
commit
9e3e2ff81a
@ -85,7 +85,7 @@ class AsmGen(internal val program: Program,
|
||||
}
|
||||
|
||||
internal fun out(str: String, splitlines: Boolean = true) {
|
||||
val fragment = (if(" | " in str) str.replace("|", "\n") else str).trim('\n')
|
||||
val fragment = (if(splitlines && " | " in str) str.replace("|", "\n") else str).trim('\n')
|
||||
if (splitlines) {
|
||||
for (line in fragment.splitToSequence('\n')) {
|
||||
val trimmed = if (line.startsWith(' ')) "\t" + line.trim() else line
|
||||
|
@ -589,7 +589,7 @@ internal class ProgramAndVarsGen(
|
||||
}
|
||||
|
||||
private fun outputStringvar(varname: String, encoding: Encoding, value: String) {
|
||||
asmgen.out("$varname\t; $encoding:\"${value.escape().replace("\u0000", "<NULL>")}\"")
|
||||
asmgen.out("$varname\t; $encoding:\"${value.escape().replace("\u0000", "<NULL>")}\"", false)
|
||||
val bytes = compTarget.encodeString(value, encoding).plus(0.toUByte())
|
||||
val outputBytes = bytes.map { "$" + it.toString(16).padStart(2, '0') }
|
||||
for (chunk in outputBytes.chunked(16))
|
||||
|
@ -50,4 +50,18 @@ class TestVariables: FunSpec({
|
||||
"""
|
||||
compileText(C64Target(), false, text, writeAssembly = true) shouldNotBe null
|
||||
}
|
||||
|
||||
|
||||
test("pipe character in string literal") {
|
||||
val text = """
|
||||
main {
|
||||
sub start() {
|
||||
str name = "first|second"
|
||||
str name2 = "first | second"
|
||||
}
|
||||
}
|
||||
"""
|
||||
compileText(C64Target(), false, text, writeAssembly = true) shouldNotBe null
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -3,7 +3,7 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- fix natt's bugs
|
||||
- fix natt's bug: ubyte - 2 + 10 somehow gets promoted to byte?
|
||||
- optimize pointervar indexing codegen: make them work as subroutine paramers
|
||||
- optimize pointervar indexing codegen: writing (all sorts of things)
|
||||
- pipe operator: (targets other than 'Virtual'): allow non-unary function calls in the pipe that specify the other argument(s) in the calls. Already working for VM target.
|
||||
|
Loading…
Reference in New Issue
Block a user