a few comment and TODO cleanups.

remove remark about chars UBYTE type, kotlin's closest native type that can contain 0-255 is a short.
This commit is contained in:
Irmen de Jong 2021-10-19 23:20:34 +02:00
parent 804bb06859
commit 82d20dea39
6 changed files with 10 additions and 15 deletions

View File

@ -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"))
}

View File

@ -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))
}

View File

@ -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<IdentifierReference>(funCall.args[0]) // make test fail
}

View File

@ -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<Statement>,
fun linkIntoProgram(program: Program) {
this.program = program
linkParents(program.namespace)
// TODO do this in program.addModule() ?
}
override val definingScope: INameScope

View File

@ -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

View File

@ -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)