Class Pattern

java.lang.Object
org.apache.xalan.xsltc.compiler.SyntaxTreeNode
org.apache.xalan.xsltc.compiler.Pattern
All Implemented Interfaces:
org.apache.bcel.generic.InstructionConstants, Constants
Direct Known Subclasses:
LocationPathPattern

public abstract class Pattern extends SyntaxTreeNode
Author:
Jacek Ambroziak, Santiago Pericas-Geertsen
  • Constructor Details

    • Pattern

      public Pattern()
  • Method Details

    • typeCheck

      public abstract Type typeCheck(org.apache.xalan.xsltc.compiler.SymbolTable stable) throws TypeCheckError
      Returns the type of a pattern, which is always a NodeType. A NodeType has a number of subtypes defined by NodeType._type corresponding to each type of node.
      Parameters:
      stable - The compiler/parser's symbol table
      Throws:
      TypeCheckError
    • translate

      public abstract void translate(ClassGenerator classGen, MethodGenerator methodGen)
      Translate this node into JVM bytecodes. Patterns are translated as boolean expressions with true/false lists. Before calling translate on a pattern, make sure that the node being matched is on top of the stack. After calling translate, make sure to backpatch both true and false lists. True lists are the default, in the sense that they always "fall through". If this is not the intended semantics (e.g., see translate(org.apache.xalan.xsltc.compiler.util.ClassGenerator, org.apache.xalan.xsltc.compiler.util.MethodGenerator)) then a GOTO must be appended to the instruction list after calling translate.
      Parameters:
      classGen - BCEL Java class generator
      methodGen - BCEL Java method generator
    • getPriority

      public abstract double getPriority()
      Returns the priority of this pattern (section 5.5 in the XSLT spec).
    • getType

      public Type getType()
    • toString

      public abstract String toString()
      Overrides:
      toString in class Object
    • hasPositionCall

      public boolean hasPositionCall()
    • hasLastCall

      public boolean hasLastCall()
    • evaluateAtCompileTime

      public Object evaluateAtCompileTime()
      Returns an object representing the compile-time evaluation of an expression. We are only using this for function-available and element-available at this time.
    • compile

      public final org.apache.bcel.generic.InstructionList compile(ClassGenerator classGen, MethodGenerator methodGen)
      Translate this node into a fresh instruction list. The original instruction list is saved and restored.
    • translateDesynthesized

      public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen)
      Redefined by expressions of type boolean that use flow lists.
    • startIterator

      public void startIterator(ClassGenerator classGen, MethodGenerator methodGen)
      If this expression is of type node-set and it is not a variable reference, then call setStartNode() passing the context node.
    • synthesize

      public void synthesize(ClassGenerator classGen, MethodGenerator methodGen)
      Synthesize a boolean expression, i.e., either push a 0 or 1 onto the operand stack for the next statement to succeed. Returns the handle of the instruction to be backpatched.
    • desynthesize

      public void desynthesize(ClassGenerator classGen, MethodGenerator methodGen)
    • getFalseList

      public FlowList getFalseList()
    • getTrueList

      public FlowList getTrueList()
    • backPatchFalseList

      public void backPatchFalseList(org.apache.bcel.generic.InstructionHandle ih)
    • backPatchTrueList

      public void backPatchTrueList(org.apache.bcel.generic.InstructionHandle ih)
    • lookupPrimop

      public MethodType lookupPrimop(org.apache.xalan.xsltc.compiler.SymbolTable stable, String op, MethodType ctype)
      Search for a primop in the symbol table that matches the method type ctype. Two methods match if they have the same arity. If a primop is overloaded then the "closest match" is returned. The first entry in the vector of primops that has the right arity is considered to be the default one.