Fixing regression after previous commit for bug 245882: when used as top scope ImporterTopLevel should not define constructor property not to hide Object.prototype.constructor.

This commit is contained in:
igor%mir2.org 2004-06-09 17:01:01 +00:00
Родитель 9abd635369
Коммит 7b30a5de99
1 изменённых файлов: 14 добавлений и 3 удалений

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

@ -100,10 +100,16 @@ public class ImporterTopLevel extends IdScriptable
{
cx.initStandardObjects(this, sealed);
prototypeFlag = true;
addAsPrototype(MAX_PROTOTYPE_ID, cx, this, sealed);
// set the flag after IdScriptable.addAsPrototype() calls
// getClassName() to get constructor name right.
topScopeFlag = true;
// topScopeFlag hides constructor property so constructor name
// would refer to constructor property in the prototype of the scope
// and not to JavaImporter.prototype.constructor.
// For this reason addAsPrototype can not be used to replace
// the following 4 lines as it requires to have id for "constructor".
setMaxId(MAX_PROTOTYPE_ID);
IdFunction ctor = newIdFunction("JavaImporter", Id_constructor, this);
ctor.markAsConstructor(this);
ctor.exportAsScopeProperty(sealed);
}
public boolean has(String name, Scriptable start) {
@ -291,6 +297,11 @@ public class ImporterTopLevel extends IdScriptable
if (X!=null && X!=s && !X.equals(s)) id = 0;
}
// #/generated#
if (id == Id_constructor && topScopeFlag) {
// see comments in initStandardObjects
id = 0;
}
return id;
}