Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 85772fb49bb8b05dce56c2635832a13af2a1f0fb (plain) (blame)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import  cs : 'generated/MiniOCLCS.ecore#/' 
import  as : '/resource/org.eclipse.qvtd.doc.miniocl/model/MiniOCL.ecore#/' 
import 'MiniOCLFullHelpers.ocl'
import 'MiniOCLFullLookup.ocl'
import 'MiniOCLFullDisambiguation.ocl'
package cs

context ExpCS
def : ast() : as::OCLExpression =
    null

context NavigationExpCS
def : ast() : as::CallExp =
   null
   
context RootCS
def : ast() : as::Root =
as::Root {
	ownedImports = imports.ast(), 
ownedPackages = packages.ast(), 
ownedConstraints = constraints.invariants.ast() 
}
context ImportCS
def : ast() : as::Import =
as::Import {
	alias = if alias = null then null else alias endif, 
uri = uri 
}
context InvariantCS
def : ast() : as::Constraint =
as::Constraint {
	ownedSpecification = as::ExpressionInOCL {
				language = 'OCL' ,
				ownedBody = exp.ast(),
				ownedSelfVar = as::Variable {
							name = 'self' ,
							type = ast().constrainedElement
						}
			}, 
constrainedElement = ast().lookupClass(self.ConstraintsDefCS.typeRef) 
}
context PackageCS
def : ast() : as::Package =
as::Package {
	name = name, 
ownedPackages = packages.ast(), 
ownedClasses = classes.ast() 
}
context ClassCS
def : ast() : as::Class =
as::Class {
	name = name, 
ownedProperties = properties.ast(), 
ownedOperations = operations.ast(), 
superClasses = if _extends->notEmpty() then _extends->collect(x | ast().lookupClass(x)) else OrderedSet { } endif 
}
context OperationCS
def : ast() : as::Operation =
as::Operation {
	name = name, 
type = ast().lookupClass(resultRef), 
ownedParameters = params.ast(), 
ownedBodyExpression = as::ExpressionInOCL {
				language = 'OCL' ,
				ownedBody = _body.ast(),
				ownedSelfVar = as::Variable {
							name = 'self' ,
							type = ast().owningClass
						}
			} 
}
context ParameterCS
def : ast() : as::Variable =
as::Variable {
	name = name, 
type = ast().lookupClass(typeRef) 
}
context PropertyCS
def : ast() : as::Property =
as::Property {
	name = name, 
lowerBound = computeLowerBound(), 
upperBound = computeUpperBound(), 
type = ast().lookupClass(typeRef) 
}
context CallExpCS
def : ast() : as::CallExp =
self.navExp.ast()
context EqualityExpCS
def : ast() : as::OperationCallExp =
as::OperationCallExp {
	ownedSource = left.ast(), 
ownedArguments = right.ast(), 
referredOperation = ast().lookupOperationFrom(ast().ownedSource.type, opName, ast().ownedArguments) 
}
context NameExpCS
def : ast() : as::OCLExpression =
if isOpCallExpWithExplicitSource()
then as::OperationCallExp {
	ownedSource = parentAsCallExpCS()._source.ast(), 
ownedArguments = roundedBrackets.args.ast(), 
referredOperation = ast().lookupOperationFrom(ast().oclAsType(as::OperationCallExp).ownedSource.type, expName, ast().oclAsType(as::OperationCallExp).ownedArguments), 
type = ast().oclAsType(as::OperationCallExp).referredOperation ?. type 
}
else
	if isOpCallExpWithImplicitSource()
	then as::OperationCallExp {
		ownedSource = let referredVar  = ast().lookupVariable(' self' )
		in as::VariableExp {
					referredVariable = referredVar,
					type = referredVar.type
				}
		, 
	ownedArguments = roundedBrackets.args.ast(), 
	referredOperation = ast().lookupOperationFrom(ast().oclAsType(as::OperationCallExp).ownedSource.type, expName, ast().oclAsType(as::OperationCallExp).ownedArguments), 
	type = ast().oclAsType(as::OperationCallExp).referredOperation ?. type 
	}
	else
		if isPropCallExpWithExplicitSource()
		then as::PropertyCallExp {
			ownedSource = parentAsCallExpCS()._source.ast(), 
		referredProperty = ast().lookupPropertyFrom(ast().oclAsType(as::PropertyCallExp).ownedSource.type, expName), 
		type = ast().oclAsType(as::PropertyCallExp).referredProperty ?. type 
		}
		else
			if isVariableExp()
			then as::VariableExp {
				referredVariable = ast().lookupVariable(expName.pathElements->first()), 
			type = ast().oclAsType(as::VariableExp).referredVariable.type 
			}
			else
				if isPropCallExpWithImplicitSource()
				then as::PropertyCallExp {
					ownedSource = let referredVar  = ast().lookupVariable(' self' )
					in as::VariableExp {
								referredVariable = referredVar,
								type = referredVar.type
							}
					, 
				referredProperty = ast().lookupPropertyFrom(ast().oclAsType(as::PropertyCallExp).ownedSource.type, expName), 
				type = ast().oclAsType(as::PropertyCallExp).referredProperty ?. type 
				}
				else
					as::VariableExp {
						referredVariable = null, 
					type = ast().lookupClass(' OclVoid' ) 
					}
				endif
			endif
		endif
	endif
endif
context LetExpCS
def : ast() : as::LetExp =
if singleVarDecl()
then as::LetExp {
	ownedVariable = letVars->at(1).ast(), 
ownedIn = inExp.ast(), 
type = inExp.ast().type 
}
else
	if multipleVarDecls()
	then as::LetExp {
		ownedVariable = letVars->first().ast(), 
	ownedIn = letVars->excluding(letVars->first())->reverse()->iterate(x : LetVarCS ; acc : as::OCLExpression = inExp.ast() |
						as::LetExp {
									ownedVariable = x.ast(),
									ownedIn = acc,
									type = acc.type
								}), 
	type = inExp.ast().type 
	}
	else
		invalid
	endif
endif
context LetVarCS
def : ast() : as::Variable =
as::Variable {
	name = name, 
ownedInitExp = initExp.ast(), 
type = if typeRef <> null then ast().lookupClass(typeRef) else ast().ownedInitExp.type endif 
}
context IterateExpCS
def : ast() : as::IterateExp =
as::IterateExp {
	ownedIterator = itVar.ast(), 
ownedResult = accVar.ast(), 
ownedBody = exp.ast(), 
type = ast().ownedResult.type 
}
context CollectExpCS
def : ast() : as::IteratorExp =
as::IteratorExp {
	iterator = ' collect' , 
ownedIterator = if itVar = null then as::Variable {
				name = ' self' ,
				type = ast().lookupClass(' OclAny' )
			} else itVar.ast() endif, 
ownedBody = exp.ast(), 
type = ast().lookupClass(' Collection' ) 
}
context IteratorVarCS
def : ast() : as::Variable =
as::Variable {
	name = itName, 
type = if itType <> null then ast().lookupClass(itType) else ast().lookupClass(' OclAny' ) endif 
}
context AccVarCS
def : ast() : as::Variable =
as::Variable {
	name = accName, 
ownedInitExp = accInitExp.ast(), 
type = if accType <> null then ast().lookupClass(accType) else ast().ownedInitExp.type endif 
}
context CollectionLiteralExpCS
def : ast() : as::CollectionLiteralExp =
as::CollectionLiteralExp {
	kind = kind, 
ownedParts = parts.ast(), 
type = ast().lookupClass(' Collection' ) 
}
context CollectionLiteralPartCS
def : ast() : as::CollectionLiteralPart =
if withoutLastExpression()
then as::CollectionItem {
	ownedItem = first.ast(), 
type = ast().oclAsType(as::CollectionItem).ownedItem.type 
}
else
	if withLastExpression()
	then as::CollectionRange {
		ownedFirst = first, 
	ownedLast = last, 
	type = ast().oclAsType(as::CollectionRange).ownedFirst.type 
	}
	else
		invalid
	endif
endif
endpackage

Back to the top