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

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.RealType. 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: 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 #2
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 #3
Source File: FormatNumberCall.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #4
Source File: EqualityExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #5
Source File: Number.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #6
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 #7
Source File: FormatNumberCall.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #8
Source File: EqualityExpr.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #9
Source File: Number.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #10
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 #11
Source File: FormatNumberCall.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #12
Source File: EqualityExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #13
Source File: Number.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #14
Source File: FormatNumberCall.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #15
Source File: FormatNumberCall.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #16
Source File: EqualityExpr.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #17
Source File: Number.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #18
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 #19
Source File: FormatNumberCall.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #20
Source File: EqualityExpr.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #21
Source File: Number.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #22
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 #23
Source File: FormatNumberCall.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

        // Inform stylesheet to instantiate a DecimalFormat object
        getStylesheet().numberFormattingUsed();

        final Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
        final Type tformat = _format.typeCheck(stable);
        if (tformat instanceof StringType == false) {
            _format = new CastExpr(_format, Type.String);
        }
        if (argumentCount() == 3) {
            final Type tname = _name.typeCheck(stable);

            if (_name instanceof LiteralExpr) {
                final LiteralExpr literal = (LiteralExpr) _name;
                _resolvedQName =
                    getParser().getQNameIgnoreDefaultNs(literal.getValue());
            }
            else if (tname instanceof StringType == false) {
                _name = new CastExpr(_name, Type.String);
            }
        }
        return _type = Type.String;
    }
 
Example #24
Source File: EqualityExpr.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #25
Source File: Number.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #26
Source File: EqualityExpr.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #27
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 #28
Source File: EqualityExpr.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #29
Source File: Number.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_value != null) {
        Type tvalue = _value.typeCheck(stable);
        if (tvalue instanceof RealType == false) {
            _value = new CastExpr(_value, Type.Real);
        }
    }
    if (_count != null) {
        _count.typeCheck(stable);
    }
    if (_from != null) {
        _from.typeCheck(stable);
    }
    if (_format != null) {
        _format.typeCheck(stable);
    }
    if (_lang != null) {
        _lang.typeCheck(stable);
    }
    if (_letterValue != null) {
        _letterValue.typeCheck(stable);
    }
    if (_groupingSeparator != null) {
        _groupingSeparator.typeCheck(stable);
    }
    if (_groupingSize != null) {
        _groupingSize.typeCheck(stable);
    }
    return Type.Void;
}
 
Example #30
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())));

    }
}