JS: Remove Import->SourceNode dependency from AMD

This commit is contained in:
Asger Feldthaus
2020-04-02 15:30:17 +01:00
parent 3804d3fcfd
commit 346867f425

View File

@@ -56,10 +56,16 @@ class AmdModuleDefinition extends CallExpr {
*/ */
pragma[nomagic] pragma[nomagic]
DataFlow::SourceNode getFactoryNode() { DataFlow::SourceNode getFactoryNode() {
result.flowsToExpr(getLastArgument()) and result = getFactoryNodeInternal() and
result instanceof DataFlow::ValueNode result instanceof DataFlow::ValueNode
} }
private
DataFlow::Node getFactoryNodeInternal() {
result = DataFlow::valueNode(getLastArgument()) or
result = getFactoryNodeInternal().getAPredecessor()
}
/** Gets the expression defining this module. */ /** Gets the expression defining this module. */
Expr getModuleExpr() { Expr getModuleExpr() {
exists(DataFlow::Node f | f = getFactoryNode() | exists(DataFlow::Node f | f = getFactoryNode() |
@@ -108,7 +114,7 @@ class AmdModuleDefinition extends CallExpr {
* Gets the `i`th parameter of the factory function of this module. * Gets the `i`th parameter of the factory function of this module.
*/ */
private SimpleParameter getFactoryParameter(int i) { private SimpleParameter getFactoryParameter(int i) {
getFactoryNode().(DataFlow::FunctionNode).getParameter(i) = DataFlow::parameterNode(result) getFactoryNodeInternal().asExpr().(Function).getParameter(i) = result
} }
/** /**