Disambiguate toStrings for nested synthetic local variables

This commit is contained in:
Tom Hvitved
2021-06-04 19:20:11 +02:00
parent 6678ac0347
commit 962768e7c0
6 changed files with 39 additions and 35 deletions

View File

@@ -434,7 +434,11 @@ class LocalVariableSynth extends LocalVariable, TLocalVariableSynth {
LocalVariableSynth() { this = TLocalVariableSynth(n, i) }
final override string getName() { result = "__synth__" + i }
final override string getName() {
exists(int level | level = desugarLevel(n) |
if level > 0 then result = "__synth__" + i + "__" + level else result = "__synth__" + i
)
}
final override Location getLocation() { result = n.getLocation() }

View File

@@ -42,8 +42,8 @@ calls/calls.rb:
# 316| getAnOperand/getRightOperand: [MethodCall] call to []
# 316| getArgument: [IntegerLiteral] 0
# 316| getReceiver: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0
# 316| getStmt: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0__1
# 316| getStmt: [LocalVariableAccess] __synth__0__1
# 316| getStmt: [AssignExpr] ... = ...
# 316| getDesugared: [StmtSequence] ...
# 316| getStmt: [SetterMethodCall] call to bar=
@@ -54,8 +54,8 @@ calls/calls.rb:
# 316| getBegin: [IntegerLiteral] 1
# 316| getEnd: [IntegerLiteral] -2
# 316| getReceiver: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0
# 316| getStmt: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0__1
# 316| getStmt: [LocalVariableAccess] __synth__0__1
# 316| getAnOperand/getLeftOperand: [MethodCall] call to bar
# 316| getStmt: [AssignExpr] ... = ...
# 316| getDesugared: [StmtSequence] ...
@@ -66,9 +66,9 @@ calls/calls.rb:
# 316| getAnOperand/getRightOperand: [MethodCall] call to []
# 316| getArgument: [IntegerLiteral] -1
# 316| getReceiver: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0
# 316| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0__1
# 316| getArgument: [IntegerLiteral] 4
# 316| getStmt: [LocalVariableAccess] __synth__0
# 316| getStmt: [LocalVariableAccess] __synth__0__1
# 316| getAnOperand/getLeftOperand: [ElementReference] ...[...]
# 316| getStmt: [AssignExpr] ... = ...
# 316| getAnOperand/getRightOperand: [SplatExpr] * ...
@@ -96,9 +96,9 @@ calls/calls.rb:
# 317| getBegin: [IntegerLiteral] 1
# 317| getEnd: [IntegerLiteral] -1
# 317| getReceiver: [LocalVariableAccess] __synth__0
# 317| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0
# 317| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0__1
# 317| getArgument: [IntegerLiteral] 5
# 317| getStmt: [LocalVariableAccess] __synth__0
# 317| getStmt: [LocalVariableAccess] __synth__0__1
# 317| getAnOperand/getLeftOperand: [ElementReference] ...[...]
# 317| getStmt: [AssignExpr] ... = ...
# 317| getAnOperand/getRightOperand: [SplatExpr] * ...

View File

@@ -888,7 +888,7 @@ cfg.rb:
#-----| -> __synth__0
# 62| ... = ...
#-----| -> __synth__0
#-----| -> __synth__0__1
# 62| call to []
#-----| -> ... = ...
@@ -914,11 +914,11 @@ cfg.rb:
# 62| * ...
#-----| -> ... = ...
# 62| __synth__0
# 62| __synth__0__1
#-----| -> __synth__0
# 62| y
#-----| -> __synth__0
#-----| -> __synth__0__1
# 62| ... = ...
#-----| -> z
@@ -929,11 +929,11 @@ cfg.rb:
# 62| 0
#-----| -> call to []
# 62| __synth__0
# 62| __synth__0__1
#-----| -> 0
# 62| z
#-----| -> __synth__0
#-----| -> __synth__0__1
# 62| ... = ...
#-----| -> ...
@@ -944,7 +944,7 @@ cfg.rb:
# 62| 1
#-----| -> call to []
# 62| __synth__0
# 62| __synth__0__1
#-----| -> 1
# 62| [...]
@@ -2519,7 +2519,7 @@ desugar.rb:
#-----| -> _ .. _
# 22| call to z
#-----| -> __synth__0
#-----| -> __synth__0__1
# 22| self
#-----| -> call to z
@@ -2534,15 +2534,15 @@ desugar.rb:
#-----| -> -1
# 22| call to bar=
#-----| -> __synth__0
#-----| -> __synth__0__1
# 22| __synth__0
# 22| __synth__0__1
#-----| -> ...
# 22| ... = ...
#-----| -> call to bar=
# 22| __synth__0
# 22| __synth__0__1
#-----| -> __synth__0
# 22| [...]
@@ -2587,7 +2587,7 @@ desugar.rb:
#-----| -> exit m7 (normal)
# 26| ... = ...
#-----| -> __synth__0
#-----| -> __synth__0__1
# 26| call to []
#-----| -> ... = ...
@@ -2616,11 +2616,11 @@ desugar.rb:
# 26| * ...
#-----| -> ... = ...
# 26| __synth__0
# 26| __synth__0__1
#-----| -> __synth__0
# 26| y
#-----| -> __synth__0
#-----| -> __synth__0__1
# 26| ... = ...
#-----| -> z
@@ -2631,11 +2631,11 @@ desugar.rb:
# 26| 0
#-----| -> call to []
# 26| __synth__0
# 26| __synth__0__1
#-----| -> 0
# 26| z
#-----| -> __synth__0
#-----| -> __synth__0__1
# 26| ... = ...
#-----| -> ...
@@ -2646,7 +2646,7 @@ desugar.rb:
# 26| 1
#-----| -> call to []
# 26| __synth__0
# 26| __synth__0__1
#-----| -> 1
# 26| [...]

View File

@@ -45,7 +45,7 @@ definition
| scopes.rb:11:4:11:9 | ... = ... | scopes.rb:7:1:7:1 | a |
| scopes.rb:13:4:13:4 | ... = ... | scopes.rb:7:1:7:1 | a |
| scopes.rb:13:7:13:7 | ... = ... | scopes.rb:13:7:13:7 | b |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 |
| scopes.rb:13:11:13:11 | ... = ... | scopes.rb:13:11:13:11 | c |
| scopes.rb:13:14:13:14 | ... = ... | scopes.rb:13:14:13:14 | d |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 |
@@ -132,8 +132,8 @@ read
| scopes.rb:11:4:11:9 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:12:9:12:9 | a |
| scopes.rb:13:4:13:4 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:14:9:14:9 | a |
| scopes.rb:13:7:13:7 | ... = ... | scopes.rb:13:7:13:7 | b | scopes.rb:15:9:15:9 | b |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:11:13:11 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:14:13:14 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:11:13:11 | __synth__0__1 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:14:13:14 | __synth__0__1 |
| scopes.rb:13:11:13:11 | ... = ... | scopes.rb:13:11:13:11 | c | scopes.rb:16:9:16:9 | c |
| scopes.rb:13:14:13:14 | ... = ... | scopes.rb:13:14:13:14 | d | scopes.rb:17:9:17:9 | d |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 | scopes.rb:13:4:13:4 | __synth__0 |
@@ -218,7 +218,7 @@ firstRead
| scopes.rb:11:4:11:9 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:12:9:12:9 | a |
| scopes.rb:13:4:13:4 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:14:9:14:9 | a |
| scopes.rb:13:7:13:7 | ... = ... | scopes.rb:13:7:13:7 | b | scopes.rb:15:9:15:9 | b |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:11:13:11 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:11:13:11 | __synth__0__1 |
| scopes.rb:13:11:13:11 | ... = ... | scopes.rb:13:11:13:11 | c | scopes.rb:16:9:16:9 | c |
| scopes.rb:13:14:13:14 | ... = ... | scopes.rb:13:14:13:14 | d | scopes.rb:17:9:17:9 | d |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 | scopes.rb:13:4:13:4 | __synth__0 |
@@ -291,7 +291,7 @@ lastRead
| scopes.rb:11:4:11:9 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:12:9:12:9 | a |
| scopes.rb:13:4:13:4 | ... = ... | scopes.rb:7:1:7:1 | a | scopes.rb:14:9:14:9 | a |
| scopes.rb:13:7:13:7 | ... = ... | scopes.rb:13:7:13:7 | b | scopes.rb:15:9:15:9 | b |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:14:13:14 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:14:13:14 | __synth__0__1 |
| scopes.rb:13:11:13:11 | ... = ... | scopes.rb:13:11:13:11 | c | scopes.rb:16:9:16:9 | c |
| scopes.rb:13:14:13:14 | ... = ... | scopes.rb:13:14:13:14 | d | scopes.rb:17:9:17:9 | d |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 | scopes.rb:13:10:13:15 | __synth__0 |
@@ -328,7 +328,7 @@ adjacentReads
| parameters.rb:7:26:7:31 | pizzas | parameters.rb:7:26:7:31 | pizzas | parameters.rb:8:6:8:11 | pizzas | parameters.rb:11:14:11:19 | pizzas |
| parameters.rb:25:15:25:18 | name | parameters.rb:25:15:25:18 | name | parameters.rb:25:40:25:43 | name | parameters.rb:26:8:26:11 | name |
| scopes.rb:9:9:18:3 | <captured> | scopes.rb:7:1:7:1 | a | scopes.rb:10:9:10:9 | a | scopes.rb:11:4:11:4 | a |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:11:13:11 | __synth__0 | scopes.rb:13:14:13:14 | __synth__0 |
| scopes.rb:13:10:13:15 | ... = ... | scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:11:13:11 | __synth__0__1 | scopes.rb:13:14:13:14 | __synth__0__1 |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 | scopes.rb:13:4:13:4 | __synth__0 | scopes.rb:13:7:13:7 | __synth__0 |
| scopes.rb:13:19:13:32 | ... = ... | scopes.rb:13:4:13:32 | __synth__0 | scopes.rb:13:7:13:7 | __synth__0 | scopes.rb:13:10:13:15 | __synth__0 |
| scopes.rb:27:1:27:5 | ... = ... | scopes.rb:27:1:27:1 | x | scopes.rb:28:8:28:8 | x | scopes.rb:31:10:31:10 | x |

View File

@@ -219,7 +219,7 @@ explicitWrite
| scopes.rb:13:4:13:4 | a | scopes.rb:13:4:13:32 | ... = ... |
| scopes.rb:13:7:13:7 | b | scopes.rb:13:4:13:32 | ... = ... |
| scopes.rb:13:7:13:7 | b | scopes.rb:13:7:13:7 | ... = ... |
| scopes.rb:13:10:13:15 | __synth__0 | scopes.rb:13:10:13:15 | ... = ... |
| scopes.rb:13:10:13:15 | __synth__0__1 | scopes.rb:13:10:13:15 | ... = ... |
| scopes.rb:13:11:13:11 | c | scopes.rb:13:4:13:32 | ... = ... |
| scopes.rb:13:11:13:11 | c | scopes.rb:13:11:13:11 | ... = ... |
| scopes.rb:13:14:13:14 | d | scopes.rb:13:4:13:32 | ... = ... |
@@ -343,8 +343,8 @@ readAccess
| scopes.rb:13:4:13:4 | __synth__0 |
| scopes.rb:13:7:13:7 | __synth__0 |
| scopes.rb:13:10:13:15 | __synth__0 |
| scopes.rb:13:11:13:11 | __synth__0 |
| scopes.rb:13:14:13:14 | __synth__0 |
| scopes.rb:13:11:13:11 | __synth__0__1 |
| scopes.rb:13:14:13:14 | __synth__0__1 |
| scopes.rb:14:9:14:9 | a |
| scopes.rb:15:9:15:9 | b |
| scopes.rb:16:9:16:9 | c |

View File

@@ -56,7 +56,7 @@
| scopes.rb:9:14:9:14 | x |
| scopes.rb:13:4:13:32 | __synth__0 |
| scopes.rb:13:7:13:7 | b |
| scopes.rb:13:10:13:15 | __synth__0 |
| scopes.rb:13:10:13:15 | __synth__0__1 |
| scopes.rb:13:11:13:11 | c |
| scopes.rb:13:14:13:14 | d |
| scopes.rb:24:1:24:6 | script |