@@ -8,48 +8,36 @@ private import internal.Operation
8
8
*
9
9
* This is the QL root class for all operations.
10
10
*/
11
- class Operation extends Expr , TOperation {
11
+ class Operation extends Expr instanceof OperationImpl {
12
12
/** Gets the operator of this operation. */
13
- string getOperator ( ) { none ( ) }
13
+ final string getOperator ( ) { result = super . getOperatorImpl ( ) }
14
14
15
15
/** Gets an operand of this operation. */
16
- Expr getAnOperand ( ) { none ( ) }
16
+ final Expr getAnOperand ( ) { result = super . getAnOperandImpl ( ) }
17
17
18
18
override AstNode getAChild ( string pred ) {
19
- result = super .getAChild ( pred )
19
+ result = Expr . super .getAChild ( pred )
20
20
or
21
21
pred = "getAnOperand" and result = this .getAnOperand ( )
22
22
}
23
23
}
24
24
25
25
/** A unary operation. */
26
- class UnaryOperation extends Operation , TUnaryOperation {
26
+ class UnaryOperation extends Operation , MethodCall instanceof UnaryOperationImpl {
27
27
/** Gets the operand of this unary operation. */
28
- Expr getOperand ( ) { none ( ) }
29
-
30
- final override Expr getAnOperand ( ) { result = this .getOperand ( ) }
28
+ final Expr getOperand ( ) { result = super .getOperandImpl ( ) }
31
29
32
30
final override AstNode getAChild ( string pred ) {
33
- result = super .getAChild ( pred )
31
+ result = Operation . super .getAChild ( pred )
34
32
or
35
33
pred = "getOperand" and result = this .getOperand ( )
36
34
}
37
35
38
36
final override string toString ( ) { result = this .getOperator ( ) + " ..." }
39
37
}
40
38
41
- private class UnaryOperationGenerated extends UnaryOperation , TUnaryOperation {
42
- private Ruby:: Unary g ;
43
-
44
- UnaryOperationGenerated ( ) { g = toGenerated ( this ) }
45
-
46
- final override Expr getOperand ( ) { toGenerated ( result ) = g .getOperand ( ) }
47
-
48
- final override string getOperator ( ) { result = g .getOperator ( ) }
49
- }
50
-
51
39
/** A unary logical operation. */
52
- class UnaryLogicalOperation extends UnaryOperationGenerated , TUnaryLogicalOperation { }
40
+ class UnaryLogicalOperation extends UnaryOperation , TUnaryLogicalOperation { }
53
41
54
42
/**
55
43
* A logical NOT operation, using either `!` or `not`.
@@ -63,7 +51,7 @@ class NotExpr extends UnaryLogicalOperation, TNotExpr {
63
51
}
64
52
65
53
/** A unary arithmetic operation. */
66
- class UnaryArithmeticOperation extends UnaryOperationGenerated , TUnaryArithmeticOperation { }
54
+ class UnaryArithmeticOperation extends UnaryOperation , TUnaryArithmeticOperation { }
67
55
68
56
/**
69
57
* A unary plus expression.
@@ -92,10 +80,6 @@ class UnaryMinusExpr extends UnaryArithmeticOperation, TUnaryMinusExpr {
92
80
* ```
93
81
*/
94
82
class SplatExpr extends UnaryOperation , TSplatExpr {
95
- final override Expr getOperand ( ) { result = this .( SplatExprImpl ) .getOperandImpl ( ) }
96
-
97
- final override string getOperator ( ) { result = "*" }
98
-
99
83
final override string getAPrimaryQlClass ( ) { result = "SplatExpr" }
100
84
}
101
85
@@ -110,10 +94,6 @@ class HashSplatExpr extends UnaryOperation, THashSplatExpr {
110
94
111
95
HashSplatExpr ( ) { this = THashSplatExpr ( g ) }
112
96
113
- final override Expr getOperand ( ) { toGenerated ( result ) = g .getChild ( ) }
114
-
115
- final override string getOperator ( ) { result = "**" }
116
-
117
97
final override string getAPrimaryQlClass ( ) { result = "HashSplatExpr" }
118
98
}
119
99
@@ -141,44 +121,22 @@ class DefinedExpr extends UnaryOperation, TDefinedExpr {
141
121
}
142
122
143
123
/** A binary operation. */
144
- class BinaryOperation extends Operation , TBinaryOperation {
145
- final override Expr getAnOperand ( ) {
146
- result = this .getLeftOperand ( ) or result = this .getRightOperand ( )
147
- }
148
-
124
+ class BinaryOperation extends Operation , MethodCall instanceof BinaryOperationImpl {
149
125
final override string toString ( ) { result = "... " + this .getOperator ( ) + " ..." }
150
126
151
127
override AstNode getAChild ( string pred ) {
152
- result = super .getAChild ( pred )
128
+ result = Operation . super .getAChild ( pred )
153
129
or
154
130
pred = "getLeftOperand" and result = this .getLeftOperand ( )
155
131
or
156
132
pred = "getRightOperand" and result = this .getRightOperand ( )
157
133
}
158
134
159
135
/** Gets the left operand of this binary operation. */
160
- Stmt getLeftOperand ( ) { none ( ) }
136
+ final Stmt getLeftOperand ( ) { result = super . getLeftOperandImpl ( ) }
161
137
162
138
/** Gets the right operand of this binary operation. */
163
- Stmt getRightOperand ( ) { none ( ) }
164
- }
165
-
166
- private class BinaryOperationReal extends BinaryOperation {
167
- private Ruby:: Binary g ;
168
-
169
- BinaryOperationReal ( ) { g = toGenerated ( this ) }
170
-
171
- final override string getOperator ( ) { result = g .getOperator ( ) }
172
-
173
- final override Stmt getLeftOperand ( ) { toGenerated ( result ) = g .getLeft ( ) }
174
-
175
- final override Stmt getRightOperand ( ) { toGenerated ( result ) = g .getRight ( ) }
176
- }
177
-
178
- abstract private class BinaryOperationSynth extends BinaryOperation {
179
- final override Stmt getLeftOperand ( ) { synthChild ( this , 0 , result ) }
180
-
181
- final override Stmt getRightOperand ( ) { synthChild ( this , 1 , result ) }
139
+ final Stmt getRightOperand ( ) { result = super .getRightOperandImpl ( ) }
182
140
}
183
141
184
142
/**
@@ -196,10 +154,6 @@ class AddExpr extends BinaryArithmeticOperation, TAddExpr {
196
154
final override string getAPrimaryQlClass ( ) { result = "AddExpr" }
197
155
}
198
156
199
- private class AddExprSynth extends AddExpr , BinaryOperationSynth , TAddExprSynth {
200
- final override string getOperator ( ) { result = "+" }
201
- }
202
-
203
157
/**
204
158
* A subtract expression.
205
159
* ```rb
@@ -210,10 +164,6 @@ class SubExpr extends BinaryArithmeticOperation, TSubExpr {
210
164
final override string getAPrimaryQlClass ( ) { result = "SubExpr" }
211
165
}
212
166
213
- private class SubExprSynth extends SubExpr , BinaryOperationSynth , TSubExprSynth {
214
- final override string getOperator ( ) { result = "-" }
215
- }
216
-
217
167
/**
218
168
* A multiply expression.
219
169
* ```rb
@@ -224,10 +174,6 @@ class MulExpr extends BinaryArithmeticOperation, TMulExpr {
224
174
final override string getAPrimaryQlClass ( ) { result = "MulExpr" }
225
175
}
226
176
227
- private class MulExprSynth extends MulExpr , BinaryOperationSynth , TMulExprSynth {
228
- final override string getOperator ( ) { result = "*" }
229
- }
230
-
231
177
/**
232
178
* A divide expression.
233
179
* ```rb
@@ -238,10 +184,6 @@ class DivExpr extends BinaryArithmeticOperation, TDivExpr {
238
184
final override string getAPrimaryQlClass ( ) { result = "DivExpr" }
239
185
}
240
186
241
- private class DivExprSynth extends DivExpr , BinaryOperationSynth , TDivExprSynth {
242
- final override string getOperator ( ) { result = "/" }
243
- }
244
-
245
187
/**
246
188
* A modulo expression.
247
189
* ```rb
@@ -252,10 +194,6 @@ class ModuloExpr extends BinaryArithmeticOperation, TModuloExpr {
252
194
final override string getAPrimaryQlClass ( ) { result = "ModuloExpr" }
253
195
}
254
196
255
- private class ModuloExprSynth extends ModuloExpr , BinaryOperationSynth , TModuloExprSynth {
256
- final override string getOperator ( ) { result = "%" }
257
- }
258
-
259
197
/**
260
198
* An exponent expression.
261
199
* ```rb
@@ -266,10 +204,6 @@ class ExponentExpr extends BinaryArithmeticOperation, TExponentExpr {
266
204
final override string getAPrimaryQlClass ( ) { result = "ExponentExpr" }
267
205
}
268
206
269
- private class ExponentExprSynth extends ExponentExpr , BinaryOperationSynth , TExponentExprSynth {
270
- final override string getOperator ( ) { result = "**" }
271
- }
272
-
273
207
/**
274
208
* A binary logical operation.
275
209
*/
@@ -286,10 +220,6 @@ class LogicalAndExpr extends BinaryLogicalOperation, TLogicalAndExpr {
286
220
final override string getAPrimaryQlClass ( ) { result = "LogicalAndExpr" }
287
221
}
288
222
289
- private class LogicalAndExprSynth extends LogicalAndExpr , BinaryOperationSynth , TLogicalAndExprSynth {
290
- final override string getOperator ( ) { result = "&&" }
291
- }
292
-
293
223
/**
294
224
* A logical OR operation, using either `or` or `||`.
295
225
* ```rb
@@ -301,10 +231,6 @@ class LogicalOrExpr extends BinaryLogicalOperation, TLogicalOrExpr {
301
231
final override string getAPrimaryQlClass ( ) { result = "LogicalOrExpr" }
302
232
}
303
233
304
- private class LogicalOrExprSynth extends LogicalOrExpr , BinaryOperationSynth , TLogicalOrExprSynth {
305
- final override string getOperator ( ) { result = "||" }
306
- }
307
-
308
234
/**
309
235
* A binary bitwise operation.
310
236
*/
@@ -320,10 +246,6 @@ class LShiftExpr extends BinaryBitwiseOperation, TLShiftExpr {
320
246
final override string getAPrimaryQlClass ( ) { result = "LShiftExpr" }
321
247
}
322
248
323
- private class LShiftExprSynth extends LShiftExpr , BinaryOperationSynth , TLShiftExprSynth {
324
- final override string getOperator ( ) { result = "<<" }
325
- }
326
-
327
249
/**
328
250
* A right-shift operation.
329
251
* ```rb
@@ -334,10 +256,6 @@ class RShiftExpr extends BinaryBitwiseOperation, TRShiftExpr {
334
256
final override string getAPrimaryQlClass ( ) { result = "RShiftExpr" }
335
257
}
336
258
337
- private class RShiftExprSynth extends RShiftExpr , BinaryOperationSynth , TRShiftExprSynth {
338
- final override string getOperator ( ) { result = ">>" }
339
- }
340
-
341
259
/**
342
260
* A bitwise AND operation.
343
261
* ```rb
@@ -348,10 +266,6 @@ class BitwiseAndExpr extends BinaryBitwiseOperation, TBitwiseAndExpr {
348
266
final override string getAPrimaryQlClass ( ) { result = "BitwiseAndExpr" }
349
267
}
350
268
351
- private class BitwiseAndSynthExpr extends BitwiseAndExpr , BinaryOperationSynth , TBitwiseAndExprSynth {
352
- final override string getOperator ( ) { result = "&" }
353
- }
354
-
355
269
/**
356
270
* A bitwise OR operation.
357
271
* ```rb
@@ -362,10 +276,6 @@ class BitwiseOrExpr extends BinaryBitwiseOperation, TBitwiseOrExpr {
362
276
final override string getAPrimaryQlClass ( ) { result = "BitwiseOrExpr" }
363
277
}
364
278
365
- private class BitwiseOrSynthExpr extends BitwiseOrExpr , BinaryOperationSynth , TBitwiseOrExprSynth {
366
- final override string getOperator ( ) { result = "|" }
367
- }
368
-
369
279
/**
370
280
* An XOR (exclusive OR) operation.
371
281
* ```rb
@@ -376,10 +286,6 @@ class BitwiseXorExpr extends BinaryBitwiseOperation, TBitwiseXorExpr {
376
286
final override string getAPrimaryQlClass ( ) { result = "BitwiseXorExpr" }
377
287
}
378
288
379
- private class BitwiseXorSynthExpr extends BitwiseXorExpr , BinaryOperationSynth , TBitwiseXorExprSynth {
380
- final override string getOperator ( ) { result = "^" }
381
- }
382
-
383
289
/**
384
290
* A comparison operation. That is, either an equality operation or a
385
291
* relational operation.
@@ -531,21 +437,17 @@ class NoRegExpMatchExpr extends BinaryOperation, TNoRegExpMatchExpr {
531
437
*
532
438
* This is a QL base class for all assignments.
533
439
*/
534
- class Assignment extends Operation , TAssignment {
440
+ class Assignment extends Operation instanceof AssignmentImpl {
535
441
/** Gets the left hand side of this assignment. */
536
- final Pattern getLeftOperand ( ) { result = this . ( AssignmentImpl ) .getLeftOperandImpl ( ) }
442
+ final Pattern getLeftOperand ( ) { result = super .getLeftOperandImpl ( ) }
537
443
538
444
/** Gets the right hand side of this assignment. */
539
- final Expr getRightOperand ( ) { result = this .( AssignmentImpl ) .getRightOperandImpl ( ) }
540
-
541
- final override Expr getAnOperand ( ) {
542
- result = this .getLeftOperand ( ) or result = this .getRightOperand ( )
543
- }
445
+ final Expr getRightOperand ( ) { result = super .getRightOperandImpl ( ) }
544
446
545
447
final override string toString ( ) { result = "... " + this .getOperator ( ) + " ..." }
546
448
547
449
override AstNode getAChild ( string pred ) {
548
- result = super .getAChild ( pred )
450
+ result = Operation . super .getAChild ( pred )
549
451
or
550
452
pred = "getLeftOperand" and result = getLeftOperand ( )
551
453
or
@@ -560,21 +462,13 @@ class Assignment extends Operation, TAssignment {
560
462
* ```
561
463
*/
562
464
class AssignExpr extends Assignment , TAssignExpr {
563
- final override string getOperator ( ) { result = "=" }
564
-
565
465
final override string getAPrimaryQlClass ( ) { result = "AssignExpr" }
566
466
}
567
467
568
468
/**
569
469
* A binary assignment operation other than `=`.
570
470
*/
571
- class AssignOperation extends Assignment , TAssignOperation {
572
- Ruby:: OperatorAssignment g ;
573
-
574
- AssignOperation ( ) { g = toGenerated ( this ) }
575
-
576
- final override string getOperator ( ) { result = g .getOperator ( ) }
577
- }
471
+ class AssignOperation extends Assignment instanceof AssignOperationImpl { }
578
472
579
473
/**
580
474
* An arithmetic assignment operation: `+=`, `-=`, `*=`, `/=`, `**=`, and `%=`.
0 commit comments