mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
JS: introduce Expr::getUnderlyingReference
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -1320,6 +1320,10 @@ class TypeAssertion extends Expr, @typeassertion {
|
||||
result = getExpression().getUnderlyingValue()
|
||||
}
|
||||
|
||||
override Expr getUnderlyingReference() {
|
||||
result = getExpression().getUnderlyingReference()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user