diff --git a/codeCore/src/prog8/code/optimize/Optimizer.kt b/codeCore/src/prog8/code/optimize/Optimizer.kt index 99d62e2de..77d3ef3ff 100644 --- a/codeCore/src/prog8/code/optimize/Optimizer.kt +++ b/codeCore/src/prog8/code/optimize/Optimizer.kt @@ -6,7 +6,7 @@ import prog8.code.ast.* import prog8.code.core.* -fun optimizeIntermediateAst(program: PtProgram, options: CompilationOptions, st: SymbolTable, errors: IErrorReporter) { +fun optimizeSimplifiedAst(program: PtProgram, options: CompilationOptions, st: SymbolTable, errors: IErrorReporter) { if (!options.optimize) return while (errors.noErrors() && optimizeAssignTargets(program, st) > 0) { diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index ebb571986..81cd45e0f 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -60,9 +60,9 @@ private fun compileMain(args: Array): Boolean { val dontWriteAssembly by cli.option(ArgType.Boolean, fullName = "noasm", description="don't create assembly code") val dontOptimize by cli.option(ArgType.Boolean, fullName = "noopt", description = "don't perform code optimizations") val outputDir by cli.option(ArgType.String, fullName = "out", description = "directory for output files instead of current directory").default(".") - val printAst1 by cli.option(ArgType.Boolean, fullName = "printast1", description = "print out the compiler AST") val plainText by cli.option(ArgType.Boolean, fullName = "plaintext", description = "output only plain text, no colors or fancy symbols") - val printAst2 by cli.option(ArgType.Boolean, fullName = "printast2", description = "print out the intermediate AST that is used for code generation") + val printAst1 by cli.option(ArgType.Boolean, fullName = "printast1", description = "print out the internal compiler AST") + val printAst2 by cli.option(ArgType.Boolean, fullName = "printast2", description = "print out the simplified AST that is used for code generation") val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results") val slabsGolden by cli.option(ArgType.Boolean, fullName = "slabsgolden", description = "put memory() slabs in 'golden ram' memory area instead of at the end of the program. On the cx16 target this is $0400-07ff. This is unavailable on other systems.") val slabsHighBank by cli.option(ArgType.Int, fullName = "slabshigh", description = "put memory() slabs in high memory area instead of at the end of the program. On the cx16 target the value specifies the HiRAM bank to use, on other systems this value is ignored.") diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index df897ee45..ad7a31584 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -14,7 +14,7 @@ import prog8.code.ast.PtProgram import prog8.code.ast.printAst import prog8.code.ast.verifyFinalAstBeforeAsmGen import prog8.code.core.* -import prog8.code.optimize.optimizeIntermediateAst +import prog8.code.optimize.optimizeSimplifiedAst import prog8.code.target.* import prog8.codegen.vm.VmCodeGen import prog8.compiler.astprocessing.* @@ -128,22 +128,22 @@ fun compileProgram(args: CompilerArguments): CompilationResult? { println("*********** COMPILER AST END *************\n") } - val intermediateAst = IntermediateAstMaker(program, args.errors).transform() + val intermediateAst = SimplifiedAstMaker(program, args.errors).transform() val stMaker = SymbolTableMaker(intermediateAst, compilationOptions) val symbolTable = stMaker.make() - postprocessIntermediateAst(intermediateAst, symbolTable, args.errors) + postprocessSimplifiedAst(intermediateAst, symbolTable, args.errors) args.errors.report() if(compilationOptions.optimize) { - optimizeIntermediateAst(intermediateAst, compilationOptions, symbolTable, args.errors) + optimizeSimplifiedAst(intermediateAst, compilationOptions, symbolTable, args.errors) args.errors.report() } if(args.printAst2) { - println("\n*********** INTERMEDIATE AST *************") + println("\n*********** SIMPLIFIED AST *************") printAst(intermediateAst, true, ::println) - println("*********** INTERMEDIATE AST END *************\n") + println("*********** SIMPLIFIED AST END *************\n") } verifyFinalAstBeforeAsmGen(intermediateAst, compilationOptions, symbolTable, args.errors) @@ -161,7 +161,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? { println("*********** COMPILER AST END *************\n") } if(args.printAst2) { - System.err.println("There is no intermediate Ast available if assembly generation is disabled.") + System.err.println("There is no simplified Ast available if assembly generation is disabled.") } } } @@ -184,11 +184,11 @@ fun compileProgram(args: CompilerArguments): CompilationResult? { } if (args.printAst2) { if(ast==null) - println("There is no intermediate AST available because of compilation errors.") + println("There is no simplified AST available because of compilation errors.") else { - println("\n*********** INTERMEDIATE AST *************") + println("\n*********** SIMPLIFIED AST *************") printAst(ast, true, ::println) - println("*********** INTERMEDIATE AST END *************\n") + println("*********** SIMPLIFIED AST END *************\n") } } if(!ac.message.isNullOrEmpty()) { diff --git a/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt b/compiler/src/prog8/compiler/astprocessing/SimplifiedAstMaker.kt similarity index 99% rename from compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt rename to compiler/src/prog8/compiler/astprocessing/SimplifiedAstMaker.kt index 839610beb..4902491b2 100644 --- a/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt +++ b/compiler/src/prog8/compiler/astprocessing/SimplifiedAstMaker.kt @@ -22,7 +22,7 @@ import kotlin.io.path.isRegularFile /** * Convert 'old' compiler-AST into the 'new' simplified AST with baked types. */ -class IntermediateAstMaker(private val program: Program, private val errors: IErrorReporter) { +class SimplifiedAstMaker(private val program: Program, private val errors: IErrorReporter) { fun transform(): PtProgram { val ptProgram = PtProgram( program.name, @@ -535,7 +535,7 @@ class IntermediateAstMaker(private val program: Program, private val errors: IEr private fun transformSub(srcSub: Subroutine): PtSub { val (vardecls, statements) = srcSub.statements.partition { it is VarDecl } - // if a sub returns 'str', replace with uword. Intermediate AST and I.R. don't contain 'str' datatype anymore. + // if a sub returns 'str', replace with uword. Simplified AST and I.R. don't contain 'str' datatype anymore. var returnTypes = srcSub.returntypes.map { if(it.isString) DataType.forDt(BaseDataType.UWORD) else it } diff --git a/compiler/src/prog8/compiler/astprocessing/IntermediateAstPostprocess.kt b/compiler/src/prog8/compiler/astprocessing/SimplifiedAstPostprocess.kt similarity index 98% rename from compiler/src/prog8/compiler/astprocessing/IntermediateAstPostprocess.kt rename to compiler/src/prog8/compiler/astprocessing/SimplifiedAstPostprocess.kt index 4d1c3d51a..bc52ca530 100644 --- a/compiler/src/prog8/compiler/astprocessing/IntermediateAstPostprocess.kt +++ b/compiler/src/prog8/compiler/astprocessing/SimplifiedAstPostprocess.kt @@ -5,7 +5,7 @@ import prog8.code.ast.* import prog8.code.core.* -internal fun postprocessIntermediateAst(program: PtProgram, st: SymbolTable, errors: IErrorReporter) { +internal fun postprocessSimplifiedAst(program: PtProgram, st: SymbolTable, errors: IErrorReporter) { processDefers(program, st, errors) } diff --git a/compiler/test/ast/TestIntermediateAst.kt b/compiler/test/ast/TestSimplifiedAst.kt similarity index 98% rename from compiler/test/ast/TestIntermediateAst.kt rename to compiler/test/ast/TestSimplifiedAst.kt index ea1766f1d..f9e500f11 100644 --- a/compiler/test/ast/TestIntermediateAst.kt +++ b/compiler/test/ast/TestSimplifiedAst.kt @@ -8,7 +8,7 @@ import prog8.code.core.BaseDataType import prog8.code.core.DataType import prog8.code.core.Position -class TestIntermediateAst: FunSpec({ +class TestSimplifiedAst: FunSpec({ test("isSame on binaryExpressions") { val expr1 = PtBinaryExpression("/", DataType.forDt(BaseDataType.UBYTE), Position.DUMMY) diff --git a/compiler/test/codegeneration/TestAsmGenSymbols.kt b/compiler/test/codegeneration/TestAsmGenSymbols.kt index 6d90eb010..d0b1937e6 100644 --- a/compiler/test/codegeneration/TestAsmGenSymbols.kt +++ b/compiler/test/codegeneration/TestAsmGenSymbols.kt @@ -19,7 +19,7 @@ import prog8.code.source.SourceCode import prog8.code.target.C64Target import prog8.code.target.VMTarget import prog8.codegen.cpu6502.AsmGen6502Internal -import prog8.compiler.astprocessing.IntermediateAstMaker +import prog8.compiler.astprocessing.SimplifiedAstMaker import prog8tests.helpers.* class TestAsmGenSymbols: StringSpec({ @@ -79,7 +79,7 @@ class TestAsmGenSymbols: StringSpec({ fun createTestAsmGen6502(program: Program): AsmGen6502Internal { val errors = ErrorReporterForTests() val options = CompilationOptions(OutputType.RAW, CbmPrgLauncherType.NONE, ZeropageType.FULL, emptyList(), CompilationOptions.AllZeropageAllowed, false, true, C64Target(), 999u, 0xffffu) - val ptProgram = IntermediateAstMaker(program, errors).transform() + val ptProgram = SimplifiedAstMaker(program, errors).transform() val st = SymbolTableMaker(ptProgram, options).make() return AsmGen6502Internal(ptProgram, st, options, errors, 0) } diff --git a/docs/source/compiling.rst b/docs/source/compiling.rst index 1f0d5eb1c..9661c6420 100644 --- a/docs/source/compiling.rst +++ b/docs/source/compiling.rst @@ -204,7 +204,7 @@ One or more .p8 module files Prints the "compiler AST" (the internal representation of the program) after all processing steps. ``-printast2`` - Prints the "intermediate AST" which is the reduced representation of the program. + Prints the "simplified AST" which is the reduced representation of the program. This is what is used in the code generators, to generate the executable code from. ``-quietasm`` diff --git a/docs/source/technical.rst b/docs/source/technical.rst index edcf71072..e69a01918 100644 --- a/docs/source/technical.rst +++ b/docs/source/technical.rst @@ -228,7 +228,7 @@ Some notes and references into the compiler's source code modules: syntax nodes closely representing the Prog8 program structure. (``compilerAst`` module) #. For code generation, a much simpler AST has been defined that replaces the *Compiler AST*. Most notably, node type information is now baked in. (``codeCore`` module, Pt- classes) -#. An *Intermediate Representation* has been defined that is generated from the intermediate AST. This IR +#. An *Intermediate Representation* has been defined that is generated from the simplified AST. This IR is more or less a machine code language for a virtual machine - and indeed this is what the built-in prog8 VM will execute if you use the 'virtual' compilation target and use ``-emu`` to launch the VM. (``intermediate`` and ``codeGenIntermediate`` modules, and ``virtualmachine`` module for the VM related stuff) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 2a6875f56..86726f109 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,7 +2,6 @@ TODO ==== - change library routines that now return 1 value + say, another in R0, to just return 2 values now that this is supported for normal subroutines too. -- rename "intermediate AST" into "simplified AST" (docs + classes in code) - add paypal donation button as well? - announce prog8 on the 6502.org site?