mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +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 first = fcall.args[0]
|
||||||
val second = fcall.args[1]
|
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
|
// optimized simple case: swap two variables
|
||||||
if(first is IdentifierReference && second is IdentifierReference) {
|
if(first is IdentifierReference && second is IdentifierReference) {
|
||||||
val firstName = asmgen.asmVariableName(first)
|
val firstName = asmgen.asmVariableName(first)
|
||||||
@ -816,6 +811,11 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(first is ArrayIndexedExpression && second is ArrayIndexedExpression) {
|
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 arrayVarName1 = asmgen.asmVariableName(first.arrayvar)
|
||||||
val arrayVarName2 = asmgen.asmVariableName(second.arrayvar)
|
val arrayVarName2 = asmgen.asmVariableName(second.arrayvar)
|
||||||
val elementIDt = first.inferType(program)
|
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
|
// all other types of swap() calls are done via a temporary variable
|
||||||
|
|
||||||
fun targetFromExpr(expr: Expression, datatype: DataType): AsmAssignTarget {
|
fun targetFromExpr(expr: Expression, datatype: DataType): AsmAssignTarget {
|
||||||
|
@ -1176,8 +1176,8 @@ internal class AstChecker(private val program: Program,
|
|||||||
override fun visit(arrayIndexedExpression: ArrayIndexedExpression) {
|
override fun visit(arrayIndexedExpression: ArrayIndexedExpression) {
|
||||||
val target = arrayIndexedExpression.arrayvar.targetStatement(program)
|
val target = arrayIndexedExpression.arrayvar.targetStatement(program)
|
||||||
if(target is VarDecl) {
|
if(target is VarDecl) {
|
||||||
if(target.datatype !in IterableDatatypes)
|
if(target.datatype !in IterableDatatypes && target.datatype!=DataType.UWORD)
|
||||||
errors.err("indexing requires an iterable variable", arrayIndexedExpression.position)
|
errors.err("indexing requires an iterable or address uword variable", arrayIndexedExpression.position)
|
||||||
val arraysize = target.arraysize?.constIndex()
|
val arraysize = target.arraysize?.constIndex()
|
||||||
if(arraysize!=null) {
|
if(arraysize!=null) {
|
||||||
// check out of bounds
|
// check out of bounds
|
||||||
|
@ -3,6 +3,8 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
|
- fix macptr issue in non-cx16 diskio
|
||||||
|
|
||||||
- why is this code so much larger:
|
- why is this code so much larger:
|
||||||
uword xx
|
uword xx
|
||||||
for xx in 0 to size-1 {
|
for xx in 0 to size-1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user