if (!stripStack || !polymorphicNames.containsKey(x) || x.isNative()) {
globalName = topScope.declareName(mangleName, name);
names.put(x, globalName);
recordSymbol(x, globalName);
}
JsFunction jsFunction;
if (x.isNative()) {
// set the global name of the JSNI peer
JsniMethodBody body = (JsniMethodBody) x.getBody();
jsFunction = body.getFunc();
jsFunction.setName(globalName);
} else {
/*
* It would be more correct here to check for an inline assignment, such
* as var foo = function blah() {} and introduce a separate scope for
* the function's name according to EcmaScript-262, but this would mess
* up stack traces by allowing two inner scope function names to
* obfuscate to the same identifier, making function names no longer a
* 1:1 mapping to obfuscated symbols. Leaving them in global scope
* causes no harm.
*/
jsFunction = new JsFunction(x.getSourceInfo(), topScope, globalName, true);
}
if (polymorphicNames.containsKey(x)) {
polymorphicJsFunctions.add(jsFunction);
}
methodBodyMap.put(x.getBody(), jsFunction);
push(jsFunction.getScope());
if (program.getIndexedMethods().contains(x)) {
indexedFunctions =
Maps.put(indexedFunctions, x.getEnclosingType().getShortName() + "." + x.getName(),
jsFunction);