@@ -101,12 +101,6 @@ class DefinedExpr extends UnaryOperation, TDefinedExpr {
101101
102102/** A binary operation. */
103103class BinaryOperation extends Operation , TBinaryOperation {
104- private Generated:: Binary g ;
105-
106- BinaryOperation ( ) { g = toGenerated ( this ) }
107-
108- final override string getOperator ( ) { result = g .getOperator ( ) }
109-
110104 final override Expr getAnOperand ( ) {
111105 result = this .getLeftOperand ( ) or result = this .getRightOperand ( )
112106 }
@@ -122,10 +116,28 @@ class BinaryOperation extends Operation, TBinaryOperation {
122116 }
123117
124118 /** Gets the left operand of this binary operation. */
125- final Stmt getLeftOperand ( ) { toGenerated ( result ) = g . getLeft ( ) }
119+ Stmt getLeftOperand ( ) { none ( ) }
126120
127121 /** Gets the right operand of this binary operation. */
128- final Stmt getRightOperand ( ) { toGenerated ( result ) = g .getRight ( ) }
122+ Stmt getRightOperand ( ) { none ( ) }
123+ }
124+
125+ private class BinaryOperationReal extends BinaryOperation {
126+ private Generated:: Binary g ;
127+
128+ BinaryOperationReal ( ) { g = toGenerated ( this ) }
129+
130+ final override string getOperator ( ) { result = g .getOperator ( ) }
131+
132+ final override Stmt getLeftOperand ( ) { toGenerated ( result ) = g .getLeft ( ) }
133+
134+ final override Stmt getRightOperand ( ) { toGenerated ( result ) = g .getRight ( ) }
135+ }
136+
137+ abstract private class BinaryOperationSynth extends BinaryOperation {
138+ final override Stmt getLeftOperand ( ) { synthChild ( this , 0 , result ) }
139+
140+ final override Stmt getRightOperand ( ) { synthChild ( this , 1 , result ) }
129141}
130142
131143/**
@@ -143,6 +155,10 @@ class AddExpr extends BinaryArithmeticOperation, TAddExpr {
143155 final override string getAPrimaryQlClass ( ) { result = "AddExpr" }
144156}
145157
158+ private class AddExprSynth extends AddExpr , BinaryOperationSynth , TAddExprSynth {
159+ final override string getOperator ( ) { result = "+" }
160+ }
161+
146162/**
147163 * A subtract expression.
148164 * ```rb
@@ -153,6 +169,10 @@ class SubExpr extends BinaryArithmeticOperation, TSubExpr {
153169 final override string getAPrimaryQlClass ( ) { result = "SubExpr" }
154170}
155171
172+ private class SubExprSynth extends SubExpr , BinaryOperationSynth , TSubExprSynth {
173+ final override string getOperator ( ) { result = "-" }
174+ }
175+
156176/**
157177 * A multiply expression.
158178 * ```rb
@@ -163,6 +183,10 @@ class MulExpr extends BinaryArithmeticOperation, TMulExpr {
163183 final override string getAPrimaryQlClass ( ) { result = "MulExpr" }
164184}
165185
186+ private class MulExprSynth extends MulExpr , BinaryOperationSynth , TMulExprSynth {
187+ final override string getOperator ( ) { result = "*" }
188+ }
189+
166190/**
167191 * A divide expression.
168192 * ```rb
@@ -173,6 +197,10 @@ class DivExpr extends BinaryArithmeticOperation, TDivExpr {
173197 final override string getAPrimaryQlClass ( ) { result = "DivExpr" }
174198}
175199
200+ private class DivExprSynth extends DivExpr , BinaryOperationSynth , TDivExprSynth {
201+ final override string getOperator ( ) { result = "/" }
202+ }
203+
176204/**
177205 * A modulo expression.
178206 * ```rb
@@ -183,6 +211,10 @@ class ModuloExpr extends BinaryArithmeticOperation, TModuloExpr {
183211 final override string getAPrimaryQlClass ( ) { result = "ModuloExpr" }
184212}
185213
214+ private class ModuloExprSynth extends ModuloExpr , BinaryOperationSynth , TModuloExprSynth {
215+ final override string getOperator ( ) { result = "%" }
216+ }
217+
186218/**
187219 * An exponent expression.
188220 * ```rb
@@ -193,6 +225,10 @@ class ExponentExpr extends BinaryArithmeticOperation, TExponentExpr {
193225 final override string getAPrimaryQlClass ( ) { result = "ExponentExpr" }
194226}
195227
228+ private class ExponentExprSynth extends ExponentExpr , BinaryOperationSynth , TExponentExprSynth {
229+ final override string getOperator ( ) { result = "**" }
230+ }
231+
196232/**
197233 * A binary logical operation.
198234 */
@@ -209,6 +245,10 @@ class LogicalAndExpr extends BinaryLogicalOperation, TLogicalAndExpr {
209245 final override string getAPrimaryQlClass ( ) { result = "LogicalAndExpr" }
210246}
211247
248+ private class LogicalAndExprSynth extends LogicalAndExpr , BinaryOperationSynth , TLogicalAndExprSynth {
249+ final override string getOperator ( ) { result = "&&" }
250+ }
251+
212252/**
213253 * A logical OR operation, using either `or` or `||`.
214254 * ```rb
@@ -220,6 +260,10 @@ class LogicalOrExpr extends BinaryLogicalOperation, TLogicalOrExpr {
220260 final override string getAPrimaryQlClass ( ) { result = "LogicalOrExpr" }
221261}
222262
263+ private class LogicalOrExprSynth extends LogicalOrExpr , BinaryOperationSynth , TLogicalOrExprSynth {
264+ final override string getOperator ( ) { result = "||" }
265+ }
266+
223267/**
224268 * A binary bitwise operation.
225269 */
@@ -235,6 +279,10 @@ class LShiftExpr extends BinaryBitwiseOperation, TLShiftExpr {
235279 final override string getAPrimaryQlClass ( ) { result = "LShiftExpr" }
236280}
237281
282+ private class LShiftExprSynth extends LShiftExpr , BinaryOperationSynth , TLShiftExprSynth {
283+ final override string getOperator ( ) { result = "<<" }
284+ }
285+
238286/**
239287 * A right-shift operation.
240288 * ```rb
@@ -245,6 +293,10 @@ class RShiftExpr extends BinaryBitwiseOperation, TRShiftExpr {
245293 final override string getAPrimaryQlClass ( ) { result = "RShiftExpr" }
246294}
247295
296+ private class RShiftExprSynth extends RShiftExpr , BinaryOperationSynth , TRShiftExprSynth {
297+ final override string getOperator ( ) { result = ">>" }
298+ }
299+
248300/**
249301 * A bitwise AND operation.
250302 * ```rb
@@ -255,6 +307,10 @@ class BitwiseAndExpr extends BinaryBitwiseOperation, TBitwiseAndExpr {
255307 final override string getAPrimaryQlClass ( ) { result = "BitwiseAndExpr" }
256308}
257309
310+ private class BitwiseAndSynthExpr extends BitwiseAndExpr , BinaryOperationSynth , TBitwiseAndExprSynth {
311+ final override string getOperator ( ) { result = "&" }
312+ }
313+
258314/**
259315 * A bitwise OR operation.
260316 * ```rb
@@ -265,6 +321,10 @@ class BitwiseOrExpr extends BinaryBitwiseOperation, TBitwiseOrExpr {
265321 final override string getAPrimaryQlClass ( ) { result = "BitwiseOrExpr" }
266322}
267323
324+ private class BitwiseOrSynthExpr extends BitwiseOrExpr , BinaryOperationSynth , TBitwiseOrExprSynth {
325+ final override string getOperator ( ) { result = "|" }
326+ }
327+
268328/**
269329 * An XOR (exclusive OR) operation.
270330 * ```rb
@@ -275,6 +335,10 @@ class BitwiseXorExpr extends BinaryBitwiseOperation, TBitwiseXorExpr {
275335 final override string getAPrimaryQlClass ( ) { result = "BitwiseXorExpr" }
276336}
277337
338+ private class BitwiseXorSynthExpr extends BitwiseXorExpr , BinaryOperationSynth , TBitwiseXorExprSynth {
339+ final override string getOperator ( ) { result = "^" }
340+ }
341+
278342/**
279343 * A comparison operation. That is, either an equality operation or a
280344 * relational operation.
@@ -455,17 +519,25 @@ class Assignment extends Operation, TAssignment {
455519 * ```
456520 */
457521class AssignExpr extends Assignment , TAssignExpr {
522+ final override string getOperator ( ) { result = "=" }
523+
524+ final override string getAPrimaryQlClass ( ) { result = "AssignExpr" }
525+ }
526+
527+ private class AssignExprReal extends AssignExpr , TAssignExprReal {
458528 private Generated:: Assignment g ;
459529
460- AssignExpr ( ) { this = TAssignExpr ( g ) }
530+ AssignExprReal ( ) { this = TAssignExprReal ( g ) }
461531
462532 final override Pattern getLeftOperand ( ) { toGenerated ( result ) = g .getLeft ( ) }
463533
464534 final override Expr getRightOperand ( ) { toGenerated ( result ) = g .getRight ( ) }
535+ }
465536
466- final override string getOperator ( ) { result = "=" }
537+ private class AssignExprSynth extends AssignExpr , TAssignExprSynth {
538+ final override Pattern getLeftOperand ( ) { synthChild ( this , 0 , result ) }
467539
468- override string getAPrimaryQlClass ( ) { result = "AssignExpr" }
540+ final override Expr getRightOperand ( ) { synthChild ( this , 1 , result ) }
469541}
470542
471543/**
0 commit comments