зеркало из https://github.com/mozilla/gecko-dev.git
Move code to put functions as properties of activation object to ScriptRuntime.putFunction so it can reused by optimizer.
This commit is contained in:
Родитель
dc573f11eb
Коммит
0815885549
|
@ -1542,22 +1542,8 @@ public class Interpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScriptRuntime.initFunction(scope, fn);
|
ScriptRuntime.initFunction(scope, fn);
|
||||||
String fnName = idata.itsName;
|
ScriptRuntime.putFunction(scope, idata.itsName, fn,
|
||||||
if (fnName.length() != 0) {
|
idata.itsFunctionType, fromEvalCode);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1939,6 +1939,27 @@ public class ScriptRuntime {
|
||||||
fn.setParentScope(scope);
|
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) {
|
static void checkDeprecated(Context cx, String name) {
|
||||||
int version = cx.getLanguageVersion();
|
int version = cx.getLanguageVersion();
|
||||||
if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
|
if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче