Fix bug 132217.

This commit is contained in:
nboyd%atg.com 2002-03-21 01:44:54 +00:00
parent db147304c7
commit 7f70eb708f
2 changed files with 22 additions and 5 deletions

View File

@ -1399,9 +1399,20 @@ public class Interpreter extends LabelTable {
if (id.itsName.length() == 0)
return;
if ((id.itsFunctionType == FunctionNode.FUNCTION_STATEMENT &&
fn.itsClosure == null) ||
(id.itsFunctionType == FunctionNode.FUNCTION_EXPRESSION_STATEMENT &&
fn.itsClosure != null))
fn.itsClosure == null))
{
try {
// ECMA specifies that functions defined in global and
// function scope should have DONTDELETE set.
((ScriptableObject) scope).defineProperty(fn.itsData.itsName,
fn, ScriptableObject.PERMANENT);
} catch (ClassCastException e) {
ScriptRuntime.setProp(scope, fn.itsData.itsName, fn, scope);
}
}
if (id.itsFunctionType == FunctionNode.FUNCTION_EXPRESSION_STATEMENT &&
fn.itsClosure != null)
{
ScriptRuntime.setProp(scope, fn.itsData.itsName, fn, scope);
}

View File

@ -2004,8 +2004,14 @@ public class ScriptRuntime {
{
fn.setPrototype(ScriptableObject.getClassPrototype(scope, "Function"));
fn.setParentScope(scope);
if (doSetName)
setName(scope, fn, scope, fnName);
if (doSetName) {
try {
((ScriptableObject) scope).defineProperty(fnName, fn,
ScriptableObject.PERMANENT);
} catch (ClassCastException e) {
setName(scope, fn, scope, fnName);
}
}
return fn;
}