start implementing ptr deref augmented assigns

This commit is contained in:
Irmen de Jong
2025-05-08 23:43:52 +02:00
parent 8353c689ca
commit 506062c6b6
5 changed files with 132 additions and 73 deletions

View File

@@ -3,21 +3,24 @@ package prog8tests.compiler
import io.kotest.core.spec.style.FunSpec
import io.kotest.engine.spec.tempdir
import io.kotest.matchers.shouldNotBe
import prog8.code.target.C64Target
import prog8.code.target.VMTarget
import prog8.vm.VmRunner
import prog8tests.helpers.compileText
import kotlin.io.path.readText
class TestPointers: FunSpec( {
val outputDir = tempdir().toPath()
xtest("block scoping still parsed correctly") {
test("block scoping still parsed correctly") {
val src="""
main {
sub start() {
readbyte(&thing.name) ; ok
readbyte(&thing.name[1]) ; TODO fix error
readbyte(&thing.array[1]) ; TODO fix error
readbyte(&thing.name)
readbyte(&thing.name[1])
readbyte(&thing.array[1])
}
sub readbyte(uword @requirezp ptr) {
@@ -29,7 +32,10 @@ thing {
str name = "error"
ubyte[10] array
}"""
compileText(VMTarget(), false, src, outputDir, writeAssembly = false) shouldNotBe null
compileText(C64Target(), false, src, outputDir) shouldNotBe null
val result = compileText(VMTarget(), false, src, outputDir)!!
val virtfile = result.compilationOptions.outputDir.resolve(result.compilerAst.name + ".p8ir")
VmRunner().runProgram(virtfile.readText(), true)
}
})