diff --git a/compiler/src/prog8/compiler/ModuleImporter.kt b/compiler/src/prog8/compiler/ModuleImporter.kt index a62e9f699..b6b270dbb 100644 --- a/compiler/src/prog8/compiler/ModuleImporter.kt +++ b/compiler/src/prog8/compiler/ModuleImporter.kt @@ -35,7 +35,7 @@ class ModuleImporter(private val program: Program, file = filePath.normalize().toFile(), reason = "searched in $searchIn")) 1 -> candidates.first() - else -> candidates.first() // TODO: report error if more than 1 candidate? + else -> candidates.first() // when more candiates, pick the one from the first location } val logMsg = "importing '${filePath.nameWithoutExtension}' (from file $srcPath)" @@ -142,7 +142,7 @@ class ModuleImporter(private val program: Program, } else { val dropCurDir = if(sourcePaths.isNotEmpty() && sourcePaths[0].name == ".") 1 else 0 sourcePaths.drop(dropCurDir) + - // TODO: won't work until Prog8Parser is fixed s.t. it fully initializes the modules it returns. ??? (what won't work?) + // TODO: won't work until Prog8Parser is fixed s.t. it fully initializes the modules it returns. // hm, what won't work?) listOf(Path(importingModule.position.file).parent ?: Path("")) + listOf(Path(".", "prog8lib")) } diff --git a/compiler/test/ModuleImporterTests.kt b/compiler/test/ModuleImporterTests.kt index 064f578b9..ecc335f68 100644 --- a/compiler/test/ModuleImporterTests.kt +++ b/compiler/test/ModuleImporterTests.kt @@ -259,7 +259,7 @@ class TestModuleImporter { val result2 = importer.importLibraryModule(filenameWithExt) assertThat(count[n] + " call / with .p8 extension", result2, Is(nullValue())) assertFalse(importer.errors.noErrors(), count[n] + " call / with .p8 extension") - assertEquals(errors.errors.single(), "no module found with name i_do_not_exist.p8") // TODO don't add a p8 extension in the import logic... + assertEquals(errors.errors.single(), "no module found with name i_do_not_exist.p8") errors.report() assertThat(program.modules.size, equalTo(1)) } diff --git a/compiler/test/TestCompilerOnCharLit.kt b/compiler/test/TestCompilerOnCharLit.kt index f68075e40..583d9983a 100644 --- a/compiler/test/TestCompilerOnCharLit.kt +++ b/compiler/test/TestCompilerOnCharLit.kt @@ -42,7 +42,7 @@ class TestCompilerOnCharLit { "char literal should have been replaced by ubyte literal") val arg = funCall.args[0] as NumericLiteralValue assertEquals(DataType.UBYTE, arg.type) - assertEquals(platform.encodeString("\n", false)[0], arg.number.toShort()) // TODO: short/int/UBYTE - which should it be? + assertEquals(platform.encodeString("\n", false)[0], arg.number.toShort()) } @Test @@ -77,7 +77,7 @@ class TestCompilerOnCharLit { "char literal should have been replaced by ubyte literal") val initializerValue = decl.value as NumericLiteralValue assertEquals(DataType.UBYTE, initializerValue.type) - assertEquals(platform.encodeString("\n", false)[0], initializerValue.number.toShort()) // TODO: short/int/UBYTE - which should it be? + assertEquals(platform.encodeString("\n", false)[0], initializerValue.number.toShort()) } @Test @@ -105,12 +105,12 @@ class TestCompilerOnCharLit { assertEquals(DataType.UBYTE, decl.datatype) assertEquals( platform.encodeString("\n", false)[0], - (decl.value as NumericLiteralValue).number.toShort()) // TODO: short/int/UBYTE - which should it be? + (decl.value as NumericLiteralValue).number.toShort()) } is NumericLiteralValue -> { assertEquals( platform.encodeString("\n", false)[0], - arg.number.toShort()) // TODO: short/int/UBYTE - which should it be? + arg.number.toShort()) } else -> assertIs(funCall.args[0]) // make test fail } diff --git a/compilerAst/src/prog8/ast/AstToplevel.kt b/compilerAst/src/prog8/ast/AstToplevel.kt index f73abdc74..9144ab75a 100644 --- a/compilerAst/src/prog8/ast/AstToplevel.kt +++ b/compilerAst/src/prog8/ast/AstToplevel.kt @@ -259,8 +259,7 @@ class Program(val name: String, require(null == _modules.firstOrNull { it.name == module.name }) { "module '${module.name}' already present" } _modules.add(module) - module.linkParents(namespace) - module.program = this + module.linkIntoProgram(this) return this } @@ -344,7 +343,7 @@ class Program(val name: String, require(node is Module && replacement is Module) val idx = _modules.indexOfFirst { it===node } _modules[idx] = replacement - replacement.parent = this // TODO: why not replacement.program = this; replacement.linkParents(namespace)?! + replacement.linkIntoProgram(this) } } @@ -374,7 +373,6 @@ open class Module(final override var statements: MutableList, fun linkIntoProgram(program: Program) { this.program = program linkParents(program.namespace) - // TODO do this in program.addModule() ? } override val definingScope: INameScope diff --git a/compilerAst/src/prog8/parser/Prog8Parser.kt b/compilerAst/src/prog8/parser/Prog8Parser.kt index 8e8d60002..9801d6593 100644 --- a/compilerAst/src/prog8/parser/Prog8Parser.kt +++ b/compilerAst/src/prog8/parser/Prog8Parser.kt @@ -31,12 +31,9 @@ object Prog8Parser { parser.addErrorListener(antlrErrorListener) val parseTree = parser.module() - val module = ParsedModule(src) - // .linkParents called in ParsedModule.add parseTree.directive().forEach { module.add(it.toAst()) } - // TODO: remove Encoding parseTree.block().forEach { module.add(it.toAst(module.isLibrary)) } return module diff --git a/examples/cx16/kefrenbars.p8 b/examples/cx16/kefrenbars.p8 index 0b7b31306..7b7cafd41 100644 --- a/examples/cx16/kefrenbars.p8 +++ b/examples/cx16/kefrenbars.p8 @@ -22,7 +22,7 @@ main { ; Not yet implemented in ROM: cx16.FB_set_palette(&colors, 0, len(colors)*3) palette.set_rgb(&colors, len(colors)) - cx16.screen_set_mode(128) ; low-res bitmap 256 colors + void cx16.screen_set_mode(128) ; low-res bitmap 256 colors cx16.FB_init() cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch display all the way to the bottom cx16.set_rasterirq(&irq.irqhandler, 0)