org.logicalcobwebs.cglib.core
Class EmitUtils
java.lang.Object
org.logicalcobwebs.cglib.core.EmitUtils
public class EmitUtils
- extends java.lang.Object
Method Summary |
static void |
add_properties(ClassEmitter ce,
java.lang.String[] names,
Type[] types)
|
static void |
add_property(ClassEmitter ce,
java.lang.String name,
Type type,
java.lang.String fieldName)
|
private static void |
append_string_helper(CodeEmitter e,
Type type,
EmitUtils.ArrayDelimiters delims,
Customizer customizer,
ProcessArrayCallback callback)
|
static void |
append_string(CodeEmitter e,
Type type,
EmitUtils.ArrayDelimiters delims,
Customizer customizer)
|
static void |
constructor_switch(CodeEmitter e,
java.lang.reflect.Constructor[] cstructs,
ObjectSwitchCallback callback)
|
private static java.lang.String |
escapeType(java.lang.String s)
|
static void |
factory_method(ClassEmitter ce,
Signature sig)
|
private static java.lang.String |
getFieldName(java.lang.String typeName)
|
(package private) static int[] |
getSwitchKeys(java.util.Map buckets)
|
private static void |
hash_array(CodeEmitter e,
Type type,
int multiplier,
Customizer customizer)
|
static void |
hash_code(CodeEmitter e,
Type type,
int multiplier,
Customizer customizer)
|
private static void |
hash_long(CodeEmitter e)
|
private static void |
hash_object(CodeEmitter e,
Type type,
Customizer customizer)
|
private static void |
hash_primitive(CodeEmitter e,
Type type)
|
private static void |
load_class_helper(CodeEmitter e,
Type type)
|
static void |
load_class_this(CodeEmitter e)
|
static void |
load_class(CodeEmitter e,
Type type)
|
static void |
load_method(CodeEmitter e,
java.lang.reflect.Method method)
|
private static void |
member_helper_size(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
EmitUtils.ParameterTyper typer,
Label def,
Label end)
|
private static void |
member_helper_type(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
EmitUtils.ParameterTyper typer,
Label def,
Label end,
java.util.BitSet checked)
|
private static void |
member_switch_helper(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
boolean useName,
EmitUtils.ParameterTyper typer)
|
static void |
method_switch(CodeEmitter e,
java.lang.reflect.Method[] methods,
ObjectSwitchCallback callback)
|
private static void |
not_equals_helper(CodeEmitter e,
Type type,
Label notEquals,
Customizer customizer,
ProcessArrayCallback callback)
|
static void |
not_equals(CodeEmitter e,
Type type,
Label notEquals,
Customizer customizer)
Branches to the specified label if the top two items on the stack
are not equal. |
static void |
null_constructor(ClassEmitter ce)
|
private static void |
nullcmp(CodeEmitter e,
Label oneNull,
Label bothNull)
If both objects on the top of the stack are non-null, does nothing. |
static void |
process_array(CodeEmitter e,
Type type,
ProcessArrayCallback callback)
Process an array on the stack. |
static void |
process_arrays(CodeEmitter e,
Type type,
ProcessArrayCallback callback)
Process two arrays on the stack in parallel. |
static void |
push_array(CodeEmitter e,
java.lang.Object[] array)
|
static void |
push_object(CodeEmitter e,
java.lang.Object obj)
|
private static void |
shrinkStringBuffer(CodeEmitter e,
int amt)
|
private static void |
string_switch_hash(CodeEmitter e,
java.lang.String[] strings,
ObjectSwitchCallback callback,
boolean skipEquals)
|
private static void |
string_switch_trie(CodeEmitter e,
java.lang.String[] strings,
ObjectSwitchCallback callback)
|
static void |
string_switch(CodeEmitter e,
java.lang.String[] strings,
int switchStyle,
ObjectSwitchCallback callback)
|
private static void |
stringSwitchHelper(CodeEmitter e,
java.util.List strings,
ObjectSwitchCallback callback,
Label def,
Label end,
int index)
|
static void |
wrap_throwable(Block block,
Type wrapper)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CSTRUCT_NULL
private static final Signature CSTRUCT_NULL
CSTRUCT_THROWABLE
private static final Signature CSTRUCT_THROWABLE
GET_NAME
private static final Signature GET_NAME
HASH_CODE
private static final Signature HASH_CODE
EQUALS
private static final Signature EQUALS
STRING_LENGTH
private static final Signature STRING_LENGTH
STRING_CHAR_AT
private static final Signature STRING_CHAR_AT
FOR_NAME
private static final Signature FOR_NAME
DOUBLE_TO_LONG_BITS
private static final Signature DOUBLE_TO_LONG_BITS
FLOAT_TO_INT_BITS
private static final Signature FLOAT_TO_INT_BITS
TO_STRING
private static final Signature TO_STRING
APPEND_STRING
private static final Signature APPEND_STRING
APPEND_INT
private static final Signature APPEND_INT
APPEND_DOUBLE
private static final Signature APPEND_DOUBLE
APPEND_FLOAT
private static final Signature APPEND_FLOAT
APPEND_CHAR
private static final Signature APPEND_CHAR
APPEND_LONG
private static final Signature APPEND_LONG
APPEND_BOOLEAN
private static final Signature APPEND_BOOLEAN
LENGTH
private static final Signature LENGTH
SET_LENGTH
private static final Signature SET_LENGTH
GET_DECLARED_METHOD
private static final Signature GET_DECLARED_METHOD
DEFAULT_DELIMITERS
public static final EmitUtils.ArrayDelimiters DEFAULT_DELIMITERS
EmitUtils
private EmitUtils()
factory_method
public static void factory_method(ClassEmitter ce,
Signature sig)
null_constructor
public static void null_constructor(ClassEmitter ce)
process_array
public static void process_array(CodeEmitter e,
Type type,
ProcessArrayCallback callback)
- Process an array on the stack. Assumes the top item on the stack
is an array of the specified type. For each element in the array,
puts the element on the stack and triggers the callback.
- Parameters:
type
- the type of the array (type.isArray() must be true)callback
- the callback triggered for each element
process_arrays
public static void process_arrays(CodeEmitter e,
Type type,
ProcessArrayCallback callback)
- Process two arrays on the stack in parallel. Assumes the top two items on the stack
are arrays of the specified class. The arrays must be the same length. For each pair
of elements in the arrays, puts the pair on the stack and triggers the callback.
- Parameters:
type
- the type of the arrays (type.isArray() must be true)callback
- the callback triggered for each pair of elements
string_switch
public static void string_switch(CodeEmitter e,
java.lang.String[] strings,
int switchStyle,
ObjectSwitchCallback callback)
string_switch_trie
private static void string_switch_trie(CodeEmitter e,
java.lang.String[] strings,
ObjectSwitchCallback callback)
throws java.lang.Exception
- Throws:
java.lang.Exception
stringSwitchHelper
private static void stringSwitchHelper(CodeEmitter e,
java.util.List strings,
ObjectSwitchCallback callback,
Label def,
Label end,
int index)
throws java.lang.Exception
- Throws:
java.lang.Exception
getSwitchKeys
static int[] getSwitchKeys(java.util.Map buckets)
string_switch_hash
private static void string_switch_hash(CodeEmitter e,
java.lang.String[] strings,
ObjectSwitchCallback callback,
boolean skipEquals)
throws java.lang.Exception
- Throws:
java.lang.Exception
load_class_this
public static void load_class_this(CodeEmitter e)
load_class
public static void load_class(CodeEmitter e,
Type type)
load_class_helper
private static void load_class_helper(CodeEmitter e,
Type type)
getFieldName
private static java.lang.String getFieldName(java.lang.String typeName)
escapeType
private static java.lang.String escapeType(java.lang.String s)
push_array
public static void push_array(CodeEmitter e,
java.lang.Object[] array)
push_object
public static void push_object(CodeEmitter e,
java.lang.Object obj)
hash_code
public static void hash_code(CodeEmitter e,
Type type,
int multiplier,
Customizer customizer)
hash_array
private static void hash_array(CodeEmitter e,
Type type,
int multiplier,
Customizer customizer)
hash_object
private static void hash_object(CodeEmitter e,
Type type,
Customizer customizer)
hash_primitive
private static void hash_primitive(CodeEmitter e,
Type type)
hash_long
private static void hash_long(CodeEmitter e)
not_equals
public static void not_equals(CodeEmitter e,
Type type,
Label notEquals,
Customizer customizer)
- Branches to the specified label if the top two items on the stack
are not equal. The items must both be of the specified
class. Equality is determined by comparing primitive values
directly and by invoking the
equals
method for
Objects. Arrays are recursively processed in the same manner.
not_equals_helper
private static void not_equals_helper(CodeEmitter e,
Type type,
Label notEquals,
Customizer customizer,
ProcessArrayCallback callback)
nullcmp
private static void nullcmp(CodeEmitter e,
Label oneNull,
Label bothNull)
- If both objects on the top of the stack are non-null, does nothing.
If one is null, or both are null, both are popped off and execution
branches to the respective label.
- Parameters:
oneNull
- label to branch to if only one of the objects is nullbothNull
- label to branch to if both of the objects are null
append_string
public static void append_string(CodeEmitter e,
Type type,
EmitUtils.ArrayDelimiters delims,
Customizer customizer)
append_string_helper
private static void append_string_helper(CodeEmitter e,
Type type,
EmitUtils.ArrayDelimiters delims,
Customizer customizer,
ProcessArrayCallback callback)
shrinkStringBuffer
private static void shrinkStringBuffer(CodeEmitter e,
int amt)
load_method
public static void load_method(CodeEmitter e,
java.lang.reflect.Method method)
method_switch
public static void method_switch(CodeEmitter e,
java.lang.reflect.Method[] methods,
ObjectSwitchCallback callback)
constructor_switch
public static void constructor_switch(CodeEmitter e,
java.lang.reflect.Constructor[] cstructs,
ObjectSwitchCallback callback)
member_switch_helper
private static void member_switch_helper(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
boolean useName,
EmitUtils.ParameterTyper typer)
member_helper_size
private static void member_helper_size(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
EmitUtils.ParameterTyper typer,
Label def,
Label end)
throws java.lang.Exception
- Throws:
java.lang.Exception
member_helper_type
private static void member_helper_type(CodeEmitter e,
java.util.List members,
ObjectSwitchCallback callback,
EmitUtils.ParameterTyper typer,
Label def,
Label end,
java.util.BitSet checked)
throws java.lang.Exception
- Throws:
java.lang.Exception
wrap_throwable
public static void wrap_throwable(Block block,
Type wrapper)
add_properties
public static void add_properties(ClassEmitter ce,
java.lang.String[] names,
Type[] types)
add_property
public static void add_property(ClassEmitter ce,
java.lang.String name,
Type type,
java.lang.String fieldName)