@@ -316,26 +316,28 @@ private IR::Instruction accessPathAux(TSsaWithFields base, Field f) {
316
316
)
317
317
}
318
318
319
- abstract class SsaWithFields extends TSsaWithFields {
319
+ class SsaWithFields extends TSsaWithFields {
320
320
/**
321
321
* Gets the SSA variable corresponding to the base of this SSA variable with fields.
322
322
*
323
323
* For example, the SSA variable corresponding to `a` for the SSA variable with fields
324
324
* corresponding to `a.b`.
325
325
*/
326
- abstract SsaVariable getBaseVariable ( ) ;
327
-
328
- /** Gets the type of this SSA variable with fields. */
329
- abstract Type getType ( ) ;
330
-
331
- /** Gets a use in basic block `bb` that refers to this SSA variable with fields. */
332
- abstract IR:: Instruction getAUseIn ( ReachableBasicBlock bb ) ;
326
+ SsaVariable getBaseVariable ( ) {
327
+ this = TRoot ( result )
328
+ or
329
+ exists ( SsaWithFields base , Field f | this = TStep ( base , f ) | result = base .getBaseVariable ( ) )
330
+ }
333
331
334
332
/** Gets a use that refers to this SSA variable with fields. */
335
- IR :: Instruction getAUse ( ) { result = this . getAUseIn ( _ ) }
333
+ DataFlow :: Node getAUse ( ) { this = accessPath ( result . asInstruction ( ) ) }
336
334
337
335
/** Gets a textual representation of this element. */
338
- abstract string toString ( ) ;
336
+ string toString ( ) {
337
+ exists ( SsaVariable var | this = TRoot ( var ) | result = "(" + var + ")" )
338
+ or
339
+ exists ( SsaWithFields base , Field f | this = TStep ( base , f ) | result = base + "." + f .getName ( ) )
340
+ }
339
341
340
342
/**
341
343
* Holds if this element is at the specified location.
@@ -350,35 +352,3 @@ abstract class SsaWithFields extends TSsaWithFields {
350
352
this .getBaseVariable ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
351
353
}
352
354
}
353
-
354
- private class SsaWithFieldsRoot extends SsaWithFields , TRoot {
355
- SsaVariable self ;
356
-
357
- SsaWithFieldsRoot ( ) { this = TRoot ( self ) }
358
-
359
- override SsaVariable getBaseVariable ( ) { result = self }
360
-
361
- override Type getType ( ) { result = self .getType ( ) }
362
-
363
- override IR:: Instruction getAUseIn ( ReachableBasicBlock bb ) { result = self .getAUseIn ( bb ) }
364
-
365
- override string toString ( ) { result = "(" + self .toString ( ) + ")" }
366
- }
367
-
368
- private class SsaWithFieldsStep extends SsaWithFields , TStep {
369
- SsaWithFields base ;
370
- Field f ;
371
-
372
- SsaWithFieldsStep ( ) { this = TStep ( base , f ) }
373
-
374
- override SsaVariable getBaseVariable ( ) { result = base .getBaseVariable ( ) }
375
-
376
- override Type getType ( ) { result = f .getType ( ) }
377
-
378
- override IR:: FieldReadInstruction getAUseIn ( ReachableBasicBlock bb ) {
379
- result .getBase ( ) = base .getAUseIn ( bb ) and
380
- result .getField ( ) = f
381
- }
382
-
383
- override string toString ( ) { result = base .toString ( ) + "." + f .getName ( ) }
384
- }
0 commit comments