mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
added -printast1 and -printast2 command line options
This commit is contained in:
parent
892fa76883
commit
99c29343de
@ -51,6 +51,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
val includeSourcelines by cli.option(ArgType.Boolean, fullName = "sourcelines", description = "include original Prog8 source lines in generated asm code")
|
||||
val splitWordArrays by cli.option(ArgType.Boolean, fullName = "splitarrays", description = "treat all word arrays as tagged with @split to make them lsb/msb split in memory")
|
||||
val noShortCircuit by cli.option(ArgType.Boolean, fullName = "noshortcircuit", description = "do not apply McCarthy/short-circuit evaluation to boolean expressions")
|
||||
val printAst1 by cli.option(ArgType.Boolean, fullName = "printast1", description = "print out the compiler AST")
|
||||
val printAst2 by cli.option(ArgType.Boolean, fullName = "printast2", description = "print out the intermediate AST that is used for code generation")
|
||||
val breakpointCpuInstruction by cli.option(ArgType.Boolean, fullName = "breakinstr", description = "also use a CPU instruction for %breakpoint")
|
||||
val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}', '${AtariTarget.NAME}', '${PETTarget.NAME}', '${VMTarget.NAME}') (required)")
|
||||
val startVm by cli.option(ArgType.Boolean, fullName = "vm", description = "load and run a .p8ir IR source file in the VM")
|
||||
@ -159,6 +161,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction = false,
|
||||
printAst1 == true,
|
||||
printAst2 == true,
|
||||
processedSymbols,
|
||||
srcdirs,
|
||||
outputPath
|
||||
@ -236,6 +240,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction == true,
|
||||
printAst1 == true,
|
||||
printAst2 == true,
|
||||
processedSymbols,
|
||||
srcdirs,
|
||||
outputPath
|
||||
|
@ -6,9 +6,11 @@ import prog8.ast.Program
|
||||
import prog8.ast.base.AstException
|
||||
import prog8.ast.expressions.Expression
|
||||
import prog8.ast.expressions.NumericLiteral
|
||||
import prog8.ast.printProgram
|
||||
import prog8.ast.statements.Directive
|
||||
import prog8.code.SymbolTableMaker
|
||||
import prog8.code.ast.PtProgram
|
||||
import prog8.code.ast.printAst
|
||||
import prog8.code.core.*
|
||||
import prog8.code.optimize.optimizeIntermediateAst
|
||||
import prog8.code.target.*
|
||||
@ -44,6 +46,8 @@ class CompilerArguments(val filepath: Path,
|
||||
val compilationTarget: String,
|
||||
val splitWordArrays: Boolean,
|
||||
val breakpointCpuInstruction: Boolean,
|
||||
val printAst1: Boolean,
|
||||
val printAst2: Boolean,
|
||||
val symbolDefs: Map<String, String>,
|
||||
val sourceDirs: List<String> = emptyList(),
|
||||
val outputDir: Path = Path(""),
|
||||
@ -121,15 +125,21 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
program.processAstBeforeAsmGeneration(compilationOptions, args.errors)
|
||||
args.errors.report()
|
||||
|
||||
// println("*********** COMPILER AST RIGHT BEFORE ASM GENERATION *************")
|
||||
// printProgram(program)
|
||||
if(args.printAst1) {
|
||||
println("\n*********** COMPILER AST *************")
|
||||
printProgram(program)
|
||||
println("*********** COMPILER AST END *************\n")
|
||||
}
|
||||
|
||||
val intermediateAst = IntermediateAstMaker(program, args.errors).transform()
|
||||
optimizeIntermediateAst(intermediateAst, compilationOptions, args.errors)
|
||||
args.errors.report()
|
||||
|
||||
// println("*********** AST RIGHT BEFORE ASM GENERATION *************")
|
||||
// printAst(intermediateAst, true, ::println)
|
||||
if(args.printAst2) {
|
||||
println("\n*********** INTERMEDIATE AST *************")
|
||||
printAst(intermediateAst, true, ::println)
|
||||
println("*********** INTERMEDIATE AST END *************\n")
|
||||
}
|
||||
|
||||
if(!createAssemblyAndAssemble(intermediateAst, args.errors, compilationOptions)) {
|
||||
System.err.println("Error in codegeneration or assembler")
|
||||
|
@ -40,6 +40,8 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
||||
compilationTarget = target.name,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
symbolDefs = emptyMap(),
|
||||
outputDir = outputDir
|
||||
)
|
||||
|
@ -38,6 +38,8 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
||||
compilationTarget = Cx16Target.NAME,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
symbolDefs = emptyMap(),
|
||||
sourceDirs,
|
||||
outputDir
|
||||
|
@ -39,7 +39,9 @@ internal fun compileFile(
|
||||
outputDir = outputDir,
|
||||
errors = errors ?: ErrorReporterForTests(),
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false
|
||||
breakpointCpuInstruction = false,
|
||||
printAst1 = false,
|
||||
printAst2 = false
|
||||
)
|
||||
return compileProgram(args)
|
||||
}
|
||||
|
@ -185,6 +185,13 @@ One or more .p8 module files
|
||||
``-expericodegen``
|
||||
Use experimental code generation backend (*incomplete*).
|
||||
|
||||
``-printast1``
|
||||
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.
|
||||
This is what is used in the code generators, to generate the executable code from.
|
||||
|
||||
``-sourcelines``
|
||||
Also include the original prog8 source code lines as comments in the generated assembly code file,
|
||||
mixed in between the actual generated assembly code.
|
||||
|
@ -44,6 +44,8 @@ class RequestParser : Take {
|
||||
experimentalCodegen = false,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
slabsHighBank = null,
|
||||
|
Loading…
Reference in New Issue
Block a user