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

java.lang.Object
  extended by org.eclipse.ocl.examples.codegen.cgmodel.util.AbstractCGModelVisitor<R,C>
      extended by org.eclipse.ocl.examples.codegen.cgmodel.util.AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>
          extended by org.eclipse.ocl.examples.codegen.analyzer.BoxingAnalyzer
All Implemented Interfaces:
CGModelVisitor<java.lang.Object>
Direct Known Subclasses:
AutoBoxingAnalyzer, OCLinEcoreCodeGenerator.EcoreBoxingAnalyzer

public class BoxingAnalyzer
extends AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

A BoxingAnalyzer performs a bottom up tree-traversal inserting:

CGBoxExp or CGUnboxExp whereever a conversion from boxed to unboxed or vice-versa is required.

CGCastExp whereever the apparent type is not available (e.g. Parameters passed as Object).

CGGuardExp whereever a non-null value is required.

No attempt at optimisation is made, since this can be performed by Common SubExpression Elimination.

Simple (both boxed and unboxed)

Boolean, String, null, EObject (except Types)

Boxed/Unboxed

IntegerValue/Number, RealValue/Number, TypeValue/EObject, InvalidValue/Exception, CollectionValue/List

Boxed

TupleValue

Boxed Protocol

Executor/Library Iteration/Operation/PropertyCall

Unboxed Protocol

Ecore Operation/PropertyCall


Field Summary
protected  CodeGenerator codeGenerator
           
 
Fields inherited from class org.eclipse.ocl.examples.codegen.cgmodel.util.AbstractCGModelVisitor
context
 
Constructor Summary
BoxingAnalyzer(CodeGenAnalyzer analyzer)
           
 
Method Summary
protected  boolean hasOclVoidOperation(OperationId operationId)
           
protected  CGValuedElement rewriteAsAssertNonNulled(CGValuedElement cgChild)
          Insert a CGAssertNonNullExp around cgChild.
protected  CGValuedElement rewriteAsBoxed(CGValuedElement cgChild)
          Insert a CGBoxExp around cgChild.
protected  CGValuedElement rewriteAsCast(CGVariableExp cgChild)
          Insert a CGCastExp around cgChild.
protected  CGValuedElement rewriteAsGuarded(CGValuedElement cgChild)
          Deprecated. 
protected  CGValuedElement rewriteAsGuarded(CGValuedElement cgChild, java.lang.String message)
           
protected  CGValuedElement rewriteAsUnboxed(CGValuedElement cgChild)
          Insert a CGUnboxExp around cgChild.
 java.lang.Object visitCGBuiltInIterationCallExp(CGBuiltInIterationCallExp cgElement)
           
 java.lang.Object visitCGConstructorPart(CGConstructorPart cgConstructorPart)
           
 java.lang.Object visitCGEcoreOperation(CGEcoreOperation cgElement)
           
 java.lang.Object visitCGEcoreOperationCallExp(CGEcoreOperationCallExp cgElement)
           
 java.lang.Object visitCGEcoreOppositePropertyCallExp(CGEcoreOppositePropertyCallExp cgElement)
           
 java.lang.Object visitCGEcorePropertyCallExp(CGEcorePropertyCallExp cgElement)
           
 java.lang.Object visitCGElement(CGElement cgElement)
           
 java.lang.Object visitCGExecutorOppositePropertyCallExp(CGExecutorOppositePropertyCallExp cgElement)
           
 java.lang.Object visitCGExecutorPropertyCallExp(CGExecutorPropertyCallExp cgElement)
           
 java.lang.Object visitCGIfExp(CGIfExp cgElement)
           
 java.lang.Object visitCGIsEqualExp(CGIsEqualExp cgElement)
           
 java.lang.Object visitCGLibraryIterateCallExp(CGLibraryIterateCallExp cgElement)
           
 java.lang.Object visitCGLibraryIterationCallExp(CGLibraryIterationCallExp cgElement)
           
 java.lang.Object visitCGLibraryOperationCallExp(CGLibraryOperationCallExp cgElement)
           
 java.lang.Object visitCGNavigationCallExp(CGNavigationCallExp cgElement)
           
 java.lang.Object visitCGOperation(CGOperation cgElement)
           
 java.lang.Object visitCGProperty(CGProperty cgElement)
           
 java.lang.Object visitCGVariableExp(CGVariableExp cgElement)
           
 java.lang.Object visiting(CGElement visitable)
          Return the result of visiting a visitable for which no more specific pivot type method is available.
 
