1 / 18

Implementation of a Modular OCL Compiler

Implementation of a Modular OCL Compiler. Frank Finger TU Dresden. Outline. Vision Features of the Compiler Problems with OCL Demonstration Discussion. Java Code Generator. public class Customer { ... }. Vision. UML Model. OCL. What happens to the OCL constraints?.

Download Presentation

Implementation of a Modular OCL Compiler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Implementation of a Modular OCL Compiler Frank Finger TU Dresden

  2. Outline • Vision • Features of the Compiler • Problems with OCL • Demonstration • Discussion

  3. Java Code Generator public class Customer { ... } Vision UML Model OCL What happens to the OCL constraints?

  4. Java Code Generator OCL to Java Generator public class Customer { ... public boolean assert() { ... } } Vision UML Model OCL

  5. Role of the Compiler context Customer inv: cards->forAll(printedName=self.name) public boolean assert() { final OclAnyImpl tudOclNode0=Ocl.toOclAnyImpl( Ocl.getFor(this) ); final OclSet tudOclNode1=Ocl.toOclSet(tudOclNode0.getFeature("cards")); final OclIterator tudOclIter0=tudOclNode1.getIterator(); final OclBooleanEvaluatable tudOclEval0=new OclBooleanEvaluatable() { public OclBoolean evaluate() { final OclString tudOclNode2= ...tudOclIter0.getValue()...getFeature("printedName"); final OclString tudOclNode3=Ocl.toOclString(tudOclNode0.getFeature("name")); final OclBoolean tudOclNode4=tudOclNode2.isEqualTo(tudOclNode3); return tudOclNode4; } }; final OclBoolean tudOclNode5=tudOclNode1.forAll(tudOclIter0, tudOclEval0); return tudOclNode5.isTrue(); }

  6. Demands • modular architecture • adaptable for different target languages • Java code generator • configurable normalization steps • close to specification (OCL 1.3)

  7. Architecture parser OCL model information sem. analysis normalization target code code gen.

  8. Normalization • faciliates code generation • no fixed normal form • configurable normalization steps • expand multiple iterators ("->forAll(i1, i2|...") • insert type information • expand shorthand for collect • ... • configured to suit target language

  9. problems with OCL • Are keywords reserved? (issue 3138) • Can type names begin with a lower-case character? (issue posted) • Which expressions may contain let expressions? (issue 3148) • What happens if the value of a constraint is undefined? (no issue so far)(true / false / malformed constraint)

  10. X Y A B type checking problems • empty collections • equality is defined on arbitrary operands • semantics of qualifiers (7.5.5 vs. 7.5.7) • What is the type of "if ... then a else b endif"?

  11. resume • OCL compiler is availablehttp://www-st.inf.tu-dresden.de/ocl(including Java sources) • code generator for SQL integrity conditions is being implemented • to do: CASE tool integration • demonstration

  12. Demonstration

  13. Demonstration

  14. Demonstration

  15. Demonstration

  16. Demonstration

  17. Demonstration

  18. Role of the Compiler context Customer inv: cards->forAll(printedName=self.name) public boolean assert() { final OclAnyImpl tudOclNode0=Ocl.toOclAnyImpl( Ocl.getFor(this) ); final OclSet tudOclNode1=Ocl.toOclSet(tudOclNode0.getFeature("cards")); final OclIterator tudOclIter0=tudOclNode1.getIterator(); final OclBooleanEvaluatable tudOclEval0=new OclBooleanEvaluatable() { public OclBoolean evaluate() { final OclString tudOclNode2= ...tudOclIter0.getValue()...getFeature("printedName"); final OclString tudOclNode3=Ocl.toOclString(tudOclNode0.getFeature("name")); final OclBoolean tudOclNode4=tudOclNode2.isEqualTo(tudOclNode3); return tudOclNode4; } }; final OclBoolean tudOclNode5=tudOclNode1.forAll(tudOclIter0, tudOclEval0); return tudOclNode5.isTrue(); }

More Related