Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a64224

Browse files
author
Max Schaefer
committed
JavaScript: Cache portal computation.
1 parent 2295353 commit 9a64224

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • javascript/ql/src/semmle/javascript/dataflow

javascript/ql/src/semmle/javascript/dataflow/Portals.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,49 +51,49 @@ private newtype TPortal =
5151
/**
5252
* A portal, that is, an interface point between different npm packages.
5353
*/
54-
class Portal extends TPortal {
54+
cached class Portal extends TPortal {
5555
/**
5656
* Gets an exit node for this portal, that is, a node from which data
5757
* that comes through the portal emerges. The flag `isRemote`
5858
* indicates whether data read from this node may come from a different
5959
* package.
6060
*/
61-
abstract DataFlow::SourceNode getAnExitNode(boolean isRemote);
61+
abstract cached DataFlow::SourceNode getAnExitNode(boolean isRemote);
6262

6363
/**
6464
* Gets an entry node for this portal, that is, a node through which data
6565
* enters the portal. The flag `escapes` indicates whether data written to
6666
* the node may escape to a different package.
6767
*/
68-
abstract DataFlow::Node getAnEntryNode(boolean escapes);
68+
abstract cached DataFlow::Node getAnEntryNode(boolean escapes);
6969

7070
/**
7171
* Gets the member portal with the given `name` of this portal, if any.
7272
*/
73-
MemberPortal getMember(string name) {
73+
cached MemberPortal getMember(string name) {
7474
result.getName() = name and
7575
result.getBasePortal() = this
7676
}
7777

7878
/**
7979
* Gets the instance portal of this portal, if any.
8080
*/
81-
InstancePortal getInstance() {
81+
cached InstancePortal getInstance() {
8282
result.getBasePortal() = this
8383
}
8484

8585
/**
8686
* Gets the portal of parameter `idx` of this portal, if any.
8787
*/
88-
ParameterPortal getParameter(int idx) {
88+
cached ParameterPortal getParameter(int idx) {
8989
result.getIndex() = idx and
9090
result.getBasePortal() = this
9191
}
9292

9393
/**
9494
* Gets the return value portal of this portal, if any.
9595
*/
96-
ReturnPortal getReturn() {
96+
cached ReturnPortal getReturn() {
9797
result.getBasePortal() = this
9898
}
9999

@@ -103,15 +103,15 @@ class Portal extends TPortal {
103103
* Different portals must have different `toString`s, so the result of
104104
* this predicate can be used to uniquely identify a portal.
105105
*/
106-
abstract string toString();
106+
cached abstract string toString();
107107

108108
/**
109109
* INTERNAL: Do not use outside this library.
110110
*
111111
* The constructor depth of this portal, used to limit the number of
112112
* portals.
113113
*/
114-
abstract int depth();
114+
cached abstract int depth();
115115
}
116116

117117
/**
@@ -220,7 +220,7 @@ private int maxdepth() {
220220
/**
221221
* A portal that is constructed over some base portal.
222222
*/
223-
abstract class CompoundPortal extends Portal {
223+
private abstract class CompoundPortal extends Portal {
224224
Portal base;
225225

226226
bindingset[this]
@@ -243,7 +243,7 @@ abstract class CompoundPortal extends Portal {
243243
* Entries to this portal are the right-hand sides of writes to the property, while
244244
* property reads are exits.
245245
*/
246-
class MemberPortal extends CompoundPortal, MkMemberPortal {
246+
private class MemberPortal extends CompoundPortal, MkMemberPortal {
247247
string prop;
248248

249249
MemberPortal() { this = MkMemberPortal(base, prop) }
@@ -319,7 +319,7 @@ private module MemberPortal {
319319
* non-primitive), while exits are `new` expressions and other expressions referring to
320320
* instances of functions/classes flowing through the base portal.
321321
*/
322-
class InstancePortal extends CompoundPortal, MkInstancePortal {
322+
private class InstancePortal extends CompoundPortal, MkInstancePortal {
323323
InstancePortal() { this = MkInstancePortal(base) }
324324

325325
override DataFlow::SourceNode getAnExitNode(boolean isRemote) {

0 commit comments

Comments
 (0)