swap isn't yet finished

This commit is contained in:
Irmen de Jong 2019-06-28 02:57:13 +02:00
parent 3ee1b2efdd
commit 6c50043a4a
2 changed files with 19 additions and 17 deletions

View File

@ -272,9 +272,7 @@ class AstVm(val program: Program) {
is BuiltinFunctionStatementPlaceholder -> {
if(target.name=="swap") {
// swap cannot be implemented as a function, so inline it here
val a1 = (stmt.arglist[0] as IdentifierReference).targetVarDecl(program.namespace)!!
val a2 = (stmt.arglist[1] as IdentifierReference).targetVarDecl(program.namespace)!!
runtimeVariables.swap(a1, a2)
executeSwap(sub, stmt)
} else {
val args = evaluate(stmt.arglist)
functions.performBuiltinFunction(target.name, args, statusflags)
@ -396,6 +394,15 @@ class AstVm(val program: Program) {
}
}
private fun executeSwap(sub: INameScope, swap: FunctionCallStatement) {
// TODO: can swap many different parameters.... in all combinations...
println("TODO SWAP ${swap.arglist}")
// val a1 = (swap.arglist[0] as IdentifierReference).targetVarDecl(program.namespace)!!
// val a2 = (swap.arglist[1] as IdentifierReference).targetVarDecl(program.namespace)!!
// runtimeVariables.swap(a1, a2)
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
fun performAssignment(target: AssignTarget, value: RuntimeValue, contextStmt: IStatement, evalCtx: EvalContext) {
when {
target.identifier != null -> {

View File

@ -9,19 +9,14 @@
ubyte[100] arr1
ubyte[100] arr2
_lp:
memcopy(arr1, arr2, len(arr2))
c64scr.setcc(20,10,65,2)
goto x
c64scr.setcc(20,10,65,2)
word w1 = 1111
word w2 = 2222
swap(w1, w2)
swap(A, Y)
swap(arr1[10], arr2[20])
swap(arr1[10], Y)
swap(Y, arr2[10])
swap(@($d020), @($d021))
}
sub x() {
derp:
c64scr.print("ey\n")
goto derp
}
}