mirror of https://github.com/irmen/prog8.git
fix compiler error
This commit is contained in:
parent
34f3169dda
commit
5f11f485a2
|
@ -463,14 +463,16 @@ class TypecastsAdder(val program: Program, val options: CompilationOptions, val
|
|||
|
||||
override fun after(whenChoice: WhenChoice, parent: Node): Iterable<IAstModification> {
|
||||
val conditionDt = (whenChoice.parent as When).condition.inferType(program)
|
||||
val values = whenChoice.values
|
||||
values?.toTypedArray()?.withIndex()?.forEach { (index, value) ->
|
||||
val valueDt = value.inferType(program)
|
||||
if(valueDt!=conditionDt) {
|
||||
val castedValue = value.typecastTo(conditionDt.getOr(DataType.UNDEFINED), valueDt.getOr(DataType.UNDEFINED), true)
|
||||
if(castedValue.first) {
|
||||
castedValue.second.linkParents(whenChoice)
|
||||
values[index] = castedValue.second
|
||||
if(conditionDt.isKnown) {
|
||||
val values = whenChoice.values
|
||||
values?.toTypedArray()?.withIndex()?.forEach { (index, value) ->
|
||||
val valueDt = value.inferType(program)
|
||||
if(valueDt!=conditionDt) {
|
||||
val castedValue = value.typecastTo(conditionDt.getOr(DataType.UNDEFINED), valueDt.getOr(DataType.UNDEFINED), true)
|
||||
if(castedValue.first) {
|
||||
castedValue.second.linkParents(whenChoice)
|
||||
values[index] = castedValue.second
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
TODO
|
||||
====
|
||||
|
||||
chess fails to compile (crash)
|
||||
|
||||
remove redundant assignments in calls like this where the result registers are the same as the assigment targets:
|
||||
void, cx16.r0s, cx16.r1s = cx16.mouse_pos()
|
||||
(6502 + IR)
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
|
||||
main {
|
||||
sub start() {
|
||||
void, cx16.r0s, cx16.r1s = cx16.mouse_pos()
|
||||
cx16.mouse_config2(1)
|
||||
wait_mousebutton()
|
||||
|
||||
sub wait_mousebutton() {
|
||||
do {
|
||||
cx16.r0L, void, void = cx16.mouse_pos()
|
||||
} until cx16.r0L!=0
|
||||
do {
|
||||
cx16.r0L, void, void = cx16.mouse_pos()
|
||||
} until cx16.r0L==0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue