org.cojen.classfile
Class AbstractCodeAssembler

java.lang.Object
  extended by org.cojen.classfile.AbstractCodeAssembler
All Implemented Interfaces:
CodeAssembler
Direct Known Subclasses:
CodeAssemblerPrinter, CodeBuilder

public abstract class AbstractCodeAssembler
extends Object
implements CodeAssembler

Author:
Brian S O'Neill

Field Summary
 
Fields inherited from interface org.cojen.classfile.CodeAssembler
CONVERT_FP_BITS, CONVERT_FP_NORMAL, CONVERT_FP_RAW_BITS
 
Constructor Summary
protected AbstractCodeAssembler()
           
 
Method Summary
 void ifComparisonBranch(Location location, String choice, TypeDesc type)
          Generates code the performs a conditional branch based on a comparison between two values of the given type on the stack.
 void inline(Object code)
          Allows code to disassembled and copied straight in.
 void invoke(Constructor constructor)
          Generates code to invoke a class constructor in any class.
 void invoke(Method method)
          Generates code to invoke a method.
 void invokeSuper(Method method)
          Generates code to invoke a method in the super class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cojen.classfile.CodeAssembler
arrayLength, branch, breakpoint, checkCast, convert, convert, createLabel, createLocalVariable, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, exceptionHandler, getParameter, getParameterCount, ifComparisonBranch, ifEqualBranch, ifNullBranch, ifZeroComparisonBranch, instanceOf, integerIncrement, invokeConstructor, invokeConstructor, invokeConstructor, invokeInterface, invokeInterface, invokePrivate, invokeStatic, invokeStatic, invokeStatic, invokeSuper, invokeSuper, invokeSuperConstructor, invokeVirtual, invokeVirtual, invokeVirtual, jsr, loadConstant, loadConstant, loadConstant, loadConstant, loadConstant, loadConstant, loadConstant, loadField, loadField, loadField, loadFromArray, loadLocal, loadNull, loadStaticField, loadStaticField, loadStaticField, loadThis, mapLineNumber, math, monitorEnter, monitorExit, newObject, newObject, nop, pop, pop2, ret, returnValue, returnVoid, storeField, storeField, storeField, storeLocal, storeStaticField, storeStaticField, storeStaticField, storeToArray, swap, swap2, switchBranch, throwObject
 

Constructor Detail

AbstractCodeAssembler

protected AbstractCodeAssembler()
Method Detail

ifComparisonBranch

public void ifComparisonBranch(Location location,
                               String choice,
                               TypeDesc type)
Description copied from interface: CodeAssembler
Generates code the performs a conditional branch based on a comparison between two values of the given type on the stack. The first int value on the stack is on the left side of the comparison expression. When comparing objects, only an identity comparison is performed.

When comparing floating point values, treatment of NaN requires special attention. Ordinarily, it is assumed that the branch location represents the target of a comparison failure, and that the code to handle the "true" condition immediately follows the comparison. If this is not the case, append a 't' suffix to the choice to indicate that the target location is reached for a "true" condition. This suffix is ignored if the type is not a float or double.

The generated instruction(s) consumes the two values on the stack.

Specified by:
ifComparisonBranch in interface CodeAssembler
Parameters:
location - The location to branch to
choice - One of "==", "!=", "<", ">=", ">", "<=", "==t", "!=t", "=t", ">t", or "<=t". Object types can only be compared for equality.
type - Type to expect on the stack

inline

public void inline(Object code)
Description copied from interface: CodeAssembler
Allows code to disassembled and copied straight in. The code object passed in must have a single method named "define" whose arguments match the type and order of values expected on the operand stack. If a return value is provided, it will pushed onto the stack. The define method can have any access modifier.

Specified by:
inline in interface CodeAssembler

invoke

public void invoke(Method method)
Description copied from interface: CodeAssembler
Generates code to invoke a method. If the method is static, the method's argument(s) must be on the stack. If the method is non-static, then the object reference must also be on the stack, prior to the arguments.

Specified by:
invoke in interface CodeAssembler

invokeSuper

public void invokeSuper(Method method)
Description copied from interface: CodeAssembler
Generates code to invoke a method in the super class. The object reference and the method's argument(s) must be on the stack.

Specified by:
invokeSuper in interface CodeAssembler

invoke

public void invoke(Constructor constructor)
Description copied from interface: CodeAssembler
Generates code to invoke a class constructor in any class. The object reference and the constructor's argument(s) must be on the stack.

Specified by:
invoke in interface CodeAssembler


Copyright © 2004-2011 Brian S O'Neill. All Rights Reserved.