Simplify, since super tokens are never variable accesses

This commit is contained in:
Nick Rolfe
2021-01-27 18:28:01 +00:00
parent 7ac46bf8f8
commit 70bbeaac3b
2 changed files with 7 additions and 7 deletions

View File

@@ -72,7 +72,9 @@ module SuperCall {
private class SuperTokenCallRange extends SuperCall::Range, @token_super {
final override Generated::Super generated;
SuperTokenCallRange() { vcall(this) and not access(this, _) }
// N.B. `super` tokens can never be accesses, so any vcall with `super` must
// be a call.
SuperTokenCallRange() { vcall(this) }
final override Expr getReceiver() { none() }

View File

@@ -125,10 +125,8 @@ private module Cached {
not scope.(CapturingScope).inherits(name, _)
}
// Token types that can be accesses/vcalls
private class AccessTokenUnion = @token_identifier or @token_super;
private class AccessToken extends Generated::Token, AccessTokenUnion { }
// Token types that can be vcalls
private class VcallToken = @token_identifier or @token_super;
/**
* Holds if `i` is an `identifier` node occurring in the context where it
@@ -144,7 +142,7 @@ private module Cached {
* ```
*/
cached
predicate vcall(AccessToken i) {
predicate vcall(VcallToken i) {
i = any(Generated::ArgumentList x).getChild(_)
or
i = any(Generated::Array x).getChild(_)
@@ -271,7 +269,7 @@ private module Cached {
}
cached
predicate access(AccessToken access, Variable variable) {
predicate access(Generated::Identifier access, Variable variable) {
exists(string name | name = access.getValue() |
variable = enclosingScope(access).getVariable(name) and
not strictlyBefore(access.getLocation(), variable.getLocation()) and