Removal of support for special handling of this for read-only methods exposed by IdScriptable under dynamic scoping. It was never used and its semantic had little to do with dynamic scoping itself.

This commit is contained in:
igor%mir2.org 2003-04-22 16:09:40 +00:00
Родитель 97d4809dd9
Коммит 27f1930196
8 изменённых файлов: 61 добавлений и 86 удалений

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

@ -379,18 +379,6 @@ public abstract class IdScriptable extends ScriptableObject
setSetupFlag(SEAL_FUNCTIONS_FLAG, sealed);
}
/**
* Set parameters of function properties.
* Currently only determines whether functions should use dynamic scope.
* @param cx context to read function parameters.
*
* @see org.mozilla.javascript.Context#hasCompileFunctionsWithDynamicScope
*/
protected void setFunctionParametrs(Context cx) {
setSetupFlag(USE_DYNAMIC_SCOPE_FLAG,
cx.hasCompileFunctionsWithDynamicScope());
}
private void setSetupFlag(int flag, boolean value) {
setupFlags = (byte)(value ? setupFlags | flag : setupFlags & ~flag);
}
@ -411,7 +399,6 @@ public abstract class IdScriptable extends ScriptableObject
setMaxId(maxId);
setSealFunctionsFlag(sealed);
setFunctionParametrs(cx);
int constructorId = mapNameToId("constructor");
if (constructorId == 0) {
@ -471,14 +458,8 @@ public abstract class IdScriptable extends ScriptableObject
* @throws RuntimeException if no more instanceof target can be found
*/
protected Scriptable nextInstanceCheck(Scriptable thisObj,
IdFunction f,
boolean readOnly)
IdFunction f)
{
if (readOnly && 0 != (setupFlags & USE_DYNAMIC_SCOPE_FLAG)) {
// for read only functions under dynamic scope look prototype chain
thisObj = thisObj.getPrototype();
if (thisObj != null) { return thisObj; }
}
throw NativeGlobal.typeError1("msg.incompat.call",
f.getFunctionName(), f);
}
@ -572,7 +553,6 @@ public abstract class IdScriptable extends ScriptableObject
private static final boolean CACHE_NAMES = true;
private int lastIdCache;
private static final int USE_DYNAMIC_SCOPE_FLAG = 1 << 0;
private static final int SEAL_FUNCTIONS_FLAG = 1 << 1;
private byte setupFlags;

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

@ -101,7 +101,7 @@ final class NativeBoolean extends IdScriptable {
private NativeBoolean realThis(Scriptable thisObj, IdFunction f) {
while (!(thisObj instanceof NativeBoolean)) {
thisObj = nextInstanceCheck(thisObj, f, true);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeBoolean)thisObj;
}

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

@ -163,217 +163,217 @@ final class NativeDate extends IdScriptable {
return jsConstructor(args, thisObj == null);
case Id_toString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return date_format(t, FORMATSPEC_FULL);
}
case Id_toTimeString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return date_format(t, FORMATSPEC_TIME);
}
case Id_toDateString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return date_format(t, FORMATSPEC_DATE);
}
case Id_toLocaleString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return js_toLocaleString(t);
}
case Id_toLocaleTimeString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return js_toLocaleTimeString(t);
}
case Id_toLocaleDateString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
return js_toLocaleDateString(t);
}
case Id_toUTCString: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { return js_toUTCString(t); }
return js_NaN_date_str;
}
case Id_valueOf:
return wrap_double(realThis(thisObj, f, true).date);
return wrap_double(realThis(thisObj, f).date);
case Id_getTime:
return wrap_double(realThis(thisObj, f, true).date);
return wrap_double(realThis(thisObj, f).date);
case Id_getYear: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = js_getYear(cx, t); }
return wrap_double(t);
}
case Id_getFullYear: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = YearFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCFullYear: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = YearFromTime(t); }
return wrap_double(t);
}
case Id_getMonth: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = MonthFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCMonth: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = MonthFromTime(t); }
return wrap_double(t);
}
case Id_getDate: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = DateFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCDate: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = DateFromTime(t); }
return wrap_double(t);
}
case Id_getDay: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = WeekDay(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCDay: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = WeekDay(t); }
return wrap_double(t);
}
case Id_getHours: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = HourFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCHours: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = HourFromTime(t); }
return wrap_double(t);
}
case Id_getMinutes: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = MinFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCMinutes: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = MinFromTime(t); }
return wrap_double(t);
}
case Id_getSeconds: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = SecFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCSeconds: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = SecFromTime(t); }
return wrap_double(t);
}
case Id_getMilliseconds: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = msFromTime(LocalTime(t)); }
return wrap_double(t);
}
case Id_getUTCMilliseconds: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = msFromTime(t); }
return wrap_double(t);
}
case Id_getTimezoneOffset: {
double t = realThis(thisObj, f, true).date;
double t = realThis(thisObj, f).date;
if (t == t) { t = js_getTimezoneOffset(t); }
return wrap_double(t);
}
case Id_setTime:
return wrap_double(realThis(thisObj, f, true).
return wrap_double(realThis(thisObj, f).
js_setTime(ScriptRuntime.toNumber(args, 0)));
case Id_setMilliseconds:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 1, true));
case Id_setUTCMilliseconds:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 1, false));
case Id_setSeconds:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 2, true));
case Id_setUTCSeconds:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 2, false));
case Id_setMinutes:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 3, true));
case Id_setUTCMinutes:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 3, false));
case Id_setHours:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 4, true));
case Id_setUTCHours:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeTime(args, 4, false));
case Id_setDate:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 1, true));
case Id_setUTCDate:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 1, false));
case Id_setMonth:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 2, true));
case Id_setUTCMonth:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 2, false));
case Id_setFullYear:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 3, true));
case Id_setUTCFullYear:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
makeDate(args, 3, false));
case Id_setYear:
return wrap_double(realThis(thisObj, f, false).
return wrap_double(realThis(thisObj, f).
js_setYear(ScriptRuntime.toNumber(args, 0)));
}
}
@ -381,11 +381,10 @@ final class NativeDate extends IdScriptable {
return super.execMethod(methodId, f, cx, scope, thisObj, args);
}
private NativeDate realThis(Scriptable thisObj, IdFunction f,
boolean readOnly)
private NativeDate realThis(Scriptable thisObj, IdFunction f)
{
while (!(thisObj instanceof NativeDate)) {
thisObj = nextInstanceCheck(thisObj, f, readOnly);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeDate)thisObj;
}

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

@ -47,7 +47,6 @@ final class NativeMath extends IdScriptable
static void init(Context cx, Scriptable scope, boolean sealed) {
NativeMath obj = new NativeMath();
obj.setSealFunctionsFlag(sealed);
obj.setFunctionParametrs(cx);
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }

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

@ -137,7 +137,7 @@ final class NativeNumber extends IdScriptable {
private NativeNumber realThis(Scriptable thisObj, IdFunction f) {
while (!(thisObj instanceof NativeNumber)) {
thisObj = nextInstanceCheck(thisObj, f, true);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeNumber)thisObj;
}

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

@ -112,13 +112,13 @@ public class NativeScript extends NativeFunction implements Script {
return jsConstructor(cx, scope, args);
case Id_toString:
return realThis(thisObj, f, true).js_toString(cx, args);
return realThis(thisObj, f).js_toString(cx, args);
case Id_exec:
return realThis(thisObj, f, true).js_exec();
return realThis(thisObj, f).js_exec();
case Id_compile:
return realThis(thisObj, f, false).
return realThis(thisObj, f).
js_compile(cx, ScriptRuntime.toString(args, 0));
}
}
@ -126,11 +126,10 @@ public class NativeScript extends NativeFunction implements Script {
return super.execMethod(methodId, f, cx, scope, thisObj, args);
}
private NativeScript realThis(Scriptable thisObj, IdFunction f,
boolean readOnly)
private NativeScript realThis(Scriptable thisObj, IdFunction f)
{
while (!(thisObj instanceof NativeScript)) {
thisObj = nextInstanceCheck(thisObj, f, readOnly);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeScript)thisObj;
}

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

@ -249,7 +249,7 @@ final class NativeString extends IdScriptable {
private NativeString realThis(Scriptable thisObj, IdFunction f) {
while (!(thisObj instanceof NativeString)) {
thisObj = nextInstanceCheck(thisObj, f, true);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeString)thisObj;
}

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

@ -133,7 +133,6 @@ public class NativeRegExp extends IdScriptable implements Function {
proto.prototypeFlag = true;
proto.setMaxId(MAX_PROTOTYPE_ID);
proto.setSealFunctionsFlag(sealed);
proto.setFunctionParametrs(cx);
proto.setParentScope(scope);
proto.setPrototype(getObjectPrototype(scope));
@ -2700,29 +2699,28 @@ System.out.println("Testing at " + x.cp + ", op = " + op);
if (prototypeFlag) {
switch (methodId) {
case Id_compile:
return realThis(thisObj, f, false).compile(cx, scope, args);
return realThis(thisObj, f).compile(cx, scope, args);
case Id_toString:
return realThis(thisObj, f, true).toString();
return realThis(thisObj, f).toString();
case Id_exec:
return realThis(thisObj, f, false).exec(cx, scope, args);
return realThis(thisObj, f).exec(cx, scope, args);
case Id_test:
return realThis(thisObj, f, false).test(cx, scope, args);
return realThis(thisObj, f).test(cx, scope, args);
case Id_prefix:
return realThis(thisObj, f, false).prefix(cx, scope, args);
return realThis(thisObj, f).prefix(cx, scope, args);
}
}
return super.execMethod(methodId, f, cx, scope, thisObj, args);
}
private NativeRegExp realThis(Scriptable thisObj, IdFunction f,
boolean readOnly)
private NativeRegExp realThis(Scriptable thisObj, IdFunction f)
{
while (!(thisObj instanceof NativeRegExp)) {
thisObj = nextInstanceCheck(thisObj, f, readOnly);
thisObj = nextInstanceCheck(thisObj, f);
}
return (NativeRegExp)thisObj;
}