/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*/
/**
* Instances of this class may be used, e.g., to generate typed
* versions of instructions. Its main purpose is to be used as the
* byte code generating backend of a compiler. You can subclass it to
* add your own create methods.
*
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Constants
*/
public class InstructionFactory
{
}
/** Initialize with ClassGen object
*/
}
/** Initialize just with ConstantPoolGen object
*/
}
/** Create an invoke instruction.
*
* @param class_name name of the called class
* @param name name of the called method
* @param ret_type return type of method
* @param arg_types argument types of method
* @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL,
* or INVOKESPECIAL
* @see Constants
*/
int index;
int nargs = 0;
else
switch(kind) {
default:
}
}
/** Create a call to the most popular System.out.println() method.
*
* @param s the string to print
*/
"Ljava/io/PrintStream;");
return il;
}
/** Uses PUSH to push a constant value onto the stack.
* @param value must be of type Number, Boolean, Character or String
*/
else
return push.getInstruction();
}
private static class MethodObject {
int access;
class_name = c;
name = n;
result_type = r;
arg_types = a;
}
}
}
};
return ((type instanceof ObjectType) &&
}
switch(t) {
default:
}
}
/** Create a field instruction.
*
* @param class_name name of the accessed class
* @param name name of the referenced field
* @param type type of field
* @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
* @see Constants
*/
int index;
switch(kind) {
default:
}
}
/** Create reference to `this'
*/
return new ALOAD(0);
}
/** Create typed return
*/
default:
}
}
switch(first) {
case '-' : return ISUB;
case '+' : return IADD;
case '%' : return IREM;
case '*' : return IMUL;
case '/' : return IDIV;
case '&' : return IAND;
case '|' : return IOR;
case '^' : return IXOR;
case '<' : return ISHL;
}
}
switch(first) {
case '-' : return LSUB;
case '+' : return LADD;
case '%' : return LREM;
case '*' : return LMUL;
case '/' : return LDIV;
case '&' : return LAND;
case '|' : return LOR;
case '^' : return LXOR;
case '<' : return LSHL;
}
}
switch(op) {
case '-' : return FSUB;
case '+' : return FADD;
case '*' : return FMUL;
case '/' : return FDIV;
}
}
switch(op) {
case '-' : return DSUB;
case '+' : return DADD;
case '*' : return DMUL;
case '/' : return DDIV;
}
}
/**
* Create binary operation for simple basic types, such as int and float.
*
* @param op operation, such as "+", "*", "<<", etc.
*/
}
}
/**
* @param size size of operand, either 1 (int, e.g.) or 2 (double)
*/
}
/**
* @param size size of operand, either 1 (int, e.g.) or 2 (double)
*/
}
/**
* @param size size of operand, either 1 (int, e.g.) or 2 (double)
*/
}
/**
* @param size size of operand, either 1 (int, e.g.) or 2 (double)
*/
}
/**
* @param index index of local variable
*/
}
}
/**
* @param index index of local variable
*/
}
}
/**
* @param type type of elements of array, i.e., array.getElementType()
*/
}
}
/**
* @param type type of elements of array, i.e., array.getElementType()
*/
}
}
/** Create conversion operation for two stack operands, this may be an I2C, instruction, e.g.,
* if the operands are basic types and CHECKCAST if they are reference types.
*/
Instruction i = null;
try {
} catch(Exception e) {
}
return i;
else
}
else
}
}
}
}
}
if(t instanceof ArrayType)
else
}
if(t instanceof ArrayType)
else
}
}
return createNew(new ObjectType(s));
}
/** Create new array of given size and type.
* @return an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction
*/
if(dim == 1) {
if(t instanceof ObjectType)
else if(t instanceof ArrayType)
else
} else {
if(t instanceof ArrayType)
else
}
}
/** Create "null" value for reference types, 0 for basic types like int
*/
default:
}
}
/** Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH.
* For those you should use the SWITCH compound instruction.
*/
switch(opcode) {
default:
}
}
}