1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
import 'SourceMM1.ecore'
import 'TargetMM1.ecore'
import 'SourceDisambiguation.ocl'
import 'TargetLookup.ocl'
package source
context SElement
def : ast() : target::Visitable =
invalid -- To be overriden by subtypes
context SRoot
def : ast() : target::TRoot =
target::TRoot {
ownedA = ownedX.ast()
}
context X
def : ast() : target::A =
if disambiguatesToA1()
then target::A1 {
name = name,
ownsB = ownsY.oclAsType(Y1).ast()
}
else if disambiguatesToA2()
then target::A2 {
name = name,
ownsC = ownsY.oclAsType(Y2).ast()
}
else target::A3 {
name = name,
ownsC = ownsY.oclAsType(Y2).ast()
}
endif endif
context Y1
def : ast() : target::B =
target::B {
ownsD = ownsZ.ast(),
name = name
}
context Y2
def : ast() : target::C =
target::C {
ownsD = ownsZ.ast(),
name = name
}
context Z
def : ast() : target::D =
if toY.oclIsKindOf(Y1)
then target::D {
toA = toY.oclAsType(Y1).ast().toA1,
refsB = if refers = null
then null
else refers.ast().oclAsType(target::B)
endif
}
else target::D {
toA = toY.oclAsType(Y2).ast().toA2,
refsC = if refers = null
then null
else refers.ast().oclAsType(target::C)
endif
}
endif
context PathNameCS
def : ast() : target::NamedElement =
path->at(path->size()).ast()
context PathElementCS
def : ast() : target::NamedElement =
let path = pathName.path,
lookupContext = pathName.oclContainer().oclAsType(SElement).ast(),
first = path->at(1),
last = path->at(path->size())
in if self = first -- A lookup for the first path element, will be non local lookup
then if self = last
then lookupContext._lookupNamedElement(self, false)
else lookupContext._lookupNamespace(self, false)
endif
else -- else, we will perform a local lookup in the referred element of the previous PathElementCS
let prevPathElement = path->at(path->indexOf(self)-1)
in if self = last
then prevPathElement.ast()._lookupNamedElement(self, true)
else prevPathElement.ast()._lookupNamespace(self, true)
endif
endif
endpackage
|