mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Allow the : operator in const-pure functions
This commit is contained in:
parent
2673a486d6
commit
7de23ddd44
@ -1,6 +1,6 @@
|
||||
package millfork.env
|
||||
|
||||
import millfork.node.{Expression, FunctionCallExpression, GeneratedConstantExpression, IfStatement, IndexedExpression, LiteralExpression, ReturnStatement, Statement, SumExpression, VariableExpression}
|
||||
import millfork.node.{Expression, FunctionCallExpression, GeneratedConstantExpression, IfStatement, IndexedExpression, LiteralExpression, ReturnStatement, SeparateBytesExpression, Statement, SumExpression, VariableExpression}
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
@ -93,6 +93,9 @@ object ConstPureFunctions {
|
||||
env.log.error(s"Calling `${vname}` not allowed in const-pure functions", expr.position)
|
||||
}
|
||||
checkConstPure(env, index, params)
|
||||
case SeparateBytesExpression(hi, lo) =>
|
||||
checkConstPure(env, hi, params)
|
||||
checkConstPure(env, lo, params)
|
||||
case _ =>
|
||||
env.log.error(s"Expression not allowed in const-pure functions", expr.position)
|
||||
|
||||
|
@ -95,6 +95,21 @@ class ConstantSuite extends FunSuite with Matchers {
|
||||
|
||||
}
|
||||
|
||||
test("Const-pure functions 2") {
|
||||
val m = EmuUnoptimizedRun(
|
||||
"""
|
||||
| word output @$c000
|
||||
| const word BASE = $d800
|
||||
| const word pair(byte x, byte y) = (x+BASE.hi):y
|
||||
| const word result = pair(1,2)
|
||||
| void main() {
|
||||
| output = result
|
||||
| }
|
||||
""".stripMargin)
|
||||
m.readWord(0xc000) should equal(0xd902)
|
||||
|
||||
}
|
||||
|
||||
test("Const-pure Fibonacci") {
|
||||
val m = EmuUnoptimizedRun(
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user