entryEnv = envPutType(entryEnv, RETVAL_ID, JSType.UNDEFINED);
} else {
nonLocals.addAll(currentScope.getExterns());
}
for (String name : nonLocals) {
JSType declType = currentScope.getDeclaredTypeOf(name);
JSType initType = declType == null
? envGetType(entryEnv, name) : pickInitialType(declType);
entryEnv = envPutType(entryEnv, name, initType);
}
// For all scopes, add local variables and (local) function definitions
// to the environment.
for (String local : currentScope.getLocals()) {
entryEnv = envPutType(entryEnv, local, JSType.UNDEFINED);
}
for (String fnName : currentScope.getLocalFunDefs()) {
JSType summaryType = getSummaryOfLocalFunDef(fnName);
FunctionType fnType = summaryType.getFunType();
if (fnType.isConstructor() || fnType.isInterfaceDefinition()) {
summaryType = fnType.createConstructorObject();
} else {
summaryType = summaryType.withProperty(
new QualifiedName("prototype"), JSType.TOP_OBJECT);
}
entryEnv = envPutType(entryEnv, fnName, summaryType);
}
println("Keeping env: ", entryEnv);