correct intermediate code output of pointers in arrayvalues

This commit is contained in:
Irmen de Jong 2019-04-10 22:08:21 +02:00
parent ce8853ab50
commit f3c1783bf2
2 changed files with 21 additions and 11 deletions

View File

@ -459,13 +459,23 @@ class IntermediateProgram(val name: String, var loadAddress: Int, val heap: Heap
out.println("%end_memory")
out.println("%heap")
heap.allEntries().forEach {
out.print("${it.key} ${it.value.type.name.toLowerCase()} ")
when {
it.value.str!=null ->
out.println("${it.key} ${it.value.type.name.toLowerCase()} \"${escape(it.value.str!!)}\"")
it.value.array!=null ->
out.println("${it.key} ${it.value.type.name.toLowerCase()} ${it.value.array!!.toList()}")
out.println("\"${escape(it.value.str!!)}\"")
it.value.array!=null -> {
// this array can contain both normal integers, and pointer values
val arrayvalues = it.value.array!!.map { av ->
when {
av.integer!=null -> av.integer.toString()
av.pointerOf!=null -> "&${av.pointerOf.identifier}"
else -> throw CompilerException("weird array value")
}
}
out.println(arrayvalues)
}
it.value.doubleArray!=null ->
out.println("${it.key} ${it.value.type.name.toLowerCase()} ${it.value.doubleArray!!.toList()}")
out.println(it.value.doubleArray!!.toList())
else -> throw CompilerException("invalid heap entry $it")
}
}

View File

@ -7,8 +7,8 @@
~ main {
sub start() {
;aggregates()
pointers()
aggregates()
;pointers()
}
sub aggregates() {
@ -51,7 +51,7 @@
c64.CHROUT(' ')
c64scr.print_uw(min(uwa))
c64.CHROUT(' ')
c64flt.print_f(min(fa)) ; @todo fix min(floatarray)
c64flt.print_f(min(fa)) ; @todo fix min(floatarray) (vm is ok)
c64.CHROUT('\n')
c64scr.print_b(max(ba))
@ -62,7 +62,7 @@
c64.CHROUT(' ')
c64scr.print_uw(max(uwa))
c64.CHROUT(' ')
c64flt.print_f(max(fa)) ; @todo fix max(floatarray)
c64flt.print_f(max(fa)) ; @todo fix max(floatarray) (vm is ok)
c64.CHROUT('\n')
c64scr.print_uw(sum(ba))
@ -110,9 +110,9 @@
;ptrsubasm("moet werken") ; @todo rewrite ast into pointer-of expression (and remove special cases from Compiler)
;pointersub("moet werken") ; @todo rewrite ast into pointer-of expression (and remove special cases from Compiler)
myprintasm("moet werken3")
myprintasm("moet werken3")
myprintasm("moet werken4")
;myprintasm("moet werken3")
;myprintasm("moet werken3")
;myprintasm("moet werken4")
c64.CHROUT('\n')