APIdia Launch Partner
Top Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.compiler

pack-priv final Class Predicate

extends Expression
implements Closure
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xalan.internal.xsltc.compiler.Closure
Imports
com.sun.org.apache.bcel.internal.classfile.Field, com.sun.org.apache.bcel.internal.generic.ASTORE, .CHECKCAST, .ConstantPoolGen, .GETFIELD, .INVOKESPECIAL, .InstructionList, .LocalVariableGen, .NEW, .PUSH, .PUTFIELD, com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType, .ClassGenerator, .FilterGenerator, .IntType, .MethodGenerator, .NumberType, .ReferenceType, .ResultTreeType, .TestGenerator, .Type, .TypeCheckError, .Util, com.sun.org.apache.xalan.internal.xsltc.runtime.Operators, java.util.ArrayList, .List

Authors
Jacek Ambroziak, Santiago Pericas-Geertsen, Morten Jorgensen

Field Summary

Modifier and TypeField and Description
private boolean
_canOptimize

This flag indicates if optimizations are turned on.

private String
_className

Name of the inner class.

private List<VariableRefBase>
_closureVars

List of variables in closure.

private Expression
_exp

The predicate's expression.

private boolean
_nthDescendant

Flag indicatig if the nth position descendant is on.

private boolean
_nthPositionFilter

Flag indicatig if the nth position optimization is on.

private Closure
_parentClosure

Reference to parent closure.

pack-priv int
_ptype

Cached node type of the expression that owns this predicate.

private Step
_step

Cached value of method getCompareValue().

private Expression
_value

Cached value of method getCompareValue().

Inherited from com.sun.org.apache.xalan.internal.xsltc.compiler.Expression:
_falseList_trueList_type

Constructor Summary

AccessConstructor and Description
public
Predicate(Expression exp)

Initializes a predicate.

Method Summary

Modifier and TypeMethod and Description
public void
private void
compileFilter(ClassGenerator classGen, MethodGenerator methodGen)

Create a new "Filter" class implementing CurrentNodeListFilter.

public void
dontOptimize()

Turns off all optimizations for this predicate.

public Expression
getCompareValue()

Returns the value in an expression of the form 'step = value'.

public Expression
public String
getInnerClassName()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.getInnerClassName.

Returns the name of the auxiliary class or null if this predicate is compiled inside the Translet.

public Closure
getParentClosure()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.getParentClosure.

Returns a reference to its parent closure or null if outermost.

public int
getPosType()

Returns the node type of the expression owning this predicate.

public Step
getStep()

Returns the step in an expression of the form 'step = value'.

public boolean
hasLastCall()

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.hasLastCall.

Returns true if the expression in this predicate contains a call to last().

public boolean
hasPositionCall()

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.hasPositionCall.

Returns true if the expression in this predicate contains a call to position().

public boolean
inInnerClass()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.inInnerClass.

Returns true if this closure is compiled in an inner class (i.e. if this is a real closure).

public boolean
isBooleanTest()

Returns true if the predicate is a test for the existance of an element or attribute.

public boolean
isNodeValueTest()

Method to see if we can optimise the predicate by using a specialised iterator for expressions like '/foo/bar[@attr = $var]', which are very common in many stylesheets

public boolean
isNthDescendant()

Returns a boolean value indicating if the nth descendant optimization is on.

public boolean
isNthPositionFilter()

Returns a boolean value indicating if the nth position optimization is on.

public boolean
public void
public String
toString()

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.toString.

Returns a string representation of the object.

public void
public void
translateFilter(ClassGenerator classGen, MethodGenerator methodGen)

Translate a predicate expression.

public Type
Inherited from com.sun.org.apache.xalan.internal.xsltc.compiler.Expression:
backPatchFalseListbackPatchTrueListcompiledesynthesizeevaluateAtCompileTimegetFalseListgetTrueListgetTypelookupPrimopstartIteratorsynthesizetranslateDesynthesized

Field Detail

_canOptimizeback to summary
private boolean _canOptimize

This flag indicates if optimizations are turned on. The method dontOptimize() can be called to turn optimizations off.

_classNameback to summary
private String _className

Name of the inner class.

_closureVarsback to summary
private List<VariableRefBase> _closureVars

List of variables in closure.

_expback to summary
private Expression _exp

The predicate's expression.

_nthDescendantback to summary
private boolean _nthDescendant

