org.eclipse.ocl.examples.codegen.analyzer
Class CodeGenAnalyzer

java.lang.Object
  extended by org.eclipse.ocl.examples.codegen.analyzer.CodeGenAnalyzer

public class CodeGenAnalyzer
extends java.lang.Object

A CodeGenAnalyzer performs the analysis of a Pivot AST in preparation for code generation.

Pass 1: Pivot2CGAnalysisVisitor
Each Pivot Element is converted to a CGElement
This conversion creates objects such as CGLibraryOperationCallEXp that are more atuned to CG and provides a tree that can be rewritten by optimizations.

Pass 2: CGPreAnalysisVisitor
Traversal of the CG containment tree performs
constant folding

Pass N-1: CG2JavaPreVisitor
Traversal of the CG containment tree prepares for Java CG by
gathering imports

Pass N: CG2JavaVisitor
Traversal of the CG containment tree emits code


Field Summary
protected  CGBoolean cgFalse
           
protected  CGNull cgNull
           
protected  CGBoolean cgTrue
           
protected  CodeGenerator codeGenerator
           
protected  NameManager nameManager
           
 
Constructor Summary
CodeGenAnalyzer(CodeGenerator codeGenerator)
           
 
Method Summary
 void analyze(CGElement cgRoot)
           
protected  CGBoolean createCGBoolean(boolean booleanValue)
           
 CGConstantExp createCGConstantExp(OCLExpression element, CGConstant constant)
           
protected  CGNull createCGNull()
           
 CGBoolean getBoolean(boolean aBoolean)
           
 CodeGenerator getCodeGenerator()
           
 CGElementId getElementId(ElementId elementId)
           
 CGExecutorConstructorPart getExecutorConstructorPart(Property pivotProperty)
           
 CGExecutorConstructorPart getExecutorConstructorPart(PropertyId propertyId)
           
 CGExecutorOperation getExecutorOperation(Operation pivotOperation)
           
 CGExecutorOperation getExecutorOperation(OperationId operationId)
           
 CGExecutorProperty getExecutorProperty(Property pivotProperty)
           
 CGExecutorProperty getExecutorProperty(PropertyId propertyId)
           
 CGValuedElement getExpression(CGValuedElement cgExpression)
           
 CGInfinity getInfinity()
           
 CGInteger getInteger(java.lang.Number aNumber)
           
 CGInvalid getInvalid()
           
 CGInvalid getInvalid(java.lang.String messageTemplate, java.lang.Object... bindings)
           
 NameManager getNameManager()
           
 CGNull getNull()
           
 CGReal getReal(java.lang.Number aNumber)
           
 CGString getString(java.lang.String aString)
           
 CGTypeId getTypeId(TypeId typeId)
           
 void setConstant(CGValuedElement oldElement, CGValuedElement aConstant)
           
 void setExplicitNames(CGValuedElement cgValue, java.lang.Object anObject)
           
 void setNames(CGValuedElement cgValue, java.lang.Object anObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codeGenerator

@NonNull
protected final CodeGenerator codeGenerator

nameManager

@NonNull
protected final NameManager nameManager

cgFalse

@NonNull
protected final CGBoolean cgFalse

cgTrue

@NonNull
protected final CGBoolean cgTrue

cgNull

@NonNull
protected final CGNull cgNull
Constructor Detail

CodeGenAnalyzer

public CodeGenAnalyzer(@NonNull
                       CodeGenerator codeGenerator)
Method Detail

analyze

public void analyze(@NonNull
                    CGElement cgRoot)

createCGConstantExp

@NonNull
public CGConstantExp createCGConstantExp(@NonNull
                                                 OCLExpression element,
                                                 @NonNull
                                                 CGConstant constant)

createCGBoolean

@NonNull
protected CGBoolean createCGBoolean(boolean booleanValue)

createCGNull

@NonNull
protected CGNull createCGNull()

getCodeGenerator

@NonNull
public CodeGenerator getCodeGenerator()

getBoolean

@NonNull
public CGBoolean getBoolean(boolean aBoolean)

getElementId

@NonNull
public CGElementId getElementId(@NonNull
                                        ElementId elementId)

getExecutorOperation

@NonNull
public CGExecutorOperation getExecutorOperation(@NonNull
                                                        Operation pivotOperation)

getExecutorOperation

@NonNull
public CGExecutorOperation getExecutorOperation(@NonNull
                                                        OperationId operationId)

getExecutorConstructorPart

@NonNull
public CGExecutorConstructorPart getExecutorConstructorPart(@NonNull
                                                                    Property pivotProperty)

getExecutorConstructorPart

@NonNull
public CGExecutorConstructorPart getExecutorConstructorPart(@NonNull
                                                                    PropertyId propertyId)

getExecutorProperty

@NonNull
public CGExecutorProperty getExecutorProperty(@NonNull
                                                      Property pivotProperty)

getExecutorProperty

@NonNull
public CGExecutorProperty getExecutorProperty(@NonNull
                                                      PropertyId propertyId)

getExpression

@NonNull
public CGValuedElement getExpression(@Nullable
                                             CGValuedElement cgExpression)

getInfinity

@NonNull
public CGInfinity getInfinity()

getInteger

@NonNull
public CGInteger getInteger(@NonNull
                                    java.lang.Number aNumber)

getInvalid

@NonNull
public CGInvalid getInvalid()

getInvalid

@NonNull
public CGInvalid getInvalid(java.lang.String messageTemplate,
                                    java.lang.Object... bindings)

getNull

@NonNull
public CGNull getNull()

getReal

@NonNull
public CGReal getReal(@NonNull
                              java.lang.Number aNumber)

getString

@NonNull
public CGString getString(@NonNull
                                  java.lang.String aString)

getNameManager

@NonNull
public NameManager getNameManager()

getTypeId

@NonNull
public CGTypeId getTypeId(@NonNull
                                  TypeId typeId)

setConstant

public void setConstant(@NonNull
                        CGValuedElement oldElement,
                        @Nullable
                        CGValuedElement aConstant)

setExplicitNames

public void setExplicitNames(@NonNull
                             CGValuedElement cgValue,
                             @Nullable
                             java.lang.Object anObject)

setNames

public void setNames(@NonNull
                     CGValuedElement cgValue,
                     @NonNull
                     java.lang.Object anObject)