Methods inherited from class org.eclipse.ocl.examples.codegen.cgmodel.util.AbstractExtendingCGModelVisitor
visitCGAccumulator, visitCGAssertNonNullExp, visitCGBoolean, visitCGBoxExp, visitCGCallable, visitCGCallExp, visitCGCastExp, visitCGCatchExp, visitCGClass, visitCGCollectionExp, visitCGCollectionPart, visitCGConstant, visitCGConstantExp, visitCGConstraint, visitCGConstructorExp, visitCGEcoreClassConstructorExp, visitCGEcoreDataTypeConstructorExp, visitCGElementId, visitCGExecutorCompositionProperty, visitCGExecutorConstructorPart, visitCGExecutorNavigationProperty, visitCGExecutorOperation, visitCGExecutorOperationCallExp, visitCGExecutorOppositeProperty, visitCGExecutorProperty, visitCGExecutorType, visitCGFinalVariable, visitCGGuardExp, visitCGInteger, visitCGInvalid, visitCGIsInvalidExp, visitCGIsUndefinedExp, visitCGIterationCallExp, visitCGIterator, visitCGLetExp, visitCGLibraryOperation, visitCGLibraryPropertyCallExp, visitCGLocalVariable, visitCGModel, visitCGNamedElement, visitCGNull, visitCGNumber, visitCGOperationCallExp, visitCGOppositePropertyCallExp, visitCGPackage, visitCGParameter, visitCGPropertyCallExp, visitCGReal, visitCGSettableVariable, visitCGString, visitCGText, visitCGTextParameter, visitCGThrowExp, visitCGTupleExp, visitCGTuplePart, visitCGTuplePartCallExp, visitCGTypedElement, visitCGTypeExp, visitCGTypeId, visitCGUnboxExp, visitCGUnlimited, visitCGValuedElement, visitCGVariable
 
Methods inherited from class org.eclipse.ocl.examples.codegen.cgmodel.util.AbstractCGModelVisitor
getAdapter, safeVisit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor
getAdapter
 

Field Detail

codeGenerator

@NonNull
protected final CodeGenerator codeGenerator
Constructor Detail

BoxingAnalyzer

public BoxingAnalyzer(@NonNull
                      CodeGenAnalyzer analyzer)
Method Detail

hasOclVoidOperation

protected boolean hasOclVoidOperation(@NonNull
                                      OperationId operationId)

rewriteAsAssertNonNulled

@Nullable
protected CGValuedElement rewriteAsAssertNonNulled(@Nullable
                                                            CGValuedElement cgChild)
Insert a CGAssertNonNullExp around cgChild.


rewriteAsBoxed

protected CGValuedElement rewriteAsBoxed(@Nullable
                                         CGValuedElement cgChild)
Insert a CGBoxExp around cgChild.


rewriteAsGuarded

@Deprecated
@Nullable
protected CGValuedElement rewriteAsGuarded(@Nullable
                                                               CGValuedElement cgChild)
Deprecated. 

Insert a CGGuardExp around cgChild.


rewriteAsGuarded

@Nullable
protected CGValuedElement rewriteAsGuarded(@Nullable
                                                    CGValuedElement cgChild,
                                                    @NonNull
                                                    java.lang.String message)

rewriteAsCast

protected CGValuedElement rewriteAsCast(@Nullable
                                        CGVariableExp cgChild)
Insert a CGCastExp around cgChild.


rewriteAsUnboxed

protected CGValuedElement rewriteAsUnboxed(@Nullable
                                           CGValuedElement cgChild)
Insert a CGUnboxExp around cgChild.


visiting

@Nullable
public java.lang.Object visiting(@NonNull
                                          CGElement visitable)
Description copied from interface: CGModelVisitor
Return the result of visiting a visitable for which no more specific pivot type method is available.


visitCGBuiltInIterationCallExp

