(type, self, args, ret, node, aval)
| 488 | function isFunExpr(node) { return node.type == "FunctionExpression" || node.type == "ArrowFunctionExpression" } |
| 489 | |
| 490 | function applyType(type, self, args, ret, node, aval) { |
| 491 | var fn; |
| 492 | if (node.type == "VariableDeclaration") { |
| 493 | var decl = node.declarations[0]; |
| 494 | if (decl.init && isFunExpr(decl.init)) fn = decl.init.scope.fnType; |
| 495 | } else if (node.type == "FunctionDeclaration") { |
| 496 | fn = node.scope.fnType; |
| 497 | } else if (node.type == "AssignmentExpression") { |
| 498 | if (isFunExpr(node.right)) |
| 499 | fn = node.right.scope.fnType; |
| 500 | } else if (node.type == "CallExpression" || node.type === "ClassDeclaration") { |
| 501 | } else { // An object property |
| 502 | if (isFunExpr(node.value)) fn = node.value.scope.fnType; |
| 503 | } |
| 504 | |
| 505 | if (fn && (args || ret || self)) { |
| 506 | if (args) for (var i = 0; i < fn.argNames.length; ++i) { |
| 507 | var name = fn.argNames[i], known = args[name]; |
| 508 | if (!known && (known = args[name + "?"])) |
| 509 | fn.argNames[i] += "?"; |
| 510 | if (known) propagateWithWeight(known, fn.args[i]); |
| 511 | } |
| 512 | if (ret) { |
| 513 | if (fn.retval == infer.ANull) fn.retval = new infer.AVal; |
| 514 | propagateWithWeight(ret, fn.retval); |
| 515 | } |
| 516 | if (self === true) { |
| 517 | var proto = fn.getProp("prototype").getObjType(); |
| 518 | self = proto && {type: infer.getInstance(proto, fn)}; |
| 519 | } |
| 520 | if (self) propagateWithWeight(self, fn.self); |
| 521 | } else if (type) { |
| 522 | propagateWithWeight(type, aval); |
| 523 | } |
| 524 | } |
| 525 | }); |
no test coverage detected
searching dependent graphs…