Add ConversionError and make it work for undefined.foo.

This commit is contained in:
norris%netscape.com 1999-11-23 17:30:31 +00:00
Родитель bf8cbd877b
Коммит eadef0d104
4 изменённых файлов: 14 добавлений и 8 удалений

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

@ -79,7 +79,8 @@ public class NativeGlobal {
global.defineProperty("undefined", Undefined.instance, global.defineProperty("undefined", Undefined.instance,
ScriptableObject.DONTENUM); ScriptableObject.DONTENUM);
String[] errorMethods = { "EvalError", String[] errorMethods = { "ConversionError",
"EvalError",
"RangeError", "RangeError",
"ReferenceError", "ReferenceError",
"SyntaxError", "SyntaxError",

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

@ -766,10 +766,12 @@ public class ScriptRuntime {
catch (ClassCastException e) { catch (ClassCastException e) {
start = toObject(scope, obj); start = toObject(scope, obj);
} }
if (start == null) { if (start == null || start == Undefined.instance) {
String msg = start == null ? "msg.null.to.object"
: "msg.undefined";
throw NativeGlobal.constructError( throw NativeGlobal.constructError(
Context.getContext(), "TypeError", Context.getContext(), "ConversionError",
ScriptRuntime.getMessage("msg.null.to.object", null), ScriptRuntime.getMessage(msg, null),
scope); scope);
} }
Scriptable m = start; Scriptable m = start;

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

@ -79,7 +79,8 @@ public class NativeGlobal {
global.defineProperty("undefined", Undefined.instance, global.defineProperty("undefined", Undefined.instance,
ScriptableObject.DONTENUM); ScriptableObject.DONTENUM);
String[] errorMethods = { "EvalError", String[] errorMethods = { "ConversionError",
"EvalError",
"RangeError", "RangeError",
"ReferenceError", "ReferenceError",
"SyntaxError", "SyntaxError",

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

@ -766,10 +766,12 @@ public class ScriptRuntime {
catch (ClassCastException e) { catch (ClassCastException e) {
start = toObject(scope, obj); start = toObject(scope, obj);
} }
if (start == null) { if (start == null || start == Undefined.instance) {
String msg = start == null ? "msg.null.to.object"
: "msg.undefined";
throw NativeGlobal.constructError( throw NativeGlobal.constructError(
Context.getContext(), "TypeError", Context.getContext(), "ConversionError",
ScriptRuntime.getMessage("msg.null.to.object", null), ScriptRuntime.getMessage(msg, null),
scope); scope);
} }
Scriptable m = start; Scriptable m = start;