@@ -33,31 +33,25 @@ class NodeModule extends Module {
33
33
* Gets an abstract value representing one or more values that may flow
34
34
* into this module's `module.exports` property.
35
35
*/
36
+ pragma [ noinline]
36
37
DefiniteAbstractValue getAModuleExportsValue ( ) {
37
- exists ( AbstractProperty moduleExports |
38
- moduleExports .getBase ( ) .( AbstractModuleObject ) .getModule ( ) = this and
39
- moduleExports .getPropertyName ( ) = "exports"
40
- |
41
- result = moduleExports .getAValue ( )
42
- )
38
+ result = getAModuleExportsProperty ( ) .getAValue ( )
39
+ }
40
+
41
+ pragma [ noinline]
42
+ private AbstractProperty getAModuleExportsProperty ( ) {
43
+ result .getBase ( ) .( AbstractModuleObject ) .getModule ( ) = this and
44
+ result .getPropertyName ( ) = "exports"
43
45
}
44
46
45
47
/**
46
48
* Gets an expression that is an alias for `module.exports`.
47
- * For performance this predicate only computes relevant expressions.
49
+ * For performance this predicate only computes relevant expressions (in `getAModuleExportsCandidate`) .
48
50
* So if using this predicate - consider expanding the list of relevant expressions.
49
51
*/
50
- pragma [ noinline]
51
- DataFlow:: Node getAModuleExportsNode ( ) {
52
- (
53
- // A bit of manual magic
54
- result = any ( DataFlow:: PropWrite w | exists ( w .getPropertyName ( ) ) ) .getBase ( )
55
- or
56
- result = DataFlow:: valueNode ( any ( PropAccess p | exists ( p .getPropertyName ( ) ) ) .getBase ( ) )
57
- or
58
- result = DataFlow:: valueNode ( any ( ObjectExpr obj ) )
59
- ) and
60
- result .analyze ( ) .getAValue ( ) = getAModuleExportsValue ( )
52
+ DataFlow:: AnalyzedNode getAModuleExportsNode ( ) {
53
+ result = getAModuleExportsCandidate ( ) and
54
+ result .getAValue ( ) = getAModuleExportsValue ( )
61
55
}
62
56
63
57
/** Gets a symbol exported by this module. */
@@ -148,6 +142,21 @@ class NodeModule extends Module {
148
142
}
149
143
}
150
144
145
+ /**
146
+ * Gets an expression that syntactically could be a alias for `module.exports`.
147
+ * This predicate exists to reduce the size of `getAModuleExportsNode`,
148
+ * while keeping all the tuples that could be relevant in later computations.
149
+ */
150
+ pragma [ noinline]
151
+ private DataFlow:: Node getAModuleExportsCandidate ( ) {
152
+ // A bit of manual magic
153
+ result = any ( DataFlow:: PropWrite w | exists ( w .getPropertyName ( ) ) ) .getBase ( )
154
+ or
155
+ result = DataFlow:: valueNode ( any ( PropAccess p | exists ( p .getPropertyName ( ) ) ) .getBase ( ) )
156
+ or
157
+ result = DataFlow:: valueNode ( any ( ObjectExpr obj ) )
158
+ }
159
+
151
160
/**
152
161
* Holds if `nodeModules` is a folder of the form `<prefix>/node_modules`, where
153
162
* `<prefix>` is a (not necessarily proper) prefix of `f` and does not end in `/node_modules`,
0 commit comments