fixed the concurrent modification issue on zeropage when running unit tests in parallel, by not having machine targets be static objects

This commit is contained in:
Irmen de Jong 2022-02-06 21:29:06 +01:00
parent d2309b8114
commit 10de7dc1f9
26 changed files with 202 additions and 183 deletions

View File

@ -12,10 +12,14 @@ import prog8.compilerinterface.IMemSizer
import prog8.compilerinterface.IStringEncoding import prog8.compilerinterface.IStringEncoding
object C128Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer { class C128Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer {
override val name = "c128" override val name = NAME
override val machine = C128MachineDefinition() override val machine = C128MachineDefinition()
companion object {
const val NAME = "c128"
}
override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> = override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> =
asmsub6502ArgsEvalOrder(sub) asmsub6502ArgsEvalOrder(sub)
override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) = override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) =

View File

@ -12,10 +12,14 @@ import prog8.compilerinterface.IMemSizer
import prog8.compilerinterface.IStringEncoding import prog8.compilerinterface.IStringEncoding
object C64Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer { class C64Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer {
override val name = "c64" override val name = NAME
override val machine = C64MachineDefinition() override val machine = C64MachineDefinition()
companion object {
const val NAME = "c64"
}
override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> = override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> =
asmsub6502ArgsEvalOrder(sub) asmsub6502ArgsEvalOrder(sub)
override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) = override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) =

View File

@ -12,10 +12,14 @@ import prog8.compilerinterface.IMemSizer
import prog8.compilerinterface.IStringEncoding import prog8.compilerinterface.IStringEncoding
object Cx16Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer { class Cx16Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by CbmMemorySizer {
override val name = "cx16" override val name = NAME
override val machine = CX16MachineDefinition() override val machine = CX16MachineDefinition()
companion object {
const val NAME = "cx16"
}
override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> = override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> =
asmsub6502ArgsEvalOrder(sub) asmsub6502ArgsEvalOrder(sub)
override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) = override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>, paramRegisters: List<RegisterOrStatusflag>) =

View File

@ -44,7 +44,7 @@ private fun compileMain(args: Array<String>): Boolean {
val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results") val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results")
val asmListfile by cli.option(ArgType.Boolean, fullName = "asmlist", description = "make the assembler produce a listing file as well") val asmListfile by cli.option(ArgType.Boolean, fullName = "asmlist", description = "make the assembler produce a listing file as well")
val experimentalCodegen by cli.option(ArgType.Boolean, fullName = "expericodegen", description = "use experimental codegen") val experimentalCodegen by cli.option(ArgType.Boolean, fullName = "expericodegen", description = "use experimental codegen")
val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.name}', '${C128Target.name}', '${Cx16Target.name}')").default(C64Target.name) val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}')").default(C64Target.NAME)
val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator) val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator)
val moduleFiles by cli.argument(ArgType.String, fullName = "modules", description = "main module file(s) to compile").multiple(999) val moduleFiles by cli.argument(ArgType.String, fullName = "modules", description = "main module file(s) to compile").multiple(999)
@ -71,7 +71,7 @@ private fun compileMain(args: Array<String>): Boolean {
if(srcdirs.firstOrNull()!=".") if(srcdirs.firstOrNull()!=".")
srcdirs.add(0, ".") srcdirs.add(0, ".")
if (compilationTarget !in setOf(C64Target.name, C128Target.name, Cx16Target.name)) { if (compilationTarget !in setOf(C64Target.NAME, C128Target.NAME, Cx16Target.NAME)) {
System.err.println("Invalid compilation target: $compilationTarget") System.err.println("Invalid compilation target: $compilationTarget")
return false return false
} }

View File

@ -54,9 +54,9 @@ fun compileProgram(args: CompilerArguments): CompilationResult {
val compTarget = val compTarget =
when(args.compilationTarget) { when(args.compilationTarget) {
C64Target.name -> C64Target C64Target.NAME -> C64Target()
C128Target.name -> C128Target C128Target.NAME -> C128Target()
Cx16Target.name -> Cx16Target Cx16Target.NAME -> Cx16Target()
else -> throw IllegalArgumentException("invalid compilation target") else -> throw IllegalArgumentException("invalid compilation target")
} }
@ -233,7 +233,7 @@ fun determineCompilationOptions(program: Program, compTarget: ICompilationTarget
// error will be printed by the astchecker // error will be printed by the astchecker
} }
if (zpType == ZeropageType.FLOATSAFE && compTarget.name == Cx16Target.name) { if (zpType == ZeropageType.FLOATSAFE && compTarget.name == Cx16Target.NAME) {
System.err.println("Warning: zp option floatsafe changed to basicsafe for cx16 target") System.err.println("Warning: zp option floatsafe changed to basicsafe for cx16 target")
zpType = ZeropageType.BASICSAFE zpType = ZeropageType.BASICSAFE
} }

View File

@ -25,7 +25,7 @@ class TestAstChecks: FunSpec({
} }
""" """
val errors = ErrorReporterForTests(keepMessagesAfterReporting = true) val errors = ErrorReporterForTests(keepMessagesAfterReporting = true)
compileText(C64Target, true, text, writeAssembly = true, errors=errors).assertSuccess() compileText(C64Target(), true, text, writeAssembly = true, errors=errors).assertSuccess()
errors.errors.size shouldBe 0 errors.errors.size shouldBe 0
errors.warnings.size shouldBe 2 errors.warnings.size shouldBe 2
errors.warnings[0] shouldContain "converted to float" errors.warnings[0] shouldContain "converted to float"
@ -50,7 +50,7 @@ class TestAstChecks: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, true, text, writeAssembly = true, errors=errors).assertFailure() compileText(C64Target(), true, text, writeAssembly = true, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.warnings.size shouldBe 0 errors.warnings.size shouldBe 0
errors.errors[0] shouldContain ":7:28) assignment value is invalid" errors.errors[0] shouldContain ":7:28) assignment value is invalid"
@ -73,7 +73,7 @@ class TestAstChecks: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.filter { it.contains("missing &") }.size shouldBe 4 errors.errors.filter { it.contains("missing &") }.size shouldBe 4
} }
@ -95,6 +95,6 @@ class TestAstChecks: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
}) })

View File

@ -26,7 +26,7 @@ class TestCallgraph: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, sourcecode).assertSuccess() val result = compileText(C64Target(), false, sourcecode).assertSuccess()
val graph = CallGraph(result.program) val graph = CallGraph(result.program)
graph.imports.size shouldBe 1 graph.imports.size shouldBe 1
@ -67,7 +67,7 @@ class TestCallgraph: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, sourcecode).assertSuccess() val result = compileText(C64Target(), false, sourcecode).assertSuccess()
val graph = CallGraph(result.program) val graph = CallGraph(result.program)
graph.imports.size shouldBe 1 graph.imports.size shouldBe 1
@ -110,7 +110,7 @@ class TestCallgraph: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, sourcecode).assertSuccess() val result = compileText(C64Target(), false, sourcecode).assertSuccess()
val graph = CallGraph(result.program) val graph = CallGraph(result.program)
graph.allIdentifiers.size shouldBeGreaterThanOrEqual 9 graph.allIdentifiers.size shouldBeGreaterThanOrEqual 9
val empties = graph.allIdentifiers.keys.filter { it.nameInSource==listOf("empty") } val empties = graph.allIdentifiers.keys.filter { it.nameInSource==listOf("empty") }

View File

@ -24,7 +24,7 @@ import prog8tests.helpers.compileText
class TestCompilerOnCharLit: FunSpec({ class TestCompilerOnCharLit: FunSpec({
test("testCharLitAsRomsubArg") { test("testCharLitAsRomsubArg") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, false, """ val result = compileText(platform, false, """
main { main {
romsub ${"$"}FFD2 = chrout(ubyte ch @ A) romsub ${"$"}FFD2 = chrout(ubyte ch @ A)
@ -47,7 +47,7 @@ class TestCompilerOnCharLit: FunSpec({
} }
test("testCharVarAsRomsubArg") { test("testCharVarAsRomsubArg") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, false, """ val result = compileText(platform, false, """
main { main {
romsub ${"$"}FFD2 = chrout(ubyte ch @ A) romsub ${"$"}FFD2 = chrout(ubyte ch @ A)
@ -87,7 +87,7 @@ class TestCompilerOnCharLit: FunSpec({
} }
test("testCharConstAsRomsubArg") { test("testCharConstAsRomsubArg") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, false, """ val result = compileText(platform, false, """
main { main {
romsub ${"$"}FFD2 = chrout(ubyte ch @ A) romsub ${"$"}FFD2 = chrout(ubyte ch @ A)

View File

@ -40,7 +40,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
private fun prepareTestFiles(source: String, optimize: Boolean, target: ICompilationTarget): Pair<String, Path> { private fun prepareTestFiles(source: String, optimize: Boolean, target: ICompilationTarget): Pair<String, Path> {
val searchIn = mutableListOf(examplesDir) val searchIn = mutableListOf(examplesDir)
if (target == Cx16Target) { if (target is Cx16Target) {
searchIn.add(0, assumeDirectory(examplesDir, "cx16")) searchIn.add(0, assumeDirectory(examplesDir, "cx16"))
} }
val filepath = searchIn.asSequence() val filepath = searchIn.asSequence()
@ -72,9 +72,10 @@ class TestCompilerOnExamplesC64: FunSpec({
onlyC64.forEach { onlyC64.forEach {
val (source, optimize) = it val (source, optimize) = it
val (displayName, filepath) = prepareTestFiles(source, optimize, C64Target) val target = C64Target()
val (displayName, filepath) = prepareTestFiles(source, optimize, target)
test(displayName) { test(displayName) {
compileTheThing(filepath, optimize, C64Target).assertSuccess() compileTheThing(filepath, optimize, target).assertSuccess()
} }
} }
}) })
@ -103,9 +104,10 @@ class TestCompilerOnExamplesCx16: FunSpec({
onlyCx16.forEach { onlyCx16.forEach {
val (source, optimize) = it val (source, optimize) = it
val (displayName, filepath) = prepareTestFiles(source, optimize, Cx16Target) val target = Cx16Target()
val (displayName, filepath) = prepareTestFiles(source, optimize, target)
test(displayName) { test(displayName) {
compileTheThing(filepath, optimize, Cx16Target).assertSuccess() compileTheThing(filepath, optimize, target).assertSuccess()
} }
} }
}) })
@ -141,13 +143,15 @@ class TestCompilerOnExamplesBothC64andCx16: FunSpec({
bothCx16AndC64.forEach { bothCx16AndC64.forEach {
val (source, optimize) = it val (source, optimize) = it
val (displayNameC64, filepathC64) = prepareTestFiles(source, optimize, C64Target) val c64target = C64Target()
val (displayNameCx16, filepathCx16) = prepareTestFiles(source, optimize, Cx16Target) val cx16target = Cx16Target()
val (displayNameC64, filepathC64) = prepareTestFiles(source, optimize, c64target)
val (displayNameCx16, filepathCx16) = prepareTestFiles(source, optimize, cx16target)
test(displayNameC64) { test(displayNameC64) {
compileTheThing(filepathC64, optimize, C64Target).assertSuccess() compileTheThing(filepathC64, optimize, c64target).assertSuccess()
} }
test(displayNameCx16) { test(displayNameCx16) {
compileTheThing(filepathCx16, optimize, Cx16Target).assertSuccess() compileTheThing(filepathCx16, optimize, cx16target).assertSuccess()
} }
} }
}) })

View File

@ -27,7 +27,7 @@ class TestCompilerOnImportsAndIncludes: FunSpec({
val filepath = assumeReadableFile(fixturesDir, "importFromSameFolder.p8") val filepath = assumeReadableFile(fixturesDir, "importFromSameFolder.p8")
assumeReadableFile(fixturesDir, "foo_bar.p8") assumeReadableFile(fixturesDir, "foo_bar.p8")
val platform = Cx16Target val platform = Cx16Target()
val result = compileFile(platform, optimize = false, fixturesDir, filepath.name) val result = compileFile(platform, optimize = false, fixturesDir, filepath.name)
.assertSuccess() .assertSuccess()
@ -50,7 +50,7 @@ class TestCompilerOnImportsAndIncludes: FunSpec({
val filepath = assumeReadableFile(fixturesDir, "asmIncludeFromSameFolder.p8") val filepath = assumeReadableFile(fixturesDir, "asmIncludeFromSameFolder.p8")
assumeReadableFile(fixturesDir, "foo_bar.asm") assumeReadableFile(fixturesDir, "foo_bar.asm")
val platform = Cx16Target val platform = Cx16Target()
val result = compileFile(platform, optimize = false, fixturesDir, filepath.name) val result = compileFile(platform, optimize = false, fixturesDir, filepath.name)
.assertSuccess() .assertSuccess()
@ -76,7 +76,7 @@ class TestCompilerOnImportsAndIncludes: FunSpec({
val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonExisting.p8") val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonExisting.p8")
assumeNotExists(fixturesDir, "i_do_not_exist.bin") assumeNotExists(fixturesDir, "i_do_not_exist.bin")
compileFile(Cx16Target, false, p8Path.parent, p8Path.name, outputDir) compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir)
.assertFailure() .assertFailure()
} }
@ -84,7 +84,7 @@ class TestCompilerOnImportsAndIncludes: FunSpec({
val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonReadable.p8") val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonReadable.p8")
assumeDirectory(fixturesDir, "subFolder") assumeDirectory(fixturesDir, "subFolder")
compileFile(Cx16Target, false, p8Path.parent, p8Path.name, outputDir) compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir)
.assertFailure() .assertFailure()
} }
@ -104,7 +104,7 @@ class TestCompilerOnImportsAndIncludes: FunSpec({
outputDir.normalize().toAbsolutePath() shouldNotBe workingDir.normalize().toAbsolutePath() outputDir.normalize().toAbsolutePath() shouldNotBe workingDir.normalize().toAbsolutePath()
} }
compileFile(Cx16Target, false, p8Path.parent, p8Path.name, outputDir) compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir)
.assertSuccess( .assertSuccess(
"argument to assembler directive .binary " + "argument to assembler directive .binary " +
"should be relative to the generated .asm file (in output dir), " + "should be relative to the generated .asm file (in output dir), " +

View File

@ -27,7 +27,7 @@ import prog8tests.helpers.*
class TestCompilerOnRanges: FunSpec({ class TestCompilerOnRanges: FunSpec({
test("testUByteArrayInitializerWithRange_char_to_char") { test("testUByteArrayInitializerWithRange_char_to_char") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, false, """ val result = compileText(platform, false, """
main { main {
sub start() { sub start() {
@ -58,7 +58,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("testFloatArrayInitializerWithRange_char_to_char") { test("testFloatArrayInitializerWithRange_char_to_char") {
val platform = C64Target val platform = C64Target()
val result = compileText(platform, optimize = false, """ val result = compileText(platform, optimize = false, """
%import floats %import floats
main { main {
@ -93,7 +93,7 @@ class TestCompilerOnRanges: FunSpec({
val combos = cartesianProduct( val combos = cartesianProduct(
listOf("", "42", "41"), // sizeInDecl listOf("", "42", "41"), // sizeInDecl
listOf("%import floats", ""), // optEnableFloats listOf("%import floats", ""), // optEnableFloats
listOf(Cx16Target, C64Target), // platform listOf(Cx16Target(), C64Target()), // platform
listOf(false, true) // optimize listOf(false, true) // optimize
) )
@ -128,7 +128,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("testForLoopWithRange_char_to_char") { test("testForLoopWithRange_char_to_char") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, optimize = true, """ val result = compileText(platform, optimize = true, """
main { main {
sub start() { sub start() {
@ -162,7 +162,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("testForLoopWithRange_bool_to_bool") { test("testForLoopWithRange_bool_to_bool") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, optimize = true, """ val result = compileText(platform, optimize = true, """
main { main {
sub start() { sub start() {
@ -188,7 +188,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("testForLoopWithRange_ubyte_to_ubyte") { test("testForLoopWithRange_ubyte_to_ubyte") {
val platform = Cx16Target val platform = Cx16Target()
val result = compileText(platform, optimize = true, """ val result = compileText(platform, optimize = true, """
main { main {
sub start() { sub start() {
@ -215,7 +215,7 @@ class TestCompilerOnRanges: FunSpec({
test("testForLoopWithRange_str_downto_str") { test("testForLoopWithRange_str_downto_str") {
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(Cx16Target, true, """ compileText(Cx16Target(), true, """
main { main {
sub start() { sub start() {
ubyte i ubyte i
@ -231,7 +231,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("testForLoopWithIterable_str") { test("testForLoopWithIterable_str") {
val result = compileText(Cx16Target, false, """ val result = compileText(Cx16Target(), false, """
main { main {
sub start() { sub start() {
ubyte i ubyte i
@ -263,7 +263,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("range with negative step should be constvalue") { test("range with negative step should be constvalue") {
val result = compileText(C64Target, false, """ val result = compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
ubyte[] array = 100 to 50 step -2 ubyte[] array = 100 to 50 step -2
@ -283,7 +283,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("range with start/end variables should be ok") { test("range with start/end variables should be ok") {
val result = compileText(C64Target, false, """ val result = compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
byte from = 100 byte from = 100
@ -302,7 +302,7 @@ class TestCompilerOnRanges: FunSpec({
test("for statement on all possible iterable expressions") { test("for statement on all possible iterable expressions") {
compileText(C64Target, false, """ compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
ubyte xx ubyte xx
@ -343,7 +343,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("if containment check on all possible iterable expressions") { test("if containment check on all possible iterable expressions") {
compileText(C64Target, false, """ compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
ubyte xx ubyte xx
@ -404,7 +404,7 @@ class TestCompilerOnRanges: FunSpec({
} }
test("containment check in expressions") { test("containment check in expressions") {
compileText(C64Target, false, """ compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
ubyte xx ubyte xx

View File

@ -46,7 +46,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
quietAssembler = true, quietAssembler = true,
asmListfile = false, asmListfile = false,
experimentalCodegen = false, experimentalCodegen = false,
compilationTarget = Cx16Target.name, compilationTarget = Cx16Target.NAME,
sourceDirs, sourceDirs,
outputDir outputDir
) )

View File

@ -18,7 +18,7 @@ import prog8tests.helpers.outputDir
class TestImportedModulesOrderAndOptions: FunSpec({ class TestImportedModulesOrderAndOptions: FunSpec({
test("testImportedModuleOrderAndMainModuleCorrect") { test("testImportedModuleOrderAndMainModuleCorrect") {
val result = compileText(C64Target, false, """ val result = compileText(C64Target(), false, """
%import textio %import textio
%import floats %import floats
@ -49,7 +49,7 @@ main {
} }
test("testCompilationOptionsCorrectFromMain") { test("testCompilationOptionsCorrectFromMain") {
val result = compileText(C64Target, false, """ val result = compileText(C64Target(), false, """
%import textio %import textio
%import floats %import floats
%zeropage dontuse %zeropage dontuse
@ -62,7 +62,7 @@ main {
} }
""").assertSuccess() """).assertSuccess()
result.program.toplevelModule.name shouldStartWith "on_the_fly_test" result.program.toplevelModule.name shouldStartWith "on_the_fly_test"
val options = determineCompilationOptions(result.program, C64Target) val options = determineCompilationOptions(result.program, C64Target())
options.floats shouldBe true options.floats shouldBe true
options.zeropage shouldBe ZeropageType.DONTUSE options.zeropage shouldBe ZeropageType.DONTUSE
options.noSysInit shouldBe true options.noSysInit shouldBe true
@ -85,7 +85,7 @@ main {
val filenameBase = "on_the_fly_test_" + sourceText.hashCode().toUInt().toString(16) val filenameBase = "on_the_fly_test_" + sourceText.hashCode().toUInt().toString(16)
val filepath = outputDir.resolve("$filenameBase.p8") val filepath = outputDir.resolve("$filenameBase.p8")
filepath.toFile().writeText(sourceText) filepath.toFile().writeText(sourceText)
val (program, options, importedfiles) = parseImports(filepath, errors, C64Target, emptyList()) val (program, options, importedfiles) = parseImports(filepath, errors, C64Target(), emptyList())
program.toplevelModule.name shouldBe filenameBase program.toplevelModule.name shouldBe filenameBase
withClue("all imports other than the test source must have been internal resources library files") { withClue("all imports other than the test source must have been internal resources library files") {

View File

@ -21,6 +21,8 @@ import prog8tests.helpers.*
class TestMemory: FunSpec({ class TestMemory: FunSpec({
val c64target = C64Target()
fun wrapWithProgram(statements: List<Statement>): Program { fun wrapWithProgram(statements: List<Statement>): Program {
val program = Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) val program = Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
val subroutine = Subroutine("test", mutableListOf(), emptyList(), statements.toMutableList(), false, Position.DUMMY) val subroutine = Subroutine("test", mutableListOf(), emptyList(), statements.toMutableList(), false, Position.DUMMY)
@ -35,49 +37,49 @@ class TestMemory: FunSpec({
var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0x1000, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0x1000, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0x9fff, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0x9fff, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0xa000, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xa000, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0xc000, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xc000, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0xcfff, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xcfff, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0xeeee, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xeeee, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = NumericLiteralValue.optimalInteger(0xffff, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xffff, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
} }
test("assign target in mapped IO space C64") { test("assign target in mapped IO space C64") {
@ -86,25 +88,25 @@ class TestMemory: FunSpec({
var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
memexpr = NumericLiteralValue.optimalInteger(0x0001, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0x0001, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
memexpr = NumericLiteralValue.optimalInteger(0xd000, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xd000, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
memexpr = NumericLiteralValue.optimalInteger(0xdfff, Position.DUMMY) memexpr = NumericLiteralValue.optimalInteger(0xdfff, Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
} }
fun createTestProgramForMemoryRefViaVar(address: UInt, vartype: VarDeclType): AssignTarget { fun createTestProgramForMemoryRefViaVar(address: UInt, vartype: VarDeclType): AssignTarget {
@ -118,17 +120,17 @@ class TestMemory: FunSpec({
test("identifier mapped to IO memory on C64") { test("identifier mapped to IO memory on C64") {
var target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.VAR) var target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.VAR)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.VAR) target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.VAR)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.CONST) target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.CONST)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.CONST) target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.CONST)
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.MEMORY) target = createTestProgramForMemoryRefViaVar(0x1000u, VarDeclType.MEMORY)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.MEMORY) target = createTestProgramForMemoryRefViaVar(0xd020u, VarDeclType.MEMORY)
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
} }
test("memory expression mapped to IO memory on C64") { test("memory expression mapped to IO memory on C64") {
@ -136,14 +138,14 @@ class TestMemory: FunSpec({
var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) var target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) var assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
memexpr = PrefixExpression("+", NumericLiteralValue.optimalInteger(0xd020, Position.DUMMY), Position.DUMMY) memexpr = PrefixExpression("+", NumericLiteralValue.optimalInteger(0xd020, Position.DUMMY), Position.DUMMY)
target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY) target = AssignTarget(null, null, DirectMemoryWrite(memexpr, Position.DUMMY), Position.DUMMY)
assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY) assign = Assignment(target, NumericLiteralValue.optimalInteger(0, Position.DUMMY), AssignmentOrigin.USERCODE, Position.DUMMY)
wrapWithProgram(listOf(assign)) wrapWithProgram(listOf(assign))
printProgram(target.definingModule.program) printProgram(target.definingModule.program)
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
} }
test("regular variable not in mapped IO ram on C64") { test("regular variable not in mapped IO ram on C64") {
@ -154,7 +156,7 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
} }
test("memory mapped variable not in mapped IO ram on C64") { test("memory mapped variable not in mapped IO ram on C64") {
@ -166,7 +168,7 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
} }
test("memory mapped variable in mapped IO ram on C64") { test("memory mapped variable in mapped IO ram on C64") {
@ -178,7 +180,7 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
} }
test("array not in mapped IO ram") { test("array not in mapped IO ram") {
@ -190,7 +192,7 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
} }
test("memory mapped array not in mapped IO ram") { test("memory mapped array not in mapped IO ram") {
@ -203,7 +205,7 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe false target.isIOAddress(c64target.machine) shouldBe false
} }
test("memory mapped array in mapped IO ram") { test("memory mapped array in mapped IO ram") {
@ -216,12 +218,12 @@ class TestMemory: FunSpec({
val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test")) val module = Module(mutableListOf(subroutine), Position.DUMMY, SourceCode.Generated("test"))
Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder) Program("test", DummyFunctions, DummyMemsizer, DummyStringEncoder)
.addModule(module) .addModule(module)
target.isIOAddress(C64Target.machine) shouldBe true target.isIOAddress(c64target.machine) shouldBe true
} }
test("memory() with spaces in name works") { test("memory() with spaces in name works") {
compileText(C64Target, false, """ compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
uword @shared mem = memory("a b c", 100, $100) uword @shared mem = memory("a b c", 100, $100)
@ -231,7 +233,7 @@ class TestMemory: FunSpec({
} }
test("memory() with invalid argument") { test("memory() with invalid argument") {
compileText(C64Target, false, """ compileText(C64Target(), false, """
main { main {
sub start() { sub start() {
uword @shared mem1 = memory("abc", 100, -2) uword @shared mem1 = memory("abc", 100, -2)

View File

@ -126,7 +126,7 @@ class TestNumbers: FunSpec({
} }
""" """
val errors = ErrorReporterForTests(keepMessagesAfterReporting = true) val errors = ErrorReporterForTests(keepMessagesAfterReporting = true)
compileText(C64Target, true, src, writeAssembly = false, errors=errors).assertSuccess() compileText(C64Target(), true, src, writeAssembly = false, errors=errors).assertSuccess()
errors.errors.size shouldBe 0 errors.errors.size shouldBe 0
errors.warnings.size shouldBe 2 errors.warnings.size shouldBe 2
errors.warnings[0] shouldContain "converted to float" errors.warnings[0] shouldContain "converted to float"
@ -146,7 +146,7 @@ class TestNumbers: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, true, src, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), true, src, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.warnings.size shouldBe 0 errors.warnings.size shouldBe 0
errors.errors[0] shouldContain "converted to float" errors.errors[0] shouldContain "converted to float"
@ -163,7 +163,7 @@ class TestNumbers: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, true, src, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), true, src, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.warnings.size shouldBe 0 errors.warnings.size shouldBe 0
errors.errors[0] shouldContain "out of range" errors.errors[0] shouldContain "out of range"
@ -179,6 +179,6 @@ class TestNumbers: FunSpec({
} }
} }
""" """
compileText(C64Target, true, src, writeAssembly = false).assertSuccess() compileText(C64Target(), true, src, writeAssembly = false).assertSuccess()
} }
}) })

View File

@ -35,7 +35,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, true, sourcecode).assertSuccess() val result = compileText(C64Target(), true, sourcecode).assertSuccess()
val toplevelModule = result.program.toplevelModule val toplevelModule = result.program.toplevelModule
val mainBlock = toplevelModule.statements.single() as Block val mainBlock = toplevelModule.statements.single() as Block
val startSub = mainBlock.statements.single() as Subroutine val startSub = mainBlock.statements.single() as Subroutine
@ -60,7 +60,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, true, sourcecode).assertSuccess() val result = compileText(C64Target(), true, sourcecode).assertSuccess()
val toplevelModule = result.program.toplevelModule val toplevelModule = result.program.toplevelModule
val mainBlock = toplevelModule.statements.single() as Block val mainBlock = toplevelModule.statements.single() as Block
val startSub = mainBlock.statements[0] as Subroutine val startSub = mainBlock.statements[0] as Subroutine
@ -119,7 +119,7 @@ class TestOptimization: FunSpec({
cx16.r7s = llw - 900 + 999 cx16.r7s = llw - 900 + 999
} }
}""" }"""
val result = compileText(C64Target, true, source, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), true, source, writeAssembly = false).assertSuccess()
// expected: // expected:
// uword load_location // uword load_location
// load_location = 12345 // load_location = 12345
@ -172,7 +172,7 @@ class TestOptimization: FunSpec({
cx16.r4s = llw * 90 / 5 ; not optimized because of loss of integer division precision cx16.r4s = llw * 90 / 5 ; not optimized because of loss of integer division precision
} }
}""" }"""
val result = compileText(C64Target, true, source, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), true, source, writeAssembly = false).assertSuccess()
printProgram(result.program) printProgram(result.program)
// expected: // expected:
// word llw // word llw
@ -229,7 +229,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, sourcecode).assertSuccess() val result = compileText(C64Target(), false, sourcecode).assertSuccess()
val mainsub = result.program.entrypoint val mainsub = result.program.entrypoint
mainsub.statements.size shouldBe 10 mainsub.statements.size shouldBe 10
val declTest = mainsub.statements[0] as VarDecl val declTest = mainsub.statements[0] as VarDecl
@ -267,7 +267,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, src, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, src, writeAssembly = false).assertSuccess()
// ww = ((( not bb as uword) or not ww) as uword) // ww = ((( not bb as uword) or not ww) as uword)
val wwAssign = result.program.entrypoint.statements.last() as Assignment val wwAssign = result.program.entrypoint.statements.last() as Assignment
@ -288,7 +288,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, src, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, src, writeAssembly = false).assertSuccess()
// bb = (( not bb as uword) or not ww) // bb = (( not bb as uword) or not ww)
val bbAssign = result.program.entrypoint.statements.last() as Assignment val bbAssign = result.program.entrypoint.statements.last() as Assignment
@ -300,7 +300,7 @@ class TestOptimization: FunSpec({
expr.right.inferType(result.program).getOrElse { fail("dt") } shouldBe DataType.UWORD expr.right.inferType(result.program).getOrElse { fail("dt") } shouldBe DataType.UWORD
expr.inferType(result.program).getOrElse { fail("dt") } shouldBe DataType.UBYTE expr.inferType(result.program).getOrElse { fail("dt") } shouldBe DataType.UBYTE
val options = CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), false, true, C64Target, outputDir= outputDir) val options = CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), false, true, C64Target(), outputDir= outputDir)
result.program.processAstBeforeAsmGeneration(options, ErrorReporterForTests()) result.program.processAstBeforeAsmGeneration(options, ErrorReporterForTests())
// assignment is now split into: // assignment is now split into:
@ -340,7 +340,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, true, src, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), true, src, writeAssembly = true).assertSuccess()
/* turned into: /* turned into:
ubyte r ubyte r
r = 0 r = 0
@ -376,7 +376,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, optimize=false, src, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), optimize=false, src, writeAssembly = false).assertSuccess()
val assignFF = result.program.entrypoint.statements.last() as Assignment val assignFF = result.program.entrypoint.statements.last() as Assignment
assignFF.isAugmentable shouldBe true assignFF.isAugmentable shouldBe true
assignFF.target.identifier!!.nameInSource shouldBe listOf("ff") assignFF.target.identifier!!.nameInSource shouldBe listOf("ff")
@ -404,7 +404,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
result.program.entrypoint.statements.size shouldBe 7 result.program.entrypoint.statements.size shouldBe 7
val alldecls = result.program.entrypoint.allDefinedSymbols.toList() val alldecls = result.program.entrypoint.allDefinedSymbols.toList()
alldecls.map { it.first } shouldBe listOf("unused_but_shared", "usedvar_only_written", "usedvar") alldecls.map { it.first } shouldBe listOf("unused_but_shared", "usedvar_only_written", "usedvar")
@ -427,7 +427,7 @@ class TestOptimization: FunSpec({
} }
} }
}""" }"""
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
printProgram(result.program) printProgram(result.program)
result.program.entrypoint.statements.size shouldBe 3 result.program.entrypoint.statements.size shouldBe 3
val ifstmt = result.program.entrypoint.statements[0] as IfElse val ifstmt = result.program.entrypoint.statements[0] as IfElse
@ -456,7 +456,7 @@ class TestOptimization: FunSpec({
z6 = z1+z6-5 z6 = z1+z6-5
} }
}""" }"""
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
/* expected: /* expected:
ubyte z1 ubyte z1
z1 = 10 z1 = 10
@ -523,7 +523,7 @@ class TestOptimization: FunSpec({
} }
""" """
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.size shouldBe 6 stmts.size shouldBe 6
val assign=stmts.last() as Assignment val assign=stmts.last() as Assignment
@ -540,7 +540,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.size shouldBe 6 stmts.size shouldBe 6
val assign=stmts.last() as Assignment val assign=stmts.last() as Assignment
@ -559,7 +559,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.size shouldBe 10 stmts.size shouldBe 10
stmts.filterIsInstance<VarDecl>().size shouldBe 5 stmts.filterIsInstance<VarDecl>().size shouldBe 5
@ -575,7 +575,7 @@ class TestOptimization: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, optimize=true, src, writeAssembly=false, errors = errors).assertFailure() compileText(C64Target(), optimize=true, src, writeAssembly=false, errors = errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "type of value BYTE doesn't match target UBYTE" errors.errors[0] shouldContain "type of value BYTE doesn't match target UBYTE"
errors.errors[1] shouldContain "out of range" errors.errors[1] shouldContain "out of range"
@ -594,7 +594,7 @@ class TestOptimization: FunSpec({
q=r q=r
} }
}""" }"""
val result = compileText(C64Target, optimize=false, src, writeAssembly=true).assertSuccess() val result = compileText(C64Target(), optimize=false, src, writeAssembly=true).assertSuccess()
result.program.entrypoint.statements.size shouldBe 11 result.program.entrypoint.statements.size shouldBe 11
result.program.entrypoint.statements.last() shouldBe instanceOf<Return>() result.program.entrypoint.statements.last() shouldBe instanceOf<Return>()
} }
@ -612,7 +612,7 @@ class TestOptimization: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
printProgram(result.program) printProgram(result.program)
/* expected result: /* expected result:
uword yy uword yy
@ -642,7 +642,7 @@ class TestOptimization: FunSpec({
xx = xx+10 ; so this should not be changed into xx=10 xx = xx+10 ; so this should not be changed into xx=10
} }
}""" }"""
val result = compileText(C64Target, optimize=true, src, writeAssembly=false).assertSuccess() val result = compileText(C64Target(), optimize=true, src, writeAssembly=false).assertSuccess()
/* /*
expected result: expected result:
uword xx uword xx

View File

@ -42,7 +42,7 @@ class TestPipes: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, true, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.size shouldBe 3 stmts.size shouldBe 3
val pipef = stmts[0] as Pipe val pipef = stmts[0] as Pipe
@ -76,7 +76,7 @@ class TestPipes: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, errors=errors).assertFailure() compileText(C64Target(), false, text, errors=errors).assertFailure()
errors.errors.size shouldBe 1 errors.errors.size shouldBe 1
errors.errors[0] shouldContain "incompatible" errors.errors[0] shouldContain "incompatible"
} }
@ -104,7 +104,7 @@ class TestPipes: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, true, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.size shouldBe 5 stmts.size shouldBe 5
val assignf = stmts[1] as Assignment val assignf = stmts[1] as Assignment
@ -139,7 +139,7 @@ class TestPipes: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, errors=errors).assertFailure() compileText(C64Target(), false, text, errors=errors).assertFailure()
errors.errors.size shouldBe 1 errors.errors.size shouldBe 1
errors.errors[0] shouldContain "incompatible" errors.errors[0] shouldContain "incompatible"
} }

View File

@ -27,7 +27,7 @@ class TestScoping: FunSpec({
} }
""" """
val result = compileText(C64Target, false, src, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, src, writeAssembly = false).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
module.parent shouldBe instanceOf<GlobalNamespace>() module.parent shouldBe instanceOf<GlobalNamespace>()
module.program shouldBeSameInstanceAs result.program module.program shouldBeSameInstanceAs result.program
@ -46,7 +46,7 @@ class TestScoping: FunSpec({
} }
""" """
val result = compileText(C64Target, false, src, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, src, writeAssembly = false).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val mainBlock = module.statements.single() as Block val mainBlock = module.statements.single() as Block
val start = mainBlock.statements.single() as Subroutine val start = mainBlock.statements.single() as Subroutine
@ -120,7 +120,7 @@ class TestScoping: FunSpec({
} }
""" """
val result = compileText(C64Target, false, src, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, src, writeAssembly = true).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val mainBlock = module.statements.single() as Block val mainBlock = module.statements.single() as Block
val start = mainBlock.statements.single() as Subroutine val start = mainBlock.statements.single() as Subroutine
@ -145,7 +145,7 @@ class TestScoping: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
test("wrong subroutine call without qualified names") { test("wrong subroutine call without qualified names") {
@ -161,7 +161,7 @@ class TestScoping: FunSpec({
} }
""" """
val errors= ErrorReporterForTests() val errors= ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors = errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors = errors).assertFailure()
errors.errors.size shouldBe 1 errors.errors.size shouldBe 1
errors.errors[0] shouldContain "undefined symbol: routine2" errors.errors[0] shouldContain "undefined symbol: routine2"
} }
@ -181,7 +181,7 @@ class TestScoping: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
test("wrong subroutine calls with qualified names (not from root)") { test("wrong subroutine calls with qualified names (not from root)") {
@ -200,7 +200,7 @@ class TestScoping: FunSpec({
} }
""" """
val errors= ErrorReporterForTests() val errors= ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 4 errors.errors.size shouldBe 4
errors.errors[0] shouldContain "undefined symbol: start.routine2" errors.errors[0] shouldContain "undefined symbol: start.routine2"
errors.errors[1] shouldContain "undefined symbol: wrong.start.routine2" errors.errors[1] shouldContain "undefined symbol: wrong.start.routine2"
@ -232,7 +232,7 @@ class TestScoping: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
test("wrong variables without qualified names") { test("wrong variables without qualified names") {
@ -264,7 +264,7 @@ class TestScoping: FunSpec({
} }
""" """
val errors= ErrorReporterForTests() val errors= ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 5 errors.errors.size shouldBe 5
errors.errors[0] shouldContain "undefined symbol: v3" errors.errors[0] shouldContain "undefined symbol: v3"
errors.errors[1] shouldContain "undefined symbol: v4" errors.errors[1] shouldContain "undefined symbol: v4"
@ -297,7 +297,7 @@ class TestScoping: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
test("wrong variable refs with qualified names 1 (not from root)") { test("wrong variable refs with qualified names 1 (not from root)") {
@ -324,7 +324,7 @@ class TestScoping: FunSpec({
} }
""" """
val errors= ErrorReporterForTests() val errors= ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 5 errors.errors.size shouldBe 5
errors.errors[0] shouldContain "undefined symbol: routine.value" errors.errors[0] shouldContain "undefined symbol: routine.value"
errors.errors[1] shouldContain "undefined symbol: routine.arg" errors.errors[1] shouldContain "undefined symbol: routine.arg"
@ -362,7 +362,7 @@ class TestScoping: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = false).assertSuccess() compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
} }
test("various wrong goto targets") { test("various wrong goto targets") {
@ -380,7 +380,7 @@ class TestScoping: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors = errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors = errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "wrong address" errors.errors[0] shouldContain "wrong address"
errors.errors[1] shouldContain "takes parameters" errors.errors[1] shouldContain "takes parameters"

View File

@ -44,7 +44,7 @@ class TestSubroutines: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val mainBlock = module.statements.single() as Block val mainBlock = module.statements.single() as Block
val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"} val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"}
@ -100,7 +100,7 @@ class TestSubroutines: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val mainBlock = module.statements.single() as Block val mainBlock = module.statements.single() as Block
val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"} val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"}
@ -162,7 +162,7 @@ class TestSubroutines: FunSpec({
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val mainBlock = module.statements.single() as Block val mainBlock = module.statements.single() as Block
val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"} val asmfunc = mainBlock.statements.filterIsInstance<Subroutine>().single { it.name=="asmfunc"}
@ -188,7 +188,7 @@ class TestSubroutines: FunSpec({
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "pass-by-reference type can't be used" errors.errors[0] shouldContain "pass-by-reference type can't be used"
errors.errors[1] shouldContain "pass-by-reference type can't be used" errors.errors[1] shouldContain "pass-by-reference type can't be used"
@ -212,7 +212,7 @@ class TestSubroutines: FunSpec({
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val block = module.statements.single() as Block val block = module.statements.single() as Block
val thing = block.statements.filterIsInstance<Subroutine>().single {it.name=="thing"} val thing = block.statements.filterIsInstance<Subroutine>().single {it.name=="thing"}
@ -253,7 +253,7 @@ class TestSubroutines: FunSpec({
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
val module = result.program.toplevelModule val module = result.program.toplevelModule
val block = module.statements.single() as Block val block = module.statements.single() as Block
val thing = block.statements.filterIsInstance<Subroutine>().single {it.name=="thing"} val thing = block.statements.filterIsInstance<Subroutine>().single {it.name=="thing"}
@ -284,7 +284,7 @@ class TestSubroutines: FunSpec({
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "7:25) invalid number of arguments" errors.errors[0] shouldContain "7:25) invalid number of arguments"
errors.errors[1] shouldContain "9:25) invalid number of arguments" errors.errors[1] shouldContain "9:25) invalid number of arguments"
@ -305,7 +305,7 @@ class TestSubroutines: FunSpec({
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "7:25) invalid number of arguments" errors.errors[0] shouldContain "7:25) invalid number of arguments"
errors.errors[1] shouldContain "9:25) invalid number of arguments" errors.errors[1] shouldContain "9:25) invalid number of arguments"
@ -325,7 +325,7 @@ class TestSubroutines: FunSpec({
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "cannot use arguments" errors.errors[0] shouldContain "cannot use arguments"
errors.errors[1] shouldContain "invalid number of arguments" errors.errors[1] shouldContain "invalid number of arguments"
@ -343,7 +343,7 @@ class TestSubroutines: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
val stmts = result.program.entrypoint.statements val stmts = result.program.entrypoint.statements
stmts.last() shouldBe instanceOf<Subroutine>() stmts.last() shouldBe instanceOf<Subroutine>()

View File

@ -32,7 +32,7 @@ class TestTypecasts: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
result.program.entrypoint.statements.size shouldBe 13 result.program.entrypoint.statements.size shouldBe 13
} }
@ -54,7 +54,7 @@ class TestTypecasts: FunSpec({
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = true, errors=errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = true, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "can't cast" errors.errors[0] shouldContain "can't cast"
errors.errors[1] shouldContain "can't cast" errors.errors[1] shouldContain "can't cast"
@ -70,7 +70,7 @@ class TestTypecasts: FunSpec({
} }
}""" }"""
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, errors=errors).assertFailure() compileText(C64Target(), false, text, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "can't cast" errors.errors[0] shouldContain "can't cast"
errors.errors[1] shouldContain "can't cast" errors.errors[1] shouldContain "can't cast"
@ -87,7 +87,7 @@ class TestTypecasts: FunSpec({
} }
}""" }"""
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, errors=errors).assertFailure() compileText(C64Target(), false, text, errors=errors).assertFailure()
errors.errors.size shouldBe 1 errors.errors.size shouldBe 1
errors.errors[0] shouldContain "in-place makes no sense" errors.errors[0] shouldContain "in-place makes no sense"
} }
@ -103,7 +103,7 @@ class TestTypecasts: FunSpec({
} }
}""" }"""
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, errors=errors).assertFailure() compileText(C64Target(), false, text, errors=errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "can't cast" errors.errors[0] shouldContain "can't cast"
errors.errors[1] shouldContain "can't cast" errors.errors[1] shouldContain "can't cast"
@ -152,7 +152,7 @@ class TestTypecasts: FunSpec({
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
printProgram(result.program) printProgram(result.program)
val statements = result.program.entrypoint.statements val statements = result.program.entrypoint.statements
statements.size shouldBe 27 statements.size shouldBe 27
@ -180,7 +180,7 @@ class TestTypecasts: FunSpec({
} }
} }
}""" }"""
val result = compileText(C64Target, false, text, writeAssembly = true).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
val statements = result.program.entrypoint.statements val statements = result.program.entrypoint.statements
statements.size shouldBe 14 statements.size shouldBe 14
} }
@ -197,7 +197,7 @@ class TestTypecasts: FunSpec({
} }
} }
""" """
compileText(C64Target, false, text, writeAssembly = true).assertSuccess() compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
} }
test("(u)byte extend to word parameters") { test("(u)byte extend to word parameters") {
@ -226,7 +226,7 @@ class TestTypecasts: FunSpec({
}} }}
} }
}""" }"""
compileText(C64Target, true, text, writeAssembly = true).assertSuccess() compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
} }
test("lsb msb used as args with word types") { test("lsb msb used as args with word types") {
@ -245,6 +245,6 @@ class TestTypecasts: FunSpec({
}} }}
} }
}""" }"""
compileText(C64Target, true, text, writeAssembly = true).assertSuccess() compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
} }
}) })

View File

@ -59,9 +59,10 @@ class TestAbstractZeropage: FunSpec({
class TestC64Zeropage: FunSpec({ class TestC64Zeropage: FunSpec({
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
val c64target = C64Target()
test("testNames") { test("testNames") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, c64target))
var result = zp.allocate(emptyList(), DataType.UBYTE, null, null, errors) var result = zp.allocate(emptyList(), DataType.UBYTE, null, null, errors)
result.onFailure { fail(it.toString()) } result.onFailure { fail(it.toString()) }
@ -75,33 +76,33 @@ class TestC64Zeropage: FunSpec({
} }
test("testZpFloatEnable") { test("testZpFloatEnable") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target))
var result = zp.allocate(emptyList(), DataType.FLOAT, null, null, errors) var result = zp.allocate(emptyList(), DataType.FLOAT, null, null, errors)
result.expectError { "should be allocation error due to disabled floats" } result.expectError { "should be allocation error due to disabled floats" }
val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), true, false, C64Target)) val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), true, false, c64target))
result = zp2.allocate(emptyList(), DataType.FLOAT, null, null, errors) result = zp2.allocate(emptyList(), DataType.FLOAT, null, null, errors)
result.expectError { "should be allocation error due to disabled ZP use" } result.expectError { "should be allocation error due to disabled ZP use" }
val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), true, false, C64Target)) val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), true, false, c64target))
zp3.allocate(emptyList(), DataType.FLOAT, null, null, errors) zp3.allocate(emptyList(), DataType.FLOAT, null, null, errors)
} }
test("testZpModesWithFloats") { test("testZpModesWithFloats") {
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target))
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, c64target))
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, c64target))
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, c64target))
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target))
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), true, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), true, false, c64target))
shouldThrow<InternalCompilerException> { shouldThrow<InternalCompilerException> {
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), true, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), true, false, c64target))
} }
shouldThrow<InternalCompilerException> { shouldThrow<InternalCompilerException> {
C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), true, false, C64Target)) C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), true, false, c64target))
} }
} }
test("testZpDontuse") { test("testZpDontuse") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), false, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), false, false, c64target))
println(zp.free) println(zp.free)
zp.availableBytes() shouldBe 0 zp.availableBytes() shouldBe 0
val result = zp.allocate(emptyList(), DataType.BYTE, null, null, errors) val result = zp.allocate(emptyList(), DataType.BYTE, null, null, errors)
@ -109,13 +110,13 @@ class TestC64Zeropage: FunSpec({
} }
test("testFreeSpacesBytes") { test("testFreeSpacesBytes") {
val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, C64Target)) val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target))
zp1.availableBytes() shouldBe 18 zp1.availableBytes() shouldBe 18
val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, C64Target)) val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FLOATSAFE, emptyList(), false, false, c64target))
zp2.availableBytes() shouldBe 85 zp2.availableBytes() shouldBe 85
val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, C64Target)) val zp3 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, c64target))
zp3.availableBytes() shouldBe 125 zp3.availableBytes() shouldBe 125
val zp4 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, C64Target)) val zp4 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target))
zp4.availableBytes() shouldBe 239 zp4.availableBytes() shouldBe 239
zp4.allocate(listOf("test"), DataType.UBYTE, null, null, errors) zp4.allocate(listOf("test"), DataType.UBYTE, null, null, errors)
zp4.availableBytes() shouldBe 238 zp4.availableBytes() shouldBe 238
@ -124,7 +125,7 @@ class TestC64Zeropage: FunSpec({
} }
test("testReservedSpace") { test("testReservedSpace") {
val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, C64Target)) val zp1 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target))
zp1.availableBytes() shouldBe 239 zp1.availableBytes() shouldBe 239
50u shouldBeIn zp1.free 50u shouldBeIn zp1.free
100u shouldBeIn zp1.free 100u shouldBeIn zp1.free
@ -133,7 +134,7 @@ class TestC64Zeropage: FunSpec({
200u shouldBeIn zp1.free 200u shouldBeIn zp1.free
255u shouldBeIn zp1.free 255u shouldBeIn zp1.free
199u shouldBeIn zp1.free 199u shouldBeIn zp1.free
val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, listOf(50u .. 100u, 200u..255u), false, false, C64Target)) val zp2 = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, listOf(50u .. 100u, 200u..255u), false, false, c64target))
zp2.availableBytes() shouldBe 139 zp2.availableBytes() shouldBe 139
50u shouldNotBeIn zp2.free 50u shouldNotBeIn zp2.free
100u shouldNotBeIn zp2.free 100u shouldNotBeIn zp2.free
@ -145,7 +146,7 @@ class TestC64Zeropage: FunSpec({
} }
test("testBasicsafeAllocation") { test("testBasicsafeAllocation") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target))
zp.availableBytes() shouldBe 18 zp.availableBytes() shouldBe 18
zp.hasByteAvailable() shouldBe true zp.hasByteAvailable() shouldBe true
zp.hasWordAvailable() shouldBe true zp.hasWordAvailable() shouldBe true
@ -167,7 +168,7 @@ class TestC64Zeropage: FunSpec({
} }
test("testFullAllocation") { test("testFullAllocation") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, c64target))
zp.availableBytes() shouldBe 239 zp.availableBytes() shouldBe 239
zp.hasByteAvailable() shouldBe true zp.hasByteAvailable() shouldBe true
zp.hasWordAvailable() shouldBe true zp.hasWordAvailable() shouldBe true
@ -198,7 +199,7 @@ class TestC64Zeropage: FunSpec({
} }
test("testEfficientAllocation") { test("testEfficientAllocation") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, c64target))
zp.availableBytes() shouldBe 18 zp.availableBytes() shouldBe 18
zp.allocate(emptyList(), DataType.WORD, null, null, errors ).getOrElse{throw it}.first shouldBe 0x04u zp.allocate(emptyList(), DataType.WORD, null, null, errors ).getOrElse{throw it}.first shouldBe 0x04u
zp.allocate(emptyList(), DataType.UBYTE, null, null, errors).getOrElse{throw it}.first shouldBe 0x06u zp.allocate(emptyList(), DataType.UBYTE, null, null, errors).getOrElse{throw it}.first shouldBe 0x06u
@ -216,7 +217,7 @@ class TestC64Zeropage: FunSpec({
} }
test("testReservedLocations") { test("testReservedLocations") {
val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, C64Target)) val zp = C64Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, c64target))
withClue("zp _B1 and _REG must be next to each other to create a word") { withClue("zp _B1 and _REG must be next to each other to create a word") {
zp.SCRATCH_B1 + 1u shouldBe zp.SCRATCH_REG zp.SCRATCH_B1 + 1u shouldBe zp.SCRATCH_REG
} }
@ -226,20 +227,21 @@ class TestC64Zeropage: FunSpec({
class TestCx16Zeropage: FunSpec({ class TestCx16Zeropage: FunSpec({
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
val cx16target = Cx16Target()
test("testReservedLocations") { test("testReservedLocations") {
val zp = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, Cx16Target)) val zp = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), false, false, cx16target))
withClue("zp _B1 and _REG must be next to each other to create a word") { withClue("zp _B1 and _REG must be next to each other to create a word") {
zp.SCRATCH_B1 + 1u shouldBe zp.SCRATCH_REG zp.SCRATCH_B1 + 1u shouldBe zp.SCRATCH_REG
} }
} }
test("testFreeSpacesBytes") { test("testFreeSpacesBytes") {
val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, Cx16Target)) val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.BASICSAFE, emptyList(), true, false, cx16target))
zp1.availableBytes() shouldBe 88 zp1.availableBytes() shouldBe 88
val zp2 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, Cx16Target)) val zp2 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.KERNALSAFE, emptyList(), false, false, cx16target))
zp2.availableBytes() shouldBe 175 zp2.availableBytes() shouldBe 175
val zp3 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, Cx16Target)) val zp3 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, cx16target))
zp3.availableBytes() shouldBe 216 zp3.availableBytes() shouldBe 216
zp3.allocate(listOf("test"), DataType.UBYTE, null, null, errors) zp3.allocate(listOf("test"), DataType.UBYTE, null, null, errors)
zp3.availableBytes() shouldBe 215 zp3.availableBytes() shouldBe 215
@ -248,7 +250,7 @@ class TestCx16Zeropage: FunSpec({
} }
test("testReservedSpace") { test("testReservedSpace") {
val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, Cx16Target)) val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, cx16target))
zp1.availableBytes() shouldBe 216 zp1.availableBytes() shouldBe 216
0x22u shouldBeIn zp1.free 0x22u shouldBeIn zp1.free
0x80u shouldBeIn zp1.free 0x80u shouldBeIn zp1.free
@ -258,7 +260,7 @@ class TestCx16Zeropage: FunSpec({
} }
test("preallocated zp vars") { test("preallocated zp vars") {
val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, Cx16Target)) val zp1 = CX16Zeropage(CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, false, cx16target))
zp1.variables[listOf("test")] shouldBe null zp1.variables[listOf("test")] shouldBe null
zp1.variables[listOf("cx16", "r0")] shouldNotBe null zp1.variables[listOf("cx16", "r0")] shouldNotBe null
zp1.variables[listOf("cx16", "r15")] shouldNotBe null zp1.variables[listOf("cx16", "r15")] shouldNotBe null

View File

@ -908,7 +908,7 @@ class TestProg8Parser: FunSpec( {
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
val start = result.program.entrypoint val start = result.program.entrypoint
val string = (start.statements[0] as VarDecl).value as StringLiteralValue val string = (start.statements[0] as VarDecl).value as StringLiteralValue
withClue("x-escapes are hacked to range 0x8000-0x80ff") { withClue("x-escapes are hacked to range 0x8000-0x80ff") {
@ -945,7 +945,7 @@ class TestProg8Parser: FunSpec( {
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
val start = result.program.entrypoint val start = result.program.entrypoint
val containmentChecks = start.statements.takeLast(4) val containmentChecks = start.statements.takeLast(4)
(containmentChecks[0] as IfElse).condition shouldBe instanceOf<ContainmentCheck>() (containmentChecks[0] as IfElse).condition shouldBe instanceOf<ContainmentCheck>()
@ -966,7 +966,7 @@ class TestProg8Parser: FunSpec( {
} }
""" """
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
compileText(C64Target, false, text, writeAssembly = false, errors = errors).assertFailure() compileText(C64Target(), false, text, writeAssembly = false, errors = errors).assertFailure()
errors.errors.size shouldBe 2 errors.errors.size shouldBe 2
errors.errors[0] shouldContain "must be an iterable type" errors.errors[0] shouldContain "must be an iterable type"
errors.errors[1] shouldContain "datatype doesn't match" errors.errors[1] shouldContain "datatype doesn't match"
@ -986,7 +986,7 @@ class TestProg8Parser: FunSpec( {
} }
} }
""" """
val result = compileText(C64Target, false, text, writeAssembly = false).assertSuccess() val result = compileText(C64Target(), false, text, writeAssembly = false).assertSuccess()
val stmt = result.program.entrypoint.statements val stmt = result.program.entrypoint.statements
stmt.size shouldBe 12 stmt.size shouldBe 12
val var1 = stmt[0] as VarDecl val var1 = stmt[0] as VarDecl

View File

@ -77,7 +77,7 @@ class TestAsmGenSymbols: StringSpec({
fun createTestAsmGen(program: Program): AsmGen6502 { fun createTestAsmGen(program: Program): AsmGen6502 {
val errors = ErrorReporterForTests() val errors = ErrorReporterForTests()
val options = CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, true, C64Target) val options = CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, true, C64Target())
options.compTarget.machine.zeropage = C64Zeropage(options) options.compTarget.machine.zeropage = C64Zeropage(options)
val asmgen = AsmGen6502(program, errors, options) val asmgen = AsmGen6502(program, errors, options)
return asmgen return asmgen

View File

@ -24,7 +24,7 @@ class TestVariables: FunSpec({
} }
} }
""" """
compileText(C64Target, true, text, writeAssembly = true).assertSuccess() compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
} }
test("array initialization with array literal") { test("array initialization with array literal") {
@ -35,7 +35,7 @@ class TestVariables: FunSpec({
} }
} }
""" """
compileText(C64Target, true, text, writeAssembly = true).assertSuccess() compileText(C64Target(), true, text, writeAssembly = true).assertSuccess()
} }
test("array initialization with array var assignment") { test("array initialization with array var assignment") {
@ -48,6 +48,6 @@ class TestVariables: FunSpec({
ubyte[] values = [1,2,3] ubyte[] values = [1,2,3]
} }
""" """
compileText(C64Target, false, text, writeAssembly = true).assertSuccess() compileText(C64Target(), false, text, writeAssembly = true).assertSuccess()
} }
}) })

View File

@ -85,7 +85,7 @@ internal fun generateAssembly(
program: Program, program: Program,
options: CompilationOptions? = null options: CompilationOptions? = null
): IAssemblyProgram? { ): IAssemblyProgram? {
val coptions = options ?: CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), true, true, C64Target, outputDir = outputDir) val coptions = options ?: CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.DONTUSE, emptyList(), true, true, C64Target(), outputDir = outputDir)
coptions.compTarget.machine.zeropage = C64Zeropage(coptions) coptions.compTarget.machine.zeropage = C64Zeropage(coptions)
val asmgen = AsmGen6502(program, ErrorReporterForTests(), coptions) val asmgen = AsmGen6502(program, ErrorReporterForTests(), coptions)
return asmgen.compileToAssembly() return asmgen.compileToAssembly()

View File

@ -3,8 +3,7 @@ TODO
For next release For next release
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
fix the concurrent modification issue on zeropage when running unit tests in parallel -> don't use static objects anymore ...
Need help with Need help with
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^