Class Macro


  • class Macro
    extends java.lang.Object
    A macro definition. Macros appear in templates using the syntax #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.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  Macro.MacroEvaluationContext
      The context for evaluation within macros.
    • Constructor Summary

      Constructors 
      Constructor Description
      Macro​(int definitionLineNumber, java.lang.String name, java.util.List<java.lang.String> parameterNames, Node body)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) java.lang.Object evaluate​(EvaluationContext context, java.util.List<Node> thunks)  
      (package private) java.lang.String name()  
      (package private) int parameterCount()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • definitionLineNumber

        private final int definitionLineNumber
      • name

        private final java.lang.String name
      • parameterNames

        private final com.google.common.collect.ImmutableList<java.lang.String> parameterNames
      • body

        private final Node body
    • Constructor Detail

      • Macro

        Macro​(int definitionLineNumber,
              java.lang.String name,
              java.util.List<java.lang.String> parameterNames,
              Node body)
    • Method Detail

      • name

        java.lang.String name()
      • parameterCount

        int parameterCount()