com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.IntType. 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: FunctionCall.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #2
Source File: FunctionCall.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #3
Source File: FunctionCall.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #4
Source File: FunctionCall.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #5
Source File: FunctionCall.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #6
Source File: FunctionCall.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #7
Source File: FunctionCall.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #8
Source File: FunctionCall.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #9
Source File: FunctionCall.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #10
Source File: FunctionCall.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #11
Source File: FunctionCall.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
Example #12
Source File: Variable.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #13
Source File: Variable.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #14
Source File: Variable.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #15
Source File: Variable.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #16
Source File: Variable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #17
Source File: Sort.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Parse the attributes of the xsl:sort element
 */
public void parseContents(Parser parser) {

    final SyntaxTreeNode parent = getParent();
    if (!(parent instanceof ApplyTemplates) &&
        !(parent instanceof ForEach)) {
        reportError(this, parser, ErrorMsg.STRAY_SORT_ERR, null);
        return;
    }

    // Parse the select expression (node string value if no expression)
    _select = parser.parseExpression(this, "select", "string(.)");

    // Get the sort order; default is 'ascending'
    String val = getAttribute("order");
    if (val.length() == 0) val = "ascending";
    _order = AttributeValue.create(this, val, parser);

    // Get the sort data type; default is text
    val = getAttribute("data-type");
    if (val.length() == 0) {
        try {
            final Type type = _select.typeCheck(parser.getSymbolTable());
            if (type instanceof IntType)
                val = "number";
            else
                val = "text";
        }
        catch (TypeCheckError e) {
            val = "text";
        }
    }
    _dataType = AttributeValue.create(this, val, parser);

    val =  getAttribute("lang");
    _lang = AttributeValue.create(this, val, parser);
    // Get the case order; default is language dependant
    val = getAttribute("case-order");
    _caseOrder = AttributeValue.create(this, val, parser);
}
 
Example #18
Source File: Sort.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse the attributes of the xsl:sort element
 */
public void parseContents(Parser parser) {

    final SyntaxTreeNode parent = getParent();
    if (!(parent instanceof ApplyTemplates) &&
        !(parent instanceof ForEach)) {
        reportError(this, parser, ErrorMsg.STRAY_SORT_ERR, null);
        return;
    }

    // Parse the select expression (node string value if no expression)
    _select = parser.parseExpression(this, "select", "string(.)");

    // Get the sort order; default is 'ascending'
    String val = getAttribute("order");
    if (val.length() == 0) val = "ascending";
    _order = AttributeValue.create(this, val, parser);

    // Get the sort data type; default is text
    val = getAttribute("data-type");
    if (val.length() == 0) {
        try {
            final Type type = _select.typeCheck(parser.getSymbolTable());
            if (type instanceof IntType)
                val = "number";
            else
                val = "text";
        }
        catch (TypeCheckError e) {
            val = "text";
        }
    }
    _dataType = AttributeValue.create(this, val, parser);

    val =  getAttribute("lang");
    _lang = AttributeValue.create(this, val, parser);
    // Get the case order; default is language dependant
    val = getAttribute("case-order");
    _caseOrder = AttributeValue.create(this, val, parser);
}
 
Example #19
Source File: Variable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #20
Source File: Sort.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse the attributes of the xsl:sort element
 */
public void parseContents(Parser parser) {

    final SyntaxTreeNode parent = getParent();
    if (!(parent instanceof ApplyTemplates) &&
        !(parent instanceof ForEach)) {
        reportError(this, parser, ErrorMsg.STRAY_SORT_ERR, null);
        return;
    }

    // Parse the select expression (node string value if no expression)
    _select = parser.parseExpression(this, "select", "string(.)");

    // Get the sort order; default is 'ascending'
    String val = getAttribute("order");
    if (val.length() == 0) val = "ascending";
    _order = AttributeValue.create(this, val, parser);

    // Get the sort data type; default is text
    val = getAttribute("data-type");
    if (val.length() == 0) {
        try {
            final Type type = _select.typeCheck(parser.getSymbolTable());
            if (type instanceof IntType)
                val = "number";
            else
                val = "text";
        }
        catch (TypeCheckError e) {
            val = "text";
        }
    }
    _dataType = AttributeValue.create(this, val, parser);

    val =  getAttribute("lang");
    _lang = AttributeValue.create(this, val, parser);
    // Get the case order; default is language dependant
    val = getAttribute("case-order");
    _caseOrder = AttributeValue.create(this, val, parser);
}
 
Example #21
Source File: Variable.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #22
Source File: Variable.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #23
Source File: Variable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #24
Source File: Variable.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #25
Source File: Variable.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
 
Example #26
Source File: EqualityExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: Predicate.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
    }
}
 
Example #28
Source File: Predicate.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
    }
}
 
Example #29
Source File: EqualityExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: EqualityExpr.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}