class Macro
extends java.lang.Object
#macro (m $x $y) ... #end
and each one produces an instance of this class. Evaluating a macro involves setting the
parameters (here {$x $y)} and evaluating the macro body. Macro arguments are call-by-name, which
means that we need to set each parameter variable to the node in the parse tree that corresponds
to it, and arrange for that node to be evaluated when the variable is actually referenced.Modifier and Type | Class and Description |
---|---|
(package private) static class |
Macro.MacroEvaluationContext
The context for evaluation within macros.
|
Modifier and Type | Field and Description |
---|---|
private Node |
body |
private int |
definitionLineNumber |
private java.lang.String |
name |
private com.google.common.collect.ImmutableList<java.lang.String> |
parameterNames |
Constructor and Description |
---|
Macro(int definitionLineNumber,
java.lang.String name,
java.util.List<java.lang.String> parameterNames,
Node body) |
Modifier and Type | Method and Description |
---|---|
(package private) java.lang.Object |
evaluate(EvaluationContext context,
java.util.List<Node> thunks) |
(package private) java.lang.String |
name() |
(package private) int |
parameterCount() |
private final int definitionLineNumber
private final java.lang.String name
private final com.google.common.collect.ImmutableList<java.lang.String> parameterNames
private final Node body
Macro(int definitionLineNumber, java.lang.String name, java.util.List<java.lang.String> parameterNames, Node body)
java.lang.String name()
int parameterCount()
java.lang.Object evaluate(EvaluationContext context, java.util.List<Node> thunks)