fixed source code output issue

This commit is contained in:
Irmen de Jong 2020-08-22 22:23:00 +02:00
parent bd9ebf4603
commit e947067dcf
2 changed files with 10 additions and 9 deletions

View File

@ -288,7 +288,9 @@ class AstToSourceCode(val output: (text: String) -> Unit, val program: Program):
override fun visit(assignment: Assignment) { override fun visit(assignment: Assignment) {
val binExpr = assignment.value as? BinaryExpression val binExpr = assignment.value as? BinaryExpression
if(binExpr!=null && binExpr.left isSameAs assignment.target) { if(binExpr!=null && binExpr.left isSameAs assignment.target
&& binExpr.operator !in setOf("and", "or", "xor")
&& binExpr.operator !in comparisonOperators) {
// we only support the inplace assignments of the form A = A <operator> <value> // we only support the inplace assignments of the form A = A <operator> <value>
assignment.target.accept(this) assignment.target.accept(this)
output(" ${binExpr.operator}= ") output(" ${binExpr.operator}= ")

View File

@ -7,15 +7,14 @@ main {
sub start() { sub start() {
ubyte ub ubyte a = 1
uword uw = $ee44 ubyte b = 2
ubyte vlsb = $11 ubyte c = 20
ubyte vmsb = $ff ubyte d = 4
uw = mkword(vmsb, vlsb) ; todo flip the order of the operands , MSB first a = c % 6
c64scr.print_uwhex(uw, 1)
uw = mkword($ee, $22) ; todo flip the order of the operands , MSB first c64scr.print_ub(a)
c64scr.print_uwhex(uw, 1)
} }
} }