Top Description Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.compiler

pack-priv final Class Mode

extends Object
implements Constants
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xalan.internal.xsltc.compiler.Constants
Imports
com.sun.org.apache.bcel.internal.generic.BranchHandle, .ConstantPoolGen, .DUP, .GOTO_W, .IFLT, .ILOAD, .INVOKEINTERFACE, .INVOKEVIRTUAL, .ISTORE, .Instruction, .InstructionHandle, .InstructionList, .LocalVariableGen, .SWITCH, .TargetLostException, com.sun.org.apache.bcel.internal.util.InstructionFinder, com.sun.org.apache.xalan.internal.xsltc.DOM, com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator, .MethodGenerator, .NamedMethodGenerator, .Util, com.sun.org.apache.xml.internal.dtm.Axis, .DTM, java.util.ArrayList, .HashMap, .LinkedHashMap, .Iterator, .List, .Map, .Set

Mode gathers all the templates belonging to a given mode; it is responsible for generating an appropriate applyTemplates + (mode name) method in the translet.
Authors
Jacek Ambroziak, Santiago Pericas-Geertsen, Morten Jorgensen, Erwin Bolwidt , G. Todd Miller

Field Summary

Modifier and TypeField and Description
private List<LocationPathPattern>
_attribNodeGroup

Group for patterns with node()-type kernel and attribute axis.

private TestSeq
_attribNodeTestSeq

Test sequence for patterns with node()-type kernel and attribute axis.

private List<LocationPathPattern>
_childNodeGroup

Group for patterns with node()-type kernel and child axis.

private TestSeq
_childNodeTestSeq

Test sequence for patterns with node()-type kernel and child axis.

private int
_currentIndex

Variable index for the current node used in code generation.

private List<LocationPathPattern>
_idxGroup

Group for patterns with id() or key()-type kernel.

private TestSeq
_idxTestSeq

Test sequence for patterns with id() or key()-type kernel.

private Map<Integer, Integer>
_importLevels

Stores ranges of template precendences for the compilation of apply-imports.

private Map<String, Key>
_keys

A mapping between key names and keys.

private final String
_methodName

The name of the method in which this mode is compiled.

private final QName
_name

The name of this mode as defined in the stylesheet.

private Map<Template, Mode>
_namedTemplates

A mapping between named templates and Mode objects.

private Map<Template, Object>
_neededTemplates

A mapping between templates and test sequences.

private List<LocationPathPattern>[]
_patternGroups

Group for patterns with any other kernel type.

private LocationPathPattern
_rootPattern

A reference to the pattern matching the root node.

private final Stylesheet
_stylesheet

A reference to the stylesheet object that owns this mode.

private Map<Template, InstructionHandle>
_templateIHs

A mapping between templates and instruction handles.

private Map<Template, InstructionList>
_templateILs

A mapping between templates and instruction lists.

private List<Template>
_templates

A vector of all the templates in this mode.

private TestSeq[]
_testSeq

Test sequence for patterns with any other kernel type.

Constructor Summary

AccessConstructor and Description
public
Mode(QName
A textual representation of the mode's QName
name
,
Stylesheet
The Stylesheet in which the mode occured
stylesheet
,
String
A suffix to append to the method name for this mode (normally a sequence number - still in a String).
suffix
)

Creates a new Mode.

Method Summary

Modifier and TypeMethod and Description
private void
addPattern(int kernelType, LocationPathPattern pattern)

Adds a pattern to a pattern group

private void
addPatternToGroup(final LocationPathPattern lpp)

Group patterns by NodeTests of their last Step Keep them sorted by priority within group

public void
private void
private void
public void
compileApplyImports(ClassGenerator classGen, int min, int max)

public void
compileApplyTemplates(ClassGenerator classGen)

Compiles the applyTemplates() method and adds it to the translet.

private InstructionList
compileDefaultRecursion(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next)

Compiles the default handling for DOM elements: traverse all children

private InstructionList
compileDefaultText(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next)

Compiles the default action for DOM text nodes and attribute nodes: output the node's text value