@Nullable
public java.lang.Object visitCGBuiltInIterationCallExp(@NonNull
                                                                CGBuiltInIterationCallExp cgElement)
Specified by:
visitCGBuiltInIterationCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGBuiltInIterationCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGConstructorPart

@Nullable
public java.lang.Object visitCGConstructorPart(@NonNull
                                                        CGConstructorPart cgConstructorPart)
Specified by:
visitCGConstructorPart in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGConstructorPart in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGEcoreOperation

@Nullable
public java.lang.Object visitCGEcoreOperation(@NonNull
                                                       CGEcoreOperation cgElement)
Specified by:
visitCGEcoreOperation in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGEcoreOperation in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGEcoreOperationCallExp

@Nullable
public java.lang.Object visitCGEcoreOperationCallExp(@NonNull
                                                              CGEcoreOperationCallExp cgElement)
Specified by:
visitCGEcoreOperationCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGEcoreOperationCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGEcoreOppositePropertyCallExp

@Nullable
public java.lang.Object visitCGEcoreOppositePropertyCallExp(@NonNull
                                                                     CGEcoreOppositePropertyCallExp cgElement)
Specified by:
visitCGEcoreOppositePropertyCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGEcoreOppositePropertyCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGEcorePropertyCallExp

@Nullable
public java.lang.Object visitCGEcorePropertyCallExp(@NonNull
                                                             CGEcorePropertyCallExp cgElement)
Specified by:
visitCGEcorePropertyCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGEcorePropertyCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGExecutorOppositePropertyCallExp

@Nullable
public java.lang.Object visitCGExecutorOppositePropertyCallExp(@NonNull
                                                                        CGExecutorOppositePropertyCallExp cgElement)
Specified by:
visitCGExecutorOppositePropertyCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGExecutorOppositePropertyCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGExecutorPropertyCallExp

@Nullable
public java.lang.Object visitCGExecutorPropertyCallExp(@NonNull
                                                                CGExecutorPropertyCallExp cgElement)
Specified by:
visitCGExecutorPropertyCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGExecutorPropertyCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGElement

@Nullable
public java.lang.Object visitCGElement(@NonNull
                                                CGElement cgElement)
Specified by:
visitCGElement in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGElement in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGIfExp

@Nullable
public java.lang.Object visitCGIfExp(@NonNull
                                              CGIfExp cgElement)
Specified by:
visitCGIfExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGIfExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGIsEqualExp

@Nullable
public java.lang.Object visitCGIsEqualExp(@NonNull
                                                   CGIsEqualExp cgElement)
Specified by:
visitCGIsEqualExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGIsEqualExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGLibraryIterateCallExp

@Nullable
public java.lang.Object visitCGLibraryIterateCallExp(@NonNull
                                                              CGLibraryIterateCallExp cgElement)
Specified by:
visitCGLibraryIterateCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGLibraryIterateCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGLibraryIterationCallExp

@Nullable
public java.lang.Object visitCGLibraryIterationCallExp(@NonNull
                                                                CGLibraryIterationCallExp cgElement)
Specified by:
visitCGLibraryIterationCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGLibraryIterationCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGLibraryOperationCallExp

@Nullable
public java.lang.Object visitCGLibraryOperationCallExp(@NonNull
                                                                CGLibraryOperationCallExp cgElement)
Specified by:
visitCGLibraryOperationCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGLibraryOperationCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGNavigationCallExp

@Nullable
public java.lang.Object visitCGNavigationCallExp(@NonNull
                                                          CGNavigationCallExp cgElement)
Specified by:
visitCGNavigationCallExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGNavigationCallExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGOperation

@Nullable
public java.lang.Object visitCGOperation(@NonNull
                                                  CGOperation cgElement)
Specified by:
visitCGOperation in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGOperation in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGProperty

@Nullable
public java.lang.Object visitCGProperty(@NonNull
                                                 CGProperty cgElement)
Specified by:
visitCGProperty in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGProperty in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>

visitCGVariableExp

@Nullable
public java.lang.Object visitCGVariableExp(@NonNull
                                                    CGVariableExp cgElement)
Specified by:
visitCGVariableExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGVariableExp in class AbstractExtendingCGModelVisitor<java.lang.Object,CodeGenAnalyzer>