com.joanju.cg.core
Class Layout

java.lang.Object
  extended by com.joanju.cg.core.Layout

public class Layout
extends java.lang.Object

Provides static Bytecode layout information. We count on some instructions to be processed before other instructions (for example: "supers", before any calls), so changing the overall layout of the bytecode must be done carefully (or not at all).

See Also:
ReservedCUID

Field Summary
static int CU_ADDRESS
          The address of the compileunit instruction.
static int CUID_CALLNAME
          ReservedCUID
static int CUID_CHECKVALS
          ReservedCUID
static int CUID_GLOBALS
          ReservedCUID
static int CUID_INCLUDES
          ReservedCUID
static int CUID_LAST_RESERVED
          ReservedCUID
static int CUID_PUBSUB
          ReservedCUID
static int CUID_SESSIONSUPERS
          ReservedCUID
static int CUID_UNRES
          ReservedCUID
static int FIRST_CU_HEADER_SEQUENTIAL_INSTRUCTION
          Sequential instructions for the compile unit header, such as string literals and other constants, begin here.
static int FIRST_INTERNAL_PROC_ADDRESS
          The address of the first internal procedure.
static int LAYOUT_VERSION
          This gives us the layout version of all the bytecode in general.
static int MAIN_PROCEDURE_ADDRESS
          The address of procedure segment for the main program block.
static char METHODSIG_INPUT
          Method sig entry for INPUT param.
static char METHODSIG_INPUTOUTPUT
          Method sig entry for INPUT-OUTPUT param.
static char METHODSIG_OUTPUT
          Method sig entry for OUTPUT param.
static char METHODSIG_RETURN
          Method sig entry for method/function return.
static int SUPERS_ADDRESS
          The address of the supers instruction.
static int UNKNOWN_VALUE_ADDRESS
          The address in every CU header for the unknown value.
static int UNRESOLVED_SOURCE_ADDRESS
          An address to be used as a local source, when the target is unresolved.
static int UNRESOLVED_VALUE
          This is used in {values} to indicate at least one unresolved value.
 
Constructor Summary
Layout()
           
 
Method Summary
static boolean isInternalProcedureAddress(int addr)
          Is the input address a valid address for an internal function/procedure?
static int methodSigArgInstructionsCount(java.lang.String methodSig)
          Given a method sig, get the number of instructions for the args.
static java.util.ArrayList<java.lang.Integer> methodSigPopAddresses(java.lang.String methodSig, int endpointAddress, boolean forCall)
          Get a list of pop instruction addresses for a call or procedure (endpoint).
static int methodSigReturnPopOffset(java.lang.String methodSig)
          Get the offset of the pop instruction for the return value from a function/method.
static int procedureAddressForPosition(int zeroBasedPosition)
          Generate the address for a procedure segment for a compile unit sub procedure.
static int procedureInstrAddrFor(int address)
          For an input instruction address, get the address for the procedure block it belongs to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHODSIG_INPUT

public static final char METHODSIG_INPUT
Method sig entry for INPUT param.

See Also:
Constant Field Values

METHODSIG_OUTPUT

public static final char METHODSIG_OUTPUT
Method sig entry for OUTPUT param.

See Also:
Constant Field Values

METHODSIG_INPUTOUTPUT

public static final char METHODSIG_INPUTOUTPUT
Method sig entry for INPUT-OUTPUT param.

See Also:
Constant Field Values

METHODSIG_RETURN

public static final char METHODSIG_RETURN
Method sig entry for method/function return.

See Also:
Constant Field Values

CUID_GLOBALS

public static final int CUID_GLOBALS
ReservedCUID

See Also:
Constant Field Values

CUID_INCLUDES

public static final int CUID_INCLUDES
ReservedCUID

See Also:
Constant Field Values

CUID_UNRES

public static final int CUID_UNRES
ReservedCUID

See Also:
Constant Field Values

CUID_SESSIONSUPERS

public static final int CUID_SESSIONSUPERS
ReservedCUID

See Also:
Constant Field Values

CUID_CALLNAME

public static final int CUID_CALLNAME
ReservedCUID

See Also:
Constant Field Values

CUID_CHECKVALS

