本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType类的典型用法代码示例。如果您正苦于以下问题:Java ResultTreeType类的具体用法?Java ResultTreeType怎么用?Java ResultTreeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultTreeType类属于com.sun.org.apache.xalan.internal.xsltc.compiler.util包,在下文中一共展示了ResultTreeType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
_type = _select.typeCheck(stable);
if (_type instanceof NodeType || _type instanceof ReferenceType) {
_select = new CastExpr(_select, Type.NodeSet);
_type = Type.NodeSet;
}
if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
typeCheckContents(stable); // with-params
return Type.Void;
}
throw new TypeCheckError(this);
}
else {
typeCheckContents(stable); // with-params
return Type.Void;
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ApplyTemplates.java
示例2: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
/**
* Type checking a cast expression amounts to verifying that the
* type conversion is legal. Cast expressions are created during
* type checking, but typeCheck() is usually not called on them.
* As a result, this method is called from the constructor.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
Type tleft = _left.getType();
if (tleft == null) {
tleft = _left.typeCheck(stable);
}
if (tleft instanceof NodeType) {
tleft = Type.Node; // multiple instances
}
else if (tleft instanceof ResultTreeType) {
tleft = Type.ResultTree; // multiple instances
}
if (InternalTypeMap.maps(tleft, _type) != null) {
return _type;
}
// throw new TypeCheckError(this);
throw new TypeCheckError(new ErrorMsg(
ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString()));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:CastExpr.java
示例3: unmapRegister
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
/**
* Remove the mapping of this variable to a register.
* Called when we leave the AST scope of the variable's declaration
*/
public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
if (_local != null) {
if (_type instanceof ResultTreeType) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
il.append(methodGen.loadDOM());
il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
il.append(loadInstruction());
il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
il.append(new INVOKEVIRTUAL(removeDA));
}
final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
il.append(loadInstruction());
il.append(new INVOKEINTERFACE(release, 1));
}
_local.setEnd(methodGen.getInstructionList().getEnd());
methodGen.removeLocalVariable(_local);
_refs = null;
_local = null;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:VariableBase.java
示例4: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
_type = _select.typeCheck(stable);
if (_type instanceof ReferenceType || _type instanceof NodeType) {
_select = new CastExpr(_select, Type.NodeSet);
typeCheckContents(stable);
return Type.Void;
}
if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
typeCheckContents(stable);
return Type.Void;
}
throw new TypeCheckError(this);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:ForEach.java
示例5: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
tselect instanceof NodeSetType ||
tselect instanceof ReferenceType ||
tselect instanceof ResultTreeType) {
// falls through
}
else {
_select = new CastExpr(_select, Type.String);
}
return Type.Void;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:CopyOf.java
示例6: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Save current node and current iterator on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
// Collect sort objects associated with this instruction
final Vector sortObjects = new Vector();
Enumeration children = elements();
while (children.hasMoreElements()) {
final Object child = children.nextElement();
if (child instanceof Sort) {
sortObjects.addElement(child);
}
}
if ((_type != null) && (_type instanceof ResultTreeType)) {
// Store existing DOM on stack - must be restored when loop is done
il.append(methodGen.loadDOM());
// <xsl:sort> cannot be applied to a result tree - issue warning
if (sortObjects.size() > 0) {
ErrorMsg msg = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
getParser().reportError(WARNING, msg);
}
// Put the result tree on the stack (DOM)
_select.translate(classGen, methodGen);
// Get an iterator for the whole DOM - excluding the root node
_type.translateTo(classGen, methodGen, Type.NodeSet);
// Store the result tree as the default DOM
il.append(SWAP);
il.append(methodGen.storeDOM());
}
else {
// Compile node iterator
if (sortObjects.size() > 0) {
Sort.translateSortIterator(classGen, methodGen,
_select, sortObjects);
}
else {
_select.translate(classGen, methodGen);
}
if (_type instanceof ReferenceType == false) {
il.append(methodGen.loadContextNode());
il.append(methodGen.setStartNode());
}
}
// Overwrite current iterator
il.append(methodGen.storeIterator());
// Give local variables (if any) default values before starting loop
initializeVariables(classGen, methodGen);
final BranchHandle nextNode = il.append(new GOTO(null));
final InstructionHandle loop = il.append(NOP);
translateContents(classGen, methodGen);
nextNode.setTarget(il.append(methodGen.loadIterator()));
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
il.append(new IFGT(loop));
// Restore current DOM (if result tree was used instead for this loop)
if ((_type != null) && (_type instanceof ResultTreeType)) {
il.append(methodGen.storeDOM());
}
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
il.append(methodGen.storeCurrentNode());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:80,代码来源:ForEach.java
示例7: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
/**
* Typing rules: see XSLT Reference by M. Kay page 345.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tleft = _left.typeCheck(stable);
final Type tright = _right.typeCheck(stable);
if (tleft.isSimple() && tright.isSimple()) {
if (tleft != tright) {
if (tleft instanceof BooleanType) {
_right = new CastExpr(_right, Type.Boolean);
}
else if (tright instanceof BooleanType) {
_left = new CastExpr(_left, Type.Boolean);
}
else if (tleft instanceof NumberType ||
tright instanceof NumberType) {
_left = new CastExpr(_left, Type.Real);
_right = new CastExpr(_right, Type.Real);
}
else { // both compared as strings
_left = new CastExpr(_left, Type.String);
_right = new CastExpr(_right, Type.String);
}
}
}
else if (tleft instanceof ReferenceType) {
_right = new CastExpr(_right, Type.Reference);
}
else if (tright instanceof ReferenceType) {
_left = new CastExpr(_left, Type.Reference);
}
// the following 2 cases optimize @attr|.|.. = 'string'
else if (tleft instanceof NodeType && tright == Type.String) {
_left = new CastExpr(_left, Type.String);
}
else if (tleft == Type.String && tright instanceof NodeType) {
_right = new CastExpr(_right, Type.String);
}
// optimize node/node
else if (tleft instanceof NodeType && tright instanceof NodeType) {
_left = new CastExpr(_left, Type.String);
_right = new CastExpr(_right, Type.String);
}
else if (tleft instanceof NodeType && tright instanceof NodeSetType) {
// compare(Node, NodeSet) will be invoked
}
else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
swapArguments(); // for compare(Node, NodeSet)
}
else {
// At least one argument is of type node, node-set or result-tree
// Promote an expression of type node to node-set
if (tleft instanceof NodeType) {
_left = new CastExpr(_left, Type.NodeSet);
}
if (tright instanceof NodeType) {
_right = new CastExpr(_right, Type.NodeSet);
}
// If one arg is a node-set then make it the left one
if (tleft.isSimple() ||
tleft instanceof ResultTreeType &&
tright instanceof NodeSetType) {
swapArguments();
}
// Promote integers to doubles to have fewer compares
if (_right.getType() instanceof IntType) {
_right = new CastExpr(_right, Type.Real);
}
}
return _type = Type.Boolean;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:EqualityExpr.java
示例8: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
/**
* 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
* <code>dontOptimize()</code>. If so, the second time it should honor
* the new value of <code>_canOptimize</code>.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
Type texp = _exp.typeCheck(stable);
// We need explicit type information for reference types - no good!
if (texp instanceof ReferenceType) {
_exp = new CastExpr(_exp, texp = Type.Real);
}
// A result tree fragment should not be cast directly to a number type,
// but rather to a boolean value, and then to a numer (0 or 1).
// Ref. section 11.2 of the XSLT 1.0 spec
if (texp instanceof ResultTreeType) {
_exp = new CastExpr(_exp, Type.Boolean);
_exp = new CastExpr(_exp, Type.Real);
texp = _exp.typeCheck(stable);
}
// Numerical types will be converted to a position filter
if (texp instanceof NumberType) {
// Cast any numerical types to an integer
if (texp instanceof IntType == false) {
_exp = new CastExpr(_exp, Type.Int);
}
if (_canOptimize) {
// Nth position optimization. Expression must not depend on context
_nthPositionFilter =
!_exp.hasLastCall() && !_exp.hasPositionCall();
// _nthDescendant optimization - only if _nthPositionFilter is on
if (_nthPositionFilter) {
SyntaxTreeNode parent = getParent();
_nthDescendant = (parent instanceof Step) &&
(parent.getParent() instanceof AbsoluteLocationPath);
return _type = Type.NodeSet;
}
}
// Reset optimization flags
_nthPositionFilter = _nthDescendant = false;
// Otherwise, expand [e] to [position() = e]
final QName position =
getParser().getQNameIgnoreDefaultNs("position");
final PositionCall positionCall =
new PositionCall(position);
positionCall.setParser(getParser());
positionCall.setParent(this);
_exp = new EqualityExpr(Operators.EQ, positionCall,
_exp);
if (_exp.typeCheck(stable) != Type.Boolean) {
_exp = new CastExpr(_exp, Type.Boolean);
}
return _type = Type.Boolean;
}
else {
// All other types will be handled as boolean values
if (texp instanceof BooleanType == false) {
_exp = new CastExpr(_exp, Type.Boolean);
}
return _type = Type.Boolean;
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:Predicate.java
示例9: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final Type tselect = _select.getType();
final String CPY1_SIG = "("+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+")V";
final int cpy1 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY1_SIG);
final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V";
final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG);
final String getDoc_SIG = "()"+NODE_SIG;
final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument", getDoc_SIG);
if (tselect instanceof NodeSetType) {
il.append(methodGen.loadDOM());
// push NodeIterator
_select.translate(classGen, methodGen);
_select.startIterator(classGen, methodGen);
// call copy from the DOM 'library'
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy1, 3));
}
else if (tselect instanceof NodeType) {
il.append(methodGen.loadDOM());
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ResultTreeType) {
_select.translate(classGen, methodGen);
// We want the whole tree, so we start with the root node
il.append(DUP); //need a pointer to the DOM ;
il.append(new INVOKEINTERFACE(getDoc,1)); //ICONST_0);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ReferenceType) {
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadDOM());
final int copy = cpg.addMethodref(BASIS_LIBRARY_CLASS, "copy",
"("
+ OBJECT_SIG
+ TRANSLET_OUTPUT_SIG
+ NODE_SIG
+ DOM_INTF_SIG
+ ")V");
il.append(new INVOKESTATIC(copy));
}
else {
il.append(classGen.loadTranslet());
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
CHARACTERSW,
CHARACTERSW_SIG)));
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:CopyOf.java
示例10: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType; //导入依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Save current node and current iterator on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
// Collect sort objects associated with this instruction
final Vector sortObjects = new Vector();
Iterator<SyntaxTreeNode> children = elements();
while (children.hasNext()) {
final Object child = children.next();
if (child instanceof Sort) {
sortObjects.addElement(child);
}
}
if ((_type != null) && (_type instanceof ResultTreeType)) {
// Store existing DOM on stack - must be restored when loop is done
il.append(methodGen.loadDOM());
// <xsl:sort> cannot be applied to a result tree - issue warning
if (sortObjects.size() > 0) {
ErrorMsg msg = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
getParser().reportError(WARNING, msg);
}
// Put the result tree on the stack (DOM)
_select.translate(classGen, methodGen);
// Get an iterator for the whole DOM - excluding the root node
_type.translateTo(classGen, methodGen, Type.NodeSet);
// Store the result tree as the default DOM
il.append(SWAP);
il.append(methodGen.storeDOM());
}
else {
// Compile node iterator
if (sortObjects.size() > 0) {
Sort.translateSortIterator(classGen, methodGen,
_select, sortObjects);
}
else {
_select.translate(classGen, methodGen);
}
if (_type instanceof ReferenceType == false) {
il.append(methodGen.loadContextNode());
il.append(methodGen.setStartNode());
}
}
// Overwrite current iterator
il.append(methodGen.storeIterator());
// Give local variables (if any) default values before starting loop
initializeVariables(classGen, methodGen);
final BranchHandle nextNode = il.append(new GOTO(null));
final InstructionHandle loop = il.append(NOP);
translateContents(classGen, methodGen);
nextNode.setTarget(il.append(methodGen.loadIterator()));
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
il.append(new IFGT(loop));
// Restore current DOM (if result tree was used instead for this loop)
if ((_type != null) && (_type instanceof ResultTreeType)) {
il.append(methodGen.storeDOM());
}
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
il.append(methodGen.storeCurrentNode());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:80,代码来源:ForEach.java
注:本文中的com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论