@@ -28,49 +28,51 @@ private import Expressions.ExprHasNoEffect
2828class AmdModuleDefinition extends CallExpr {
2929 AmdModuleDefinition ( ) {
3030 inVoidContext ( this ) and
31- getCallee ( ) .( GlobalVarAccess ) .getName ( ) = "define" and
32- exists ( int n | n = getNumArgument ( ) |
31+ this . getCallee ( ) .( GlobalVarAccess ) .getName ( ) = "define" and
32+ exists ( int n | n = this . getNumArgument ( ) |
3333 n = 1
3434 or
35- n = 2 and getArgument ( 0 ) instanceof ArrayExpr
35+ n = 2 and this . getArgument ( 0 ) instanceof ArrayExpr
3636 or
37- n = 3 and getArgument ( 0 ) instanceof ConstantString and getArgument ( 1 ) instanceof ArrayExpr
37+ n = 3 and
38+ this .getArgument ( 0 ) instanceof ConstantString and
39+ this .getArgument ( 1 ) instanceof ArrayExpr
3840 )
3941 }
4042
4143 /** Gets the array of module dependencies, if any. */
4244 ArrayExpr getDependencies ( ) {
43- result = getArgument ( 0 ) or
44- result = getArgument ( 1 )
45+ result = this . getArgument ( 0 ) or
46+ result = this . getArgument ( 1 )
4547 }
4648
4749 /** Gets the `i`th dependency of this module definition. */
48- PathExpr getDependency ( int i ) { result = getDependencies ( ) .getElement ( i ) }
50+ PathExpr getDependency ( int i ) { result = this . getDependencies ( ) .getElement ( i ) }
4951
5052 /** Gets a dependency of this module definition. */
5153 PathExpr getADependency ( ) {
52- result = getDependency ( _) or
53- result = getARequireCall ( ) .getAnArgument ( )
54+ result = this . getDependency ( _) or
55+ result = this . getARequireCall ( ) .getAnArgument ( )
5456 }
5557
5658 /**
5759 * Gets a data flow node containing the factory value of this module definition.
5860 */
5961 pragma [ nomagic]
6062 DataFlow:: SourceNode getFactoryNode ( ) {
61- result = getFactoryNodeInternal ( ) and
63+ result = this . getFactoryNodeInternal ( ) and
6264 result instanceof DataFlow:: ValueNode
6365 }
6466
6567 private DataFlow:: Node getFactoryNodeInternal ( ) {
6668 // To avoid recursion, this should not depend on `SourceNode`.
67- result = DataFlow:: valueNode ( getLastArgument ( ) ) or
68- result = getFactoryNodeInternal ( ) .getAPredecessor ( )
69+ result = DataFlow:: valueNode ( this . getLastArgument ( ) ) or
70+ result = this . getFactoryNodeInternal ( ) .getAPredecessor ( )
6971 }
7072
7173 /** Gets the expression defining this module. */
7274 Expr getModuleExpr ( ) {
73- exists ( DataFlow:: Node f | f = getFactoryNode ( ) |
75+ exists ( DataFlow:: Node f | f = this . getFactoryNode ( ) |
7476 if f instanceof DataFlow:: FunctionNode
7577 then
7678 exists ( ReturnStmt ret | ret .getContainer ( ) = f .( DataFlow:: FunctionNode ) .getAstNode ( ) |
@@ -81,15 +83,15 @@ class AmdModuleDefinition extends CallExpr {
8183 }
8284
8385 /** Gets a source node whose value becomes the definition of this module. */
84- DataFlow:: SourceNode getAModuleSource ( ) { result .flowsToExpr ( getModuleExpr ( ) ) }
86+ DataFlow:: SourceNode getAModuleSource ( ) { result .flowsToExpr ( this . getModuleExpr ( ) ) }
8587
8688 /**
8789 * Holds if `p` is the parameter corresponding to dependency `dep`.
8890 */
8991 predicate dependencyParameter ( PathExpr dep , Parameter p ) {
9092 exists ( int i |
91- dep = getDependency ( i ) and
92- p = getFactoryParameter ( i )
93+ dep = this . getDependency ( i ) and
94+ p = this . getFactoryParameter ( i )
9395 )
9496 }
9597
@@ -107,7 +109,7 @@ class AmdModuleDefinition extends CallExpr {
107109 */
108110 Parameter getDependencyParameter ( string name ) {
109111 exists ( PathExpr dep |
110- dependencyParameter ( dep , result ) and
112+ this . dependencyParameter ( dep , result ) and
111113 dep .getValue ( ) = name
112114 )
113115 }
@@ -116,54 +118,54 @@ class AmdModuleDefinition extends CallExpr {
116118 * Gets the `i`th parameter of the factory function of this module.
117119 */
118120 private Parameter getFactoryParameter ( int i ) {
119- getFactoryNodeInternal ( ) .asExpr ( ) .( Function ) .getParameter ( i ) = result
121+ this . getFactoryNodeInternal ( ) .asExpr ( ) .( Function ) .getParameter ( i ) = result
120122 }
121123
122124 /**
123125 * Gets the parameter corresponding to the pseudo-dependency `require`.
124126 */
125127 Parameter getRequireParameter ( ) {
126- result = getDependencyParameter ( "require" )
128+ result = this . getDependencyParameter ( "require" )
127129 or
128130 // if no dependencies are listed, the first parameter is assumed to be `require`
129- not exists ( getDependencies ( ) ) and result = getFactoryParameter ( 0 )
131+ not exists ( this . getDependencies ( ) ) and result = this . getFactoryParameter ( 0 )
130132 }
131133
132134 pragma [ noinline]
133- private Variable getRequireVariable ( ) { result = getRequireParameter ( ) .getVariable ( ) }
135+ private Variable getRequireVariable ( ) { result = this . getRequireParameter ( ) .getVariable ( ) }
134136
135137 /**
136138 * Gets the parameter corresponding to the pseudo-dependency `exports`.
137139 */
138140 Parameter getExportsParameter ( ) {
139- result = getDependencyParameter ( "exports" )
141+ result = this . getDependencyParameter ( "exports" )
140142 or
141143 // if no dependencies are listed, the second parameter is assumed to be `exports`
142- not exists ( getDependencies ( ) ) and result = getFactoryParameter ( 1 )
144+ not exists ( this . getDependencies ( ) ) and result = this . getFactoryParameter ( 1 )
143145 }
144146
145147 /**
146148 * Gets the parameter corresponding to the pseudo-dependency `module`.
147149 */
148150 Parameter getModuleParameter ( ) {
149- result = getDependencyParameter ( "module" )
151+ result = this . getDependencyParameter ( "module" )
150152 or
151153 // if no dependencies are listed, the third parameter is assumed to be `module`
152- not exists ( getDependencies ( ) ) and result = getFactoryParameter ( 2 )
154+ not exists ( this . getDependencies ( ) ) and result = this . getFactoryParameter ( 2 )
153155 }
154156
155157 /**
156158 * Gets an abstract value representing one or more values that may flow
157159 * into this module's `module.exports` property.
158160 */
159161 DefiniteAbstractValue getAModuleExportsValue ( ) {
160- result = [ getAnImplicitExportsValue ( ) , getAnExplicitExportsValue ( ) ]
162+ result = [ this . getAnImplicitExportsValue ( ) , this . getAnExplicitExportsValue ( ) ]
161163 }
162164
163165 pragma [ noinline, nomagic]
164166 private AbstractValue getAnImplicitExportsValue ( ) {
165167 // implicit exports: anything that is returned from the factory function
166- result = getModuleExpr ( ) .analyze ( ) .getAValue ( )
168+ result = this . getModuleExpr ( ) .analyze ( ) .getAValue ( )
167169 }
168170
169171 pragma [ noinline]
@@ -182,7 +184,7 @@ class AmdModuleDefinition extends CallExpr {
182184 * Gets a call to `require` inside this module.
183185 */
184186 CallExpr getARequireCall ( ) {
185- result .getCallee ( ) .getUnderlyingValue ( ) = getRequireVariable ( ) .getAnAccess ( )
187+ result .getCallee ( ) .getUnderlyingValue ( ) = this . getRequireVariable ( ) .getAnAccess ( )
186188 }
187189}
188190
@@ -200,7 +202,7 @@ private class AmdDependencyPath extends PathExprCandidate {
200202private class ConstantAmdDependencyPathElement extends PathExpr , ConstantString {
201203 ConstantAmdDependencyPathElement ( ) { this = any ( AmdDependencyPath amd ) .getAPart ( ) }
202204
203- override string getValue ( ) { result = getStringValue ( ) }
205+ override string getValue ( ) { result = this . getStringValue ( ) }
204206}
205207
206208/**
@@ -239,7 +241,7 @@ private class AmdDependencyImport extends Import {
239241 */
240242 private File guessTarget ( ) {
241243 exists ( PathString imported , string abspath , string dirname , string basename |
242- targetCandidate ( result , abspath , imported , dirname , basename )
244+ this . targetCandidate ( result , abspath , imported , dirname , basename )
243245 |
244246 abspath .regexpMatch ( ".*/\\Q" + imported + "\\E" )
245247 or
@@ -262,7 +264,7 @@ private class AmdDependencyImport extends Import {
262264 private predicate targetCandidate (
263265 File f , string abspath , PathString imported , string dirname , string basename
264266 ) {
265- imported = getImportedPath ( ) .getValue ( ) and
267+ imported = this . getImportedPath ( ) .getValue ( ) and
266268 f .getStem ( ) = imported .getStem ( ) and
267269 f .getAbsolutePath ( ) = abspath and
268270 dirname = imported .getDirName ( ) and
@@ -273,14 +275,14 @@ private class AmdDependencyImport extends Import {
273275 * Gets the module whose absolute path matches this import, if there is only a single such module.
274276 */
275277 private Module resolveByAbsolutePath ( ) {
276- result .getFile ( ) = unique( File file | file = guessTarget ( ) )
278+ result .getFile ( ) = unique( File file | file = this . guessTarget ( ) )
277279 }
278280
279281 override Module getImportedModule ( ) {
280282 result = super .getImportedModule ( )
281283 or
282284 not exists ( super .getImportedModule ( ) ) and
283- result = resolveByAbsolutePath ( )
285+ result = this . resolveByAbsolutePath ( )
284286 }
285287
286288 override DataFlow:: Node getImportedModuleNode ( ) {
@@ -314,7 +316,7 @@ class AmdModule extends Module {
314316
315317 override DataFlow:: Node getAnExportedValue ( string name ) {
316318 exists ( DataFlow:: PropWrite pwn | result = pwn .getRhs ( ) |
317- pwn .getBase ( ) .analyze ( ) .getAValue ( ) = getDefine ( ) .getAModuleExportsValue ( ) and
319+ pwn .getBase ( ) .analyze ( ) .getAValue ( ) = this . getDefine ( ) .getAModuleExportsValue ( ) and
318320 name = pwn .getPropertyName ( )
319321 )
320322 }
@@ -329,6 +331,6 @@ class AmdModule extends Module {
329331 )
330332 or
331333 // Returned from factory function
332- result = getDefine ( ) .getModuleExpr ( ) .flow ( )
334+ result = this . getDefine ( ) .getModuleExpr ( ) .flow ( )
333335 }
334336}
0 commit comments