Subject:
Re: Small usage simplification for Rhino
Date:
Mon, 22 Jan 2001 20:32:12 +0100
From:
Igor Bukanov <igor@icesoft.no>
To:
Norris Boyd <nboyd@atg.com>
References:
1 , 2
Norris Boyd wrote:
> Sounds like a good change to reduce codesize. I'll take the patches for the
> changes.
>
> Thanks,
> Norris
I made this patch, the files in the attachment were produced via:
diff -bB javascript.orig javascript -c > patch_context
and
diff -bB javascript.orig javascript > patch_std
run from org/mozilla directory.
This patch reduces uncopressed Rhino jar by 3K.
>
> Igor Bukanov wrote:
>
>
>> Hi, Noris!
>>
>> To shorten/cleanup usage of getMessage and reportRuntimeError methods
>> from org/mozilla/javascript/Context.java I suggest to add few utility
>> methods like
>>
>> static String getMessage0(String messageId) {
>> return getMessage(messageId, null);
>> }
>>
>> static String getMessage1(String messageId, Object arg1) {
>> Object[] arguments = {arg1};
>> return getMessage(messageId, arguments);
>> }
>>
>> static String getMessage2(String messageId, Object arg1, Object arg2) {
>> Object[] arguments = {arg1, arg2};
>> return getMessage(messageId, arguments);
>> }
>>
>> static String getMessage3
>> (String messageId, Object arg1, Object arg2, Object arg3) {
>> Object[] arguments = {arg1, arg2, arg3};
>> return getMessage(messageId, arguments);
>> }
>>
>> and
>>
>> static EvaluatorException reportRuntimeError0(String messageId) {
>> return reportRuntimeError(getMessage0(messageId));
>> }
>>
>> static EvaluatorException reportRuntimeError1
>> (String messageId, Object arg1)
>> {
>> return reportRuntimeError(getMessage1(messageId, arg1));
>> }
>>
>> static EvaluatorException reportRuntimeError2
>> (String messageId, Object arg1, Object arg2)
>> {
>> return reportRuntimeError(getMessage2(messageId, arg1, arg2));
>> }
>>
>> static EvaluatorException reportRuntimeError3
>> (String messageId, Object arg1, Object arg2, Object arg3)
>> {
>> return reportRuntimeError(getMessage3(messageId, arg1, arg2,
>> arg3));
>> }
>>
>> This allows to write, for example, instead of
>>
>> Object[] args = { Integer.toString(base) };
>> throw Context.reportRuntimeError(getMessage
>> ("msg.bad.radix", args));
>> simply
>> throw Context.reportRuntimeError1(
>> "msg.bad.radix", Integer.toString(base));
>>
>> which is not only easy to read but also generates less code.
>>
>> I attach my patch to Context.java to implement this plus a patch to
>> ScriptRuntime.java that utilizes the additions. The patches are in
>> standard and context versions.
>>
>> If you think that this make sense to incorporate, I can send a patch
>> that utilizes this everywhere.
>>
>> ------------------------------------------------------------------------
>> Name: patch.context.Context.java
>> patch.context.Context.java Type: Plain Text (text/plain)
>> Encoding: base64
>>
>> Name: patch.std.Context.java
>> patch.std.Context.java Type: Plain Text (text/plain)
>> Encoding: base64
>>
>> Name: patch.context.ScriptRuntime.java
>> patch.context.ScriptRuntime.java Type: Plain Text (text/plain)
>> Encoding: base64
>>
>> Name: patch.std.ScriptRuntime.java
>> patch.std.ScriptRuntime.java Type: Plain Text (text/plain)
>> Encoding: base64
>>
>> Name: all.zip
>> all.zip Type: Zip Compressed Data (application/x-zip-compressed)
>> Encoding: base64
git-svn-id: svn://10.0.0.236/trunk@85289 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -532,6 +532,28 @@ public final class Context {
|
||||
}
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError0(String messageId) {
|
||||
return reportRuntimeError(getMessage0(messageId));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError1
|
||||
(String messageId, Object arg1)
|
||||
{
|
||||
return reportRuntimeError(getMessage1(messageId, arg1));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return reportRuntimeError(getMessage2(messageId, arg1, arg2));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError3
|
||||
(String messageId, Object arg1, Object arg2, Object arg3)
|
||||
{
|
||||
return reportRuntimeError(getMessage3(messageId, arg1, arg2, arg3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a runtime error using the error reporter for the current thread.
|
||||
*
|
||||
@@ -1010,13 +1032,11 @@ public final class Context {
|
||||
{
|
||||
Object ctorVal = ScriptRuntime.getTopLevelProp(scope, constructorName);
|
||||
if (ctorVal == Scriptable.NOT_FOUND) {
|
||||
Object[] errArgs = { constructorName };
|
||||
String message = getMessage("msg.ctor.not.found", errArgs);
|
||||
String message = getMessage1("msg.ctor.not.found", constructorName);
|
||||
throw new PropertyException(message);
|
||||
}
|
||||
if (!(ctorVal instanceof Function)) {
|
||||
Object[] errArgs = { constructorName };
|
||||
String message = getMessage("msg.not.ctor", errArgs);
|
||||
String message = getMessage1("msg.not.ctor", constructorName);
|
||||
throw new NotAFunctionException(message);
|
||||
}
|
||||
Function ctor = (Function) ctorVal;
|
||||
@@ -1528,6 +1548,26 @@ public final class Context {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static String getMessage0(String messageId) {
|
||||
return getMessage(messageId, null);
|
||||
}
|
||||
|
||||
static String getMessage1(String messageId, Object arg1) {
|
||||
Object[] arguments = {arg1};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
|
||||
static String getMessage2(String messageId, Object arg1, Object arg2) {
|
||||
Object[] arguments = {arg1, arg2};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
|
||||
static String getMessage3
|
||||
(String messageId, Object arg1, Object arg2, Object arg3) {
|
||||
Object[] arguments = {arg1, arg2, arg3};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
/**
|
||||
* Internal method that reports an error for missing calls to
|
||||
* enter().
|
||||
|
||||
@@ -306,8 +306,7 @@ public class FlattenedObject {
|
||||
JavaScriptException
|
||||
{
|
||||
if (!hasProperty(id)) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
Object o = getProperty(id);
|
||||
if (o instanceof FlattenedObject)
|
||||
|
||||
@@ -138,10 +138,8 @@ public class FunctionObject extends NativeFunction {
|
||||
types[2] != ScriptRuntime.FunctionClass ||
|
||||
types[3] != Boolean.TYPE)
|
||||
{
|
||||
String[] args = { methodName };
|
||||
String message = Context.getMessage("msg.varargs.ctor",
|
||||
args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.varargs.ctor", methodName);
|
||||
}
|
||||
parmsLength = VARARGS_CTOR;
|
||||
} else {
|
||||
@@ -151,10 +149,8 @@ public class FunctionObject extends NativeFunction {
|
||||
types[2].getComponentType() != ScriptRuntime.ObjectClass ||
|
||||
types[3] != ScriptRuntime.FunctionClass)
|
||||
{
|
||||
String[] args = { methodName };
|
||||
String message = Context.getMessage("msg.varargs.fun",
|
||||
args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.varargs.fun", methodName);
|
||||
}
|
||||
parmsLength = VARARGS_METHOD;
|
||||
}
|
||||
@@ -176,10 +172,9 @@ public class FunctionObject extends NativeFunction {
|
||||
type != Float.TYPE &&
|
||||
type != Double.TYPE)
|
||||
{
|
||||
// Note that long is not supported; see comments above
|
||||
Object[] errArgs = { methodName };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.bad.parms", errArgs));
|
||||
// Note that long is not supported.
|
||||
throw Context.reportRuntimeError1("msg.bad.parms",
|
||||
methodName);
|
||||
}
|
||||
}
|
||||
length = parmsLength;
|
||||
@@ -426,9 +421,8 @@ public class FunctionObject extends NativeFunction {
|
||||
|
||||
// Note that the long type is not supported; see the javadoc for
|
||||
// the constructor for this class
|
||||
Object[] errArgs = { desired.getName() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.convert", errArgs));
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.cant.convert", desired.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,8 +457,8 @@ public class FunctionObject extends NativeFunction {
|
||||
thisObj = thisObj.getPrototype();
|
||||
if (thisObj == null || !useDynamicScope) {
|
||||
// Couldn't find an object to call this on.
|
||||
Object[] errArgs = { names[0] };
|
||||
String msg = Context.getMessage("msg.incompat.call", errArgs);
|
||||
String msg = Context.getMessage1
|
||||
("msg.incompat.call", names[0]);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", msg, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1036,10 +1036,10 @@ public class IRFactory {
|
||||
if (scope != null)
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "SyntaxError",
|
||||
ScriptRuntime.getMessage(msgResource, null),
|
||||
ScriptRuntime.getMessage0(msgResource),
|
||||
scope);
|
||||
else {
|
||||
String message = Context.getMessage(msgResource, null);
|
||||
String message = Context.getMessage0(msgResource);
|
||||
Context.reportError(message, ts.getSourceName(), ts.getLineno(),
|
||||
ts.getLine(), ts.getOffset());
|
||||
}
|
||||
|
||||
@@ -106,10 +106,8 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
if (result == NOT_FOUND) {
|
||||
result = v;
|
||||
} else {
|
||||
String[] args = { result.toString(), v.toString() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.ambig.import",
|
||||
args));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.ambig.import", result.toString(), v.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,15 +119,14 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
for (int i=0; i<args.length; i++) {
|
||||
Object cl = args[i];
|
||||
if (!(cl instanceof NativeJavaClass)) {
|
||||
String[] eargs = { Context.toString(cl) };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.not.class", eargs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.not.class", Context.toString(cl));
|
||||
}
|
||||
String s = ((NativeJavaClass) cl).getClassObject().getName();
|
||||
String n = s.substring(s.lastIndexOf('.')+1);
|
||||
Object val = thisObj.get(n, thisObj);
|
||||
if (val != NOT_FOUND && val != cl) {
|
||||
String[] eargs = { n };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.prop.defined", eargs));
|
||||
throw Context.reportRuntimeError1("msg.prop.defined", n);
|
||||
}
|
||||
//thisObj.defineProperty(n, cl, DONTENUM);
|
||||
thisObj.put(n,thisObj,cl);
|
||||
@@ -150,8 +147,8 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
for (int i=0; i<args.length; i++) {
|
||||
Object pkg = args[i];
|
||||
if (!(pkg instanceof NativeJavaPackage)) {
|
||||
String[] eargs = { Context.toString(pkg) };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.not.pkg", eargs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.not.pkg", Context.toString(pkg));
|
||||
}
|
||||
Object[] elements = cx.getElements(importedPackages);
|
||||
for (int j=0; j < elements.length; j++) {
|
||||
|
||||
@@ -220,25 +220,22 @@ class JavaMembers {
|
||||
try {
|
||||
field = (Field) member;
|
||||
if (field == null) {
|
||||
Object[] args = {name};
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.internal.private", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", name);
|
||||
}
|
||||
field.set(javaObject, NativeJavaObject.coerceType(field.getType(),
|
||||
value));
|
||||
field.set(javaObject,
|
||||
NativeJavaObject.coerceType(field.getType(), value));
|
||||
} catch (ClassCastException e) {
|
||||
Object errArgs[] = { name };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.method.assign",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.method.assign", name);
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
throw new RuntimeException("unexpected IllegalAccessException "+
|
||||
"accessing Java field");
|
||||
} catch (IllegalArgumentException argEx) {
|
||||
Object errArgs[] = { value.getClass().getName(), field,
|
||||
javaObject.getClass().getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage(
|
||||
"msg.java.internal.field.type", errArgs));
|
||||
throw Context.reportRuntimeError3(
|
||||
"msg.java.internal.field.type",
|
||||
value.getClass().getName(), field,
|
||||
javaObject.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,11 +513,8 @@ class JavaMembers {
|
||||
}
|
||||
|
||||
RuntimeException reportMemberNotFound(String memberName) {
|
||||
Object errArgs[] = { cl.getName(),
|
||||
memberName };
|
||||
return Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.member.not.found",
|
||||
errArgs));
|
||||
return Context.reportRuntimeError2(
|
||||
"msg.java.member.not.found", cl.getName(), memberName);
|
||||
}
|
||||
|
||||
static Hashtable classTable = new Hashtable();
|
||||
@@ -573,9 +567,8 @@ class FieldAndMethods extends NativeJavaMethod {
|
||||
rval = field.get(javaObject);
|
||||
type = field.getType();
|
||||
} catch (IllegalAccessException accEx) {
|
||||
Object[] args = {getName()};
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.internal.private", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", getName());
|
||||
}
|
||||
rval = NativeJavaObject.wrap(this, rval, type);
|
||||
if (rval instanceof Scriptable) {
|
||||
|
||||
@@ -219,8 +219,7 @@ public class NativeArray extends ScriptableObject {
|
||||
else {
|
||||
long len = ScriptRuntime.toUint32(args[0]);
|
||||
if (len != (((Number)(args[0])).doubleValue()))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
return new NativeArray(len);
|
||||
}
|
||||
}
|
||||
@@ -242,13 +241,11 @@ public class NativeArray extends ScriptableObject {
|
||||
*/
|
||||
|
||||
if (!(val instanceof Number))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
|
||||
long longVal = ScriptRuntime.toUint32(val);
|
||||
if (longVal != (((Number)val).doubleValue()))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
|
||||
if (longVal < length) {
|
||||
// remove all properties between longVal and length
|
||||
|
||||
@@ -91,9 +91,7 @@ public final class NativeCall extends ScriptableObject {
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
if (!inNewExpr) {
|
||||
Object[] errArgs = { "Call" };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.only.from.new", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.only.from.new", "Call");
|
||||
}
|
||||
ScriptRuntime.checkDeprecated(cx, "Call");
|
||||
NativeCall result = new NativeCall();
|
||||
|
||||
@@ -1148,8 +1148,8 @@ public class NativeDate extends ScriptableObject {
|
||||
Function funObj) {
|
||||
if (obj == null || !(obj instanceof NativeDate)) {
|
||||
Context cx = Context.getCurrentContext();
|
||||
Object[] args = { ((NativeFunction) funObj).names[0] };
|
||||
String msg = Context.getMessage("msg.incompat.call", args);
|
||||
String name = ((NativeFunction) funObj).names[0];
|
||||
String msg = Context.getMessage1("msg.incompat.call", name);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", msg, funObj);
|
||||
}
|
||||
return (NativeDate) obj;
|
||||
|
||||
@@ -117,9 +117,8 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
if (protoProp instanceof Scriptable && protoProp != Undefined.instance) {
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
}
|
||||
Object[] args = { names[0] };
|
||||
String m = ScriptRuntime.getMessage("msg.instanceof.bad.prototype",
|
||||
args);
|
||||
String m = ScriptRuntime.getMessage1("msg.instanceof.bad.prototype",
|
||||
names[0]);
|
||||
throw NativeGlobal.constructError(Context.getContext(), "TypeError",
|
||||
m, instance);
|
||||
}
|
||||
@@ -404,15 +403,13 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
if (names != null && names.length > 0
|
||||
&& names[0].length() > 0)
|
||||
{
|
||||
Object[] errArgs = { new Integer((int)source.charAt(i)),
|
||||
names[0] };
|
||||
message = Context.getMessage
|
||||
("msg.no.function.ref.found.in", errArgs);
|
||||
message = Context.getMessage2
|
||||
("msg.no.function.ref.found.in",
|
||||
new Integer((int)source.charAt(i)), names[0]);
|
||||
} else {
|
||||
Object[] errArgs
|
||||
= { new Integer((int)source.charAt(i)) };
|
||||
message = Context.getMessage
|
||||
("msg.no.function.ref.found", errArgs);
|
||||
message = Context.getMessage1
|
||||
("msg.no.function.ref.found",
|
||||
new Integer((int)source.charAt(i)));
|
||||
}
|
||||
throw Context.reportRuntimeError(message);
|
||||
}
|
||||
@@ -844,9 +841,8 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
{
|
||||
Object val = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
|
||||
if (!(val instanceof NativeFunction)) {
|
||||
Object[] errArgs = { "toString" };
|
||||
String message = Context.getMessage("msg.incompat.call", errArgs);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", message, funObj);
|
||||
String m = Context.getMessage1("msg.incompat.call", "toString");
|
||||
throw NativeGlobal.constructError(cx, "TypeError", m, funObj);
|
||||
}
|
||||
if (val instanceof NativeJavaMethod) {
|
||||
return "\nfunction " + ((NativeFunction) val).jsGet_name() +
|
||||
@@ -932,7 +928,7 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
else
|
||||
throw NativeGlobal.constructError(
|
||||
cx, "TypeError",
|
||||
ScriptRuntime.getMessage("msg.arg.isnt.array", null),
|
||||
ScriptRuntime.getMessage0("msg.arg.isnt.array"),
|
||||
thisObj);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -386,8 +386,7 @@ public class NativeGlobal {
|
||||
Object[] args, Function funObj)
|
||||
throws JavaScriptException
|
||||
{
|
||||
Object[] a = { "eval" };
|
||||
String m = ScriptRuntime.getMessage("msg.cant.call.indirect", a);
|
||||
String m = ScriptRuntime.getMessage1("msg.cant.call.indirect", "eval");
|
||||
throw NativeGlobal.constructError(cx, "EvalError", m, funObj);
|
||||
}
|
||||
|
||||
@@ -405,7 +404,7 @@ public class NativeGlobal {
|
||||
return Undefined.instance;
|
||||
Object x = args[0];
|
||||
if (!(x instanceof String)) {
|
||||
String message = Context.getMessage("msg.eval.nonstring", null);
|
||||
String message = Context.getMessage0("msg.eval.nonstring");
|
||||
Context.reportWarning(message);
|
||||
return x;
|
||||
}
|
||||
@@ -435,7 +434,7 @@ public class NativeGlobal {
|
||||
// infinite looping on while(true) { eval('foo bar') } -
|
||||
// so we throw an EvaluatorException.
|
||||
if (script == null) {
|
||||
String message = Context.getMessage("msg.syntax", null);
|
||||
String message = Context.getMessage0("msg.syntax");
|
||||
throw new EvaluatorException(message);
|
||||
}
|
||||
|
||||
@@ -544,21 +543,18 @@ public class NativeGlobal {
|
||||
R.append(C);
|
||||
} else {
|
||||
if ((C >= 0xDC00) && (C <= 0xDFFF)) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
if ((C < 0xD800) || (C > 0xDBFF))
|
||||
V = C;
|
||||
else {
|
||||
k++;
|
||||
if (k == str.length()) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
C2 = str.charAt(k);
|
||||
if ((C2 < 0xDC00) || (C2 > 0xDFFF)) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
V = ((C - 0xD800) << 10) + (C2 - 0xDC00) + 0x10000;
|
||||
}
|
||||
@@ -607,11 +603,9 @@ public class NativeGlobal {
|
||||
if (C == '%') {
|
||||
start = k;
|
||||
if ((k + 2) >= str.length())
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
if (!isHex(str.charAt(k + 1)) || !isHex(str.charAt(k + 2)))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
B = unHex(str.charAt(k + 1)) * 16 + unHex(str.charAt(k + 2));
|
||||
k += 2;
|
||||
if ((B & 0x80) == 0)
|
||||
@@ -620,26 +614,21 @@ public class NativeGlobal {
|
||||
n = 1;
|
||||
while ((B & (0x80 >>> n)) != 0) n++;
|
||||
if ((n == 1) || (n > 6))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
octets[0] = (char)B;
|
||||
if ((k + 3 * (n - 1)) >= str.length())
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
for (j = 1; j < n; j++) {
|
||||
k++;
|
||||
if (str.charAt(k) != '%')
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
if (!isHex(str.charAt(k + 1))
|
||||
|| !isHex(str.charAt(k + 2)))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
B = unHex(str.charAt(k + 1)) * 16
|
||||
+ unHex(str.charAt(k + 2));
|
||||
if ((B & 0xC0) != 0x80)
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
k += 2;
|
||||
octets[j] = (char)B;
|
||||
}
|
||||
@@ -647,8 +636,7 @@ public class NativeGlobal {
|
||||
if (V >= 0x10000) {
|
||||
V -= 0x10000;
|
||||
if (V > 0xFFFFF)
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
C = (char)((V & 0x3FF) + 0xDC00);
|
||||
H = (char)((V >>> 10) + 0xD800);
|
||||
R.append(H);
|
||||
|
||||
@@ -88,11 +88,8 @@ public class NativeJavaArray extends NativeJavaObject {
|
||||
if (result == NOT_FOUND &&
|
||||
!ScriptRuntime.hasProp(getPrototype(), id))
|
||||
{
|
||||
Object errArgs[] = { array.getClass().getName(),
|
||||
id };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.member.not.found",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.java.member.not.found", array.getClass().getName(), id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -172,9 +172,8 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
Constructor ctor = (Constructor) member;
|
||||
if (ctor == null) {
|
||||
String sig = NativeJavaMethod.scriptSignature(args);
|
||||
Object errArgs[] = { classObject.getName(), sig };
|
||||
throw Context.reportRuntimeError(Context.getMessage(
|
||||
"msg.no.java.ctor", errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.no.java.ctor", classObject.getName(), sig);
|
||||
}
|
||||
|
||||
// Found the constructor, so try invoking it.
|
||||
@@ -200,10 +199,8 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
if (m != null)
|
||||
msg = m;
|
||||
}
|
||||
Object[] errArgs = { msg, classObject.getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.cant.instantiate",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.cant.instantiate", msg, classObject.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,24 +227,19 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
classObject);
|
||||
|
||||
} catch (InstantiationException instEx) {
|
||||
Object[] errArgs = { instEx.getMessage(),
|
||||
classObject.getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.cant.instantiate",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.cant.instantiate",
|
||||
instEx.getMessage(), classObject.getName());
|
||||
} catch (IllegalArgumentException argEx) {
|
||||
String signature = NativeJavaMethod.scriptSignature(args);
|
||||
String ctorString = ctor.toString();
|
||||
Object[] errArgs = { argEx.getMessage(),ctorString,signature };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.bad.ctor.sig",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError3(
|
||||
"msg.bad.ctor.sig", argEx.getMessage(), ctorString, signature);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw JavaScriptException.wrapException(scope, e);
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
Object[] errArgs = { accessEx.getMessage() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.internal.private", errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", accessEx.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,9 +180,7 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
Class c = methods[0].getDeclaringClass();
|
||||
String sig = c.getName() + "." + names[0] + "(" +
|
||||
scriptSignature(args) + ")";
|
||||
Object errArgs[] = { sig };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.no_such_method", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.java.no_such_method", sig);
|
||||
}
|
||||
|
||||
// OPT: already retrieved in findFunction, so we should inline that
|
||||
@@ -201,9 +199,8 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
while (!(o instanceof Wrapper)) {
|
||||
o = o.getPrototype();
|
||||
if (o == null) {
|
||||
Object errArgs[] = { names[0] };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.nonjava.method", errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.nonjava.method", names[0]);
|
||||
}
|
||||
}
|
||||
javaObject = ((Wrapper) o).unwrap();
|
||||
|
||||
@@ -222,10 +222,10 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
{
|
||||
Function converter = getConverter(converterName);
|
||||
if (converter == null) {
|
||||
Object[] errArgs = { converterName, javaObject.getClass().getName() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.conversion.implicit_method",
|
||||
errArgs));
|
||||
String className = javaObject.getClass().getName();
|
||||
throw Context.reportRuntimeError2
|
||||
("msg.java.conversion.implicit_method",
|
||||
converterName, className);
|
||||
}
|
||||
return callConverter(converter);
|
||||
}
|
||||
@@ -243,8 +243,7 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
} catch (JavaScriptException jse) {
|
||||
// fall through to error message
|
||||
}
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.default.value", null));
|
||||
throw Context.reportRuntimeError0("msg.default.value");
|
||||
}
|
||||
|
||||
|
||||
@@ -888,11 +887,9 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
}
|
||||
|
||||
static void reportConversionError(Object value, Class type) {
|
||||
Object[] args = { value.toString(),
|
||||
NativeJavaMethod.javaSignature(type)
|
||||
};
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.conversion.not.allowed", args));
|
||||
throw Context.reportRuntimeError2
|
||||
("msg.conversion.not.allowed",
|
||||
value.toString(), NativeJavaMethod.javaSignature(type));
|
||||
}
|
||||
|
||||
public static void initJSObject() {
|
||||
|
||||
@@ -145,8 +145,7 @@ public class NativeJavaPackage extends ScriptableObject {
|
||||
}
|
||||
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.pkg.int", null));
|
||||
throw Context.reportRuntimeError0("msg.pkg.int");
|
||||
}
|
||||
|
||||
public Object get(String id, Scriptable start) {
|
||||
@@ -230,7 +229,7 @@ public class NativeJavaPackage extends ScriptableObject {
|
||||
}
|
||||
}
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.not.java.obj", null));
|
||||
Context.getMessage0("msg.not.java.obj"));
|
||||
}
|
||||
|
||||
private String packageName;
|
||||
|
||||
@@ -144,11 +144,10 @@ public class NativeNumber extends ScriptableObject {
|
||||
} else {
|
||||
precision = ScriptRuntime.toInt32(arg);
|
||||
if (precision < precisionMin || precision > precisionMax) {
|
||||
Object args[] = new Object[1];
|
||||
args[0] = Integer.toString(precision);
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getCurrentContext(), "RangeError",
|
||||
ScriptRuntime.getMessage("msg.bad.precision", args),
|
||||
ScriptRuntime.getMessage1(
|
||||
"msg.bad.precision", Integer.toString(precision)),
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,8 @@ public class NativeScript extends NativeFunction implements Script {
|
||||
}
|
||||
|
||||
public Object jsFunction_exec() throws JavaScriptException {
|
||||
Object[] msgArgs = { "exec" };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.call.indirect", msgArgs));
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.cant.call.indirect", "exec");
|
||||
}
|
||||
|
||||
public static Object jsFunction_toString(Context cx, Scriptable thisObj,
|
||||
@@ -163,8 +162,7 @@ public class NativeScript extends NativeFunction implements Script {
|
||||
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
String message = Context.getMessage("msg.script.is.not.constructor", null);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError0("msg.script.is.not.constructor");
|
||||
}
|
||||
|
||||
private Script script;
|
||||
|
||||
@@ -726,7 +726,7 @@ public class NativeString extends ScriptableObject {
|
||||
private static RegExpProxy checkReProxy(Context cx) {
|
||||
RegExpProxy result = cx.getRegExpProxy();
|
||||
if (result == null) {
|
||||
throw cx.reportRuntimeError(cx.getMessage("msg.no.regexp", null));
|
||||
throw cx.reportRuntimeError0("msg.no.regexp");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -141,18 +141,14 @@ public class NativeWith implements Scriptable {
|
||||
public static Object jsConstructor(Context cx, Object[] args,
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
Object[] msgArgs = { "With" };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.call.indirect", msgArgs));
|
||||
throw Context.reportRuntimeError1("msg.cant.call.indirect", "With");
|
||||
}
|
||||
|
||||
public static Object newWithSpecial(Context cx, Object[] args,
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
if (!inNewExpr) {
|
||||
Object[] errArgs = { "With" };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.only.from.new", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.only.from.new", "With");
|
||||
}
|
||||
|
||||
ScriptRuntime.checkDeprecated(cx, "With");
|
||||
|
||||
@@ -133,9 +133,8 @@ public class NodeTransformer {
|
||||
if (n.getType() == TokenStream.LABEL) {
|
||||
String otherId = (String)n.getProp(Node.LABEL_PROP);
|
||||
if (id.equals(otherId)) {
|
||||
Object[] errArgs = { id };
|
||||
String message = Context.getMessage("msg.dup.label",
|
||||
errArgs);
|
||||
String message = Context.getMessage1(
|
||||
"msg.dup.label", id);
|
||||
reportMessage(Context.getContext(), message, node,
|
||||
tree, true, scope);
|
||||
break typeswitch;
|
||||
@@ -361,8 +360,7 @@ public class NodeTransformer {
|
||||
("msg.bad.break", null);
|
||||
}
|
||||
} else if (loop != null) {
|
||||
message = Context.getMessage("msg.continue.nonloop",
|
||||
null);
|
||||
message = Context.getMessage0("msg.continue.nonloop");
|
||||
} else {
|
||||
Object[] errArgs = { id };
|
||||
message = Context.getMessage
|
||||
|
||||
@@ -47,4 +47,19 @@ public class PropertyException extends Exception {
|
||||
super(detail);
|
||||
}
|
||||
|
||||
static PropertyException withMessage0(String messageId) {
|
||||
return new PropertyException(Context.getMessage0(messageId));
|
||||
}
|
||||
|
||||
static PropertyException withMessage1(String messageId, Object arg1) {
|
||||
return new PropertyException(Context.getMessage1(messageId, arg1));
|
||||
}
|
||||
|
||||
static PropertyException withMessage2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return new PropertyException
|
||||
(Context.getMessage2(messageId, arg1, arg2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -432,9 +432,8 @@ public class ScriptRuntime {
|
||||
return "0";
|
||||
|
||||
if ((base < 2) || (base > 36)) {
|
||||
Object[] args = { Integer.toString(base) };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.bad.radix", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.bad.radix", Integer.toString(base));
|
||||
}
|
||||
|
||||
if (base != 10) {
|
||||
@@ -462,14 +461,14 @@ public class ScriptRuntime {
|
||||
if (val == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
if (val instanceof Scriptable) {
|
||||
if (val == Undefined.instance) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.undef.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.undef.to.object"),
|
||||
scope);
|
||||
}
|
||||
return (Scriptable) val;
|
||||
@@ -683,7 +682,7 @@ public class ScriptRuntime {
|
||||
: "msg.undefined";
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ConversionError",
|
||||
ScriptRuntime.getMessage(msg, null),
|
||||
ScriptRuntime.getMessage0(msg),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -722,7 +721,7 @@ public class ScriptRuntime {
|
||||
if (s == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
return s.getPrototype();
|
||||
@@ -752,7 +751,7 @@ public class ScriptRuntime {
|
||||
if (s == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
return s.getParentScope();
|
||||
@@ -769,16 +768,15 @@ public class ScriptRuntime {
|
||||
Scriptable s = result;
|
||||
while (s != null) {
|
||||
if (s == start) {
|
||||
Object[] args = { "__proto__" };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.cyclic.value", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.cyclic.value", "__proto__");
|
||||
}
|
||||
s = s.getPrototype();
|
||||
}
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
start.setPrototype(result);
|
||||
@@ -796,16 +794,15 @@ public class ScriptRuntime {
|
||||
Scriptable s = result;
|
||||
while (s != null) {
|
||||
if (s == start) {
|
||||
Object[] args = { "__parent__" };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.cyclic.value", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.cyclic.value", "__parent__");
|
||||
}
|
||||
s = s.getParentScope();
|
||||
}
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
start.setParentScope(result);
|
||||
@@ -824,7 +821,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1090,10 +1087,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object[] args = { id.toString() };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id.toString()),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1137,10 +1133,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object[] args = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1171,8 +1166,7 @@ public class ScriptRuntime {
|
||||
This code is causing immense performance problems in
|
||||
scripts that assign to the variables as a way of creating them.
|
||||
XXX need strict mode
|
||||
String[] args = { id };
|
||||
String message = getMessage("msg.assn.create", args);
|
||||
String message = getMessage1("msg.assn.create", id);
|
||||
Context.reportWarning(message);
|
||||
*/
|
||||
return value;
|
||||
@@ -1213,11 +1207,9 @@ public class ScriptRuntime {
|
||||
function = (Function) fun;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
Object[] errorArgs = { toString(fun) };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.isnt.function",
|
||||
errorArgs),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage1("msg.isnt.function", toString(fun)),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1293,10 +1285,9 @@ public class ScriptRuntime {
|
||||
} catch (ClassCastException e) {
|
||||
// fall through to error
|
||||
}
|
||||
Object[] errorArgs = { toString(fun) };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.isnt.function", errorArgs),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage1("msg.isnt.function", toString(fun)),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1396,10 +1387,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object args[] = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1413,7 +1403,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1493,10 +1483,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object args[] = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1510,7 +1499,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1543,7 +1532,7 @@ public class ScriptRuntime {
|
||||
if (result != null && result instanceof Scriptable)
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.bad.default.value", null),
|
||||
ScriptRuntime.getMessage0("msg.bad.default.value"),
|
||||
val);
|
||||
return result;
|
||||
}
|
||||
@@ -1696,7 +1685,7 @@ public class ScriptRuntime {
|
||||
if (! (b instanceof Scriptable)) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.not.object", null),
|
||||
ScriptRuntime.getMessage0("msg.instanceof.not.object"),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1744,7 +1733,7 @@ public class ScriptRuntime {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(),
|
||||
"TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.not.object", null),
|
||||
ScriptRuntime.getMessage0("msg.instanceof.not.object"),
|
||||
scope);
|
||||
}
|
||||
String s = getStringId(a);
|
||||
@@ -2002,9 +1991,7 @@ public class ScriptRuntime {
|
||||
static void checkDeprecated(Context cx, String name) {
|
||||
int version = cx.getLanguageVersion();
|
||||
if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
|
||||
Object[] errArgs = { name };
|
||||
String msg = getMessage("msg.deprec.ctor",
|
||||
errArgs);
|
||||
String msg = getMessage1("msg.deprec.ctor", name);
|
||||
if (version == Context.VERSION_DEFAULT)
|
||||
Context.reportWarning(msg);
|
||||
else
|
||||
@@ -2012,6 +1999,20 @@ public class ScriptRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMessage0(String messageId) {
|
||||
return Context.getMessage0(messageId);
|
||||
}
|
||||
|
||||
public static String getMessage1(String messageId, Object arg1) {
|
||||
return Context.getMessage1(messageId, arg1);
|
||||
}
|
||||
|
||||
public static String getMessage2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return Context.getMessage2(messageId, arg1, arg2);
|
||||
}
|
||||
|
||||
public static String getMessage(String messageId, Object[] arguments) {
|
||||
return Context.getMessage(messageId, arguments);
|
||||
}
|
||||
@@ -2085,8 +2086,7 @@ public class ScriptRuntime {
|
||||
|
||||
private static RuntimeException errorWithClassName(String msg, Object val)
|
||||
{
|
||||
Object[] args = { val.getClass().getName() };
|
||||
return Context.reportRuntimeError(getMessage(msg, args));
|
||||
return Context.reportRuntimeError1(msg, val.getClass().getName());
|
||||
}
|
||||
|
||||
static public Object[] emptyArgs = new Object[0];
|
||||
|
||||
@@ -356,8 +356,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(name, name.hashCode());
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
return slots[slotIndex].attributes;
|
||||
}
|
||||
@@ -381,8 +380,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(null, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
return slots[slotIndex].attributes;
|
||||
}
|
||||
@@ -418,8 +416,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
attributes &= mask; // mask out unused bits
|
||||
int slotIndex = getSlot(name, name.hashCode());
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
slots[slotIndex].attributes = (short) attributes;
|
||||
}
|
||||
@@ -444,8 +441,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(null, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
slots[slotIndex].attributes = (short) attributes;
|
||||
}
|
||||
@@ -562,9 +558,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
typeHint == Double.TYPE)
|
||||
hint = "number";
|
||||
else {
|
||||
Object[] args = { typeHint.toString() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.invalid.type", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.invalid.type", typeHint.toString());
|
||||
}
|
||||
Object v = getProperty(this, "valueOf");
|
||||
if (!(v instanceof Function))
|
||||
@@ -596,10 +591,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
// fall through to error
|
||||
}
|
||||
Object arg = typeHint == null ? "undefined" : typeHint.toString();
|
||||
Object[] args = { arg };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.default.value", args),
|
||||
ScriptRuntime.getMessage1("msg.default.value", arg),
|
||||
this);
|
||||
}
|
||||
|
||||
@@ -782,9 +776,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
}
|
||||
if (protoCtor == null) {
|
||||
Object[] args = { clazz.getName() };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.zero.arg.ctor", args));
|
||||
Context.getMessage1("msg.zero.arg.ctor", clazz.getName()));
|
||||
}
|
||||
|
||||
Scriptable proto = (Scriptable)
|
||||
@@ -808,9 +801,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
Member ctorMember = null;
|
||||
if (ctorMeths != null) {
|
||||
if (ctorMeths.length > 1) {
|
||||
Object[] args = { ctorMeths[0], ctorMeths[1] };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.multiple.ctors", args));
|
||||
Context.getMessage2("msg.multiple.ctors",
|
||||
ctorMeths[0], ctorMeths[1]));
|
||||
}
|
||||
ctorMember = ctorMeths[0];
|
||||
}
|
||||
@@ -841,9 +834,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
if (name.equals(className)) {
|
||||
if (ctorMember != null) {
|
||||
Object[] args = { ctorMember, methods[i] };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.multiple.ctors", args));
|
||||
Context.getMessage2("msg.multiple.ctors",
|
||||
ctorMember, methods[i]));
|
||||
}
|
||||
ctorMember = methods[i];
|
||||
}
|
||||
@@ -859,17 +852,16 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
ctorMember = ctors[0];
|
||||
}
|
||||
if (ctorMember == null) {
|
||||
Object[] args = { clazz.getName() };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.ctor.multiple.parms", args));
|
||||
Context.getMessage1("msg.ctor.multiple.parms",
|
||||
clazz.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
FunctionObject ctor = new FunctionObject(className, ctorMember, scope);
|
||||
if (ctor.isVarArgsMethod()) {
|
||||
Object[] args = { ctorMember.getName() };
|
||||
String message = Context.getMessage("msg.varargs.ctor", args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.varargs.ctor", ctorMember.getName());
|
||||
}
|
||||
ctor.addAsConstructor(scope, proto);
|
||||
|
||||
@@ -928,17 +920,15 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
continue; // deal with set when we see get
|
||||
if (prefix != null && prefix.equals(getterPrefix)) {
|
||||
if (!(proto instanceof ScriptableObject)) {
|
||||
Object[] args = { proto.getClass().toString(), name };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.extend.scriptable", args));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.extend.scriptable", proto.getClass().toString(), name);
|
||||
}
|
||||
Method[] setter = FunctionObject.findMethods(
|
||||
clazz,
|
||||
setterPrefix + name);
|
||||
if (setter != null && setter.length != 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
int attr = ScriptableObject.PERMANENT |
|
||||
ScriptableObject.DONTENUM |
|
||||
@@ -956,9 +946,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
prefix.equals(staticFunctionPrefix))))
|
||||
{
|
||||
if (!(proto instanceof ScriptableObject)) {
|
||||
Object[] args = { proto.getClass().toString(), name };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.extend.scriptable", args));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.extend.scriptable",
|
||||
proto.getClass().toString(), name);
|
||||
}
|
||||
if (name.startsWith("set"))
|
||||
continue; // deal with set when we see get
|
||||
@@ -976,9 +966,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
hasPrefix ? genericPrefix + setterName
|
||||
: setterName);
|
||||
if (setter != null && setter.length != 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
if (setter == null && hasPrefix)
|
||||
setter = FunctionObject.findMethods(
|
||||
@@ -996,9 +985,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
FunctionObject f = new FunctionObject(name, methods[i], proto);
|
||||
if (f.isVarArgsConstructor()) {
|
||||
Object[] args = { ctorMember.getName() };
|
||||
String message = Context.getMessage("msg.varargs.fun", args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.varargs.fun", ctorMember.getName());
|
||||
}
|
||||
Scriptable dest = prefix == staticFunctionPrefix
|
||||
? ctor
|
||||
@@ -1087,9 +1075,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
if (setter == null)
|
||||
attributes |= ScriptableObject.READONLY;
|
||||
if (getter.length != 1 || (setter != null && setter.length != 1)) {
|
||||
Object[] errArgs = { propertyName, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", propertyName, clazz.getName());
|
||||
}
|
||||
defineProperty(propertyName, null, getter[0],
|
||||
setter == null ? null : setter[0], attributes);
|
||||
@@ -1150,43 +1137,36 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
if (parmTypes.length != 1 ||
|
||||
parmTypes[0] != ScriptableObject.class)
|
||||
{
|
||||
Object[] args = { getter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.bad.getter.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.bad.getter.parms", getter.toString());
|
||||
}
|
||||
} else if (delegateTo != null) {
|
||||
Object[] args = { getter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.obj.getter.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.obj.getter.parms", getter.toString());
|
||||
}
|
||||
if (setter != null) {
|
||||
flags |= Slot.HAS_SETTER;
|
||||
if ((delegateTo == HAS_STATIC_ACCESSORS) !=
|
||||
(Modifier.isStatic(setter.getModifiers())))
|
||||
{
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.getter.static", null));
|
||||
throw PropertyException.withMessage0("msg.getter.static");
|
||||
}
|
||||
parmTypes = setter.getParameterTypes();
|
||||
if (parmTypes.length == 2) {
|
||||
if (parmTypes[0] != ScriptableObject.class) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter2.parms", null));
|
||||
throw PropertyException.withMessage0("msg.setter2.parms");
|
||||
}
|
||||
if (delegateTo == null) {
|
||||
Object[] args = { setter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter1.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.setter1.parms", setter.toString());
|
||||
}
|
||||
} else if (parmTypes.length == 1) {
|
||||
if (delegateTo != null) {
|
||||
Object[] args = { setter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter2.expected", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.setter2.expected", setter.toString());
|
||||
}
|
||||
} else {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter.parms", null));
|
||||
throw PropertyException.withMessage0("msg.setter.parms");
|
||||
}
|
||||
}
|
||||
int slotIndex = getSlotToSet(propertyName,
|
||||
@@ -1226,14 +1206,12 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
String name = names[i];
|
||||
Method[] m = FunctionObject.findMethods(clazz, name);
|
||||
if (m == null) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.method.not.found", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.method.not.found", name, clazz.getName());
|
||||
}
|
||||
if (m.length > 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
FunctionObject f = new FunctionObject(name, m[0], this);
|
||||
defineProperty(name, f, attributes);
|
||||
@@ -1639,8 +1617,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
private synchronized int addSlot(String id, int index, boolean getterSlot)
|
||||
{
|
||||
if (count == -1)
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.add.sealed", null));
|
||||
throw Context.reportRuntimeError0("msg.add.sealed");
|
||||
int start = (index & 0x7fffffff) % slots.length;
|
||||
int i = start;
|
||||
do {
|
||||
@@ -1678,8 +1655,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
*/
|
||||
private synchronized void removeSlot(String name, int index) {
|
||||
if (count == -1)
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.remove.sealed", null));
|
||||
throw Context.reportRuntimeError0("msg.remove.sealed");
|
||||
int slotIndex = getSlot(name, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND)
|
||||
return;
|
||||
|
||||
@@ -635,10 +635,8 @@ public class TokenStream {
|
||||
|
||||
public void ungetToken(int tt) {
|
||||
if (this.pushbackToken != EOF && tt != ERROR) {
|
||||
Object[] errArgs = { tokenToString(tt),
|
||||
tokenToString(this.pushbackToken) };
|
||||
String message = Context.getMessage("msg.token.replaces.pushback",
|
||||
errArgs);
|
||||
String message = Context.getMessage2("msg.token.replaces.pushback",
|
||||
tokenToString(tt), tokenToString(this.pushbackToken));
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
this.pushbackToken = tt;
|
||||
|
||||
@@ -133,7 +133,6 @@ public class Undefined implements Scriptable {
|
||||
}
|
||||
|
||||
private RuntimeException reportError() {
|
||||
String message = Context.getMessage("msg.undefined", null);
|
||||
return Context.reportRuntimeError(message);
|
||||
return Context.reportRuntimeError0("msg.undefined");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,7 @@ public class VariableTable {
|
||||
LocalVariable p = (LocalVariable)
|
||||
(itsVariables.elementAt(pIndex.intValue()));
|
||||
if (p.isParameter()) {
|
||||
Object[] errorArgs = { pName };
|
||||
String message = Context.getMessage("msg.dup.parms", errorArgs);
|
||||
String message = Context.getMessage1("msg.dup.parms", pName);
|
||||
Context.reportWarning(message, null, 0, null, 0);
|
||||
}
|
||||
else { // there's a local variable with this name, blow it off
|
||||
|
||||
@@ -532,6 +532,28 @@ public final class Context {
|
||||
}
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError0(String messageId) {
|
||||
return reportRuntimeError(getMessage0(messageId));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError1
|
||||
(String messageId, Object arg1)
|
||||
{
|
||||
return reportRuntimeError(getMessage1(messageId, arg1));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return reportRuntimeError(getMessage2(messageId, arg1, arg2));
|
||||
}
|
||||
|
||||
static EvaluatorException reportRuntimeError3
|
||||
(String messageId, Object arg1, Object arg2, Object arg3)
|
||||
{
|
||||
return reportRuntimeError(getMessage3(messageId, arg1, arg2, arg3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a runtime error using the error reporter for the current thread.
|
||||
*
|
||||
@@ -1010,13 +1032,11 @@ public final class Context {
|
||||
{
|
||||
Object ctorVal = ScriptRuntime.getTopLevelProp(scope, constructorName);
|
||||
if (ctorVal == Scriptable.NOT_FOUND) {
|
||||
Object[] errArgs = { constructorName };
|
||||
String message = getMessage("msg.ctor.not.found", errArgs);
|
||||
String message = getMessage1("msg.ctor.not.found", constructorName);
|
||||
throw new PropertyException(message);
|
||||
}
|
||||
if (!(ctorVal instanceof Function)) {
|
||||
Object[] errArgs = { constructorName };
|
||||
String message = getMessage("msg.not.ctor", errArgs);
|
||||
String message = getMessage1("msg.not.ctor", constructorName);
|
||||
throw new NotAFunctionException(message);
|
||||
}
|
||||
Function ctor = (Function) ctorVal;
|
||||
@@ -1528,6 +1548,26 @@ public final class Context {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static String getMessage0(String messageId) {
|
||||
return getMessage(messageId, null);
|
||||
}
|
||||
|
||||
static String getMessage1(String messageId, Object arg1) {
|
||||
Object[] arguments = {arg1};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
|
||||
static String getMessage2(String messageId, Object arg1, Object arg2) {
|
||||
Object[] arguments = {arg1, arg2};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
|
||||
static String getMessage3
|
||||
(String messageId, Object arg1, Object arg2, Object arg3) {
|
||||
Object[] arguments = {arg1, arg2, arg3};
|
||||
return getMessage(messageId, arguments);
|
||||
}
|
||||
/**
|
||||
* Internal method that reports an error for missing calls to
|
||||
* enter().
|
||||
|
||||
@@ -306,8 +306,7 @@ public class FlattenedObject {
|
||||
JavaScriptException
|
||||
{
|
||||
if (!hasProperty(id)) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
Object o = getProperty(id);
|
||||
if (o instanceof FlattenedObject)
|
||||
|
||||
@@ -138,10 +138,8 @@ public class FunctionObject extends NativeFunction {
|
||||
types[2] != ScriptRuntime.FunctionClass ||
|
||||
types[3] != Boolean.TYPE)
|
||||
{
|
||||
String[] args = { methodName };
|
||||
String message = Context.getMessage("msg.varargs.ctor",
|
||||
args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.varargs.ctor", methodName);
|
||||
}
|
||||
parmsLength = VARARGS_CTOR;
|
||||
} else {
|
||||
@@ -151,10 +149,8 @@ public class FunctionObject extends NativeFunction {
|
||||
types[2].getComponentType() != ScriptRuntime.ObjectClass ||
|
||||
types[3] != ScriptRuntime.FunctionClass)
|
||||
{
|
||||
String[] args = { methodName };
|
||||
String message = Context.getMessage("msg.varargs.fun",
|
||||
args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.varargs.fun", methodName);
|
||||
}
|
||||
parmsLength = VARARGS_METHOD;
|
||||
}
|
||||
@@ -176,10 +172,9 @@ public class FunctionObject extends NativeFunction {
|
||||
type != Float.TYPE &&
|
||||
type != Double.TYPE)
|
||||
{
|
||||
// Note that long is not supported; see comments above
|
||||
Object[] errArgs = { methodName };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.bad.parms", errArgs));
|
||||
// Note that long is not supported.
|
||||
throw Context.reportRuntimeError1("msg.bad.parms",
|
||||
methodName);
|
||||
}
|
||||
}
|
||||
length = parmsLength;
|
||||
@@ -426,9 +421,8 @@ public class FunctionObject extends NativeFunction {
|
||||
|
||||
// Note that the long type is not supported; see the javadoc for
|
||||
// the constructor for this class
|
||||
Object[] errArgs = { desired.getName() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.convert", errArgs));
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.cant.convert", desired.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,8 +457,8 @@ public class FunctionObject extends NativeFunction {
|
||||
thisObj = thisObj.getPrototype();
|
||||
if (thisObj == null || !useDynamicScope) {
|
||||
// Couldn't find an object to call this on.
|
||||
Object[] errArgs = { names[0] };
|
||||
String msg = Context.getMessage("msg.incompat.call", errArgs);
|
||||
String msg = Context.getMessage1
|
||||
("msg.incompat.call", names[0]);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", msg, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1036,10 +1036,10 @@ public class IRFactory {
|
||||
if (scope != null)
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "SyntaxError",
|
||||
ScriptRuntime.getMessage(msgResource, null),
|
||||
ScriptRuntime.getMessage0(msgResource),
|
||||
scope);
|
||||
else {
|
||||
String message = Context.getMessage(msgResource, null);
|
||||
String message = Context.getMessage0(msgResource);
|
||||
Context.reportError(message, ts.getSourceName(), ts.getLineno(),
|
||||
ts.getLine(), ts.getOffset());
|
||||
}
|
||||
|
||||
@@ -106,10 +106,8 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
if (result == NOT_FOUND) {
|
||||
result = v;
|
||||
} else {
|
||||
String[] args = { result.toString(), v.toString() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.ambig.import",
|
||||
args));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.ambig.import", result.toString(), v.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,15 +119,14 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
for (int i=0; i<args.length; i++) {
|
||||
Object cl = args[i];
|
||||
if (!(cl instanceof NativeJavaClass)) {
|
||||
String[] eargs = { Context.toString(cl) };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.not.class", eargs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.not.class", Context.toString(cl));
|
||||
}
|
||||
String s = ((NativeJavaClass) cl).getClassObject().getName();
|
||||
String n = s.substring(s.lastIndexOf('.')+1);
|
||||
Object val = thisObj.get(n, thisObj);
|
||||
if (val != NOT_FOUND && val != cl) {
|
||||
String[] eargs = { n };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.prop.defined", eargs));
|
||||
throw Context.reportRuntimeError1("msg.prop.defined", n);
|
||||
}
|
||||
//thisObj.defineProperty(n, cl, DONTENUM);
|
||||
thisObj.put(n,thisObj,cl);
|
||||
@@ -150,8 +147,8 @@ public class ImporterTopLevel extends ScriptableObject {
|
||||
for (int i=0; i<args.length; i++) {
|
||||
Object pkg = args[i];
|
||||
if (!(pkg instanceof NativeJavaPackage)) {
|
||||
String[] eargs = { Context.toString(pkg) };
|
||||
throw Context.reportRuntimeError(Context.getMessage("msg.not.pkg", eargs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.not.pkg", Context.toString(pkg));
|
||||
}
|
||||
Object[] elements = cx.getElements(importedPackages);
|
||||
for (int j=0; j < elements.length; j++) {
|
||||
|
||||
@@ -220,25 +220,22 @@ class JavaMembers {
|
||||
try {
|
||||
field = (Field) member;
|
||||
if (field == null) {
|
||||
Object[] args = {name};
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.internal.private", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", name);
|
||||
}
|
||||
field.set(javaObject, NativeJavaObject.coerceType(field.getType(),
|
||||
value));
|
||||
field.set(javaObject,
|
||||
NativeJavaObject.coerceType(field.getType(), value));
|
||||
} catch (ClassCastException e) {
|
||||
Object errArgs[] = { name };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.method.assign",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.method.assign", name);
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
throw new RuntimeException("unexpected IllegalAccessException "+
|
||||
"accessing Java field");
|
||||
} catch (IllegalArgumentException argEx) {
|
||||
Object errArgs[] = { value.getClass().getName(), field,
|
||||
javaObject.getClass().getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage(
|
||||
"msg.java.internal.field.type", errArgs));
|
||||
throw Context.reportRuntimeError3(
|
||||
"msg.java.internal.field.type",
|
||||
value.getClass().getName(), field,
|
||||
javaObject.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,11 +513,8 @@ class JavaMembers {
|
||||
}
|
||||
|
||||
RuntimeException reportMemberNotFound(String memberName) {
|
||||
Object errArgs[] = { cl.getName(),
|
||||
memberName };
|
||||
return Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.member.not.found",
|
||||
errArgs));
|
||||
return Context.reportRuntimeError2(
|
||||
"msg.java.member.not.found", cl.getName(), memberName);
|
||||
}
|
||||
|
||||
static Hashtable classTable = new Hashtable();
|
||||
@@ -573,9 +567,8 @@ class FieldAndMethods extends NativeJavaMethod {
|
||||
rval = field.get(javaObject);
|
||||
type = field.getType();
|
||||
} catch (IllegalAccessException accEx) {
|
||||
Object[] args = {getName()};
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.internal.private", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", getName());
|
||||
}
|
||||
rval = NativeJavaObject.wrap(this, rval, type);
|
||||
if (rval instanceof Scriptable) {
|
||||
|
||||
@@ -219,8 +219,7 @@ public class NativeArray extends ScriptableObject {
|
||||
else {
|
||||
long len = ScriptRuntime.toUint32(args[0]);
|
||||
if (len != (((Number)(args[0])).doubleValue()))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
return new NativeArray(len);
|
||||
}
|
||||
}
|
||||
@@ -242,13 +241,11 @@ public class NativeArray extends ScriptableObject {
|
||||
*/
|
||||
|
||||
if (!(val instanceof Number))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
|
||||
long longVal = ScriptRuntime.toUint32(val);
|
||||
if (longVal != (((Number)val).doubleValue()))
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.arraylength.bad", null));
|
||||
throw Context.reportRuntimeError0("msg.arraylength.bad");
|
||||
|
||||
if (longVal < length) {
|
||||
// remove all properties between longVal and length
|
||||
|
||||
@@ -91,9 +91,7 @@ public final class NativeCall extends ScriptableObject {
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
if (!inNewExpr) {
|
||||
Object[] errArgs = { "Call" };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.only.from.new", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.only.from.new", "Call");
|
||||
}
|
||||
ScriptRuntime.checkDeprecated(cx, "Call");
|
||||
NativeCall result = new NativeCall();
|
||||
|
||||
@@ -1148,8 +1148,8 @@ public class NativeDate extends ScriptableObject {
|
||||
Function funObj) {
|
||||
if (obj == null || !(obj instanceof NativeDate)) {
|
||||
Context cx = Context.getCurrentContext();
|
||||
Object[] args = { ((NativeFunction) funObj).names[0] };
|
||||
String msg = Context.getMessage("msg.incompat.call", args);
|
||||
String name = ((NativeFunction) funObj).names[0];
|
||||
String msg = Context.getMessage1("msg.incompat.call", name);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", msg, funObj);
|
||||
}
|
||||
return (NativeDate) obj;
|
||||
|
||||
@@ -117,9 +117,8 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
if (protoProp instanceof Scriptable && protoProp != Undefined.instance) {
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
}
|
||||
Object[] args = { names[0] };
|
||||
String m = ScriptRuntime.getMessage("msg.instanceof.bad.prototype",
|
||||
args);
|
||||
String m = ScriptRuntime.getMessage1("msg.instanceof.bad.prototype",
|
||||
names[0]);
|
||||
throw NativeGlobal.constructError(Context.getContext(), "TypeError",
|
||||
m, instance);
|
||||
}
|
||||
@@ -404,15 +403,13 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
if (names != null && names.length > 0
|
||||
&& names[0].length() > 0)
|
||||
{
|
||||
Object[] errArgs = { new Integer((int)source.charAt(i)),
|
||||
names[0] };
|
||||
message = Context.getMessage
|
||||
("msg.no.function.ref.found.in", errArgs);
|
||||
message = Context.getMessage2
|
||||
("msg.no.function.ref.found.in",
|
||||
new Integer((int)source.charAt(i)), names[0]);
|
||||
} else {
|
||||
Object[] errArgs
|
||||
= { new Integer((int)source.charAt(i)) };
|
||||
message = Context.getMessage
|
||||
("msg.no.function.ref.found", errArgs);
|
||||
message = Context.getMessage1
|
||||
("msg.no.function.ref.found",
|
||||
new Integer((int)source.charAt(i)));
|
||||
}
|
||||
throw Context.reportRuntimeError(message);
|
||||
}
|
||||
@@ -844,9 +841,8 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
{
|
||||
Object val = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
|
||||
if (!(val instanceof NativeFunction)) {
|
||||
Object[] errArgs = { "toString" };
|
||||
String message = Context.getMessage("msg.incompat.call", errArgs);
|
||||
throw NativeGlobal.constructError(cx, "TypeError", message, funObj);
|
||||
String m = Context.getMessage1("msg.incompat.call", "toString");
|
||||
throw NativeGlobal.constructError(cx, "TypeError", m, funObj);
|
||||
}
|
||||
if (val instanceof NativeJavaMethod) {
|
||||
return "\nfunction " + ((NativeFunction) val).jsGet_name() +
|
||||
@@ -932,7 +928,7 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
else
|
||||
throw NativeGlobal.constructError(
|
||||
cx, "TypeError",
|
||||
ScriptRuntime.getMessage("msg.arg.isnt.array", null),
|
||||
ScriptRuntime.getMessage0("msg.arg.isnt.array"),
|
||||
thisObj);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -386,8 +386,7 @@ public class NativeGlobal {
|
||||
Object[] args, Function funObj)
|
||||
throws JavaScriptException
|
||||
{
|
||||
Object[] a = { "eval" };
|
||||
String m = ScriptRuntime.getMessage("msg.cant.call.indirect", a);
|
||||
String m = ScriptRuntime.getMessage1("msg.cant.call.indirect", "eval");
|
||||
throw NativeGlobal.constructError(cx, "EvalError", m, funObj);
|
||||
}
|
||||
|
||||
@@ -405,7 +404,7 @@ public class NativeGlobal {
|
||||
return Undefined.instance;
|
||||
Object x = args[0];
|
||||
if (!(x instanceof String)) {
|
||||
String message = Context.getMessage("msg.eval.nonstring", null);
|
||||
String message = Context.getMessage0("msg.eval.nonstring");
|
||||
Context.reportWarning(message);
|
||||
return x;
|
||||
}
|
||||
@@ -435,7 +434,7 @@ public class NativeGlobal {
|
||||
// infinite looping on while(true) { eval('foo bar') } -
|
||||
// so we throw an EvaluatorException.
|
||||
if (script == null) {
|
||||
String message = Context.getMessage("msg.syntax", null);
|
||||
String message = Context.getMessage0("msg.syntax");
|
||||
throw new EvaluatorException(message);
|
||||
}
|
||||
|
||||
@@ -544,21 +543,18 @@ public class NativeGlobal {
|
||||
R.append(C);
|
||||
} else {
|
||||
if ((C >= 0xDC00) && (C <= 0xDFFF)) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
if ((C < 0xD800) || (C > 0xDBFF))
|
||||
V = C;
|
||||
else {
|
||||
k++;
|
||||
if (k == str.length()) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
C2 = str.charAt(k);
|
||||
if ((C2 < 0xDC00) || (C2 > 0xDFFF)) {
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
}
|
||||
V = ((C - 0xD800) << 10) + (C2 - 0xDC00) + 0x10000;
|
||||
}
|
||||
@@ -607,11 +603,9 @@ public class NativeGlobal {
|
||||
if (C == '%') {
|
||||
start = k;
|
||||
if ((k + 2) >= str.length())
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
if (!isHex(str.charAt(k + 1)) || !isHex(str.charAt(k + 2)))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
B = unHex(str.charAt(k + 1)) * 16 + unHex(str.charAt(k + 2));
|
||||
k += 2;
|
||||
if ((B & 0x80) == 0)
|
||||
@@ -620,26 +614,21 @@ public class NativeGlobal {
|
||||
n = 1;
|
||||
while ((B & (0x80 >>> n)) != 0) n++;
|
||||
if ((n == 1) || (n > 6))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
octets[0] = (char)B;
|
||||
if ((k + 3 * (n - 1)) >= str.length())
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
for (j = 1; j < n; j++) {
|
||||
k++;
|
||||
if (str.charAt(k) != '%')
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
if (!isHex(str.charAt(k + 1))
|
||||
|| !isHex(str.charAt(k + 2)))
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
B = unHex(str.charAt(k + 1)) * 16
|
||||
+ unHex(str.charAt(k + 2));
|
||||
if ((B & 0xC0) != 0x80)
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
k += 2;
|
||||
octets[j] = (char)B;
|
||||
}
|
||||
@@ -647,8 +636,7 @@ public class NativeGlobal {
|
||||
if (V >= 0x10000) {
|
||||
V -= 0x10000;
|
||||
if (V > 0xFFFFF)
|
||||
throw cx.reportRuntimeError(
|
||||
cx.getMessage("msg.bad.uri", null));
|
||||
throw cx.reportRuntimeError0("msg.bad.uri");
|
||||
C = (char)((V & 0x3FF) + 0xDC00);
|
||||
H = (char)((V >>> 10) + 0xD800);
|
||||
R.append(H);
|
||||
|
||||
@@ -88,11 +88,8 @@ public class NativeJavaArray extends NativeJavaObject {
|
||||
if (result == NOT_FOUND &&
|
||||
!ScriptRuntime.hasProp(getPrototype(), id))
|
||||
{
|
||||
Object errArgs[] = { array.getClass().getName(),
|
||||
id };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.member.not.found",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.java.member.not.found", array.getClass().getName(), id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -172,9 +172,8 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
Constructor ctor = (Constructor) member;
|
||||
if (ctor == null) {
|
||||
String sig = NativeJavaMethod.scriptSignature(args);
|
||||
Object errArgs[] = { classObject.getName(), sig };
|
||||
throw Context.reportRuntimeError(Context.getMessage(
|
||||
"msg.no.java.ctor", errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.no.java.ctor", classObject.getName(), sig);
|
||||
}
|
||||
|
||||
// Found the constructor, so try invoking it.
|
||||
@@ -200,10 +199,8 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
if (m != null)
|
||||
msg = m;
|
||||
}
|
||||
Object[] errArgs = { msg, classObject.getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.cant.instantiate",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.cant.instantiate", msg, classObject.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,24 +227,19 @@ public class NativeJavaClass extends NativeJavaObject implements Function {
|
||||
classObject);
|
||||
|
||||
} catch (InstantiationException instEx) {
|
||||
Object[] errArgs = { instEx.getMessage(),
|
||||
classObject.getName() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.cant.instantiate",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError2(
|
||||
"msg.cant.instantiate",
|
||||
instEx.getMessage(), classObject.getName());
|
||||
} catch (IllegalArgumentException argEx) {
|
||||
String signature = NativeJavaMethod.scriptSignature(args);
|
||||
String ctorString = ctor.toString();
|
||||
Object[] errArgs = { argEx.getMessage(),ctorString,signature };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.bad.ctor.sig",
|
||||
errArgs));
|
||||
throw Context.reportRuntimeError3(
|
||||
"msg.bad.ctor.sig", argEx.getMessage(), ctorString, signature);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw JavaScriptException.wrapException(scope, e);
|
||||
} catch (IllegalAccessException accessEx) {
|
||||
Object[] errArgs = { accessEx.getMessage() };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.java.internal.private", errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.java.internal.private", accessEx.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,9 +180,7 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
Class c = methods[0].getDeclaringClass();
|
||||
String sig = c.getName() + "." + names[0] + "(" +
|
||||
scriptSignature(args) + ")";
|
||||
Object errArgs[] = { sig };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.no_such_method", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.java.no_such_method", sig);
|
||||
}
|
||||
|
||||
// OPT: already retrieved in findFunction, so we should inline that
|
||||
@@ -201,9 +199,8 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
||||
while (!(o instanceof Wrapper)) {
|
||||
o = o.getPrototype();
|
||||
if (o == null) {
|
||||
Object errArgs[] = { names[0] };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.nonjava.method", errArgs));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.nonjava.method", names[0]);
|
||||
}
|
||||
}
|
||||
javaObject = ((Wrapper) o).unwrap();
|
||||
|
||||
@@ -222,10 +222,10 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
{
|
||||
Function converter = getConverter(converterName);
|
||||
if (converter == null) {
|
||||
Object[] errArgs = { converterName, javaObject.getClass().getName() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.java.conversion.implicit_method",
|
||||
errArgs));
|
||||
String className = javaObject.getClass().getName();
|
||||
throw Context.reportRuntimeError2
|
||||
("msg.java.conversion.implicit_method",
|
||||
converterName, className);
|
||||
}
|
||||
return callConverter(converter);
|
||||
}
|
||||
@@ -243,8 +243,7 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
} catch (JavaScriptException jse) {
|
||||
// fall through to error message
|
||||
}
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.default.value", null));
|
||||
throw Context.reportRuntimeError0("msg.default.value");
|
||||
}
|
||||
|
||||
|
||||
@@ -888,11 +887,9 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
||||
}
|
||||
|
||||
static void reportConversionError(Object value, Class type) {
|
||||
Object[] args = { value.toString(),
|
||||
NativeJavaMethod.javaSignature(type)
|
||||
};
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.conversion.not.allowed", args));
|
||||
throw Context.reportRuntimeError2
|
||||
("msg.conversion.not.allowed",
|
||||
value.toString(), NativeJavaMethod.javaSignature(type));
|
||||
}
|
||||
|
||||
public static void initJSObject() {
|
||||
|
||||
@@ -145,8 +145,7 @@ public class NativeJavaPackage extends ScriptableObject {
|
||||
}
|
||||
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.pkg.int", null));
|
||||
throw Context.reportRuntimeError0("msg.pkg.int");
|
||||
}
|
||||
|
||||
public Object get(String id, Scriptable start) {
|
||||
@@ -230,7 +229,7 @@ public class NativeJavaPackage extends ScriptableObject {
|
||||
}
|
||||
}
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.not.java.obj", null));
|
||||
Context.getMessage0("msg.not.java.obj"));
|
||||
}
|
||||
|
||||
private String packageName;
|
||||
|
||||
@@ -144,11 +144,10 @@ public class NativeNumber extends ScriptableObject {
|
||||
} else {
|
||||
precision = ScriptRuntime.toInt32(arg);
|
||||
if (precision < precisionMin || precision > precisionMax) {
|
||||
Object args[] = new Object[1];
|
||||
args[0] = Integer.toString(precision);
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getCurrentContext(), "RangeError",
|
||||
ScriptRuntime.getMessage("msg.bad.precision", args),
|
||||
ScriptRuntime.getMessage1(
|
||||
"msg.bad.precision", Integer.toString(precision)),
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,8 @@ public class NativeScript extends NativeFunction implements Script {
|
||||
}
|
||||
|
||||
public Object jsFunction_exec() throws JavaScriptException {
|
||||
Object[] msgArgs = { "exec" };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.call.indirect", msgArgs));
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.cant.call.indirect", "exec");
|
||||
}
|
||||
|
||||
public static Object jsFunction_toString(Context cx, Scriptable thisObj,
|
||||
@@ -163,8 +162,7 @@ public class NativeScript extends NativeFunction implements Script {
|
||||
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
String message = Context.getMessage("msg.script.is.not.constructor", null);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError0("msg.script.is.not.constructor");
|
||||
}
|
||||
|
||||
private Script script;
|
||||
|
||||
@@ -726,7 +726,7 @@ public class NativeString extends ScriptableObject {
|
||||
private static RegExpProxy checkReProxy(Context cx) {
|
||||
RegExpProxy result = cx.getRegExpProxy();
|
||||
if (result == null) {
|
||||
throw cx.reportRuntimeError(cx.getMessage("msg.no.regexp", null));
|
||||
throw cx.reportRuntimeError0("msg.no.regexp");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -141,18 +141,14 @@ public class NativeWith implements Scriptable {
|
||||
public static Object jsConstructor(Context cx, Object[] args,
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
Object[] msgArgs = { "With" };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.cant.call.indirect", msgArgs));
|
||||
throw Context.reportRuntimeError1("msg.cant.call.indirect", "With");
|
||||
}
|
||||
|
||||
public static Object newWithSpecial(Context cx, Object[] args,
|
||||
Function ctorObj, boolean inNewExpr)
|
||||
{
|
||||
if (!inNewExpr) {
|
||||
Object[] errArgs = { "With" };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.only.from.new", errArgs));
|
||||
throw Context.reportRuntimeError1("msg.only.from.new", "With");
|
||||
}
|
||||
|
||||
ScriptRuntime.checkDeprecated(cx, "With");
|
||||
|
||||
@@ -133,9 +133,8 @@ public class NodeTransformer {
|
||||
if (n.getType() == TokenStream.LABEL) {
|
||||
String otherId = (String)n.getProp(Node.LABEL_PROP);
|
||||
if (id.equals(otherId)) {
|
||||
Object[] errArgs = { id };
|
||||
String message = Context.getMessage("msg.dup.label",
|
||||
errArgs);
|
||||
String message = Context.getMessage1(
|
||||
"msg.dup.label", id);
|
||||
reportMessage(Context.getContext(), message, node,
|
||||
tree, true, scope);
|
||||
break typeswitch;
|
||||
@@ -361,8 +360,7 @@ public class NodeTransformer {
|
||||
("msg.bad.break", null);
|
||||
}
|
||||
} else if (loop != null) {
|
||||
message = Context.getMessage("msg.continue.nonloop",
|
||||
null);
|
||||
message = Context.getMessage0("msg.continue.nonloop");
|
||||
} else {
|
||||
Object[] errArgs = { id };
|
||||
message = Context.getMessage
|
||||
|
||||
@@ -47,4 +47,19 @@ public class PropertyException extends Exception {
|
||||
super(detail);
|
||||
}
|
||||
|
||||
static PropertyException withMessage0(String messageId) {
|
||||
return new PropertyException(Context.getMessage0(messageId));
|
||||
}
|
||||
|
||||
static PropertyException withMessage1(String messageId, Object arg1) {
|
||||
return new PropertyException(Context.getMessage1(messageId, arg1));
|
||||
}
|
||||
|
||||
static PropertyException withMessage2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return new PropertyException
|
||||
(Context.getMessage2(messageId, arg1, arg2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -432,9 +432,8 @@ public class ScriptRuntime {
|
||||
return "0";
|
||||
|
||||
if ((base < 2) || (base > 36)) {
|
||||
Object[] args = { Integer.toString(base) };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.bad.radix", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.bad.radix", Integer.toString(base));
|
||||
}
|
||||
|
||||
if (base != 10) {
|
||||
@@ -462,14 +461,14 @@ public class ScriptRuntime {
|
||||
if (val == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
if (val instanceof Scriptable) {
|
||||
if (val == Undefined.instance) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.undef.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.undef.to.object"),
|
||||
scope);
|
||||
}
|
||||
return (Scriptable) val;
|
||||
@@ -683,7 +682,7 @@ public class ScriptRuntime {
|
||||
: "msg.undefined";
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ConversionError",
|
||||
ScriptRuntime.getMessage(msg, null),
|
||||
ScriptRuntime.getMessage0(msg),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -722,7 +721,7 @@ public class ScriptRuntime {
|
||||
if (s == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
return s.getPrototype();
|
||||
@@ -752,7 +751,7 @@ public class ScriptRuntime {
|
||||
if (s == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
return s.getParentScope();
|
||||
@@ -769,16 +768,15 @@ public class ScriptRuntime {
|
||||
Scriptable s = result;
|
||||
while (s != null) {
|
||||
if (s == start) {
|
||||
Object[] args = { "__proto__" };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.cyclic.value", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.cyclic.value", "__proto__");
|
||||
}
|
||||
s = s.getPrototype();
|
||||
}
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
start.setPrototype(result);
|
||||
@@ -796,16 +794,15 @@ public class ScriptRuntime {
|
||||
Scriptable s = result;
|
||||
while (s != null) {
|
||||
if (s == start) {
|
||||
Object[] args = { "__parent__" };
|
||||
throw Context.reportRuntimeError(getMessage
|
||||
("msg.cyclic.value", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.cyclic.value", "__parent__");
|
||||
}
|
||||
s = s.getParentScope();
|
||||
}
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
start.setParentScope(result);
|
||||
@@ -824,7 +821,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1090,10 +1087,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object[] args = { id.toString() };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id.toString()),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1137,10 +1133,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object[] args = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1171,8 +1166,7 @@ public class ScriptRuntime {
|
||||
This code is causing immense performance problems in
|
||||
scripts that assign to the variables as a way of creating them.
|
||||
XXX need strict mode
|
||||
String[] args = { id };
|
||||
String message = getMessage("msg.assn.create", args);
|
||||
String message = getMessage1("msg.assn.create", id);
|
||||
Context.reportWarning(message);
|
||||
*/
|
||||
return value;
|
||||
@@ -1213,11 +1207,9 @@ public class ScriptRuntime {
|
||||
function = (Function) fun;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
Object[] errorArgs = { toString(fun) };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.isnt.function",
|
||||
errorArgs),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage1("msg.isnt.function", toString(fun)),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1293,10 +1285,9 @@ public class ScriptRuntime {
|
||||
} catch (ClassCastException e) {
|
||||
// fall through to error
|
||||
}
|
||||
Object[] errorArgs = { toString(fun) };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.isnt.function", errorArgs),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage1("msg.isnt.function", toString(fun)),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1396,10 +1387,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object args[] = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1413,7 +1403,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1493,10 +1483,9 @@ public class ScriptRuntime {
|
||||
} while (m != null);
|
||||
obj = obj.getParentScope();
|
||||
}
|
||||
Object args[] = { id };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage("msg.is.not.defined", args),
|
||||
throw NativeGlobal.constructError
|
||||
(Context.getContext(), "ReferenceError",
|
||||
ScriptRuntime.getMessage1("msg.is.not.defined", id),
|
||||
scopeChain);
|
||||
}
|
||||
|
||||
@@ -1510,7 +1499,7 @@ public class ScriptRuntime {
|
||||
if (start == null) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.null.to.object", null),
|
||||
ScriptRuntime.getMessage0("msg.null.to.object"),
|
||||
scope);
|
||||
}
|
||||
Scriptable m = start;
|
||||
@@ -1543,7 +1532,7 @@ public class ScriptRuntime {
|
||||
if (result != null && result instanceof Scriptable)
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.bad.default.value", null),
|
||||
ScriptRuntime.getMessage0("msg.bad.default.value"),
|
||||
val);
|
||||
return result;
|
||||
}
|
||||
@@ -1696,7 +1685,7 @@ public class ScriptRuntime {
|
||||
if (! (b instanceof Scriptable)) {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.not.object", null),
|
||||
ScriptRuntime.getMessage0("msg.instanceof.not.object"),
|
||||
scope);
|
||||
}
|
||||
|
||||
@@ -1744,7 +1733,7 @@ public class ScriptRuntime {
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(),
|
||||
"TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.not.object", null),
|
||||
ScriptRuntime.getMessage0("msg.instanceof.not.object"),
|
||||
scope);
|
||||
}
|
||||
String s = getStringId(a);
|
||||
@@ -2002,9 +1991,7 @@ public class ScriptRuntime {
|
||||
static void checkDeprecated(Context cx, String name) {
|
||||
int version = cx.getLanguageVersion();
|
||||
if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
|
||||
Object[] errArgs = { name };
|
||||
String msg = getMessage("msg.deprec.ctor",
|
||||
errArgs);
|
||||
String msg = getMessage1("msg.deprec.ctor", name);
|
||||
if (version == Context.VERSION_DEFAULT)
|
||||
Context.reportWarning(msg);
|
||||
else
|
||||
@@ -2012,6 +1999,20 @@ public class ScriptRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMessage0(String messageId) {
|
||||
return Context.getMessage0(messageId);
|
||||
}
|
||||
|
||||
public static String getMessage1(String messageId, Object arg1) {
|
||||
return Context.getMessage1(messageId, arg1);
|
||||
}
|
||||
|
||||
public static String getMessage2
|
||||
(String messageId, Object arg1, Object arg2)
|
||||
{
|
||||
return Context.getMessage2(messageId, arg1, arg2);
|
||||
}
|
||||
|
||||
public static String getMessage(String messageId, Object[] arguments) {
|
||||
return Context.getMessage(messageId, arguments);
|
||||
}
|
||||
@@ -2085,8 +2086,7 @@ public class ScriptRuntime {
|
||||
|
||||
private static RuntimeException errorWithClassName(String msg, Object val)
|
||||
{
|
||||
Object[] args = { val.getClass().getName() };
|
||||
return Context.reportRuntimeError(getMessage(msg, args));
|
||||
return Context.reportRuntimeError1(msg, val.getClass().getName());
|
||||
}
|
||||
|
||||
static public Object[] emptyArgs = new Object[0];
|
||||
|
||||
@@ -356,8 +356,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(name, name.hashCode());
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
return slots[slotIndex].attributes;
|
||||
}
|
||||
@@ -381,8 +380,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(null, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
return slots[slotIndex].attributes;
|
||||
}
|
||||
@@ -418,8 +416,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
attributes &= mask; // mask out unused bits
|
||||
int slotIndex = getSlot(name, name.hashCode());
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
slots[slotIndex].attributes = (short) attributes;
|
||||
}
|
||||
@@ -444,8 +441,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
{
|
||||
int slotIndex = getSlot(null, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.prop.not.found", null));
|
||||
throw PropertyException.withMessage0("msg.prop.not.found");
|
||||
}
|
||||
slots[slotIndex].attributes = (short) attributes;
|
||||
}
|
||||
@@ -562,9 +558,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
typeHint == Double.TYPE)
|
||||
hint = "number";
|
||||
else {
|
||||
Object[] args = { typeHint.toString() };
|
||||
throw Context.reportRuntimeError(
|
||||
Context.getMessage("msg.invalid.type", args));
|
||||
throw Context.reportRuntimeError1(
|
||||
"msg.invalid.type", typeHint.toString());
|
||||
}
|
||||
Object v = getProperty(this, "valueOf");
|
||||
if (!(v instanceof Function))
|
||||
@@ -596,10 +591,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
// fall through to error
|
||||
}
|
||||
Object arg = typeHint == null ? "undefined" : typeHint.toString();
|
||||
Object[] args = { arg };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.default.value", args),
|
||||
ScriptRuntime.getMessage1("msg.default.value", arg),
|
||||
this);
|
||||
}
|
||||
|
||||
@@ -782,9 +776,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
}
|
||||
if (protoCtor == null) {
|
||||
Object[] args = { clazz.getName() };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.zero.arg.ctor", args));
|
||||
Context.getMessage1("msg.zero.arg.ctor", clazz.getName()));
|
||||
}
|
||||
|
||||
Scriptable proto = (Scriptable)
|
||||
@@ -808,9 +801,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
Member ctorMember = null;
|
||||
if (ctorMeths != null) {
|
||||
if (ctorMeths.length > 1) {
|
||||
Object[] args = { ctorMeths[0], ctorMeths[1] };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.multiple.ctors", args));
|
||||
Context.getMessage2("msg.multiple.ctors",
|
||||
ctorMeths[0], ctorMeths[1]));
|
||||
}
|
||||
ctorMember = ctorMeths[0];
|
||||
}
|
||||
@@ -841,9 +834,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
if (name.equals(className)) {
|
||||
if (ctorMember != null) {
|
||||
Object[] args = { ctorMember, methods[i] };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.multiple.ctors", args));
|
||||
Context.getMessage2("msg.multiple.ctors",
|
||||
ctorMember, methods[i]));
|
||||
}
|
||||
ctorMember = methods[i];
|
||||
}
|
||||
@@ -859,17 +852,16 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
ctorMember = ctors[0];
|
||||
}
|
||||
if (ctorMember == null) {
|
||||
Object[] args = { clazz.getName() };
|
||||
throw new ClassDefinitionException(
|
||||
Context.getMessage("msg.ctor.multiple.parms", args));
|
||||
Context.getMessage1("msg.ctor.multiple.parms",
|
||||
clazz.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
FunctionObject ctor = new FunctionObject(className, ctorMember, scope);
|
||||
if (ctor.isVarArgsMethod()) {
|
||||
Object[] args = { ctorMember.getName() };
|
||||
String message = Context.getMessage("msg.varargs.ctor", args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.varargs.ctor", ctorMember.getName());
|
||||
}
|
||||
ctor.addAsConstructor(scope, proto);
|
||||
|
||||
@@ -928,17 +920,15 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
continue; // deal with set when we see get
|
||||
if (prefix != null && prefix.equals(getterPrefix)) {
|
||||
if (!(proto instanceof ScriptableObject)) {
|
||||
Object[] args = { proto.getClass().toString(), name };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.extend.scriptable", args));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.extend.scriptable", proto.getClass().toString(), name);
|
||||
}
|
||||
Method[] setter = FunctionObject.findMethods(
|
||||
clazz,
|
||||
setterPrefix + name);
|
||||
if (setter != null && setter.length != 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
int attr = ScriptableObject.PERMANENT |
|
||||
ScriptableObject.DONTENUM |
|
||||
@@ -956,9 +946,9 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
prefix.equals(staticFunctionPrefix))))
|
||||
{
|
||||
if (!(proto instanceof ScriptableObject)) {
|
||||
Object[] args = { proto.getClass().toString(), name };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.extend.scriptable", args));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.extend.scriptable",
|
||||
proto.getClass().toString(), name);
|
||||
}
|
||||
if (name.startsWith("set"))
|
||||
continue; // deal with set when we see get
|
||||
@@ -976,9 +966,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
hasPrefix ? genericPrefix + setterName
|
||||
: setterName);
|
||||
if (setter != null && setter.length != 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
if (setter == null && hasPrefix)
|
||||
setter = FunctionObject.findMethods(
|
||||
@@ -996,9 +985,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
}
|
||||
FunctionObject f = new FunctionObject(name, methods[i], proto);
|
||||
if (f.isVarArgsConstructor()) {
|
||||
Object[] args = { ctorMember.getName() };
|
||||
String message = Context.getMessage("msg.varargs.fun", args);
|
||||
throw Context.reportRuntimeError(message);
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.varargs.fun", ctorMember.getName());
|
||||
}
|
||||
Scriptable dest = prefix == staticFunctionPrefix
|
||||
? ctor
|
||||
@@ -1087,9 +1075,8 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
if (setter == null)
|
||||
attributes |= ScriptableObject.READONLY;
|
||||
if (getter.length != 1 || (setter != null && setter.length != 1)) {
|
||||
Object[] errArgs = { propertyName, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", propertyName, clazz.getName());
|
||||
}
|
||||
defineProperty(propertyName, null, getter[0],
|
||||
setter == null ? null : setter[0], attributes);
|
||||
@@ -1150,43 +1137,36 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
if (parmTypes.length != 1 ||
|
||||
parmTypes[0] != ScriptableObject.class)
|
||||
{
|
||||
Object[] args = { getter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.bad.getter.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.bad.getter.parms", getter.toString());
|
||||
}
|
||||
} else if (delegateTo != null) {
|
||||
Object[] args = { getter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.obj.getter.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.obj.getter.parms", getter.toString());
|
||||
}
|
||||
if (setter != null) {
|
||||
flags |= Slot.HAS_SETTER;
|
||||
if ((delegateTo == HAS_STATIC_ACCESSORS) !=
|
||||
(Modifier.isStatic(setter.getModifiers())))
|
||||
{
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.getter.static", null));
|
||||
throw PropertyException.withMessage0("msg.getter.static");
|
||||
}
|
||||
parmTypes = setter.getParameterTypes();
|
||||
if (parmTypes.length == 2) {
|
||||
if (parmTypes[0] != ScriptableObject.class) {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter2.parms", null));
|
||||
throw PropertyException.withMessage0("msg.setter2.parms");
|
||||
}
|
||||
if (delegateTo == null) {
|
||||
Object[] args = { setter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter1.parms", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.setter1.parms", setter.toString());
|
||||
}
|
||||
} else if (parmTypes.length == 1) {
|
||||
if (delegateTo != null) {
|
||||
Object[] args = { setter.toString() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter2.expected", args));
|
||||
throw PropertyException.withMessage1
|
||||
("msg.setter2.expected", setter.toString());
|
||||
}
|
||||
} else {
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.setter.parms", null));
|
||||
throw PropertyException.withMessage0("msg.setter.parms");
|
||||
}
|
||||
}
|
||||
int slotIndex = getSlotToSet(propertyName,
|
||||
@@ -1226,14 +1206,12 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
String name = names[i];
|
||||
Method[] m = FunctionObject.findMethods(clazz, name);
|
||||
if (m == null) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.method.not.found", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.method.not.found", name, clazz.getName());
|
||||
}
|
||||
if (m.length > 1) {
|
||||
Object[] errArgs = { name, clazz.getName() };
|
||||
throw new PropertyException(
|
||||
Context.getMessage("msg.no.overload", errArgs));
|
||||
throw PropertyException.withMessage2
|
||||
("msg.no.overload", name, clazz.getName());
|
||||
}
|
||||
FunctionObject f = new FunctionObject(name, m[0], this);
|
||||
defineProperty(name, f, attributes);
|
||||
@@ -1639,8 +1617,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
private synchronized int addSlot(String id, int index, boolean getterSlot)
|
||||
{
|
||||
if (count == -1)
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.add.sealed", null));
|
||||
throw Context.reportRuntimeError0("msg.add.sealed");
|
||||
int start = (index & 0x7fffffff) % slots.length;
|
||||
int i = start;
|
||||
do {
|
||||
@@ -1678,8 +1655,7 @@ public abstract class ScriptableObject implements Scriptable {
|
||||
*/
|
||||
private synchronized void removeSlot(String name, int index) {
|
||||
if (count == -1)
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.remove.sealed", null));
|
||||
throw Context.reportRuntimeError0("msg.remove.sealed");
|
||||
int slotIndex = getSlot(name, index);
|
||||
if (slotIndex == SLOT_NOT_FOUND)
|
||||
return;
|
||||
|
||||
@@ -635,10 +635,8 @@ public class TokenStream {
|
||||
|
||||
public void ungetToken(int tt) {
|
||||
if (this.pushbackToken != EOF && tt != ERROR) {
|
||||
Object[] errArgs = { tokenToString(tt),
|
||||
tokenToString(this.pushbackToken) };
|
||||
String message = Context.getMessage("msg.token.replaces.pushback",
|
||||
errArgs);
|
||||
String message = Context.getMessage2("msg.token.replaces.pushback",
|
||||
tokenToString(tt), tokenToString(this.pushbackToken));
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
this.pushbackToken = tt;
|
||||
|
||||
@@ -133,7 +133,6 @@ public class Undefined implements Scriptable {
|
||||
}
|
||||
|
||||
private RuntimeException reportError() {
|
||||
String message = Context.getMessage("msg.undefined", null);
|
||||
return Context.reportRuntimeError(message);
|
||||
return Context.reportRuntimeError0("msg.undefined");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,7 @@ public class VariableTable {
|
||||
LocalVariable p = (LocalVariable)
|
||||
(itsVariables.elementAt(pIndex.intValue()));
|
||||
if (p.isParameter()) {
|
||||
Object[] errorArgs = { pName };
|
||||
String message = Context.getMessage("msg.dup.parms", errorArgs);
|
||||
String message = Context.getMessage1("msg.dup.parms", pName);
|
||||
Context.reportWarning(message, null, 0, null, 0);
|
||||
}
|
||||
else { // there's a local variable with this name, blow it off
|
||||
|
||||
Reference in New Issue
Block a user