get rid of containment expression restriction

This commit is contained in:
Irmen de Jong 2024-03-12 23:39:54 +01:00
parent 51d708bbdd
commit 33c8caac8f
3 changed files with 8 additions and 39 deletions

View File

@ -1437,15 +1437,6 @@ internal class AstChecker(private val program: Program,
val elementDt = containment.element.inferType(program) val elementDt = containment.element.inferType(program)
val iterableDt = containment.iterable.inferType(program) val iterableDt = containment.iterable.inferType(program)
if(compilerOptions.compTarget.name!=VMTarget.NAME) {
val parentBinexpr = containment.parent as? BinaryExpression
if(parentBinexpr!=null) {
// only supported if compared to 1 or 0, more complex expressions aren't supported in the 6502 code-gen.
if(parentBinexpr.operator!="==" || parentBinexpr.right.constValue(program)?.number !in listOf(0.0, 1.0))
errors.err("containment check is currently not supported inside complex expressions", containment.position)
}
}
if (iterableDt.isIterable) { if (iterableDt.isIterable) {
if (containment.iterable !is RangeExpression) { if (containment.iterable !is RangeExpression) {
val iterableEltDt = ArrayToElementTypes.getValue(iterableDt.getOr(DataType.UNDEFINED)) val iterableEltDt = ArrayToElementTypes.getValue(iterableDt.getOr(DataType.UNDEFINED))

View File

@ -1,8 +1,6 @@
TODO TODO
==== ====
fix containment check is currently not supported inside complex expressions
... ...

View File

@ -1,35 +1,15 @@
%import math %import textio
%import monogfx %zeropage basicsafe
%option no_sysinit
main { main {
sub start() { sub start() {
monogfx.lores() str name = "irmen"
monogfx.drawmode(monogfx.MODE_INVERT) ubyte @shared cc='m'
uword x1, x2 cx16.r0=9999
uword y1, y2
repeat 200 { if cx16.r0<10000 and 'q' in name
x1 = math.rnd() txt.print("yes")
y1 = math.rnd() % 240
x2 = math.rnd()
y2 = math.rnd() % 240
monogfx.line(x1, y1, x2, y2, true)
}
repeat 5 {
for cx16.r9L in 0 to 200 {
monogfx.vertical_line(cx16.r9L, 10, 200, true)
}
}
monogfx.disc(160, 120, 100, true)
monogfx.fillrect(20, 100, 280, 50, true)
monogfx.drawmode(monogfx.MODE_STIPPLE)
monogfx.fillrect(80, 10, 50, 220, true)
repeat {
}
} }
} }