JS: introduce Expr::getUnderlyingReference

This commit is contained in:
Esben Sparre Andreasen
2018-10-15 09:40:36 +02:00
parent 8fc89e2e36
commit 376245da06
3 changed files with 25 additions and 0 deletions

View File

@@ -48,6 +48,13 @@ class ExprOrType extends @exprortype, Documentable {
/** Gets this expression or type, with any surrounding parentheses removed. */
ExprOrType stripParens() { result = this }
/**
* Gets the innermost reference that this expression evaluates to, if any.
*/
Expr getUnderlyingReference() {
none()
}
/**
* Gets the innermost expression that this expression evaluates to.
*/
@@ -223,6 +230,10 @@ class ParExpr extends @parexpr, Expr {
result = getExpression().getUnderlyingValue()
}
override Expr getUnderlyingReference() {
result = getExpression().getUnderlyingReference()
}
}
/** A `null` literal. */
@@ -880,6 +891,11 @@ class PropAccess extends @propaccess, Expr {
override ControlFlowNode getFirstControlFlowNode() {
result = getBase().getFirstControlFlowNode()
}
override Expr getUnderlyingReference() {
result = this
}
}
/** A dot expression. */

View File

@@ -1320,6 +1320,10 @@ class TypeAssertion extends Expr, @typeassertion {
result = getExpression().getUnderlyingValue()
}
override Expr getUnderlyingReference() {
result = getExpression().getUnderlyingReference()
}
}
/**

View File

@@ -298,6 +298,11 @@ class VarRef extends @varref, Identifier, BindingPattern, LexicalRef {
override VarRef getABindingVarRef() { result = this }
override predicate isImpure() { none() }
override Expr getUnderlyingReference() {
result = this
}
}
/** An identifier that refers to a variable in a non-declaring position. */