mirror of
https://github.com/irmen/prog8.git
synced 2024-10-17 10:24:55 +00:00
fix endless loop in optimizer, fix cx16 register clobbering in psg interrupt handler, fix crash on certain arrays, fix undefined symbol when it's in another imported module
This commit is contained in:
parent
10ddd5b127
commit
35af53828a
@ -30,8 +30,9 @@ class ExpressionSimplifier(private val program: Program) : AstWalker() {
|
|||||||
val literal = typecast.expression as? NumericLiteral
|
val literal = typecast.expression as? NumericLiteral
|
||||||
if (literal != null) {
|
if (literal != null) {
|
||||||
val newLiteral = literal.cast(typecast.type)
|
val newLiteral = literal.cast(typecast.type)
|
||||||
if (newLiteral.isValid && newLiteral.valueOrZero() !== literal)
|
if (newLiteral.isValid && newLiteral.valueOrZero() !== literal) {
|
||||||
mods += IAstModification.ReplaceNode(typecast.expression, newLiteral.valueOrZero(), typecast)
|
mods += IAstModification.ReplaceNode(typecast, newLiteral.valueOrZero(), parent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove redundant nested typecasts
|
// remove redundant nested typecasts
|
||||||
|
@ -90,6 +90,10 @@ psg {
|
|||||||
; cx16.r1L = the voice number
|
; cx16.r1L = the voice number
|
||||||
; cx16.r2L = attack value
|
; cx16.r2L = attack value
|
||||||
|
|
||||||
|
pushw(cx16.r0)
|
||||||
|
push(cx16.r1L)
|
||||||
|
push(cx16.r2L)
|
||||||
|
pushw(cx16.r9)
|
||||||
; calculate new volumes
|
; calculate new volumes
|
||||||
for cx16.r1L in 0 to 15 {
|
for cx16.r1L in 0 to 15 {
|
||||||
when envelope_states[cx16.r1L] {
|
when envelope_states[cx16.r1L] {
|
||||||
@ -138,6 +142,10 @@ psg {
|
|||||||
cx16.VERA_DATA0 = cx16.VERA_DATA1 & %11000000 | msb(envelope_volumes[cx16.r1L])
|
cx16.VERA_DATA0 = cx16.VERA_DATA1 & %11000000 | msb(envelope_volumes[cx16.r1L])
|
||||||
}
|
}
|
||||||
cx16.pop_vera_context()
|
cx16.pop_vera_context()
|
||||||
|
popw(cx16.r9)
|
||||||
|
pop(cx16.r2L)
|
||||||
|
pop(cx16.r1L)
|
||||||
|
popw(cx16.r0)
|
||||||
}
|
}
|
||||||
|
|
||||||
ubyte[16] envelope_states
|
ubyte[16] envelope_states
|
||||||
|
@ -1 +1 @@
|
|||||||
8.3
|
8.4-dev
|
||||||
|
@ -197,6 +197,14 @@ interface INameScope: IStatementContainer, INamedStatement {
|
|||||||
else
|
else
|
||||||
statementScope = (statementScope as Node).definingScope
|
statementScope = (statementScope as Node).definingScope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// still not found, maybe it is a symbol in another module
|
||||||
|
for(module in (this as Node).definingModule.program.modules) {
|
||||||
|
val stmt = module.searchSymbol(name)
|
||||||
|
if(stmt!=null)
|
||||||
|
return stmt
|
||||||
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,9 +757,11 @@ class ArrayLiteral(val type: InferredTypes.InferredType, // inferred because
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, select the "biggegst" datatype based on the elements in the array.
|
// otherwise, select the "biggest" datatype based on the elements in the array.
|
||||||
|
require(value.isNotEmpty()) { "can't determine type of empty array" }
|
||||||
val datatypesInArray = value.map { it.inferType(program) }
|
val datatypesInArray = value.map { it.inferType(program) }
|
||||||
require(datatypesInArray.isNotEmpty() && datatypesInArray.all { it.isKnown }) { "can't determine type of empty array" }
|
if(datatypesInArray.any{ it.isUnknown })
|
||||||
|
return InferredTypes.InferredType.unknown()
|
||||||
val dts = datatypesInArray.map { it.getOr(DataType.UNDEFINED) }
|
val dts = datatypesInArray.map { it.getOr(DataType.UNDEFINED) }
|
||||||
return when {
|
return when {
|
||||||
DataType.FLOAT in dts -> InferredTypes.InferredType.known(DataType.ARRAY_F)
|
DataType.FLOAT in dts -> InferredTypes.InferredType.known(DataType.ARRAY_F)
|
||||||
|
@ -1,22 +1,17 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte value1 = %1110
|
repeat {
|
||||||
ubyte value2 = %1111
|
uword keys = cx16.kbdbuf_peek2()
|
||||||
|
txt.print_uwhex(keys, true)
|
||||||
bool[2] @shared barr = [true, false]
|
if msb(keys) {
|
||||||
|
c64.GETIN()
|
||||||
; if value1 and value2 ; TODO value1 isn't converted to bool in 6502 preprocess
|
}
|
||||||
; txt.print("ok")
|
txt.nl()
|
||||||
; else
|
}
|
||||||
; txt.print("fail!")
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
if value1 and value2!=255 ; TODO value1 isn't converted to bool in 6502 preprocess
|
|
||||||
txt.print("ok")
|
|
||||||
else
|
|
||||||
txt.print("fail!")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user