mirror of
https://github.com/irmen/prog8.git
synced 2025-05-12 19:47:48 +00:00
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:
parent
804bb06859
commit
82d20dea39
@ -35,7 +35,7 @@ class ModuleImporter(private val program: Program,
|
|||||||
file = filePath.normalize().toFile(),
|
file = filePath.normalize().toFile(),
|
||||||
reason = "searched in $searchIn"))
|
reason = "searched in $searchIn"))
|
||||||
1 -> candidates.first()
|
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)"
|
val logMsg = "importing '${filePath.nameWithoutExtension}' (from file $srcPath)"
|
||||||
@ -142,7 +142,7 @@ class ModuleImporter(private val program: Program,
|
|||||||
} else {
|
} else {
|
||||||
val dropCurDir = if(sourcePaths.isNotEmpty() && sourcePaths[0].name == ".") 1 else 0
|
val dropCurDir = if(sourcePaths.isNotEmpty() && sourcePaths[0].name == ".") 1 else 0
|
||||||
sourcePaths.drop(dropCurDir) +
|
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(importingModule.position.file).parent ?: Path("")) +
|
||||||
listOf(Path(".", "prog8lib"))
|
listOf(Path(".", "prog8lib"))
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ class TestModuleImporter {
|
|||||||
val result2 = importer.importLibraryModule(filenameWithExt)
|
val result2 = importer.importLibraryModule(filenameWithExt)
|
||||||
assertThat(count[n] + " call / with .p8 extension", result2, Is(nullValue()))
|
assertThat(count[n] + " call / with .p8 extension", result2, Is(nullValue()))
|
||||||
assertFalse(importer.errors.noErrors(), count[n] + " call / with .p8 extension")
|
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()
|
errors.report()
|
||||||
assertThat(program.modules.size, equalTo(1))
|
assertThat(program.modules.size, equalTo(1))
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class TestCompilerOnCharLit {
|
|||||||
"char literal should have been replaced by ubyte literal")
|
"char literal should have been replaced by ubyte literal")
|
||||||
val arg = funCall.args[0] as NumericLiteralValue
|
val arg = funCall.args[0] as NumericLiteralValue
|
||||||
assertEquals(DataType.UBYTE, arg.type)
|
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
|
@Test
|
||||||
@ -77,7 +77,7 @@ class TestCompilerOnCharLit {
|
|||||||
"char literal should have been replaced by ubyte literal")
|
"char literal should have been replaced by ubyte literal")
|
||||||
val initializerValue = decl.value as NumericLiteralValue
|
val initializerValue = decl.value as NumericLiteralValue
|
||||||
assertEquals(DataType.UBYTE, initializerValue.type)
|
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
|
@Test
|
||||||
@ -105,12 +105,12 @@ class TestCompilerOnCharLit {
|
|||||||
assertEquals(DataType.UBYTE, decl.datatype)
|
assertEquals(DataType.UBYTE, decl.datatype)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
platform.encodeString("\n", false)[0],
|
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 -> {
|
is NumericLiteralValue -> {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
platform.encodeString("\n", false)[0],
|
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
|
else -> assertIs<IdentifierReference>(funCall.args[0]) // make test fail
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,7 @@ class Program(val name: String,
|
|||||||
require(null == _modules.firstOrNull { it.name == module.name })
|
require(null == _modules.firstOrNull { it.name == module.name })
|
||||||
{ "module '${module.name}' already present" }
|
{ "module '${module.name}' already present" }
|
||||||
_modules.add(module)
|
_modules.add(module)
|
||||||
module.linkParents(namespace)
|
module.linkIntoProgram(this)
|
||||||
module.program = this
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +343,7 @@ class Program(val name: String,
|
|||||||
require(node is Module && replacement is Module)
|
require(node is Module && replacement is Module)
|
||||||
val idx = _modules.indexOfFirst { it===node }
|
val idx = _modules.indexOfFirst { it===node }
|
||||||
_modules[idx] = replacement
|
_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) {
|
fun linkIntoProgram(program: Program) {
|
||||||
this.program = program
|
this.program = program
|
||||||
linkParents(program.namespace)
|
linkParents(program.namespace)
|
||||||
// TODO do this in program.addModule() ?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val definingScope: INameScope
|
override val definingScope: INameScope
|
||||||
|
@ -31,12 +31,9 @@ object Prog8Parser {
|
|||||||
parser.addErrorListener(antlrErrorListener)
|
parser.addErrorListener(antlrErrorListener)
|
||||||
|
|
||||||
val parseTree = parser.module()
|
val parseTree = parser.module()
|
||||||
|
|
||||||
val module = ParsedModule(src)
|
val module = ParsedModule(src)
|
||||||
|
|
||||||
// .linkParents called in ParsedModule.add
|
|
||||||
parseTree.directive().forEach { module.add(it.toAst()) }
|
parseTree.directive().forEach { module.add(it.toAst()) }
|
||||||
// TODO: remove Encoding
|
|
||||||
parseTree.block().forEach { module.add(it.toAst(module.isLibrary)) }
|
parseTree.block().forEach { module.add(it.toAst(module.isLibrary)) }
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
@ -22,7 +22,7 @@ main {
|
|||||||
|
|
||||||
; Not yet implemented in ROM: cx16.FB_set_palette(&colors, 0, len(colors)*3)
|
; Not yet implemented in ROM: cx16.FB_set_palette(&colors, 0, len(colors)*3)
|
||||||
palette.set_rgb(&colors, len(colors))
|
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.FB_init()
|
||||||
cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch display all the way to the bottom
|
cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch display all the way to the bottom
|
||||||
cx16.set_rasterirq(&irq.irqhandler, 0)
|
cx16.set_rasterirq(&irq.irqhandler, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user