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:
OCLinEcoreCodeGenerator.EcoreBoxingAnalyzer

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

A BoxingAnalyzer performs a bottom up tree-traversal inserting CGBoxExp or CGUnboxExp wherever a conversion from boxed to unboxed or vice-versa 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 rewriteAsBoxed(CGValuedElement cgChild)
          Insert a CGBoxExp between cgParent and cgChild.
protected  CGValuedElement rewriteAsGuarded(CGValuedElement cgChild)
           
protected  CGValuedElement rewriteAsUnboxed(CGValuedElement cgChild)
          Insert a CGUnboxExp between cgParent and cgChild.
 java.lang.Object visitCGBuiltInIterationCallExp(CGBuiltInIterationCallExp cgElement)
           
 java.lang.Object visitCGConstructorPart(CGConstructorPart cgConstructorPart)
           
 java.lang.Object visitCGEcoreOperationCallExp(CGEcoreOperationCallExp cgElement)
           
 java.lang.Object visitCGElement(CGElement cgElement)
           
 java.lang.Object visitCGEqualsExp(CGEqualsExp cgElement)
           
 java.lang.Object visitCGExecutorPropertyCallExp(CGExecutorPropertyCallExp cgElement)
           
 java.lang.Object visitCGIfExp(CGIfExp cgElement)
           
 java.lang.Object visitCGLibraryIterateCallExp(CGLibraryIterateCallExp cgElement)
           
 java.lang.Object visitCGLibraryIterationCallExp(CGLibraryIterationCallExp cgElement)
           
 java.lang.Object visitCGLibraryOperationCallExp(CGLibraryOperationCallExp cgElement)
           
 java.lang.Object visitCGOperation(CGOperation cgElement)
           
 java.lang.Object visitCGProperty(CGProperty cgElement)
           
 java.lang.Object visitCGPropertyCallExp(CGPropertyCallExp 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
visitCGBoolean, visitCGBoxExp, visitCGCallExp, visitCGCastParameter, visitCGCatchExp, visitCGClass, visitCGCollectionExp, visitCGCollectionPart, visitCGConstant, visitCGConstantExp, visitCGConstraint, visitCGConstructorExp, visitCGEcoreClassConstructorExp, visitCGEcoreDataTypeConstructorExp, visitCGEcorePropertyCallExp, visitCGElementId, visitCGExecutorCompositionProperty, visitCGExecutorConstructorPart, visitCGExecutorNavigationProperty, visitCGExecutorOperation, visitCGExecutorOperationCallExp, visitCGExecutorOppositeProperty, visitCGExecutorProperty, visitCGExecutorType, visitCGFinalVariable, visitCGGuardExp, visitCGInfinity, visitCGInteger, visitCGInvalid, visitCGIsInvalidExp, visitCGIsUndefinedExp, visitCGIterationCallExp, visitCGIterator, visitCGLetExp, visitCGLibraryPropertyCallExp, visitCGLocalVariable, visitCGModel, visitCGNamedElement, visitCGNull, visitCGOperationCallExp, visitCGPackage, visitCGParameter, visitCGReal, visitCGSettableVariable, visitCGString, visitCGText, visitCGTextParameter, visitCGThrowExp, visitCGTupleExp, visitCGTuplePart, visitCGTuplePartCallExp, visitCGTypedElement, visitCGTypeExp, visitCGTypeId, visitCGUnboxExp, visitCGValuedElement, visitCGVariable, visitCGVariableExp
 
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)

rewriteAsBoxed

protected CGValuedElement rewriteAsBoxed(@Nullable
                                         CGValuedElement cgChild)
Insert a CGBoxExp between cgParent and cgChild.


rewriteAsGuarded

@Nullable
protected CGValuedElement rewriteAsGuarded(@Nullable
                                                    CGValuedElement cgChild)

rewriteAsUnboxed

protected CGValuedElement rewriteAsUnboxed(@Nullable
                                           CGValuedElement cgChild)
Insert a CGUnboxExp between cgParent and 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>

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>

visitCGEqualsExp

@Nullable
public java.lang.Object visitCGEqualsExp(@NonNull
                                                  CGEqualsExp cgElement)
Specified by:
visitCGEqualsExp in interface CGModelVisitor<java.lang.Object>
Overrides:
visitCGEqualsExp 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>

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>

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>

visitCGPropertyCallExp

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