mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
fix symbol table issue
This commit is contained in:
parent
66a6659a6e
commit
cfe3fcc9e7
@ -8,7 +8,6 @@ import prog8.ast.expressions.Expression
|
||||
import prog8.ast.expressions.NumericLiteral
|
||||
import prog8.ast.printProgram
|
||||
import prog8.ast.statements.Directive
|
||||
import prog8.code.SymbolTable
|
||||
import prog8.code.SymbolTableMaker
|
||||
import prog8.code.ast.PtProgram
|
||||
import prog8.code.ast.printAst
|
||||
@ -148,7 +147,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
println("*********** INTERMEDIATE AST END *************\n")
|
||||
}
|
||||
|
||||
if(!createAssemblyAndAssemble(intermediateAst, symbolTable, args.errors, compilationOptions)) {
|
||||
if(!createAssemblyAndAssemble(intermediateAst, args.errors, compilationOptions)) {
|
||||
System.err.println("Error in codegeneration or assembler")
|
||||
return null
|
||||
}
|
||||
@ -469,7 +468,6 @@ private fun postprocessAst(program: Program, errors: IErrorReporter, compilerOpt
|
||||
}
|
||||
|
||||
private fun createAssemblyAndAssemble(program: PtProgram,
|
||||
symbolTable: SymbolTable,
|
||||
errors: IErrorReporter,
|
||||
compilerOptions: CompilationOptions
|
||||
): Boolean {
|
||||
@ -483,6 +481,10 @@ private fun createAssemblyAndAssemble(program: PtProgram,
|
||||
else
|
||||
throw NotImplementedError("no code generator for cpu ${compilerOptions.compTarget.machine.cpu}")
|
||||
|
||||
// need to make a new symboltable here to capture possible changes made by optimization steps performed earlier!
|
||||
val stMaker = SymbolTableMaker(program, compilerOptions)
|
||||
val symbolTable = stMaker.make()
|
||||
|
||||
val assembly = asmgen.generate(program, symbolTable, compilerOptions, errors)
|
||||
errors.report()
|
||||
|
||||
|
@ -1030,4 +1030,21 @@ main {
|
||||
(a3.children[0] as PtAssignTarget).void shouldBe false
|
||||
(a3.children[0] as PtAssignTarget).identifier!!.name shouldBe "cx16.r0H"
|
||||
}
|
||||
|
||||
test("symbol table correct in asmgen after earlier optimization steps") {
|
||||
val src="""
|
||||
main {
|
||||
sub start() {
|
||||
uword @shared bulletRef, enemyRef
|
||||
const ubyte BD_Y = 10
|
||||
const ubyte EN_Y = 11
|
||||
|
||||
if bulletRef[BD_Y] == enemyRef[EN_Y] or bulletRef[BD_Y] == enemyRef[EN_Y] + 1 {
|
||||
cx16.r0++
|
||||
}
|
||||
}
|
||||
}"""
|
||||
compileText(VMTarget(), true, src, writeAssembly = true) shouldNotBe null
|
||||
compileText(C64Target(), true, src, writeAssembly = true) shouldNotBe null
|
||||
}
|
||||
})
|
||||
|
@ -1,11 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
imageviewer is a lot larger now?
|
||||
|
||||
fix compiler crash for assembler: unknown identifier [PtIdentifier:parser.proces_directive_str.prog8_subexprvar_1 UBYTE [src/assembler.p8: line 875 col 29-29]]
|
||||
fix similar crash for petaxian
|
||||
|
||||
check docs on assign about status register in assignment (can no longer be ignored, use void to not assign it)
|
||||
|
||||
...
|
||||
|
Loading…
Reference in New Issue
Block a user