All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.fub.bytecode.generic.InstructionFactory

java.lang.Object
   |
   +----de.fub.bytecode.generic.InstructionFactory

public class InstructionFactory
extends Object
implements InstructionConstants
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.

Version:
$Id: InstructionFactory.java,v 1.5 2000/02/22 09:34:47 dahm Exp $
Author:
M. Dahm

Variable Index

 o cg
 o cp

Constructor Index

 o InstructionFactory(ClassGen)
Need a ClassGen object to obtain a constant pool, e.g.

Method Index

 o createArrayLoad(Type)
 o createArrayStore(Type)
 o createBinaryOperation(String, Type)
Create binary operation for simple basic types, such as int and float.
 o createCast(Type, Type)
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.
 o createCheckCast(ReferenceType)
 o createDup(int)
 o createDup_1(int)
 o createDup_2(int)
 o createGetField(String, String, Type)
 o createGetStatic(String, String, Type)
 o createInvoke(String, String, Type, Type[], short)
Create an invoke instruction.
 o createLoad(Type, int)
 o createNew(ObjectType)
 o createNew(String)
 o createNewArray(Type, short)
Create new array of given size and type.
 o createNull(Type)
Create "null" value for reference types, 0 for basic types like int
 o createPop(int)
 o createPutField(String, String, Type)
 o createPutStatic(String, String, Type)
 o createReturn(Type)
Create typed return
 o createStore(Type, int)
 o createThis()
Create reference to `this'

Variables

 o cg
 protected ClassGen cg
 o cp
 protected ConstantPoolGen cp

Constructors

 o InstructionFactory
 public InstructionFactory(ClassGen cg)
Need a ClassGen object to obtain a constant pool, e.g.

Methods

 o createInvoke
 public InvokeInstruction createInvoke(String class_name,
                                       String name,
                                       Type ret_type,
                                       Type arg_types[],
                                       short kind)
Create an invoke instruction.

Parameters:
class_name - name of the called class
name - name of the called method
ret_type - return type of method
arg_types - argument types of method
kind - how to invoke, i.e. INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL
 o createThis
 public static Instruction createThis()
Create reference to `this'

 o createReturn
 public static ReturnInstruction createReturn(Type type)
Create typed return

 o createBinaryOperation
 public static ArithmeticInstruction createBinaryOperation(String op,
                                                           Type type)
Create binary operation for simple basic types, such as int and float.

Parameters:
op - operation, such as "+", "*", "<<", etc.
 o createPop
 public static StackInstruction createPop(int size)
Parameters:
size - size of operand, either 1 (int, e.g.) or 2 (double)
 o createDup
 public static StackInstruction createDup(int size)
Parameters:
size - size of operand, either 1 (int, e.g.) or 2 (double)
 o createDup_2
 public static StackInstruction createDup_2(int size)
Parameters:
size - size of operand, either 1 (int, e.g.) or 2 (double)
 o createDup_1
 public static StackInstruction createDup_1(int size)
Parameters:
size - size of operand, either 1 (int, e.g.) or 2 (double)
 o createStore
 public static LocalVariableInstruction createStore(Type type,
                                                    int index)
Parameters:
index - index of local variable
 o createLoad
 public static LocalVariableInstruction createLoad(Type type,
                                                   int index)
Parameters:
index - index of local variable
 o createArrayLoad
 public static ArrayInstruction createArrayLoad(Type type)
Parameters:
type - type of elements of array, i.e. array.getElementType()
 o createArrayStore
 public static ArrayInstruction createArrayStore(Type type)
Parameters:
type - type of elements of array, i.e. array.getElementType()
 o createCast
 public Instruction createCast(Type src_type,
                               Type dest_type)
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.

 o createGetField
 public GETFIELD createGetField(String class_name,
                                String name,
                                Type t)
 o createGetStatic
 public GETSTATIC createGetStatic(String class_name,
                                  String name,
                                  Type t)
 o createPutField
 public PUTFIELD createPutField(String class_name,
                                String name,
                                Type t)
 o createPutStatic
 public PUTSTATIC createPutStatic(String class_name,
                                  String name,
                                  Type t)
 o createCheckCast
 public CHECKCAST createCheckCast(ReferenceType t)
 o createNew
 public NEW createNew(ObjectType t)
 o createNew
 public NEW createNew(String s)
 o createNewArray
 public AllocationInstruction createNewArray(Type t,
                                             short dim)
Create new array of given size and type.

 o createNull
 public static Instruction createNull(Type type)
Create "null" value for reference types, 0 for basic types like int


All Packages  Class Hierarchy  This Package  Previous  Next  Index