本文整理汇总了Java中org.mozilla.javascript.ScriptRuntime.constructError方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.constructError方法的具体用法?Java ScriptRuntime.constructError怎么用?Java ScriptRuntime.constructError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ScriptRuntime
的用法示例。
在下文中一共展示了ScriptRuntime.constructError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRange
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void setRange(NativeTypedArrayView v, int off)
{
if (off >= length) {
throw ScriptRuntime.constructError("RangeError", "offset out of range");
}
if (v.length > (length - off)) {
throw ScriptRuntime.constructError("RangeError", "source array too long");
}
if (v.arrayBuffer == arrayBuffer) {
// Copy to temporary space first, as per spec, to avoid messing up overlapping copies
Object[] tmp = new Object[v.length];
for (int i = 0; i < v.length; i++) {
tmp[i] = v.js_get(i);
}
for (int i = 0; i < v.length; i++) {
js_set(i + off, tmp[i]);
}
} else {
for (int i = 0; i < v.length; i++) {
js_set(i + off, v.js_get(i));
}
}
}
示例2: addCharacterRangeToCharSet
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private static void
addCharacterRangeToCharSet(RECharSet cs, char c1, char c2)
{
int i;
int byteIndex1 = (c1 / 8);
int byteIndex2 = (c2 / 8);
if ((c2 >= cs.length) || (c1 > c2)) {
throw ScriptRuntime.constructError("SyntaxError",
"invalid range in character class");
}
c1 &= 0x7;
c2 &= 0x7;
if (byteIndex1 == byteIndex2) {
cs.bits[byteIndex1] |= ((0xFF) >> (7 - (c2 - c1))) << c1;
}
else {
cs.bits[byteIndex1] |= 0xFF << c1;
for (i = byteIndex1 + 1; i < byteIndex2; i++)
cs.bits[i] = (byte)0xFF;
cs.bits[byteIndex2] |= (0xFF) >> (7 - c2);
}
}
示例3: NativeArrayBuffer
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
/**
* Create a buffer of the specified length in bytes.
*/
public NativeArrayBuffer(int len)
{
if (len < 0) {
throw ScriptRuntime.constructError("RangeError", "Negative array length " + len);
}
if (len == 0) {
buffer = EMPTY_BUF;
} else {
buffer = new byte[len];
}
}
示例4: checkOffset
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void checkOffset(Object[] args, int pos)
{
if (args.length <= pos) {
throw ScriptRuntime.constructError("TypeError", "missing required offset parameter");
}
if (Undefined.instance.equals(args[pos])) {
throw ScriptRuntime.constructError("RangeError", "invalid offset");
}
}
示例5: checkValue
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void checkValue(Object[] args, int pos)
{
if (args.length <= pos) {
throw ScriptRuntime.constructError("TypeError", "missing required value parameter");
}
if (Undefined.instance.equals(args[pos])) {
throw ScriptRuntime.constructError("RangeError", "invalid value parameter");
}
}
示例6: js_constructor
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private NativeDataView js_constructor(NativeArrayBuffer ab, int offset, int length)
{
if (length < 0) {
throw ScriptRuntime.constructError("RangeError", "length out of range");
}
if ((offset < 0) || ((offset + length) > ab.getLength())) {
throw ScriptRuntime.constructError("RangeError", "offset out of range");
}
return new NativeDataView(ab, offset, length);
}
示例7: addCharacterToCharSet
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private static void
addCharacterToCharSet(RECharSet cs, char c)
{
int byteIndex = (c / 8);
if (c >= cs.length) {
throw ScriptRuntime.constructError("SyntaxError",
"invalid range in character class");
}
cs.bits[byteIndex] |= 1 << (c & 0x7);
}
示例8: setRange
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void setRange(NativeArray a, int off)
{
if (off > length) {
throw ScriptRuntime.constructError("RangeError", "offset out of range");
}
if ((off + a.size()) > length) {
throw ScriptRuntime.constructError("RangeError", "offset + length out of range");
}
int pos = off;
for (Object val : a) {
js_set(pos, val);
pos++;
}
}
示例9: rangeCheck
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void rangeCheck(int offset, int len)
{
if ((offset < 0) || ((offset + len) > byteLength)) {
throw ScriptRuntime.constructError("RangeError", "offset out of range");
}
}
示例10: execIdCall
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope,
Scriptable thisObj, Object[] args)
{
if (!f.hasTag(getClassName())) {
return super.execIdCall(f, cx, scope, thisObj, args);
}
int id = f.methodId();
switch (id) {
case Id_constructor:
if (isArg(args, 0) && (args[0] instanceof NativeArrayBuffer)) {
NativeArrayBuffer ab = (NativeArrayBuffer)args[0];
int off = isArg(args, 1) ? ScriptRuntime.toInt32(args[1]) : 0;
int len = isArg(args, 2) ? ScriptRuntime.toInt32(args[2]) : ab.getLength() - off;
return js_constructor(ab, off, len);
} else {
throw ScriptRuntime.constructError("TypeError", "Missing parameters");
}
case Id_getInt8:
return realThis(thisObj, f).js_getInt(1, true, args);
case Id_getUint8:
return realThis(thisObj, f).js_getInt(1, false, args);
case Id_getInt16:
return realThis(thisObj, f).js_getInt(2, true, args);
case Id_getUint16:
return realThis(thisObj, f).js_getInt(2, false, args);
case Id_getInt32:
return realThis(thisObj, f).js_getInt(4, true, args);
case Id_getUint32:
return realThis(thisObj, f).js_getInt(4, false, args);
case Id_getFloat32:
return realThis(thisObj, f).js_getFloat(4, args);
case Id_getFloat64:
return realThis(thisObj, f).js_getFloat(8, args);
case Id_setInt8:
realThis(thisObj, f).js_setInt(1, true, args);
return Undefined.instance;
case Id_setUint8:
realThis(thisObj, f).js_setInt(1, false, args);
return Undefined.instance;
case Id_setInt16:
realThis(thisObj, f).js_setInt(2, true, args);
return Undefined.instance;
case Id_setUint16:
realThis(thisObj, f).js_setInt(2, false, args);
return Undefined.instance;
case Id_setInt32:
realThis(thisObj, f).js_setInt(4, true, args);
return Undefined.instance;
case Id_setUint32:
realThis(thisObj, f).js_setInt(4, false, args);
return Undefined.instance;
case Id_setFloat32:
realThis(thisObj, f).js_setFloat(4, args);
return Undefined.instance;
case Id_setFloat64:
realThis(thisObj, f).js_setFloat(8, args);
return Undefined.instance;
}
throw new IllegalArgumentException(String.valueOf(id));
}
示例11: reportError
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private static void reportError(String messageId, String arg)
{
String msg = ScriptRuntime.getMessage1(messageId, arg);
throw ScriptRuntime.constructError("SyntaxError", msg);
}