mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
fixed string interning to also consider the alt-encoding
This commit is contained in:
parent
6e65cb2c0a
commit
c677f0a875
@ -407,8 +407,9 @@ internal class AsmGen(private val program: Program,
|
||||
}
|
||||
|
||||
private fun outputStringvar(lastvar: VarDecl, encoded: List<Short>) {
|
||||
val string = (lastvar.value as StringLiteralValue).value
|
||||
out("${lastvar.name}\t; ${lastvar.datatype} \"${escape(string).replace("\u0000", "<NULL>")}\"")
|
||||
val sv = lastvar.value as StringLiteralValue
|
||||
val altEncoding = if(sv.altEncoding) "@" else ""
|
||||
out("${lastvar.name}\t; ${lastvar.datatype} $altEncoding\"${escape(sv.value).replace("\u0000", "<NULL>")}\"")
|
||||
val outputBytes = encoded.map { "$" + it.toString(16).padStart(2, '0') }
|
||||
for (chunk in outputBytes.chunked(16))
|
||||
out(" .byte " + chunk.joinToString())
|
||||
|
@ -268,7 +268,7 @@ class Program(val name: String,
|
||||
get() = mainModule.loadAddress
|
||||
|
||||
var actualLoadAddress: Int = 0
|
||||
private val internedStrings = mutableMapOf<String, List<String>>()
|
||||
private val internedStrings = mutableMapOf<Pair<String, Boolean>, List<String>>()
|
||||
val internedStringsModuleName = "prog8_interned_strings"
|
||||
|
||||
init {
|
||||
@ -295,7 +295,9 @@ class Program(val name: String,
|
||||
}
|
||||
|
||||
fun internString(string: StringLiteralValue): List<String> {
|
||||
val existing = internedStrings[string.value]
|
||||
val key = Pair(string.value, string.altEncoding)
|
||||
string.heapId
|
||||
val existing = internedStrings[key]
|
||||
if(existing!=null)
|
||||
return existing
|
||||
|
||||
@ -305,7 +307,7 @@ class Program(val name: String,
|
||||
(internedStringsBlock as Block).statements.add(decl)
|
||||
decl.linkParents(internedStringsBlock)
|
||||
val scopedName = listOf(internedStringsModuleName, decl.name)
|
||||
internedStrings[string.value] = scopedName
|
||||
internedStrings[key] = scopedName
|
||||
return scopedName
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,9 @@ main {
|
||||
vtui.gotoxy(10,10)
|
||||
vtui.border(1, 40, 6, $47)
|
||||
vtui.gotoxy(12,12)
|
||||
vtui.print_str(@"Hello, world! VTUI from Prog8!", $f2, false)
|
||||
vtui.print_str(@"Hello, world! vtui from Prog8!", $f2, $80)
|
||||
vtui.gotoxy(12,13)
|
||||
vtui.print_str("Hello, world! vtui from Prog8!", $f2, $00)
|
||||
|
||||
repeat {
|
||||
}
|
||||
@ -22,7 +24,7 @@ main {
|
||||
|
||||
vtui $1000 {
|
||||
|
||||
%asmbinary "VTUI0.4.BIN", 2 ; skip the 2 dummy load address bytes
|
||||
%asmbinary "VTUI0.5.BIN", 2 ; skip the 2 dummy load address bytes
|
||||
|
||||
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
||||
romsub $1000 = initialize() clobbers(A, X, Y)
|
||||
@ -35,7 +37,7 @@ vtui $1000 {
|
||||
romsub $1014 = scan_char() -> ubyte @A, ubyte @X
|
||||
romsub $1017 = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101a = vline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101d = print_str(str string @R0, ubyte colors @X, ubyte convertchars @Pc) clobbers(A, Y)
|
||||
romsub $101d = print_str(str string @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
||||
romsub $1020 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
||||
romsub $1023 = pet2scr(ubyte char @A) -> ubyte @A
|
||||
romsub $1026 = scr2pet(ubyte char @A) -> ubyte @A
|
||||
|
Loading…
Reference in New Issue
Block a user