public class ClassInitializeMethodBuilder extends RecoderModelTransformer
<clprepare>
responsible for the class
preparation.RecoderModelTransformer.FinalOuterVarsCollector, RecoderModelTransformer.TransformerCache
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_INITIALIZE_IDENTIFIER |
private java.util.HashMap<TypeDeclaration,ASTList<Statement>> |
class2initializers
maps a class to its static NON CONSTANT fields
|
private java.util.HashMap<ClassDeclaration,TypeReference> |
class2super
maps a class to its superclass
|
private ClassType |
javaLangObject |
cache, services
EQUIVALENCE, IDENTITY, NO_PROBLEM
Constructor and Description |
---|
ClassInitializeMethodBuilder(CrossReferenceServiceConfiguration services,
RecoderModelTransformer.TransformerCache cache)
Creates an instance of the class preparation method model
transformer.
|
Modifier and Type | Method and Description |
---|---|
ProblemReport |
analyze() |
protected CopyAssignment |
assign(Expression left,
Expression right)
creates a recoder copy assignment
|
private Catch |
createCatchClause(java.lang.String caughtType,
java.lang.String caughtParam,
Throw t)
creates the following catch clause
catch (caughtType caughtParam) {
<classInitializationInProgress>=false;
<classClassErroneous>=true;
t;
}
|
private MethodDeclaration |
createInitializeMethod(TypeDeclaration td)
creates the static method
<clprepare> for the
given type declaration |
private StatementBlock |
createInitializeMethodBody(TypeDeclaration td)
creates the body of the initialize method
|
private Try |
createInitializerExecutionTryBlock(TypeDeclaration td)
around the initializers there is a try block that catches
eventually thrown errors or exceptions and handles them in a
special way
|
private PackageReference |
createJavaLangPackageReference()
creates the package reference java.lang
|
private ASTList<Statement> |
fieldInitializersToAssignments(FieldDeclaration fd)
iterates throuh the given field declaration and creates for each
specification that contains an initializer a corresponding copy
assignment.
|
private ASTList<Statement> |
getInitializers(TypeDeclaration typeDeclaration)
retrieves all static non constant fields and returns a list of
copy assignment pre-initialising them with their default values
some special settings for implicit fields are performed here as well
|
private boolean |
isConstantField(FieldSpecification spec)
returns true if the given fieldspecification denotes a constant
field.
|
protected void |
makeExplicit(TypeDeclaration td)
entry method for the constructor normalform builder
|
protected PassiveExpression |
passiveFieldReference(Identifier id)
creates passive field reference access
|
attach, attribute, classDeclarations, containingClass, containingMethod, declare, declare, getAllSupertypes, getDefaultValue, getId, getLocalClass2FinalVar, getUnits, isVisible, makeExplicit, transform
execute
attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attach, attachAsArgument, attachAsArgument, attachAsArgument, attachAsArgument, attachAsArgument, attachAsArgument, attachAsArgument, attachAsArgument, attachAsBody, attachAsCondition, attachAsGuard, attachAsInitializer, attachAsLabel, attachAsMessage, attachAsPrefix, attachAsPrefix, attachAsPrefix, attachAsPrefix, attachAsUpdate, detach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttach, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsArgument, doAttachAsBody, doAttachAsCondition, doAttachAsGuard, doAttachAsInitializer, doAttachAsLabel, doAttachAsMessage, doAttachAsPrefix, doAttachAsPrefix, doAttachAsPrefix, doAttachAsPrefix, doAttachAsUpdate, doDetach, doReplace, getChangeHistory, getCrossReferenceSourceInfo, getNameInfo, getProblemReport, getProgramFactory, getServiceConfiguration, getSourceFileRepository, getSourceInfo, replace, rollback, setProblemReport, setServiceConfiguration, toString
public static final java.lang.String CLASS_INITIALIZE_IDENTIFIER
private java.util.HashMap<TypeDeclaration,ASTList<Statement>> class2initializers
private java.util.HashMap<ClassDeclaration,TypeReference> class2super
private ClassType javaLangObject
public ClassInitializeMethodBuilder(CrossReferenceServiceConfiguration services, RecoderModelTransformer.TransformerCache cache)
services
- the CrossReferenceServiceConfiguration with the
information about the recoder modelcache
- a cache object that stores information which is needed by
and common to many transformations. it includes the
compilation units, the declared classes, and information
for local classes.private boolean isConstantField(FieldSpecification spec)
private PackageReference createJavaLangPackageReference()
private ASTList<Statement> fieldInitializersToAssignments(FieldDeclaration fd)
private ASTList<Statement> getInitializers(TypeDeclaration typeDeclaration)
typeDeclaration
- the ClassDeclaration whose fields have to be preparedpublic ProblemReport analyze()
analyze
in class TwoPassTransformation
protected PassiveExpression passiveFieldReference(Identifier id)
protected CopyAssignment assign(Expression left, Expression right)
assign
in class RecoderModelTransformer
private Catch createCatchClause(java.lang.String caughtType, java.lang.String caughtParam, Throw t)
catch (caughtType caughtParam) {
<classInitializationInProgress>=false;
<classClassErroneous>=true;
t;
}
private Try createInitializerExecutionTryBlock(TypeDeclaration td)
private StatementBlock createInitializeMethodBody(TypeDeclaration td)
private MethodDeclaration createInitializeMethod(TypeDeclaration td)
<clprepare>
for the
given type declarationtd
- the TypeDeclaration to which the new created method
will be attachedprotected void makeExplicit(TypeDeclaration td)
makeExplicit
in class RecoderModelTransformer
td
- the TypeDeclaration