From 08e052380a8683cbc1ca7e7e9ca37a6494ecefea Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 5 Feb 2022 03:14:26 +0100 Subject: [PATCH] comments --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 3 +++ compiler/src/prog8/compiler/astprocessing/AstExtensions.kt | 1 + docs/source/todo.rst | 2 +- examples/test.p8 | 6 +++--- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index d6edcaae0..0b4aeff51 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -10,6 +10,9 @@ import java.io.CharConversionException import java.io.File import kotlin.io.path.Path +/** + * Semantic analysis. + */ internal class AstChecker(private val program: Program, private val errors: IErrorReporter, private val compilerOptions: CompilationOptions diff --git a/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt b/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt index 08b762661..46187a925 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt @@ -16,6 +16,7 @@ import prog8.compilerinterface.IStringEncoding internal fun Program.checkValid(errors: IErrorReporter, compilerOptions: CompilationOptions) { + // semantic analysis to see if the program is valid. val parentChecker = ParentNodeChecker() parentChecker.visit(this) val checker = AstChecker(this, errors, compilerOptions) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index fd4c1aaab..3b5ab9112 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -35,7 +35,6 @@ Ast modifications done in AsmGen, that should be done BEFORE calling asmgen (so and pass that via a new datastructure to asmgen? So that asmgen is no longer tasked with doing the allocations. This could perhaps make it easer for the codegen as well to deal with sections, if any, in the future. - - remove support for old @"screencodes" string encoding syntax (parser+code+docs) - allow "xxx" * constexpr (where constexpr is not a number literal), now gives expression error not same type - unify FunctioncallExpression + FunctioncallStatement and PipeExpression + Pipe statement classes, may require moving Expression/Statement into interfaces instead of abstract base classes @@ -73,6 +72,7 @@ More optimization ideas - when a for loop's loopvariable isn't referenced in the body, and the iterations are known, replace the loop by a repeatloop - automatically convert if statements that test for multiple values (if X==1 or X==2..) to if X in [1,2,..] statements, instead of just a warning. - rewrite expression tree evaluation such that it doesn't use an eval stack but flatten the tree into linear code that uses a fixed number of predetermined value 'variables'? + "Three address code" was mentioned. https://en.wikipedia.org/wiki/Three-address_code these variables have to be unique for each subroutine because they could otherwise be interfered with from irq routines etc. - this removes the need for the BinExprSplitter? (which is problematic and very limited now) and perhaps as well the assignment splitting in BeforeAsmAstChanger too diff --git a/examples/test.p8 b/examples/test.p8 index 7a08ead44..b71fdee54 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -2,9 +2,9 @@ main { sub start() { - word w1 = 10 - byte bb = -2 - w1 *= bb + word w1 = -10 + byte bb = 2 + w1 -= bb-1 txt.print_w(w1) txt.nl()