com.sun.org.apache.bcel.internal.generic.ICONST Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.generic.ICONST. 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 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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())));

    }
}