mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 04:30:03 +00:00
compiler warning instead of crash when attempting to assign invalid array value to other array
This commit is contained in:
parent
292640b17a
commit
1b14da6c03
@ -298,6 +298,10 @@ internal class StatementReorderer(val program: Program, val errors: IErrorReport
|
||||
if(targetVar.arraysize==null)
|
||||
errors.err("array has no defined size", assign.position)
|
||||
|
||||
if(assign.value !is IdentifierReference) {
|
||||
errors.err("invalid array value to assign to other array", assign.value.position)
|
||||
return noModifications
|
||||
}
|
||||
val sourceIdent = assign.value as IdentifierReference
|
||||
val sourceVar = sourceIdent.targetVarDecl(program)!!
|
||||
if(!sourceVar.isArray) {
|
||||
@ -310,7 +314,7 @@ internal class StatementReorderer(val program: Program, val errors: IErrorReport
|
||||
}
|
||||
|
||||
if(!errors.isEmpty())
|
||||
return emptyList()
|
||||
return noModifications
|
||||
|
||||
val memcopy = FunctionCallStatement(IdentifierReference(listOf("sys", "memcopy"), assign.position),
|
||||
mutableListOf(
|
||||
|
@ -270,8 +270,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetStorageKind.REGISTER -> TODO("reg in-place modification")
|
||||
TargetStorageKind.STACK -> TODO("stack in-place modification")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg in-place modification")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack in-place modification")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1732,9 +1732,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetStorageKind.ARRAY -> TODO("in-place not of ubyte array")
|
||||
TargetStorageKind.REGISTER -> TODO("reg not")
|
||||
TargetStorageKind.STACK -> TODO("stack not")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place not of ubyte array")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg not")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack not")
|
||||
}
|
||||
}
|
||||
DataType.UWORD -> {
|
||||
@ -1751,9 +1751,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sta ${target.asmVarname}+1""")
|
||||
}
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("no asm gen for uword-memory not")
|
||||
TargetStorageKind.ARRAY -> TODO("in-place not of uword array")
|
||||
TargetStorageKind.REGISTER -> TODO("reg not")
|
||||
TargetStorageKind.STACK -> TODO("stack not")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place not of uword array")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg not")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack not")
|
||||
}
|
||||
}
|
||||
else -> throw AssemblyError("boolean-not of invalid type")
|
||||
@ -1798,9 +1798,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetStorageKind.ARRAY -> TODO("in-place invert ubyte array")
|
||||
TargetStorageKind.REGISTER -> TODO("reg invert")
|
||||
TargetStorageKind.STACK -> TODO("stack invert")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place invert ubyte array")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg invert")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack invert")
|
||||
}
|
||||
}
|
||||
DataType.UWORD -> {
|
||||
@ -1815,9 +1815,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sta ${target.asmVarname}+1""")
|
||||
}
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("no asm gen for uword-memory invert")
|
||||
TargetStorageKind.ARRAY -> TODO("in-place invert uword array")
|
||||
TargetStorageKind.REGISTER -> TODO("reg invert")
|
||||
TargetStorageKind.STACK -> TODO("stack invert")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place invert uword array")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg invert")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack invert")
|
||||
}
|
||||
}
|
||||
else -> throw AssemblyError("invert of invalid type")
|
||||
@ -1836,9 +1836,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sta ${target.asmVarname}""")
|
||||
}
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("can't in-place negate memory ubyte")
|
||||
TargetStorageKind.ARRAY -> TODO("in-place negate byte array")
|
||||
TargetStorageKind.REGISTER -> TODO("reg negate")
|
||||
TargetStorageKind.STACK -> TODO("stack negate")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place negate byte array")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg negate")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack negate")
|
||||
}
|
||||
}
|
||||
DataType.WORD -> {
|
||||
@ -1853,10 +1853,10 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sbc ${target.asmVarname}+1
|
||||
sta ${target.asmVarname}+1""")
|
||||
}
|
||||
TargetStorageKind.ARRAY -> TODO("in-place negate word array")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place negate word array")
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("no asm gen for word memory negate")
|
||||
TargetStorageKind.REGISTER -> TODO("reg negate")
|
||||
TargetStorageKind.STACK -> TODO("stack negate")
|
||||
TargetStorageKind.REGISTER -> throw AssemblyError("missing codegen for reg negate")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack negate")
|
||||
}
|
||||
}
|
||||
DataType.FLOAT -> {
|
||||
@ -1869,8 +1869,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sta ${target.asmVarname}+1
|
||||
""")
|
||||
}
|
||||
TargetStorageKind.ARRAY -> TODO("in-place negate float array")
|
||||
TargetStorageKind.STACK -> TODO("stack float negate")
|
||||
TargetStorageKind.ARRAY -> throw AssemblyError("missing codegen for in-place negate float array")
|
||||
TargetStorageKind.STACK -> throw AssemblyError("missing codegen for stack float negate")
|
||||
else -> throw AssemblyError("weird target kind for float")
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,14 @@ main {
|
||||
str string2 = "hello"
|
||||
|
||||
uword xx = $f000
|
||||
word ww
|
||||
|
||||
ubyte[] arr = [1,2,3]
|
||||
arr = ~ arr
|
||||
cx16.r0 = ~cx16.r0
|
||||
ww = -cx16.r0
|
||||
cx16.r0 = not cx16.r0
|
||||
|
||||
; string1 = xx
|
||||
; string1 = string2
|
||||
string1 = string2 as uword
|
||||
|
||||
; ubyte[] array = [1,2,3,4]
|
||||
; ubyte ix
|
||||
|
Loading…
x
Reference in New Issue
Block a user