This commit is contained in:
Irmen de Jong 2019-06-30 17:07:08 +02:00
parent 267c678292
commit a3004555a8
2 changed files with 24 additions and 4 deletions

View File

@ -285,9 +285,6 @@ class AstVm(val program: Program) {
}
}
}
is BuiltinFunctionStatementPlaceholder -> {
TODO("builtinfun $stmt")
}
is Return -> throw LoopControlReturn(stmt.values.map { evaluate(it, evalCtx) })
is Continue -> throw LoopControlContinue()
is Break -> throw LoopControlBreak()
@ -339,7 +336,15 @@ class AstVm(val program: Program) {
executeAnonymousScope(stmt.elsepart)
}
is BranchStatement -> {
TODO("branch $stmt")
when(stmt.condition) {
BranchCondition.CS -> if(statusflags.carry) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.CC -> if(!statusflags.carry) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.EQ, BranchCondition.Z -> if(statusflags.zero) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.NE, BranchCondition.NZ -> if(statusflags.zero) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.MI, BranchCondition.NEG -> if(statusflags.negative) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.PL, BranchCondition.POS -> if(statusflags.negative) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart)
BranchCondition.VS, BranchCondition.VC -> TODO("overflow status")
}
}
is ForLoop -> {
val iterable = evaluate(stmt.iterable, evalCtx)

View File

@ -18,6 +18,21 @@
word w1 = 1111
word w2 = 2222
sum(arr2)
if_cc goto start
if_cs goto start
if_eq goto start
if_mi goto start
if_ne goto start
if_neg goto start
if_nz goto start
if_pl goto start
if_pos goto start
if_vc goto start
if_vs goto start
if_z goto start
m1 = 0
mw1 = 65535