public class CodeBuilderUtil
extends java.lang.Object
Constructor and Description |
---|
CodeBuilderUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addEqualsCall(org.cojen.classfile.CodeBuilder b,
java.lang.String fieldName,
org.cojen.classfile.TypeDesc fieldType,
boolean testForNull,
org.cojen.classfile.Label fail,
org.cojen.classfile.LocalVariable other)
Generates code to compare a field in this object against the same one in a
different instance.
|
static void |
addValueHashCodeCall(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc valueType,
boolean testForNull,
boolean mixIn)
Generates code to compute a hashcode for a value on the stack, consuming
the value.
|
static void |
addValuesEqualCall(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc valueType,
boolean testForNull,
org.cojen.classfile.Label label,
boolean choice)
Generates code to compare two values on the stack, and branch to the
provided Label if they are not equal.
|
static void |
assertParameterNotNull(org.cojen.classfile.CodeBuilder b,
int paramIndex)
Generate code to throw an exception if a parameter is null
|
static org.cojen.classfile.TypeDesc |
bindQueryParam(java.lang.Class clazz)
Determines which overloaded "with" method on Query should be bound to.
|
static void |
blankValue(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc type)
Generates code to push a blank value to the stack.
|
static void |
callStringBuilderAppendChar(org.cojen.classfile.CodeBuilder b)
Appends a char to a StringBuilder.
|
static void |
callStringBuilderAppendString(org.cojen.classfile.CodeBuilder b)
Appends a String to a StringBuilder.
|
static void |
callStringBuilderLength(org.cojen.classfile.CodeBuilder b)
Calls length on a StringBuilder on the stack, leaving an int on the stack.
|
static void |
callStringBuilderSetLength(org.cojen.classfile.CodeBuilder b)
Calls setLength on a StringBuilder.
|
static void |
callStringBuilderToString(org.cojen.classfile.CodeBuilder b)
Calls toString on a StringBuilder.
|
static void |
convertValue(org.cojen.classfile.CodeBuilder b,
java.lang.Class from,
java.lang.Class to)
Converts a value on the stack.
|
static <S extends Storable> |
createStorableClassFile(org.cojen.util.ClassInjector ci,
java.lang.Class<S> type,
boolean isAbstract,
java.lang.String aSourcefileName)
Define a classfile appropriate for most Storables.
|
static void |
defineCopyBridges(org.cojen.classfile.ClassFile cf,
java.lang.Class leaf)
Add copy bridge methods for all classes/interfaces between the leaf
(genericised class) and the root (genericised baseclass).
|
static void |
definePrepareBridges(org.cojen.classfile.ClassFile cf,
java.lang.Class leaf)
Add prepare bridge methods for all classes/interfaces between the leaf
(genericised class) and the root (genericised baseclass).
|
static void |
definePrepareMethod(org.cojen.classfile.ClassFile cf,
java.lang.Class storableClass,
org.cojen.classfile.TypeDesc supportCtorType)
Defines a Storable prepare method, which assumes that a support field
exists and a single-argument constructor exists which accepts a support
instance.
|
static void |
definePrepareMethod(org.cojen.classfile.ClassFile cf,
java.lang.Class storableClass,
org.cojen.classfile.TypeDesc supportCtorType,
java.lang.String supportFieldName,
org.cojen.classfile.TypeDesc supportFieldType)
Defines a Storable prepare method, which assumes that a support field
exists and a single-argument constructor exists which accepts a support
instance.
|
static java.util.Set<java.lang.Class> |
gatherAllBridgeTypes(java.util.Set<java.lang.Class> set,
java.lang.Class leaf)
Collect a set of all the interfaces and recursively all superclasses for the leaf
(genericised class) and root (genericised base class).
|
static void |
incrementVersion(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc type)
Generates code to increment a version property value, already on the stack.
|
static void |
initialVersion(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc type,
int value)
Generates code to push an initial version property value on the stack.
|
static boolean |
isPublicMethodFinal(java.lang.Class clazz,
java.lang.String name,
org.cojen.classfile.TypeDesc retType,
org.cojen.classfile.TypeDesc[] params)
Returns true if a public final method exists which matches the given
specification.
|
static void |
throwConcatException(org.cojen.classfile.CodeBuilder b,
java.lang.Class type,
java.lang.String... messages)
Generate code to throw an exception with a message concatenated at runtime.
|
static void |
throwException(org.cojen.classfile.CodeBuilder b,
java.lang.Class type,
java.lang.String message)
Generate code to throw an exception with an optional message.
|
static org.cojen.classfile.LocalVariable |
uneraseGenericParameter(org.cojen.classfile.CodeBuilder b,
org.cojen.classfile.TypeDesc paramType,
int paramIndex)
Generate code to create a local variable containing the specified parameter coerced
to the specified type.
|
public static void assertParameterNotNull(org.cojen.classfile.CodeBuilder b, int paramIndex)
b
- CodeBuilder into which to append the codeparamIndex
- index of the parameter to checkpublic static org.cojen.classfile.LocalVariable uneraseGenericParameter(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc paramType, int paramIndex)
b
- CodeBuilder into which to append the codeparamType
- the more specific type which was erased during compilationparamIndex
- index of the parameter to unerasepublic static void throwException(org.cojen.classfile.CodeBuilder b, java.lang.Class type, java.lang.String message)
b
- CodeBuilder
to which to add codetype
- type of the object to throwmessage
- optional message to provide to the constructorpublic static void throwConcatException(org.cojen.classfile.CodeBuilder b, java.lang.Class type, java.lang.String... messages)
b
- CodeBuilder
to which to add codetype
- type of the object to throwmessages
- messages to concat at runtimepublic static java.util.Set<java.lang.Class> gatherAllBridgeTypes(java.util.Set<java.lang.Class> set, java.lang.Class leaf)
A copy must be coercible into any of these types, and copy bridge methods must be provided to do so.
Note that the official documentation for this is in draft form, and you have to be psychic to have figured out the necessity in the first place.
set
- set into which the class types will be collectedleaf
- leaf classpublic static void defineCopyBridges(org.cojen.classfile.ClassFile cf, java.lang.Class leaf)
cf
- file to which to add the copy bridgeleaf
- leaf classpublic static void definePrepareMethod(org.cojen.classfile.ClassFile cf, java.lang.Class storableClass, org.cojen.classfile.TypeDesc supportCtorType)
cf
- file to which to add the prepare methodpublic static void definePrepareMethod(org.cojen.classfile.ClassFile cf, java.lang.Class storableClass, org.cojen.classfile.TypeDesc supportCtorType, java.lang.String supportFieldName, org.cojen.classfile.TypeDesc supportFieldType)
cf
- file to which to add the prepare methodpublic static void definePrepareBridges(org.cojen.classfile.ClassFile cf, java.lang.Class leaf)
cf
- file to which to add the prepare bridgeleaf
- leaf classpublic static boolean isPublicMethodFinal(java.lang.Class clazz, java.lang.String name, org.cojen.classfile.TypeDesc retType, org.cojen.classfile.TypeDesc[] params)
public static <S extends Storable> org.cojen.classfile.ClassFile createStorableClassFile(org.cojen.util.ClassInjector ci, java.lang.Class<S> type, boolean isAbstract, java.lang.String aSourcefileName)
ci
- ClassInjector for the storabletype
- specific Storable implementation to generateisAbstract
- true if the class should be abstractaSourcefileName
- identifier for the classfile, typically the factory class namepublic static void addValueHashCodeCall(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc valueType, boolean testForNull, boolean mixIn)
b
- CodeBuilder
to which to add the codevalueType
- the type of the valuetestForNull
- if true and the value is a reference and might be nullmixIn
- if true, stack has an existing hashcode followed by a valuepublic static void addEqualsCall(org.cojen.classfile.CodeBuilder b, java.lang.String fieldName, org.cojen.classfile.TypeDesc fieldType, boolean testForNull, org.cojen.classfile.Label fail, org.cojen.classfile.LocalVariable other)
b
- CodeBuilder
to which to add the codefieldName
- the name of the fieldfieldType
- the type of the fieldtestForNull
- if true and the values are references, they will be considered
unequal unless neither or both are null. If false, assume neither is null.fail
- the label to branch toother
- the other instance to testpublic static void addValuesEqualCall(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc valueType, boolean testForNull, org.cojen.classfile.Label label, boolean choice)
The generated instruction consumes both values on the stack.
b
- CodeBuilder
to which to add the codevalueType
- the type of the valuestestForNull
- if true and the values are references, they will be considered
unequal unless neither or both are null. If false, assume neither is null.label
- the label to branch tochoice
- when true, branch to label if values are equal, else
branch to label if values are unequal.public static void convertValue(org.cojen.classfile.CodeBuilder b, java.lang.Class from, java.lang.Class to)
public static void initialVersion(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc type, int value) throws SupportException
SupportException
- if version type is not supportedpublic static void incrementVersion(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc type) throws SupportException
SupportException
- if version type is not supportedpublic static void blankValue(org.cojen.classfile.CodeBuilder b, org.cojen.classfile.TypeDesc type)
public static org.cojen.classfile.TypeDesc bindQueryParam(java.lang.Class clazz)
public static void callStringBuilderAppendString(org.cojen.classfile.CodeBuilder b)
public static void callStringBuilderAppendChar(org.cojen.classfile.CodeBuilder b)
public static void callStringBuilderLength(org.cojen.classfile.CodeBuilder b)
public static void callStringBuilderSetLength(org.cojen.classfile.CodeBuilder b)
public static void callStringBuilderToString(org.cojen.classfile.CodeBuilder b)
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.