public static final int CUID_CHECKVALS
ReservedCUID

See Also:
Constant Field Values

CUID_PUBSUB

public static final int CUID_PUBSUB
ReservedCUID

See Also:
Constant Field Values

CUID_LAST_RESERVED

public static final int CUID_LAST_RESERVED
ReservedCUID

See Also:
Constant Field Values

LAYOUT_VERSION

public static final int LAYOUT_VERSION
This gives us the layout version of all the bytecode in general. If a CU is found in the bytecode database with out-of-date bytecode, the old bytecode needs to be discarded, and new bytecode needs to be built, with full CU xref reindexing.

See Also:
Constant Field Values

UNRESOLVED_VALUE

public static final int UNRESOLVED_VALUE
This is used in {values} to indicate at least one unresolved value. This value isn't in the string table, and attempting to fetch it will return null. So, either value=UNRESOLVED must be checked, or null return from the strings table must be checked.

See Also:
Constant Field Values

CU_ADDRESS

public static final int CU_ADDRESS
The address of the compileunit instruction.

See Also:
Constant Field Values

SUPERS_ADDRESS

public static final int SUPERS_ADDRESS
The address of the supers instruction.

See Also:
Constant Field Values

UNRESOLVED_SOURCE_ADDRESS

public static final int UNRESOLVED_SOURCE_ADDRESS
An address to be used as a local source, when the target is unresolved. There is a special unres instruction at this address, for each compile unit.

See Also:
Constant Field Values

UNKNOWN_VALUE_ADDRESS

public static final int UNKNOWN_VALUE_ADDRESS
The address in every CU header for the unknown value.

See Also:
Constant Field Values

FIRST_CU_HEADER_SEQUENTIAL_INSTRUCTION

public static final int FIRST_CU_HEADER_SEQUENTIAL_INSTRUCTION
Sequential instructions for the compile unit header, such as string literals and other constants, begin here. Addresses prior to this address are reserved for "fixed address" instructions.

See Also:
Constant Field Values

MAIN_PROCEDURE_ADDRESS

public static final int MAIN_PROCEDURE_ADDRESS
The address of procedure segment for the main program block. The first segment is reserved for data about the compile unit itself. The main procedure begins at the first procedure segment.

See Also:
Constant Field Values

FIRST_INTERNAL_PROC_ADDRESS

public static final int FIRST_INTERNAL_PROC_ADDRESS
The address of the first internal procedure. The layout is: header instructions, main procedure segment instructions, then internal procedure, function, and method instructions.

See Also:
Constant Field Values
Constructor Detail

Layout

public Layout()
Method Detail

isInternalProcedureAddress

public static boolean isInternalProcedureAddress(int addr)
Is the input address a valid address for an internal function/procedure?


methodSigArgInstructionsCount

public static int methodSigArgInstructionsCount(java.lang.String methodSig)
Given a method sig, get the number of instructions for the args. An INPUT-OUTPUT gets two instructions, and is represented as 'x' in the method sig. That's why it isn't just a simple matter of using the string length.


methodSigPopAddresses

public static java.util.ArrayList<java.lang.Integer> methodSigPopAddresses(java.lang.String methodSig,
                                                                           int endpointAddress,
                                                                           boolean forCall)
Get a list of pop instruction addresses for a call or procedure (endpoint).

Parameters:
isCall - True if calculating for a call, false if calculating for a procedure.

methodSigReturnPopOffset

public static int methodSigReturnPopOffset(java.lang.String methodSig)
Get the offset of the pop instruction for the return value from a function/method. Returns 0 if there's no return (i.e. if it's a PROCEDURE).


procedureAddressForPosition

public static int procedureAddressForPosition(int zeroBasedPosition)
Generate the address for a procedure segment for a compile unit sub procedure.

Parameters:
zeroBasedPosition - Internal procedure positions are persistent from build to build. The positions are counted from zero.
See Also:
for the main program block's procedure segment.

procedureInstrAddrFor

public static int procedureInstrAddrFor(int address)
For an input instruction address, get the address for the procedure block it belongs to. Note that the procedure block might actually be a trigger block (TriggerblockInstr).



Copyright © 2008 Joanju Software. All Rights Reserved.