Flag indicatig if the nth position descendant is on. It is set in typeCheck().

_nthPositionFilterback to summary
private boolean _nthPositionFilter

Flag indicatig if the nth position optimization is on. It is set in typeCheck().

_parentClosureback to summary
private Closure _parentClosure

Reference to parent closure.

_ptypeback to summary
pack-priv int _ptype

Cached node type of the expression that owns this predicate.

_stepback to summary
private Step _step

Cached value of method getCompareValue().

_valueback to summary
private Expression _value

Cached value of method getCompareValue().

Constructor Detail

Predicateback to summary
public Predicate(Expression exp)

Initializes a predicate.

Method Detail

addVariableback to summary
public void addVariable(VariableRefBase variableRef)

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.addVariable.

Add new variable to the closure.

compileFilterback to summary
private void compileFilter(ClassGenerator classGen, MethodGenerator methodGen)

Create a new "Filter" class implementing CurrentNodeListFilter. Allocate registers for local variables and local parameters passed in the closure to test(). Notice that local variables need to be "unboxed".

dontOptimizeback to summary
public void dontOptimize()

Turns off all optimizations for this predicate.

getCompareValueback to summary
public Expression getCompareValue()

Returns the value in an expression of the form 'step = value'. A value may be either a literal string or a variable whose type is string. Optimization if off if null is returned.

getExprback to summary
public Expression getExpr()
getInnerClassNameback to summary
public String getInnerClassName()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.getInnerClassName.

Returns the name of the auxiliary class or null if this predicate is compiled inside the Translet.

getParentClosureback to summary
public Closure getParentClosure()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.getParentClosure.

Returns a reference to its parent closure or null if outermost.

getPosTypeback to summary
public int getPosType()

Returns the node type of the expression owning this predicate. The return value is cached in _ptype.

getStepback to summary
public Step getStep()

Returns the step in an expression of the form 'step = value'. Null is returned if the expression is not of the right form. Optimization if off if null is returned.

hasLastCallback to summary
public boolean hasLastCall()

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.hasLastCall.

Returns true if the expression in this predicate contains a call to last().

hasPositionCallback to summary
public boolean hasPositionCall()

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.hasPositionCall.

Returns true if the expression in this predicate contains a call to position().

inInnerClassback to summary
public boolean inInnerClass()

Implements com.sun.org.apache.xalan.internal.xsltc.compiler.Closure.inInnerClass.

Returns true if this closure is compiled in an inner class (i.e. if this is a real closure).

isBooleanTestback to summary
public boolean isBooleanTest()

Returns true if the predicate is a test for the existance of an element or attribute. All we have to do is to get the first node from the step, check if it is there, and then return true/false.

isNodeValueTestback to summary
public boolean isNodeValueTest()

Method to see if we can optimise the predicate by using a specialised iterator for expressions like '/foo/bar[@attr = $var]', which are very common in many stylesheets

isNthDescendantback to summary
public boolean isNthDescendant()

Returns a boolean value indicating if the nth descendant optimization is on. Must be call after type checking!

isNthPositionFilterback to summary
public boolean isNthPositionFilter()

Returns a boolean value indicating if the nth position optimization is on. Must be call after type checking!

parentIsPatternback to summary
public boolean parentIsPattern()
setParserback to summary
public void setParser(Parser parser)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.setParser.

Set the parser for this expression.

toStringback to summary
public String toString()

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

translateback to summary
public void translate(ClassGenerator classGen, MethodGenerator methodGen)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.translate.

Translate a predicate expression. If non of the optimizations apply then this translation pushes two references on the stack: a reference to a newly created filter object and a reference to the predicate's closure. See class Step for further details.

translateFilterback to summary
public void translateFilter(ClassGenerator classGen, MethodGenerator methodGen)

Translate a predicate expression. This translation pushes two references on the stack: a reference to a newly created filter object and a reference to the predicate's closure.

typeCheckback to summary
public Type typeCheck(SymbolTable stable) throws TypeCheckError

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.Expression.typeCheck.

Type check a predicate expression. If the type of the expression is number convert it to boolean by adding a comparison with position(). Note that if the expression is a parameter, we cannot distinguish at compile time if its type is number or not. Hence, expressions of reference type are always converted to booleans. This method may be called twice, before and after calling dontOptimize(). If so, the second time it should honor the new value of _canOptimize.