Title: Implementation of a Modular OCL Compiler
1Implementation of a Modular OCL Compiler
2Outline
- Vision
- Features of the Compiler
- Problems with OCL
- Demonstration
- Discussion
3Vision
UML Model
OCL
What happens to the OCL constraints?
4Vision
UML Model
OCL
5Role of the Compiler
context Customer inv cards-gtforAll(printedNamese
lf.name)
public boolean assert() final OclAnyImpl
tudOclNode0Ocl.toOclAnyImpl( Ocl.getFor(this)
) final OclSet tudOclNode1Ocl.toOclSet(tudOcl
Node0.getFeature("cards")) final OclIterator
tudOclIter0tudOclNode1.getIterator() final
OclBooleanEvaluatable tudOclEval0new
OclBooleanEvaluatable() public OclBoolean
evaluate() final OclString tudOclNode2
...tudOclIter0.getValue()...getFeature("printedNam
e") final OclString tudOclNode3Ocl.toOclS
tring(tudOclNode0.getFeature("name"))
final OclBoolean tudOclNode4tudOclNode2.isEqualTo
(tudOclNode3) return tudOclNode4
final OclBoolean tudOclNode5tudOclNode1.f
orAll(tudOclIter0, tudOclEval0) return
tudOclNode5.isTrue()
6Demands
- modular architecture
- adaptable for different target languages
- Java code generator
- configurable normalization steps
- close to specification (OCL 1.3)
7Architecture
parser
OCL
model information
sem. analysis
normalization
target code
code gen.
8Normalization
- faciliates code generation
- no fixed normal form
- configurable normalization steps
- expand multiple iterators ("-gtforAll(i1, i2...")
- insert type information
- expand shorthand for collect
- ...
- configured to suit target language
9problems 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)
10type 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"?
11resume
- OCL compiler is availablehttp//www-st.inf.tu-dre
sden.de/ocl(including Java sources) - code generator for SQL integrity conditions is
being implemented - to do CASE tool integration
- demonstration
12Demonstration
13Demonstration
14Demonstration
15Demonstration
16Demonstration
17Demonstration
18Role of the Compiler
context Customer inv cards-gtforAll(printedNamese
lf.name)
public boolean assert() final OclAnyImpl
tudOclNode0Ocl.toOclAnyImpl( Ocl.getFor(this)
) final OclSet tudOclNode1Ocl.toOclSet(tudOcl
Node0.getFeature("cards")) final OclIterator
tudOclIter0tudOclNode1.getIterator() final
OclBooleanEvaluatable tudOclEval0new
OclBooleanEvaluatable() public OclBoolean
evaluate() final OclString tudOclNode2
...tudOclIter0.getValue()...getFeature("printedNam
e") final OclString tudOclNode3Ocl.toOclS
tring(tudOclNode0.getFeature("name"))
final OclBoolean tudOclNode4tudOclNode2.isEqualTo
(tudOclNode3) return tudOclNode4
final OclBoolean tudOclNode5tudOclNode1.f
orAll(tudOclIter0, tudOclEval0) return
tudOclNode5.isTrue()