mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-27 11:30:19 +00:00
Various fixes related to the -> operator
This commit is contained in:
parent
088b28989f
commit
63c43c414a
@ -156,6 +156,9 @@ abstract class AbstractStatementPreprocessor(ctx: CompilationContext, statements
|
|||||||
case ExpressionStatement(expr) =>
|
case ExpressionStatement(expr) =>
|
||||||
cv = search(expr, cv)
|
cv = search(expr, cv)
|
||||||
ExpressionStatement(optimizeExpr(expr, cv)).pos(pos) -> cv
|
ExpressionStatement(optimizeExpr(expr, cv)).pos(pos) -> cv
|
||||||
|
case ReturnStatement(Some(expr)) =>
|
||||||
|
cv = search(expr, cv)
|
||||||
|
ReturnStatement(Some(optimizeExpr(expr, cv))).pos(pos) -> cv
|
||||||
case IfStatement(cond, th, el) =>
|
case IfStatement(cond, th, el) =>
|
||||||
cv = search(cond, cv)
|
cv = search(cond, cv)
|
||||||
val c = optimizeExpr(cond, cv)
|
val c = optimizeExpr(cond, cv)
|
||||||
|
@ -64,6 +64,7 @@ object UnusedGlobalVariables extends NodeOptimization {
|
|||||||
case FunctionCallExpression(name, xs) => name :: getAllReadVariables(xs)
|
case FunctionCallExpression(name, xs) => name :: getAllReadVariables(xs)
|
||||||
case IndexedExpression(arr, index) => arr :: getAllReadVariables(List(index))
|
case IndexedExpression(arr, index) => arr :: getAllReadVariables(List(index))
|
||||||
case SeparateBytesExpression(h, l) => getAllReadVariables(List(h, l))
|
case SeparateBytesExpression(h, l) => getAllReadVariables(List(h, l))
|
||||||
|
case IndirectFieldExpression(root, firstIndices, fields) => getAllReadVariables(List(root) ++ firstIndices ++ fields.flatMap(_._2))
|
||||||
case _ => Nil
|
case _ => Nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,4 +209,26 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("Pointers and arrays") {
|
||||||
|
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)(
|
||||||
|
"""
|
||||||
|
| struct P {
|
||||||
|
| word i
|
||||||
|
| byte c
|
||||||
|
| byte d
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| array a [sizeof(P)*8]
|
||||||
|
|
|
||||||
|
| noinline byte f(byte i) {
|
||||||
|
| return pointer.P(a.addr + sizeof(P)*i)->c
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| void main() {
|
||||||
|
| f(6)
|
||||||
|
| }
|
||||||
|
""".stripMargin) { m =>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user