Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* The class of error objects
*
*
ECMA 15.11
*/
final class NativeError extends IdScriptableObject {
private static final long serialVersionUID = -5338413581437645187L;
private static final Object ERROR_TAG = "Error";
private static final String STACK_TAG = "stack";
/** Default stack limit is set to "Infinity", here represented as a negative int */
public static final int DEFAULT_STACK_LIMIT = -1;
// This is used by "captureStackTrace"
private static final String STACK_HIDE_KEY = "_stackHide";
private RhinoException stackProvider;
private Object stack;
static void init(Scriptable scope, boolean sealed) {
NativeError obj = new NativeError();
ScriptableObject.putProperty(obj, "name", "Error");
ScriptableObject.putProperty(obj, "message", "");
ScriptableObject.putProperty(obj, "fileName", "");
ScriptableObject.putProperty(obj, "lineNumber", 0);
obj.setAttributes("name", DONTENUM);
obj.setAttributes("message", DONTENUM);
obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
NativeCallSite.init(obj, sealed);
}
static NativeError makeProto(Scriptable scope, IdFunctionObject ctorObj) {
Scriptable proto = (Scriptable) ctorObj.get("prototype", ctorObj);
NativeError obj = new NativeError();
obj.setPrototype(proto);
obj.setParentScope(scope);
return obj;
}
static NativeError make(Context cx, Scriptable scope, IdFunctionObject ctorObj, Object[] args) {
NativeError obj = makeProto(scope, ctorObj);
int arglen = args.length;
if (arglen >= 1) {
if (!Undefined.isUndefined(args[0])) {
ScriptableObject.putProperty(obj, "message", ScriptRuntime.toString(args[0]));
obj.setAttributes("message", DONTENUM);
}
if (arglen >= 2) {
if (args[1] instanceof NativeObject) {
installCause((NativeObject) args[1], obj);
} else {
ScriptableObject.putProperty(obj, "fileName", ScriptRuntime.toString(args[1]));
if (arglen >= 3) {
ScriptableObject.putProperty(
obj, "lineNumber", ScriptRuntime.toInt32(args[2]));
}
}
}
}
// All new Errors (but not prototypes) have a default exception installed so that
// there is a stack trace captured even if they are never thrown.
obj.setStackProvider(new EvaluatorException(""));
return obj;
}
static NativeError makeAggregate(
Context cx, Scriptable scope, IdFunctionObject ctorObj, Object[] args) {
NativeError obj = makeProto(scope, ctorObj);
int arglen = args.length;
if (arglen >= 1) {
if (arglen >= 2) {
if (!Undefined.isUndefined(args[1])) {
ScriptableObject.putProperty(obj, "message", ScriptRuntime.toString(args[1]));
obj.setAttributes("message", DONTENUM);
}
if (arglen >= 3) {
if (args[2] instanceof NativeObject) {
installCause((NativeObject) args[2], obj);
} else {
ScriptableObject.putProperty(
obj, "fileName", ScriptRuntime.toString(args[2]));
if (arglen >= 4) {
ScriptableObject.putProperty(
obj, "lineNumber", ScriptRuntime.toInt32(args[3]));
}
}
}
}
final Object iterator = ScriptRuntime.callIterator(args[0], cx, scope);
try (IteratorLikeIterable it = new IteratorLikeIterable(cx, scope, iterator)) {
List