mirror of
https://github.com/irmen/prog8.git
synced 2024-11-27 03:50:27 +00:00
assign type assert
This commit is contained in:
parent
97ce72521d
commit
f4dafec645
@ -23,6 +23,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
val target = AsmAssignTarget.fromAstAssignment(assignment, program, asmgen)
|
val target = AsmAssignTarget.fromAstAssignment(assignment, program, asmgen)
|
||||||
val assign = AsmAssignment(source, target, assignment.isAugmentable, assignment.position)
|
val assign = AsmAssignment(source, target, assignment.isAugmentable, assignment.position)
|
||||||
|
|
||||||
|
// assert that the source and target types are identical (with some signed/unsigned relaxations)
|
||||||
|
if(target.datatype!=source.datatype) {
|
||||||
|
if (!(target.datatype in ByteDatatypes && source.datatype in ByteDatatypes ||
|
||||||
|
target.datatype in WordDatatypes && source.datatype in WordDatatypes)) {
|
||||||
|
throw AssemblyError("assignment type incompatibility ${target.datatype}=${source.datatype}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
source.type==AsmSourceStorageType.LITERALNUMBER -> translateConstantValueAssignment(assign)
|
source.type==AsmSourceStorageType.LITERALNUMBER -> translateConstantValueAssignment(assign)
|
||||||
source.type==AsmSourceStorageType.VARIABLE -> translateVariableAssignment(assign)
|
source.type==AsmSourceStorageType.VARIABLE -> translateVariableAssignment(assign)
|
||||||
|
Loading…
Reference in New Issue
Block a user