22 * Provides classes for working with
33 * [Asynchronous Module Definitions](https://github.com/amdjs/amdjs-api/wiki/AMD).
44 */
5+ overlay [ local]
6+ module ;
57
68import javascript
79private import semmle.javascript.internal.CachedStages
@@ -62,9 +64,11 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
6264 }
6365
6466 /** DEPRECATED. Use `getDependencyExpr` instead. */
67+ overlay [ global]
6568 deprecated PathExpr getDependency ( int i ) { result = this .getDependencyExpr ( i ) }
6669
6770 /** DEPRECATED. Use `getADependencyExpr` instead. */
71+ overlay [ global]
6872 deprecated PathExpr getADependency ( ) { result = this .getADependencyExpr ( ) }
6973
7074 /** Gets the `i`th dependency of this module definition. */
@@ -194,16 +198,19 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
194198 * Gets an abstract value representing one or more values that may flow
195199 * into this module's `module.exports` property.
196200 */
201+ overlay [ global]
197202 DefiniteAbstractValue getAModuleExportsValue ( ) {
198203 result = [ this .getAnImplicitExportsValue ( ) , this .getAnExplicitExportsValue ( ) ]
199204 }
200205
206+ overlay [ global]
201207 pragma [ noinline, nomagic]
202208 private AbstractValue getAnImplicitExportsValue ( ) {
203209 // implicit exports: anything that is returned from the factory function
204210 result = this .getModuleExpr ( ) .analyze ( ) .getAValue ( )
205211 }
206212
213+ overlay [ global]
207214 pragma [ noinline]
208215 private AbstractValue getAnExplicitExportsValue ( ) {
209216 // explicit exports: anything assigned to `module.exports`
@@ -227,6 +234,7 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
227234private predicate isPseudoDependency ( string s ) { s = [ "exports" , "require" , "module" ] }
228235
229236/** An AMD dependency, considered as a path expression. */
237+ overlay [ global]
230238private class AmdDependencyPath extends PathExprCandidate {
231239 AmdDependencyPath ( ) {
232240 exists ( AmdModuleDefinition amd |
@@ -239,6 +247,7 @@ private class AmdDependencyPath extends PathExprCandidate {
239247}
240248
241249/** A constant path element appearing in an AMD dependency expression. */
250+ overlay [ global]
242251deprecated private class ConstantAmdDependencyPathElement extends PathExpr , ConstantString {
243252 ConstantAmdDependencyPathElement ( ) { this = any ( AmdDependencyPath amd ) .getAPart ( ) }
244253
@@ -281,6 +290,7 @@ private class AmdDependencyImport extends Import {
281290 * Specifically, we look for files whose absolute path ends with the imported path, possibly
282291 * adding well-known JavaScript file extensions like `.js`.
283292 */
293+ overlay [ global]
284294 private File guessTarget ( ) {
285295 exists ( FilePath imported , string abspath , string dirname , string basename |
286296 this .targetCandidate ( result , abspath , imported , dirname , basename )
@@ -303,6 +313,7 @@ private class AmdDependencyImport extends Import {
303313 * Additionally, `abspath` is bound to the absolute path of `f`, `imported` to the imported path, and
304314 * `dirname` and `basename` to the dirname and basename (respectively) of `imported`.
305315 */
316+ overlay [ global]
306317 private predicate targetCandidate (
307318 File f , string abspath , FilePath imported , string dirname , string basename
308319 ) {
@@ -316,10 +327,12 @@ private class AmdDependencyImport extends Import {
316327 /**
317328 * Gets the module whose absolute path matches this import, if there is only a single such module.
318329 */
330+ overlay [ global]
319331 private Module resolveByAbsolutePath ( ) {
320332 result .getFile ( ) = unique( File file | file = this .guessTarget ( ) )
321333 }
322334
335+ overlay [ global]
323336 override Module getImportedModule ( ) {
324337 result = super .getImportedModule ( )
325338 or
@@ -348,21 +361,20 @@ private class AmdDependencyImport extends Import {
348361 */
349362class AmdModule extends Module {
350363 cached
351- AmdModule ( ) {
352- Stages:: DataFlowStage:: ref ( ) and
353- exists ( unique( AmdModuleDefinition def | amdModuleTopLevel ( def , this ) ) )
354- }
364+ AmdModule ( ) { exists ( unique( AmdModuleDefinition def | amdModuleTopLevel ( def , this ) ) ) }
355365
356366 /** Gets the definition of this module. */
357367 AmdModuleDefinition getDefine ( ) { amdModuleTopLevel ( result , this ) }
358368
369+ overlay [ global]
359370 override DataFlow:: Node getAnExportedValue ( string name ) {
360371 exists ( DataFlow:: PropWrite pwn | result = pwn .getRhs ( ) |
361372 pwn .getBase ( ) .analyze ( ) .getAValue ( ) = this .getDefine ( ) .getAModuleExportsValue ( ) and
362373 name = pwn .getPropertyName ( )
363374 )
364375 }
365376
377+ overlay [ global]
366378 override DataFlow:: Node getABulkExportedNode ( ) {
367379 // Assigned to `module.exports` via the factory's `module` parameter
368380 exists ( AbstractModuleObject m , DataFlow:: PropWrite write |
0 commit comments