diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index 363b776c7..8d1d9e255 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -280,6 +280,8 @@ private fun processAst(programAst: Program, errors: IErrorReporter, compilerOpti programAst.checkIdentifiers(errors, compilerOptions) errors.report() // TODO: turning char literals into UBYTEs via an encoding should really happen in code gen - but for that we'd need DataType.CHAR + // NOTE: we will then lose the opportunity to do constant-folding on any expression containing a char literal, but how often will those occur? + // Also they might be optimized away eventually in codegen or by the assembler even programAst.charLiteralsToUByteLiterals(errors, compilerOptions.compTarget) errors.report() programAst.constantFold(errors, compilerOptions.compTarget) diff --git a/compiler/src/prog8/compiler/ModuleImporter.kt b/compiler/src/prog8/compiler/ModuleImporter.kt index 9a60e2d1f..f15374151 100644 --- a/compiler/src/prog8/compiler/ModuleImporter.kt +++ b/compiler/src/prog8/compiler/ModuleImporter.kt @@ -132,7 +132,7 @@ class ModuleImporter(private val program: Program, } else { val dropCurDir = if(sourcePaths.isNotEmpty() && sourcePaths[0].name == ".") 1 else 0 sourcePaths.drop(dropCurDir) + - // FIXME: won't work until Prog8Parser is fixed s.t. it fully initialzes the modules it returns + // TODO: won't work until Prog8Parser is fixed s.t. it fully initializes the modules it returns. ??? (what won't work?) listOf(Path(importingModule.position.file).parent ?: Path("")) + listOf(Path(".", "prog8lib")) } diff --git a/compiler/test/fixtures/asmIncludeFromSameFolder.p8 b/compiler/test/fixtures/asmIncludeFromSameFolder.p8 index 6fe983fba..8c5617d77 100644 --- a/compiler/test/fixtures/asmIncludeFromSameFolder.p8 +++ b/compiler/test/fixtures/asmIncludeFromSameFolder.p8 @@ -2,7 +2,7 @@ main { str myBar = "main.bar" ;foo_bar: -; %asminclude "foo_bar.asm" ; FIXME: should be accessible from inside start() but give assembler error. See github issue #62 +; %asminclude "foo_bar.asm" ; TODO: should be accessible from inside start() but give assembler error. See github issue #62 sub start() { txt.print(myBar) txt.print(&foo_bar) diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index d30c9aed2..3878278e9 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -301,7 +301,7 @@ class TypecastExpression(var expression: Expression, var type: DataType, val imp override fun accept(visitor: AstWalker, parent: Node)= visitor.visit(this, parent) override fun referencesIdentifier(vararg scopedName: String) = expression.referencesIdentifier(*scopedName) - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(type) + override fun inferType(program: Program) = InferredTypes.knownFor(type) override fun constValue(program: Program): NumericLiteralValue? { val cv = expression.constValue(program) ?: return null val cast = cv.cast(type) @@ -334,7 +334,7 @@ data class AddressOf(var identifier: IdentifierReference, override val position: override fun constValue(program: Program): NumericLiteralValue? = null override fun referencesIdentifier(vararg scopedName: String) = false - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(DataType.UWORD) + override fun inferType(program: Program) = InferredTypes.knownFor(DataType.UWORD) override fun accept(visitor: IAstVisitor) = visitor.visit(this) override fun accept(visitor: AstWalker, parent: Node)= visitor.visit(this, parent) } @@ -359,7 +359,7 @@ class DirectMemoryRead(var addressExpression: Expression, override val position: override fun accept(visitor: AstWalker, parent: Node)= visitor.visit(this, parent) override fun referencesIdentifier(vararg scopedName: String) = false - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(DataType.UBYTE) + override fun inferType(program: Program) = InferredTypes.knownFor(DataType.UBYTE) override fun constValue(program: Program): NumericLiteralValue? = null override fun toString(): String { @@ -422,7 +422,7 @@ class NumericLiteralValue(val type: DataType, // only numerical types allowed override fun toString(): String = "NumericLiteral(${type.name}:$number)" - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(type) + override fun inferType(program: Program) = InferredTypes.knownFor(type) override fun hashCode(): Int = Objects.hash(type, number) @@ -518,7 +518,7 @@ class CharLiteral(val value: Char, override fun accept(visitor: AstWalker, parent: Node) = visitor.visit(this, parent) override fun toString(): String = "'${escape(value.toString())}'" - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(DataType.UNDEFINED) // FIXME: CharLiteral.inferType + override fun inferType(program: Program) = InferredTypes.knownFor(DataType.UBYTE) operator fun compareTo(other: CharLiteral): Int = value.compareTo(other.value) override fun hashCode(): Int = Objects.hash(value, altEncoding) override fun equals(other: Any?): Boolean { @@ -550,7 +550,7 @@ class StringLiteralValue(val value: String, override fun accept(visitor: AstWalker, parent: Node)= visitor.visit(this, parent) override fun toString(): String = "'${escape(value)}'" - override fun inferType(program: Program): InferredTypes.InferredType = InferredTypes.knownFor(DataType.STR) + override fun inferType(program: Program) = InferredTypes.knownFor(DataType.STR) operator fun compareTo(other: StringLiteralValue): Int = value.compareTo(other.value) override fun hashCode(): Int = Objects.hash(value, altEncoding) override fun equals(other: Any?): Boolean { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 2be82798f..e9117d513 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -14,7 +14,7 @@ Blocked by Commander-x16 v39 release Future ^^^^^^ -- get rid of all TODO's and FIXME's in the code +- get rid of all TODO's in the code - improve testability further, add more tests, address more questions/issues from the testability discussions. - replace certain uses of inferredType.getOr(DataType.UNDEFINED) by i.getOrElse({ errorhandler }) - see if we can remove more "[InferredType].getOr(DataType.UNDEFINED)"