Move code to put functions as properties of activation object to ScriptRuntime.putFunction so it can reused by optimizer.

This commit is contained in:
igor%mir2.org 2002-12-22 19:08:52 +00:00
Родитель dc573f11eb
Коммит 0815885549
2 изменённых файлов: 23 добавлений и 16 удалений

Просмотреть файл

@ -1542,22 +1542,8 @@ public class Interpreter {
}
}
ScriptRuntime.initFunction(scope, fn);
String fnName = idata.itsName;
if (fnName.length() != 0) {
int type = idata.itsFunctionType;
if (type == FunctionNode.FUNCTION_STATEMENT) {
if (fromEvalCode) {
scope.put(fnName, scope, fn);
} else {
// ECMA specifies that functions defined in global and
// function scope should have DONTDELETE set.
ScriptableObject.defineProperty(scope,
fnName, fn, ScriptableObject.PERMANENT);
}
} else if (type == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) {
scope.put(fnName, scope, fn);
}
}
ScriptRuntime.putFunction(scope, idata.itsName, fn,
idata.itsFunctionType, fromEvalCode);
return fn;
}

Просмотреть файл

@ -1939,6 +1939,27 @@ public class ScriptRuntime {
fn.setParentScope(scope);
}
public static void putFunction(Scriptable scope, String name,
Function function, int type,
boolean fromEvalCode)
{
if (type == FunctionNode.FUNCTION_STATEMENT
|| type == FunctionNode.FUNCTION_EXPRESSION_STATEMENT)
{
if (name != null && name.length() != 0) {
if (type == FunctionNode.FUNCTION_STATEMENT && !fromEvalCode) {
// ECMA specifies that functions defined in global and
// function scope outside eval should have DONTDELETE set.
ScriptableObject.defineProperty
(scope, name, function, ScriptableObject.PERMANENT);
} else {
scope.put(name, scope, function);
}
}
}
}
static void checkDeprecated(Context cx, String name) {
int version = cx.getLanguageVersion();
if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {