Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5f33d27108bedc54123f46926a10fb55dde8395a (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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import 'KiamaAS.ecore#/';
import 'KiamaCS.ecore#/';

transformation KiamaRewrite_qvtp_qvtcas
{
	leftCS imports kiamacs;
	rightAS imports kiamaas;
}

map __root__ in KiamaRewrite_qvtp_qvtcas
{
	var roots : Set(ocl::OclElement) := leftCS.rootObjects();
	var _'«child-NumCS»' : Set(kiamacs::NumCS) := roots->selectByKind(kiamacs::NumCS);
	buffer ji_NumCS1 : Set(kiamacs::NumCS) := _'«child-NumCS»';
	var _'«child-PlusCS»' : Set(kiamacs::PlusCS) := roots->selectByKind(kiamacs::PlusCS);
	buffer ji_PlusCS1 : Set(kiamacs::PlusCS) := _'«child-PlusCS»';
	buffer ji_PlusCS_31 : Set(kiamacs::PlusCS) := _'«child-PlusCS»';
	var _'«child-TopCS»' : Set(kiamacs::TopCS) := roots->selectByKind(kiamacs::TopCS);
	var ji_TopCS1 : Set(kiamacs::TopCS) := _'«child-TopCS»';
	for loop0 : kiamacs::TopCS in ji_TopCS1 {
		call m_TopCS_ast {
			lTopCS iterates loop0;
		}
	}
	for loop0 : kiamacs::TopCS in ji_TopCS1 {
		call r_TopCS_node {
			ji_NumCS appendsTo ji_NumCS1;
			ji_PlusCS appendsTo ji_PlusCS1;
			ji_PlusCS_3 appendsTo ji_PlusCS_31;
			_'«parent»' iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS_31 {
		call r__PlusCS {
			ji_NumCS appendsTo ji_NumCS1;
			ji_PlusCS appendsTo ji_PlusCS1;
			_'«head»' iterates loop0;
		}
	}
	for loop0 : kiamacs::NumCS in ji_NumCS1 {
		call m_NumCS_ast {
			lNumCS iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS1 {
		call m_PlusCS_ast_2 {
			lPlusCS iterates loop0;
		}
	}
	for loop0 : kiamacs::NumCS in ji_NumCS1 {
		call m_NumCS_ast_value_1 {
			lNumCS iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS1 {
		call m_PlusCS_ast_left {
			lPlusCS iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS1 {
		call m_PlusCS_ast_right {
			lPlusCS iterates loop0;
		}
	}
	for loop0 : kiamacs::TopCS in ji_TopCS1 {
		call m_TopCS_ast_node {
			lTopCS iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS1 {
		call m_PlusCS_ast_1 {
			lPlusCS iterates loop0;
		}
	}
	for loop0 : kiamacs::NumCS in ji_NumCS1 {
		call m_NumCS_ast_2 {
			lNumCS iterates loop0;
		}
	}
	for loop0 : kiamacs::PlusCS in ji_PlusCS1 {
		call m_PlusCS_ast {
			lPlusCS iterates loop0;
		}
	}
}

map m_NumCS_ast in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lNumCS : NumCS;
	new:rightAS rNum : Num;
	set lNumCS.ast := rNum;
}

map m_NumCS_ast_2 in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lNumCS : NumCS;
	var ast : ecore::EObject := lNumCS.ast;
	var aNum : kiamaas::Num := ast.oclAsType(kiamaas::Num);
	var oclContainer : ocl::OclElement := aNum.oclContainer;
	var _'oclIsKindOf\nkiamaas::Top' : Boolean := oclContainer.oclIsKindOf(kiamaas::Top);
	var _'if' : Integer := if _'oclIsKindOf\nkiamaas::Top'
	then 0
	else oclContainer.oclAsType(kiamaas::Plus).depth + 1 endif;
	notify set aNum.depth := _'if';
}

map m_NumCS_ast_value_1 in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lNumCS : NumCS;
	var ast : ecore::EObject := lNumCS.ast;
	var value : ecore::EInt := lNumCS.value;
	var aNum : kiamaas::Num := ast.oclAsType(kiamaas::Num);
	notify set aNum.height := 0;
	set aNum.value := value;
}

map m_PlusCS_ast in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lPlusCS : PlusCS;
	var ast : ecore::EObject := lPlusCS.ast;
	var aPlus : kiamaas::Plus := ast.oclAsType(kiamaas::Plus);
	var left : kiamaas::Node := aPlus.left;
	var right : kiamaas::Node := aPlus.right;
	observe kiamaas::Node::height var height : ecore::EIntegerObject := left.height;
	observe kiamaas::Node::height var height1 : ecore::EIntegerObject := right.height;
	var oclAsSet : Set(ecore::EIntegerObject) := height.oclAsSet();
	var including : Set(ecore::EIntegerObject) := oclAsSet->including(height1);
	var max : ecore::EIntegerObject := including->max();
	var _'+' : Integer := max + 1;
	notify set aPlus.height := _'+';
}

map m_PlusCS_ast_1 in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lPlusCS : PlusCS;
	var ast : ecore::EObject := lPlusCS.ast;
	var aPlus : kiamaas::Plus := ast.oclAsType(kiamaas::Plus);
	var oclContainer : ocl::OclElement := aPlus.oclContainer;
	var _'oclIsKindOf\nkiamaas::Top' : Boolean := oclContainer.oclIsKindOf(kiamaas::Top);
	observe kiamaas::Node::depth var _'if' : Integer := if _'oclIsKindOf\nkiamaas::Top'
	then 0
	else oclContainer.oclAsType(kiamaas::Plus).depth + 1 endif;
	notify set aPlus.depth := _'if';
}

map m_PlusCS_ast_2 in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lPlusCS : PlusCS;
	new:rightAS rPlus : Plus;
	set lPlusCS.ast := rPlus;
}

map m_PlusCS_ast_left in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lPlusCS : PlusCS;
	var ast : ecore::EObject := lPlusCS.ast;
	var left : kiamacs::NodeCS := lPlusCS.left;
	var aPlus : kiamaas::Plus := ast.oclAsType(kiamaas::Plus);
	var ast1 : ecore::EObject := left.ast;
	var aNode : kiamaas::Node := ast1.oclAsType(kiamaas::Node);
	set aPlus.left := aNode;
}

map m_PlusCS_ast_right in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lPlusCS : PlusCS;
	var ast : ecore::EObject := lPlusCS.ast;
	var right : kiamacs::NodeCS := lPlusCS.right;
	var aPlus : kiamaas::Plus := ast.oclAsType(kiamaas::Plus);
	var ast1 : ecore::EObject := right.ast;
	var aNode : kiamaas::Node := ast1.oclAsType(kiamaas::Node);
	set aPlus.right := aNode;
}

map m_TopCS_ast in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lTopCS : TopCS;
	new:rightAS rTop : Top;
	set lTopCS.ast := rTop;
}

map m_TopCS_ast_node in KiamaRewrite_qvtp_qvtcas
{
	guard:leftCS lTopCS : TopCS;
	var ast : ecore::EObject := lTopCS.ast;
	var node : kiamacs::NodeCS := lTopCS.node;
	var aTop : kiamaas::Top := ast.oclAsType(kiamaas::Top);
	var ast1 : ecore::EObject := node.ast;
	var aNode : kiamaas::Node := ast1.oclAsType(kiamaas::Node);
	set aTop.node := aNode;
}

map r_PlusCS_left in KiamaRewrite_qvtp_qvtcas
{
	append ji_PlusCS : Set(kiamacs::PlusCS);
	append ji_NumCS : Set(kiamacs::NumCS);
	in:leftCS _'«parent»' : PlusCS;
	var allChildren : Set(kiamacs::NodeCS) := _'«parent»'.left.oclAsSet();
	var _'«child-PlusCS»' : Set(kiamacs::PlusCS) := allChildren->selectByKind(kiamacs::PlusCS);
	var _'«child-NumCS»' : Set(kiamacs::NumCS) := allChildren->selectByKind(kiamacs::NumCS);
	add ji_PlusCS += _'«child-PlusCS»';
	add ji_NumCS += _'«child-NumCS»';
	for aChild : kiamacs::PlusCS in _'«child-PlusCS»' {
		call r_PlusCS_left {
			_'«parent»' uses aChild;
			ji_PlusCS appendsTo ji_PlusCS;
			ji_NumCS appendsTo ji_NumCS;
		}
	}
}

map r_PlusCS_right in KiamaRewrite_qvtp_qvtcas
{
	append ji_PlusCS : Set(kiamacs::PlusCS);
	append ji_NumCS : Set(kiamacs::NumCS);
	in:leftCS _'«parent»' : PlusCS;
	var allChildren : Set(kiamacs::NodeCS) := _'«parent»'.right.oclAsSet();
	var _'«child-PlusCS»' : Set(kiamacs::PlusCS) := allChildren->selectByKind(kiamacs::PlusCS);
	var _'«child-NumCS»' : Set(kiamacs::NumCS) := allChildren->selectByKind(kiamacs::NumCS);
	add ji_PlusCS += _'«child-PlusCS»';
	add ji_NumCS += _'«child-NumCS»';
	for aChild : kiamacs::PlusCS in _'«child-PlusCS»' {
		call r_PlusCS_right {
			_'«parent»' uses aChild;
			ji_PlusCS appendsTo ji_PlusCS;
			ji_NumCS appendsTo ji_NumCS;
		}
	}
}

map r_TopCS_node in KiamaRewrite_qvtp_qvtcas
{
	append ji_PlusCS : Set(kiamacs::PlusCS);
	append ji_PlusCS_3 : Set(kiamacs::PlusCS);
	append ji_NumCS : Set(kiamacs::NumCS);
	guard:leftCS _'«parent»' : TopCS;
	var allChildren : Set(kiamacs::NodeCS) := _'«parent»'.node.oclAsSet();
	var _'«child-PlusCS»' : Set(kiamacs::PlusCS) := allChildren->selectByKind(kiamacs::PlusCS);
	var _'«child-NumCS»' : Set(kiamacs::NumCS) := allChildren->selectByKind(kiamacs::NumCS);
	add ji_PlusCS += _'«child-PlusCS»';
	add ji_PlusCS_3 += _'«child-PlusCS»';
	add ji_NumCS += _'«child-NumCS»';
}

strict map r__PlusCS in KiamaRewrite_qvtp_qvtcas
{
	append ji_PlusCS : Set(kiamacs::PlusCS);
	append ji_NumCS : Set(kiamacs::NumCS);
	guard:leftCS _'«head»' : PlusCS;
	buffer _'«local»' : Set(kiamacs::PlusCS);
	buffer _'«new»' : Set(kiamacs::PlusCS);
	call r_PlusCS_left {
		ji_NumCS appendsTo ji_NumCS;
		 ji_PlusCS appendsTo _'«local»';
		_'«parent»' uses _'«head»';
	}
	call r_PlusCS_right {
		ji_NumCS appendsTo ji_NumCS;
		 ji_PlusCS appendsTo _'«local»';
		_'«parent»' uses _'«head»';
	}
	add _'«new»' += _'«local»'->excludingAll(ji_PlusCS);
	add ji_PlusCS += _'«new»';
	for loop0 : kiamacs::PlusCS in _'«new»' {
		call r__PlusCS {
			ji_NumCS appendsTo ji_NumCS;
			ji_PlusCS appendsTo ji_PlusCS;
			_'«head»' iterates  loop0;
		}
	}
}

Back to the top