fixed some compiler errors

This commit is contained in:
Irmen de Jong
2019-08-04 19:54:32 +02:00
parent 0f91ce6441
commit 309c82fc9e
6 changed files with 11 additions and 9 deletions

View File

@@ -376,6 +376,8 @@ internal class AstChecker(private val program: Program,
} }
override fun visit(assignTarget: AssignTarget) { override fun visit(assignTarget: AssignTarget) {
super.visit(assignTarget)
val memAddr = assignTarget.memoryAddress?.addressExpression?.constValue(program)?.number?.toInt() val memAddr = assignTarget.memoryAddress?.addressExpression?.constValue(program)?.number?.toInt()
if (memAddr != null) { if (memAddr != null) {
if (memAddr < 0 || memAddr >= 65536) if (memAddr < 0 || memAddr >= 65536)

View File

@@ -172,8 +172,6 @@ interface IAstModifyingVisitor {
val ident = arrayIndexedExpression.identifier.accept(this) val ident = arrayIndexedExpression.identifier.accept(this)
if(ident is IdentifierReference) if(ident is IdentifierReference)
arrayIndexedExpression.identifier = ident arrayIndexedExpression.identifier = ident
else
throw FatalAstException("can't change class of indexed identifier")
arrayIndexedExpression.arrayspec.accept(this) arrayIndexedExpression.arrayspec.accept(this)
return arrayIndexedExpression return arrayIndexedExpression
} }

View File

@@ -1436,7 +1436,12 @@ $endLabel""")
if(incr) if(incr)
out(" inc $what | bne + | inc $what+1 |+") out(" inc $what | bne + | inc $what+1 |+")
else else
out(" lda $what | bne + | dec $what+1 |+ | dec $what") out("""
lda $what
bne +
dec $what+1
+ dec $what
""")
} }
DataType.FLOAT -> { DataType.FLOAT -> {
out(" lda #<$what | ldy #>$what") out(" lda #<$what | ldy #>$what")

View File

@@ -46,7 +46,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
if(arg is NumericLiteralValue) if(arg is NumericLiteralValue)
throw AssemblyError("should have been const-folded") throw AssemblyError("should have been const-folded")
if(arg is IdentifierReference) { if(arg is IdentifierReference) {
val sourceName = arg.nameInSource.joinToString(".") val sourceName = asmgen.asmIdentifierName(arg)
asmgen.out(" lda $sourceName+1 | sta $ESTACK_LO_HEX,x | dex") asmgen.out(" lda $sourceName+1 | sta $ESTACK_LO_HEX,x | dex")
} else { } else {
asmgen.translateExpression(arg) asmgen.translateExpression(arg)

View File

@@ -234,8 +234,6 @@ class ConstantFolding(private val program: Program) : IAstModifyingVisitor {
} }
} }
} }
} else {
throw FatalAstException("can't find function ${functionCall.target}")
} }
} }

View File

@@ -25,7 +25,7 @@ main {
Y=100 Y=100
Y++ Y++
check_ub(Y, 101) check_ub(Y, 101)
check_fl(fl, 100.99) ; @todo CLOBBERS OTHER VARS check_fl(fl, 100.99)
check_b(bb, -99) check_b(bb, -99)
check_uw(uw, 2001) check_uw(uw, 2001)
check_w(ww, -999) check_w(ww, -999)
@@ -40,13 +40,12 @@ main {
Y=100 Y=100
Y-- Y--
check_ub(Y, 99) check_ub(Y, 99)
check_fl(fl, 99.99) ; @todo CLOBBERS OTHER VARS check_fl(fl, 99.99)
check_b(bb, -100) check_b(bb, -100)
check_uw(uw, 2000) check_uw(uw, 2000)
check_w(ww, -1000) check_w(ww, -1000)
@($0400+39) = X @($0400+39) = X
;c64.Screen[39] = X ; @todo compiler error
} }
sub check_ub(ubyte value, ubyte expected) { sub check_ub(ubyte value, ubyte expected) {