public static void
compileGetChildren(ClassGenerator classGen, MethodGenerator methodGen, int node)

private void
private InstructionList
compileNamespaces(ClassGenerator classGen, MethodGenerator methodGen, boolean[] isNamespace, boolean[] isAttribute, boolean attrFlag, InstructionHandle defaultTarget)

private void
compileTemplateCalls(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next, int min, int max)

private void
private void
completeTestSequences(int nodeType, List<LocationPathPattern> patterns)

Complete test sequences of a given type by adding all patterns from a given group.

private void
flattenAlternative(Pattern pattern, Template template, Map<String, Key> keys)

This method will break up alternative patterns (ie.

public String

Returns:

Method name for this mode
functionName
()

Returns the name of the method (_not_ function) that will be compiled for this mode.

public String
functionName(int min, int max)

private String
getClassName()

Shortcut to get the class compiled for this mode (will be inlined).

public Stylesheet
public InstructionHandle
private static boolean
isAttributeName(String qname)

Auxiliary method to determine if a qname is an attribute.

private static boolean
isNamespaceName(String qname)

Auxiliary method to determine if a qname is a namespace qualified "*".

private int
partition(List<Template> templates, int p, int r)

private void
peepHoleOptimization(MethodGenerator methodGen)

Peephole optimization.

private void
prepareTestSequences()

Build test sequences.

public void
processPatterns(Map<String, Key> keys)

Process all the test patterns in this mode

private List<Template>
quicksort(List<Template> templates, int p, int r)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_attribNodeGroupback to summary
private List<LocationPathPattern> _attribNodeGroup

Group for patterns with node()-type kernel and attribute axis.

_attribNodeTestSeqback to summary
private TestSeq _attribNodeTestSeq

Test sequence for patterns with node()-type kernel and attribute axis.

_childNodeGroupback to summary
private List<LocationPathPattern> _childNodeGroup

Group for patterns with node()-type kernel and child axis.

_childNodeTestSeqback to summary
private TestSeq _childNodeTestSeq

Test sequence for patterns with node()-type kernel and child axis.

_currentIndexback to summary
private int _currentIndex

Variable index for the current node used in code generation.

_idxGroupback to summary
private List<LocationPathPattern> _idxGroup

Group for patterns with id() or key()-type kernel.

_idxTestSeqback to summary
private TestSeq _idxTestSeq

Test sequence for patterns with id() or key()-type kernel.

_importLevelsback to summary
private Map<Integer, Integer> _importLevels

Stores ranges of template precendences for the compilation of apply-imports.

_keysback to summary
private Map<String, Key> _keys

A mapping between key names and keys.

_methodNameback to summary
private final String _methodName

The name of the method in which this mode is compiled.

_nameback to summary
private final QName _name

The name of this mode as defined in the stylesheet.

_namedTemplatesback to summary
private Map<Template, Mode> _namedTemplates

A mapping between named templates and Mode objects. LinkedHashMap is necessary to make traversal order consistent across runs.

_neededTemplatesback to summary
private Map<Template, Object> _neededTemplates

A mapping between templates and test sequences. LinkedHashMap is necessary to make traversal order consistent across runs.

_patternGroupsback to summary
private List<LocationPathPattern>[] _patternGroups

Group for patterns with any other kernel type.

_rootPatternback to summary
private LocationPathPattern _rootPattern

A reference to the pattern matching the root node.

_stylesheetback to summary
private final Stylesheet _stylesheet

A reference to the stylesheet object that owns this mode.

_templateIHsback to summary
private Map<Template, InstructionHandle> _templateIHs

A mapping between templates and instruction handles.

_templateILsback to summary
private Map<Template, InstructionList> _templateILs

A mapping between templates and instruction lists.

_templatesback to summary
private List<Template> _templates

A vector of all the templates in this mode.

_testSeqback to summary
private TestSeq[] _testSeq

Test sequence for patterns with any other kernel type.

Constructor Detail

Modeback to summary
public Mode(QName name, Stylesheet stylesheet, String suffix)

Creates a new Mode.

Parameters
name:QName

A textual representation of the mode's QName

stylesheet:Stylesheet

The Stylesheet in which the mode occured

suffix:String

A suffix to append to the method name for this mode (normally a sequence number - still in a String).

Annotations
@SuppressWarnings:rawtypes, unchecked

Method Detail

addPatternback to summary
private void addPattern(int kernelType, LocationPathPattern pattern)

Adds a pattern to a pattern group

addPatternToGroupback to summary
private void addPatternToGroup(final LocationPathPattern lpp)

Group patterns by NodeTests of their last Step Keep them sorted by priority within group

addTemplateback to summary
public void addTemplate(Template template)
appendTemplateCodeback to summary
private void appendTemplateCode(InstructionList body)
appendTestSequencesback to summary
private void appendTestSequences(InstructionList body)
compileApplyImportsback to summary
public void compileApplyImports(ClassGenerator classGen, int min, int max)
Annotations
@SuppressWarnings:rawtypes, unchecked
compileApplyTemplatesback to summary
public void compileApplyTemplates(ClassGenerator classGen)

Compiles the applyTemplates() method and adds it to the translet. This is the main dispatch method.

compileDefaultRecursionback to summary
private InstructionList compileDefaultRecursion(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next)

Compiles the default handling for DOM elements: traverse all children

compileDefaultTextback to summary
private InstructionList compileDefaultText(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next)

Compiles the default action for DOM text nodes and attribute nodes: output the node's text value

compileGetChildrenback to summary
public static void compileGetChildren(ClassGenerator classGen, MethodGenerator methodGen, int node)
compileNamedTemplateback to summary
private void compileNamedTemplate(Template template, ClassGenerator classGen)
compileNamespacesback to summary
private InstructionList compileNamespaces(ClassGenerator classGen, MethodGenerator methodGen, boolean[] isNamespace, boolean[] isAttribute, boolean attrFlag, InstructionHandle defaultTarget)
compileTemplateCallsback to summary
private void compileTemplateCalls(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next, int min, int max)
compileTemplatesback to summary
private void compileTemplates(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next)
completeTestSequencesback to summary
private void completeTestSequences(int nodeType, List<LocationPathPattern> patterns)

Complete test sequences of a given type by adding all patterns from a given group.

flattenAlternativeback to summary
private void flattenAlternative(Pattern pattern, Template template, Map<String, Key> keys)

This method will break up alternative patterns (ie. unions of patterns, such as match="A/B | C/B") and add the basic patterns to their respective pattern groups.

functionNameback to summary
public String functionName()

Returns the name of the method (_not_ function) that will be compiled for this mode. Normally takes the form 'applyTemplates()' or * 'applyTemplates2()'.

Returns:String

Method name for this mode

functionNameback to summary
public String functionName(int min, int max)
getClassNameback to summary
private String getClassName()

Shortcut to get the class compiled for this mode (will be inlined).

getStylesheetback to summary
public Stylesheet getStylesheet()
getTemplateInstructionHandleback to summary
public InstructionHandle getTemplateInstructionHandle(Template template)
isAttributeNameback to summary
private static boolean isAttributeName(String qname)

Auxiliary method to determine if a qname is an attribute.

isNamespaceNameback to summary
private static boolean isNamespaceName(String qname)

Auxiliary method to determine if a qname is a namespace qualified "*".

partitionback to summary
private int partition(List<Template> templates, int p, int r)
peepHoleOptimizationback to summary
private void peepHoleOptimization(MethodGenerator methodGen)

Peephole optimization.

prepareTestSequencesback to summary
private void prepareTestSequences()

Build test sequences. The first step is to complete the test sequences by including patterns of "*" and "node()" kernel to all element test sequences, and of "@*" to all attribute test sequences.

processPatternsback to summary
public void processPatterns(Map<String, Key> keys)

Process all the test patterns in this mode

quicksortback to summary
private List<Template> quicksort(List<Template> templates, int p, int r)