mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-30 00:33:14 +00:00
Don't modify macro invocations
This commit is contained in:
parent
efe69eb5a9
commit
7d051eb5e0
@ -142,6 +142,9 @@ abstract class AbstractStatementPreprocessor(protected val ctx: CompilationConte
|
|||||||
cv = search(arg, cv)
|
cv = search(arg, cv)
|
||||||
cv = search(ve, cv)
|
cv = search(ve, cv)
|
||||||
Assignment(ve, optimizeExpr(arg, cv)).pos(pos) -> cv
|
Assignment(ve, optimizeExpr(arg, cv)).pos(pos) -> cv
|
||||||
|
case ExpressionStatement(expr@FunctionCallExpression(fname, List(VariableExpression(v), arg)))
|
||||||
|
if ctx.env.maybeGet[Thing](fname).exists(i => i.isInstanceOf[MacroFunction]) =>
|
||||||
|
ExpressionStatement(optimizeExpr(expr, Map())).pos(pos) -> Map()
|
||||||
case ExpressionStatement(expr@FunctionCallExpression("+=", List(VariableExpression(v), arg)))
|
case ExpressionStatement(expr@FunctionCallExpression("+=", List(VariableExpression(v), arg)))
|
||||||
if currentVarValues.contains(v) =>
|
if currentVarValues.contains(v) =>
|
||||||
cv = search(arg, cv)
|
cv = search(arg, cv)
|
||||||
@ -366,7 +369,12 @@ abstract class AbstractStatementPreprocessor(protected val ctx: CompilationConte
|
|||||||
// Eliminating variables may eliminate carry
|
// Eliminating variables may eliminate carry
|
||||||
FunctionCallExpression("nonet", args.map(arg => optimizeExpr(arg, Map()))).pos(pos)
|
FunctionCallExpression("nonet", args.map(arg => optimizeExpr(arg, Map()))).pos(pos)
|
||||||
case FunctionCallExpression(name, args) =>
|
case FunctionCallExpression(name, args) =>
|
||||||
FunctionCallExpression(name, args.map(arg => optimizeExpr(arg, currentVarValues))).pos(pos)
|
ctx.env.maybeGet[Thing](name) match {
|
||||||
|
case Some(_: MacroFunction) =>
|
||||||
|
FunctionCallExpression(name, args.map(arg => optimizeExpr(arg, Map()))).pos(pos)
|
||||||
|
case _ =>
|
||||||
|
FunctionCallExpression(name, args.map(arg => optimizeExpr(arg, currentVarValues))).pos(pos)
|
||||||
|
}
|
||||||
case SumExpression(expressions, decimal) =>
|
case SumExpression(expressions, decimal) =>
|
||||||
// don't collapse additions, let the later stages deal with it
|
// don't collapse additions, let the later stages deal with it
|
||||||
// expecially important when inside a nonet operation
|
// expecially important when inside a nonet operation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user