1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-01-10 05:29:49 +00:00

Support local labels in macros for all instructions

This commit is contained in:
Karol Stasiak 2020-07-31 13:29:48 +02:00
parent 03a57138f0
commit 2905e99521

View File

@ -937,8 +937,15 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
case ConstantArrayElementExpression(c) => Some(c)
case VariableExpression(name) =>
val result = maybeGet[ConstantThing](name).map(_.value).orElse(maybeGet[ThingInMemory](name).map(_.toAddress))
if (!silent && result.isEmpty) log.warn(s"$name is not known", e.position)
result
result match {
case Some(x) => result
case None =>
if (name.startsWith(".")) Some(Label(name).toAddress)
else {
if (!silent) log.warn(s"$name is not known", e.position)
None
}
}
case IndexedExpression(name, index) => (evalForAsm(VariableExpression(name)), evalForAsm(index)) match {
case (Some(a), Some(b)) => Some(CompoundConstant(MathOperator.Plus, a, b).quickSimplify)
}