Fix JS DCE removing reachable functions

This commit is contained in:
Alexey Andreev
2017-10-09 20:12:03 +03:00
parent cb7d561c6c
commit 8cdef4139e
11 changed files with 108 additions and 13 deletions
@@ -562,15 +562,18 @@ public class JsAstMapper {
Node fromFnNameNode = fnNode.getFirstChild();
Node fromParamNode = fnNode.getFirstChild().getNext().getFirstChild();
Node fromBodyNode = fnNode.getFirstChild().getNext().getNext();
JsFunction toFn = scopeContext.enterFunction();
// Decide the function's name, if any.
//
String fnNameIdent = fromFnNameNode.getString();
JsName functionName = null;
if (fnNameIdent != null && fnNameIdent.length() > 0) {
toFn.setName(scopeContext.globalNameFor(fnNameIdent));
functionName = scopeContext.localNameFor(fnNameIdent);
}
JsFunction toFn = scopeContext.enterFunction();
toFn.setName(functionName);
while (fromParamNode != null) {
String fromParamName = fromParamNode.getString();
JsName name = scopeContext.localNameFor(fromParamName);