Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#Node

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#Node . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberCall.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.Real)) {
        targ.translateTo(classGen, methodGen, Type.Real);
    }
}
 
Example 2
Source File: StringCall.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(classGen, methodGen, Type.String);
    }
}
 
Example 3
Source File: ValueOf.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type type = _select.typeCheck(stable);

    // Prefer to handle the value as a node; fall back to String, otherwise
    if (type != null && !type.identicalTo(Type.Node)) {
        /***
         *** %HZ% Would like to treat result-tree fragments in the same
         *** %HZ% way as node sets for value-of, but that's running into
         *** %HZ% some snags.  Instead, they'll be converted to String
        if (type.identicalTo(Type.ResultTree)) {
            _select = new CastExpr(new CastExpr(_select, Type.NodeSet),
                                   Type.Node);
        } else
        ***/
        if (type.identicalTo(Type.NodeSet)) {
            _select = new CastExpr(_select, Type.Node);
        } else {
            _isString = true;
            if (!type.identicalTo(Type.String)) {
                _select = new CastExpr(_select, Type.String);
            }
            _isString = true;
        }
    }
    return Type.Void;
}
 
Example 4
Source File: NameBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: NumberCall.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.Real)) {
        targ.translateTo(classGen, methodGen, Type.Real);
    }
}
 
Example 6
Source File: StringCall.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(classGen, methodGen, Type.String);
    }
}
 
Example 7
Source File: NameBase.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: ValueOf.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type type = _select.typeCheck(stable);

    // Prefer to handle the value as a node; fall back to String, otherwise
    if (type != null && !type.identicalTo(Type.Node)) {
        /***
         *** %HZ% Would like to treat result-tree fragments in the same
         *** %HZ% way as node sets for value-of, but that's running into
         *** %HZ% some snags.  Instead, they'll be converted to String
        if (type.identicalTo(Type.ResultTree)) {
            _select = new CastExpr(new CastExpr(_select, Type.NodeSet),
                                   Type.Node);
        } else
        ***/
        if (type.identicalTo(Type.NodeSet)) {
            _select = new CastExpr(_select, Type.Node);
        } else {
            _isString = true;
            if (!type.identicalTo(Type.String)) {
                _select = new CastExpr(_select, Type.String);
            }
            _isString = true;
        }
    }
    return Type.Void;
}
 
Example 9
Source File: CastExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example 10
Source File: CastExpr.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example 11
Source File: StringCall.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(classGen, methodGen, Type.String);
    }
}
 
Example 12
Source File: NameBase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: CastExpr.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example 14
Source File: ValueOf.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type type = _select.typeCheck(stable);

    // Prefer to handle the value as a node; fall back to String, otherwise
    if (type != null && !type.identicalTo(Type.Node)) {
        /***
         *** %HZ% Would like to treat result-tree fragments in the same
         *** %HZ% way as node sets for value-of, but that's running into
         *** %HZ% some snags.  Instead, they'll be converted to String
        if (type.identicalTo(Type.ResultTree)) {
            _select = new CastExpr(new CastExpr(_select, Type.NodeSet),
                                   Type.Node);
        } else
        ***/
        if (type.identicalTo(Type.NodeSet)) {
            _select = new CastExpr(_select, Type.Node);
        } else {
            _isString = true;
            if (!type.identicalTo(Type.String)) {
                _select = new CastExpr(_select, Type.String);
            }
            _isString = true;
        }
    }
    return Type.Void;
}
 
Example 15
Source File: StringCall.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(classGen, methodGen, Type.String);
    }
}
 
Example 16
Source File: StringCall.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;

    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    }
    else {
        final Expression arg = argument();
        arg.translate(classGen, methodGen);
        arg.startIterator(classGen, methodGen);
        targ = arg.getType();
    }

    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(classGen, methodGen, Type.String);
    }
}
 
Example 17
Source File: NameBase.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 18
Source File: Step.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Type check this step. The abbreviated steps '.' and '@attr' are
 * assigned type node if they have no predicates. All other steps
 * have type node-set.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

    // Save this value for later - important for testing for special
    // combinations of steps and patterns than can be optimised
    _hadPredicates = hasPredicates();

    // Special case for '.'
    //   in the case where '.' has a context such as book/.
    //   or .[false()] we can not optimize the nodeset to a single node.
    if (isAbbreviatedDot()) {
        _type = (hasParentPattern() || hasPredicates() || hasParentLocationPath()) ?
            Type.NodeSet : Type.Node;
    }
    else {
        _type = Type.NodeSet;
    }

    // Type check all predicates (expressions applied to the step)
    if (_predicates != null) {
        final int n = _predicates.size();
        for (int i = 0; i < n; i++) {
            final Expression pred = (Expression)_predicates.elementAt(i);
            pred.typeCheck(stable);
        }
    }

    // Return either Type.Node or Type.NodeSet
    return _type;
}
 
Example 19
Source File: Step.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Type check this step. The abbreviated steps '.' and '@attr' are
 * assigned type node if they have no predicates. All other steps
 * have type node-set.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

    // Save this value for later - important for testing for special
    // combinations of steps and patterns than can be optimised
    _hadPredicates = hasPredicates();

    // Special case for '.'
    //   in the case where '.' has a context such as book/.
    //   or .[false()] we can not optimize the nodeset to a single node.
    if (isAbbreviatedDot()) {
        _type = (hasParentPattern() || hasPredicates() || hasParentLocationPath()) ?
            Type.NodeSet : Type.Node;
    }
    else {
        _type = Type.NodeSet;
    }

    // Type check all predicates (expressions applied to the step)
    if (_predicates != null) {
        final int n = _predicates.size();
        for (int i = 0; i < n; i++) {
            final Expression pred = (Expression)_predicates.elementAt(i);
            pred.typeCheck(stable);
        }
    }

    // Return either Type.Node or Type.NodeSet
    return _type;
}
 
Example 20
Source File: NameBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}