mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
swap() checks for unsupported code gen
This commit is contained in:
parent
5fe6aa2800
commit
73a3a61729
@ -710,11 +710,6 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
||||
val first = fcall.args[0]
|
||||
val second = fcall.args[1]
|
||||
|
||||
val arrayVarDecl1 = (first as? ArrayIndexedExpression)?.arrayvar?.targetVarDecl(program)
|
||||
val arrayVarDecl2 = (second as? ArrayIndexedExpression)?.arrayvar?.targetVarDecl(program)
|
||||
if((arrayVarDecl1!=null && !arrayVarDecl1.isArray) || (arrayVarDecl2!=null && !arrayVarDecl2.isArray))
|
||||
throw AssemblyError("no asm gen for swapping bytes to and/or from indexed pointer var ${fcall.position}")
|
||||
|
||||
// optimized simple case: swap two variables
|
||||
if(first is IdentifierReference && second is IdentifierReference) {
|
||||
val firstName = asmgen.asmVariableName(first)
|
||||
@ -816,6 +811,11 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
||||
}
|
||||
|
||||
if(first is ArrayIndexedExpression && second is ArrayIndexedExpression) {
|
||||
val arrayVarDecl1 = first.arrayvar.targetVarDecl(program)!!
|
||||
val arrayVarDecl2 = second.arrayvar.targetVarDecl(program)!!
|
||||
if(!arrayVarDecl1.isArray || !arrayVarDecl2.isArray)
|
||||
throw AssemblyError("no asm gen for swapping bytes to and/or from indexed pointer var ${fcall.position}")
|
||||
|
||||
val arrayVarName1 = asmgen.asmVariableName(first.arrayvar)
|
||||
val arrayVarName2 = asmgen.asmVariableName(second.arrayvar)
|
||||
val elementIDt = first.inferType(program)
|
||||
@ -841,6 +841,11 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
||||
}
|
||||
}
|
||||
|
||||
val arrayVarDecl1 = (first as? ArrayIndexedExpression)?.arrayvar?.targetVarDecl(program)
|
||||
val arrayVarDecl2 = (second as? ArrayIndexedExpression)?.arrayvar?.targetVarDecl(program)
|
||||
if((arrayVarDecl1!=null && !arrayVarDecl1.isArray) || (arrayVarDecl2!=null && !arrayVarDecl2.isArray))
|
||||
throw AssemblyError("no asm gen for swapping bytes to and/or from indexed pointer var ${fcall.position}")
|
||||
|
||||
// all other types of swap() calls are done via a temporary variable
|
||||
|
||||
fun targetFromExpr(expr: Expression, datatype: DataType): AsmAssignTarget {
|
||||
|
@ -1176,8 +1176,8 @@ internal class AstChecker(private val program: Program,
|
||||
override fun visit(arrayIndexedExpression: ArrayIndexedExpression) {
|
||||
val target = arrayIndexedExpression.arrayvar.targetStatement(program)
|
||||
if(target is VarDecl) {
|
||||
if(target.datatype !in IterableDatatypes)
|
||||
errors.err("indexing requires an iterable variable", arrayIndexedExpression.position)
|
||||
if(target.datatype !in IterableDatatypes && target.datatype!=DataType.UWORD)
|
||||
errors.err("indexing requires an iterable or address uword variable", arrayIndexedExpression.position)
|
||||
val arraysize = target.arraysize?.constIndex()
|
||||
if(arraysize!=null) {
|
||||
// check out of bounds
|
||||
|
@ -3,6 +3,8 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- fix macptr issue in non-cx16 diskio
|
||||
|
||||
- why is this code so much larger:
|
||||
uword xx
|
||||
for xx in 0 to size-1 {
|
||||
|
Loading…
Reference in New Issue
Block a user