本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Reference方法的典型用法代码示例。如果您正苦于以下问题:Java Type.Reference方法的具体用法?Java Type.Reference怎么用?Java Type.Reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type
的用法示例。
在下文中一共展示了Type.Reference方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Runs a type check on either the variable element body or the
* expression in the 'select' attribute
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Type check the 'select' expression if present
if (_select != null) {
_type = _select.typeCheck(stable);
}
// Type check the element contents otherwise
else if (hasContents()) {
typeCheckContents(stable);
_type = Type.ResultTree;
}
else {
_type = Type.Reference;
}
// The return type is void as the variable element does not leave
// anything on the JVM's stack. The '_type' global will be returned
// by the references to this variable, and not by the variable itself.
return Type.Void;
}
示例2: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Check that we either have no parameters or one parameter that is
* either a node or a node-set.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Check the argument type (if any)
switch(argumentCount()) {
case 0:
_paramType = Type.Node;
break;
case 1:
_paramType = _param.typeCheck(stable);
break;
default:
throw new TypeCheckError(this);
}
// The argument has to be a node, a node-set or a node reference
if ((_paramType != Type.NodeSet) &&
(_paramType != Type.Node) &&
(_paramType != Type.Reference)) {
throw new TypeCheckError(this);
}
return (_type = Type.String);
}
示例3: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type-checks the parameter. The parameter type is determined by the
* 'select' expression (if present) or is a result tree if the parameter
* element has a body and no 'select' expression.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
_type = _select.typeCheck(stable);
if (_type instanceof ReferenceType == false && !(_type instanceof ObjectType)) {
_select = new CastExpr(_select, Type.Reference);
}
}
else if (hasContents()) {
typeCheckContents(stable);
}
_type = Type.Reference;
// This element has no type (the parameter does, but the parameter
// element itself does not).
return Type.Void;
}
示例4: translate
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Translate the code required for getting the node for which the
* QName, local-name or namespace URI should be extracted.
*/
public void translate(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(methodGen.loadDOM());
// Function was called with no parameters
if (argumentCount() == 0) {
il.append(methodGen.loadContextNode());
}
// Function was called with node parameter
else if (_paramType == Type.Node) {
_param.translate(classGen, methodGen);
}
else if (_paramType == Type.Reference) {
_param.translate(classGen, methodGen);
il.append(new INVOKESTATIC(cpg.addMethodref
(BASIS_LIBRARY_CLASS,
"referenceToNodeSet",
"("
+ OBJECT_SIG
+ ")"
+ NODE_ITERATOR_SIG)));
il.append(methodGen.nextNode());
}
// Function was called with node-set parameter
else {
_param.translate(classGen, methodGen);
_param.startIterator(classGen, methodGen);
il.append(methodGen.nextNode());
}
}
示例5: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check the two parameters for this function
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Check that the function was passed exactly two arguments
if (argumentCount() != 2) {
throw new TypeCheckError(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
getName(), this));
}
// The first argument must be a literal String
Expression exp = argument(0);
if (exp instanceof LiteralExpr) {
_className = ((LiteralExpr) exp).getValue();
_type = Type.newObjectType(_className);
}
else {
throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
getName(), this));
}
// Second argument must be of type reference or object
_right = argument(1);
Type tright = _right.typeCheck(stable);
if (tright != Type.Reference &&
tright instanceof ObjectType == false)
{
throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
tright, _type, this));
}
return _type;
}
示例6: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type-check either the select attribute or the element body, depending
* on which is in use.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof ReferenceType == false) {
_select = new CastExpr(_select, Type.Reference);
}
}
else {
typeCheckContents(stable);
}
return Type.Void;
}
示例7: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type-check either the select attribute or the element body, depending
* on which is in use.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof ReferenceType == false) {
_select = new CastExpr(_select, Type.Reference);
}
} else {
typeCheckContents(stable);
}
return Type.Void;
}
示例8: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的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;
}
示例9: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check the parameters for the id() or key() function.
* The index name (for key() call only) must be a string or convertable
* to a string, and the lookup-value must be a string or a node-set.
* @param stable The parser's symbol table
* @throws TypeCheckError When the parameters have illegal type
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type returnType = super.typeCheck(stable);
// Run type check on the key name (first argument) - must be a string,
// and if it is not it must be converted to one using string() rules.
if (_name != null) {
final Type nameType = _name.typeCheck(stable);
if (_name instanceof LiteralExpr) {
final LiteralExpr literal = (LiteralExpr) _name;
_resolvedQName =
getParser().getQNameIgnoreDefaultNs(literal.getValue());
}
else if (nameType instanceof StringType == false) {
_name = new CastExpr(_name, Type.String);
}
}
// Run type check on the value for this key. This value can be of
// any data type, so this should never cause any type-check errors.
// If the value is a reference, then we have to defer the decision
// of how to process it until run-time.
// If the value is known not to be a node-set, then it should be
// converted to a string before the lookup is done. If the value is
// known to be a node-set then this process (convert to string, then
// do lookup) should be applied to every node in the set, and the
// result from all lookups should be added to the resulting node-set.
_valueType = _value.typeCheck(stable);
if (_valueType != Type.NodeSet
&& _valueType != Type.Reference
&& _valueType != Type.String) {
_value = new CastExpr(_value, Type.String);
_valueType = _value.typeCheck(stable);
}
// If in a top-level element, create dependency to the referenced key
addParentDependency();
return returnType;
}