Exception Fact Sheet for "rhino"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 313
Number of Domain Exception Types (Thrown or Caught) 10
Number of Domain Checked Exception Types 1
Number of Domain Runtime Exception Types 9
Number of Domain Unknown Exception Types 0
nTh = Number of Throw 796
nTh = Number of Throw in Catch 59
Number of Catch-Rethrow (may not be correct) 10
nC = Number of Catch 130
nCTh = Number of Catch with Throw 58
Number of Empty Catch (really Empty) 27
Number of Empty Catch (with comments) 12
Number of Empty Catch 39
nM = Number of Methods 3613
nbFunctionWithCatch = Number of Methods with Catch 86 / 3613
nbFunctionWithThrow = Number of Methods with Throw 559 / 3613
nbFunctionWithThrowS = Number of Methods with ThrowS 176 / 3613
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 133 / 3613
P1 = nCTh / nC 44.6% (0.446)
P2 = nMC / nM 2.4% (0.024)
P3 = nbFunctionWithThrow / nbFunction 15.5% (0.155)
P4 = nbFunctionTransmitting / nbFunction 3.7% (0.037)
P5 = nbThrowInCatch / nbThrow 7.4% (0.074)
R2 = nCatch / nThrow 0.163
A1 = Number of Caught Exception Types From External Libraries 22
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 13

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 5
ContinuationPending
              package org.mozilla.javascript;public class ContinuationPending extends RuntimeException {
    private static final long serialVersionUID = 4956008116771118856L;
    private NativeContinuation continuationState;
    private Object applicationState;

    /**
     * Construct a ContinuationPending exception. Internal call only;
     * users of the API should get continuations created on their behalf by
     * calling {@link org.mozilla.javascript.Context#executeScriptWithContinuations(Script, Scriptable)}
     * and {@link org.mozilla.javascript.Context#callFunctionWithContinuations(Callable, Scriptable, Object[])}
     * @param continuationState Internal Continuation object
     */
    ContinuationPending(NativeContinuation continuationState) {
        this.continuationState = continuationState;
    }

    /**
     * Get continuation object. The only
     * use for this object is to be passed to
     * {@link org.mozilla.javascript.Context#resumeContinuation(Object, Scriptable, Object)}.
     * @return continuation object
     */
    public Object getContinuation() {
        return continuationState;
    }

    /**
     * @return internal continuation state
     */
    NativeContinuation getContinuationState() {
        return continuationState;
    }

    /**
     * Store an arbitrary object that applications can use to associate
     * their state with the continuation.
     * @param applicationState arbitrary application state
     */
    public void setApplicationState(Object applicationState) {
        this.applicationState = applicationState;
    }

    /**
     * @return arbitrary application state
     */
    public Object getApplicationState() {
        return applicationState;
    }
}
            
RhinoException
              package org.mozilla.javascript;public abstract class RhinoException extends RuntimeException
{

    RhinoException()
    {
        Evaluator e = Context.createInterpreter();
        if (e != null)
            e.captureStackInfo(this);
    }

    RhinoException(String details)
    {
        super(details);
        Evaluator e = Context.createInterpreter();
        if (e != null)
            e.captureStackInfo(this);
    }

    @Override
    public final String getMessage()
    {
        String details = details();
        if (sourceName == null || lineNumber <= 0) {
            return details;
        }
        StringBuffer buf = new StringBuffer(details);
        buf.append(" (");
        if (sourceName != null) {
            buf.append(sourceName);
        }
        if (lineNumber > 0) {
            buf.append('#');
            buf.append(lineNumber);
        }
        buf.append(')');
        return buf.toString();
    }

    public String details()
    {
        return super.getMessage();
    }

    /**
     * Get the uri of the script source containing the error, or null
     * if that information is not available.
     */
    public final String sourceName()
    {
        return sourceName;
    }

    /**
     * Initialize the uri of the script source containing the error.
     *
     * @param sourceName the uri of the script source responsible for the error.
     *                   It should not be <tt>null</tt>.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initSourceName(String sourceName)
    {
        if (sourceName == null) throw new IllegalArgumentException();
        if (this.sourceName != null) throw new IllegalStateException();
        this.sourceName = sourceName;
    }

    /**
     * Returns the line number of the statement causing the error,
     * or zero if not available.
     */
    public final int lineNumber()
    {
        return lineNumber;
    }

    /**
     * Initialize the line number of the script statement causing the error.
     *
     * @param lineNumber the line number in the script source.
     *                   It should be positive number.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initLineNumber(int lineNumber)
    {
        if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber));
        if (this.lineNumber > 0) throw new IllegalStateException();
        this.lineNumber = lineNumber;
    }

    /**
     * The column number of the location of the error, or zero if unknown.
     */
    public final int columnNumber()
    {
        return columnNumber;
    }

    /**
     * Initialize the column number of the script statement causing the error.
     *
     * @param columnNumber the column number in the script source.
     *                     It should be positive number.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initColumnNumber(int columnNumber)
    {
        if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber));
        if (this.columnNumber > 0) throw new IllegalStateException();
        this.columnNumber = columnNumber;
    }

    /**
     * The source text of the line causing the error, or null if unknown.
     */
    public final String lineSource()
    {
        return lineSource;
    }

    /**
     * Initialize the text of the source line containing the error.
     *
     * @param lineSource the text of the source line responsible for the error.
     *                   It should not be <tt>null</tt>.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initLineSource(String lineSource)
    {
        if (lineSource == null) throw new IllegalArgumentException();
        if (this.lineSource != null) throw new IllegalStateException();
        this.lineSource = lineSource;
    }

    final void recordErrorOrigin(String sourceName, int lineNumber,
                                 String lineSource, int columnNumber)
    {
        // XXX: for compatibility allow for now -1 to mean 0
        if (lineNumber == -1) {
            lineNumber = 0;
        }

        if (sourceName != null) {
            initSourceName(sourceName);
        }
        if (lineNumber != 0) {
            initLineNumber(lineNumber);
        }
        if (lineSource != null) {
            initLineSource(lineSource);
        }
        if (columnNumber != 0) {
            initColumnNumber(columnNumber);
        }
    }

    private String generateStackTrace()
    {
        // Get stable reference to work properly with concurrent access
        CharArrayWriter writer = new CharArrayWriter();
        super.printStackTrace(new PrintWriter(writer));
        String origStackTrace = writer.toString();
        Evaluator e = Context.createInterpreter();
        if (e != null)
            return e.getPatchedStack(this, origStackTrace);
        return null;
    }

    /**
     * Get a string representing the script stack of this exception.
     * If optimization is enabled, this includes java stack elements
     * whose source and method names suggest they have been generated
     * by the Rhino script compiler.
     * @return a script stack dump
     * @since 1.6R6
     */
    public String getScriptStackTrace()
    {
        StringBuilder buffer = new StringBuilder();
        String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
        ScriptStackElement[] stack = getScriptStack();
        for (ScriptStackElement elem : stack) {
            if (useMozillaStackStyle) {
                elem.renderMozillaStyle(buffer);
            } else {
                elem.renderJavaStyle(buffer);
            }
            buffer.append(lineSeparator);
        }
        return buffer.toString();
    }

    /**
     * Get a string representing the script stack of this exception.
     * @deprecated the filter argument is ignored as we are able to
     * recognize script stack elements by our own. Use
     * #getScriptStackTrace() instead.
     * @param filter ignored
     * @return a script stack dump
     * @since 1.6R6
     */
    public String getScriptStackTrace(FilenameFilter filter)
    {
        return getScriptStackTrace();
    }

    /**
     * Get the script stack of this exception as an array of
     * {@link ScriptStackElement}s.
     * If optimization is enabled, this includes java stack elements
     * whose source and method names suggest they have been generated
     * by the Rhino script compiler.
     * @return the script stack for this exception
     * @since 1.7R3
     */
    public ScriptStackElement[] getScriptStack() {
        List<ScriptStackElement> list = new ArrayList<ScriptStackElement>();
        ScriptStackElement[][] interpreterStack = null;
        if (interpreterStackInfo != null) {
            Evaluator interpreter = Context.createInterpreter();
            if (interpreter instanceof Interpreter)
                interpreterStack = ((Interpreter) interpreter).getScriptStackElements(this);
        }
        int interpreterStackIndex = 0;
        StackTraceElement[] stack = getStackTrace();
        // Pattern to recover function name from java method name -
        // see Codegen.getBodyMethodName()
        // kudos to Marc Guillemot for coming up with this
        Pattern pattern = Pattern.compile("_c_(.*)_\\d+");
        for (StackTraceElement e : stack) {
            String fileName = e.getFileName();
            if (e.getMethodName().startsWith("_c_")
                    && e.getLineNumber() > -1
                    && fileName != null
                    && !fileName.endsWith(".java")) {
                String methodName = e.getMethodName();
                Matcher match = pattern.matcher(methodName);
                // the method representing the main script is always "_c_script_0" -
                // at least we hope so
                methodName = !"_c_script_0".equals(methodName) && match.find() ?
                        match.group(1) : null;
                list.add(new ScriptStackElement(fileName, methodName, e.getLineNumber()));
            } else if ("org.mozilla.javascript.Interpreter".equals(e.getClassName())
                    && "interpretLoop".equals(e.getMethodName())
                    && interpreterStack != null
                    && interpreterStack.length > interpreterStackIndex) {
                for (ScriptStackElement elem : interpreterStack[interpreterStackIndex++]) {
                    list.add(elem);
                }
            }
        }
        return list.toArray(new ScriptStackElement[list.size()]);
    }


    @Override
    public void printStackTrace(PrintWriter s)
    {
        if (interpreterStackInfo == null) {
            super.printStackTrace(s);
        } else {
            s.print(generateStackTrace());
        }
    }

    @Override
    public void printStackTrace(PrintStream s)
    {
        if (interpreterStackInfo == null) {
            super.printStackTrace(s);
        } else {
            s.print(generateStackTrace());
        }
    }

    /**
     * Returns true if subclasses of <code>RhinoException</code>
     * use the Mozilla/Firefox style of rendering script stacks
     * (<code>functionName()@fileName:lineNumber</code>)
     * instead of Rhino's own Java-inspired format
     * (<code>    at fileName:lineNumber (functionName)</code>).
     * @return true if stack is rendered in Mozilla/Firefox style
     * @see ScriptStackElement
     * @since 1.7R3
     */
    public static boolean usesMozillaStackStyle() {
        return useMozillaStackStyle;
    }

    /**
     * Tell subclasses of <code>RhinoException</code> whether to
     * use the Mozilla/Firefox style of rendering script stacks
     * (<code>functionName()@fileName:lineNumber</code>)
     * instead of Rhino's own Java-inspired format
     * (<code>    at fileName:lineNumber (functionName)</code>)
     * @param flag whether to render stacks in Mozilla/Firefox style
     * @see ScriptStackElement
     * @since 1.7R3
     */
    public static void useMozillaStackStyle(boolean flag) {
        useMozillaStackStyle = flag;
    }

    static final long serialVersionUID = 1883500631321581169L;
    
    private static boolean useMozillaStackStyle = false;

    private String sourceName;
    private int lineNumber;
    private String lineSource;
    private int columnNumber;

    Object interpreterStackInfo;
    int[] interpreterLineData;
}
            
WrappedException
              package org.mozilla.javascript;public class WrappedException extends EvaluatorException
{
    static final long serialVersionUID = -1551979216966520648L;

    /**
     * @see Context#throwAsScriptRuntimeEx(Throwable e)
     */
    public WrappedException(Throwable exception)
    {
        super("Wrapped "+exception.toString());
        this.exception = exception;
        Kit.initCause(this, exception);

        int[] linep = { 0 };
        String sourceName = Context.getSourcePositionFromStack(linep);
        int lineNumber = linep[0];
        if (sourceName != null) {
            initSourceName(sourceName);
        }
        if (lineNumber != 0) {
            initLineNumber(lineNumber);
        }
    }

    /**
     * Get the wrapped exception.
     *
     * @return the exception that was presented as a argument to the
     *         constructor when this object was created
     */
    public Throwable getWrappedException()
    {
        return exception;
    }

    /**
     * @deprecated Use {@link #getWrappedException()} instead.
     */
    public Object unwrap()
    {
        return getWrappedException();
    }

    private Throwable exception;
}
            
JavaScriptException
              package org.mozilla.javascript;public class JavaScriptException extends RhinoException
{
    static final long serialVersionUID = -7666130513694669293L;

    /**
     * @deprecated
     * Use {@link WrappedException#WrappedException(Throwable)} to report
     * exceptions in Java code.
     */
    public JavaScriptException(Object value)
    {
        this(value, "", 0);
    }

    /**
     * Create a JavaScript exception wrapping the given JavaScript value
     *
     * @param value the JavaScript value thrown.
     */
    public JavaScriptException(Object value, String sourceName, int lineNumber)
    {
        recordErrorOrigin(sourceName, lineNumber, null, 0);
        this.value = value;
        // Fill in fileName and lineNumber automatically when not specified
        // explicitly, see Bugzilla issue #342807
        if (value instanceof NativeError && Context.getContext()
                .hasFeature(Context.FEATURE_LOCATION_INFORMATION_IN_ERROR)) {
            NativeError error = (NativeError) value;
            if (!error.has("fileName", error)) {
                error.put("fileName", error, sourceName);
            }
            if (!error.has("lineNumber", error)) {
                error.put("lineNumber", error, Integer.valueOf(lineNumber));
            }
            // set stack property, see bug #549604
            error.setStackProvider(this);
        }
    }

    @Override
    public String details()
    {
        if (value == null) {
            return "null";
        } else if (value instanceof NativeError) {
            return value.toString();
        }
        try {
            return ScriptRuntime.toString(value);
        } catch (RuntimeException rte) {
            // ScriptRuntime.toString may throw a RuntimeException
            if (value instanceof Scriptable) {
                return ScriptRuntime.defaultObjectToString((Scriptable)value);
            } else {
                return value.toString();
            }
        }
    }

    /**
     * @return the value wrapped by this exception
     */
    public Object getValue()
    {
        return value;
    }

    /**
     * @deprecated Use {@link RhinoException#sourceName()} from the super class.
     */
    public String getSourceName()
    {
        return sourceName();
    }

    /**
     * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
     */
    public int getLineNumber()
    {
        return lineNumber();
    }

    private Object value;
}
            
EcmaError
              package org.mozilla.javascript;public class EcmaError extends RhinoException
{
    static final long serialVersionUID = -6261226256957286699L;

    private String errorName;
    private String errorMessage;

    /**
     * Create an exception with the specified detail message.
     *
     * Errors internal to the JavaScript engine will simply throw a
     * RuntimeException.
     *
     * @param sourceName the name of the source responsible for the error
     * @param lineNumber the line number of the source
     * @param columnNumber the columnNumber of the source (may be zero if
     *                     unknown)
     * @param lineSource the source of the line containing the error (may be
     *                   null if unknown)
     */
    EcmaError(String errorName, String errorMessage,
              String sourceName, int lineNumber,
              String lineSource, int columnNumber)
    {
        recordErrorOrigin(sourceName, lineNumber, lineSource, columnNumber);
        this.errorName = errorName;
        this.errorMessage = errorMessage;
    }

    /**
     * @deprecated EcmaError error instances should not be constructed
     *             explicitly since they are generated by the engine.
     */
    public EcmaError(Scriptable nativeError, String sourceName,
                     int lineNumber, int columnNumber, String lineSource)
    {
        this("InternalError", ScriptRuntime.toString(nativeError),
             sourceName, lineNumber, lineSource, columnNumber);
    }

    @Override
    public String details()
    {
        return errorName+": "+errorMessage;
    }

    /**
     * Gets the name of the error.
     *
     * ECMA edition 3 defines the following
     * errors: EvalError, RangeError, ReferenceError,
     * SyntaxError, TypeError, and URIError. Additional error names
     * may be added in the future.
     *
     * See ECMA edition 3, 15.11.7.9.
     *
     * @return the name of the error.
     */
    public String getName()
    {
        return errorName;
    }

    /**
     * Gets the message corresponding to the error.
     *
     * See ECMA edition 3, 15.11.7.10.
     *
     * @return an implementation-defined string describing the error.
     */
    public String getErrorMessage()
    {
        return errorMessage;
    }

    /**
     * @deprecated Use {@link RhinoException#sourceName()} from the super class.
     */
    public String getSourceName()
    {
        return sourceName();
    }

    /**
     * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
     */
    public int getLineNumber()
    {
        return lineNumber();
    }

    /**
     * @deprecated
     * Use {@link RhinoException#columnNumber()} from the super class.
     */
    public int getColumnNumber() {
        return columnNumber();
    }

    /**
     * @deprecated Use {@link RhinoException#lineSource()} from the super class.
     */
    public String getLineSource() {
        return lineSource();
    }

    /**
     * @deprecated
     * Always returns <b>null</b>.
     */
    public Scriptable getErrorObject()
    {
        return null;
    }
}
            

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 382
              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(caseNode);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UniqueTag.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
throw Context.reportRuntimeError("Direct call is not supported");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
throw Context.reportRuntimeError("Direct call is not supported");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
throw Context.reportRuntimeError(msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BoundFunction.java
throw ScriptRuntime.typeError0("msg.not.ctor");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BoundFunction.java
throw ScriptRuntime.typeError0("msg.not.ctor");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
throw Context.reportRuntimeError1("msg.cant.call.indirect", "With");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
throw f.unknown();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw Context.reportRuntimeError0("msg.script.is.not.constructor");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw Context.reportRuntimeError1(
                "msg.cant.call.indirect", "exec");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
throw ScriptRuntime.notFunctionError(badArg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
throw Context.reportRuntimeError2(
                        "msg.extend.scriptable",
                        thisObj.getClass().getName(),
                        String.valueOf(args[0]));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.typeError0("msg.bad.regexp.compile");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Context.reportRuntimeError("Too complex regexp");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError",
                    "invalid range in character class");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError",
                    "invalid range in character class");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug("invalid bytecode");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/RegExpImpl.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw members.reportMemberNotFound(Integer.toString(index));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw members.reportMemberNotFound(Integer.toString(index));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw Context.reportRuntimeError0("msg.default.value");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw Context.reportRuntimeError2(
            "msg.conversion.not.allowed",
            String.valueOf(value),
            JavaMembers.javaSignature(type));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptFunctionNode.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptFunctionNode.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw reportClassFileFormatException(scriptOrFn, e.getMessage());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw reportClassFileFormatException(n, e.getMessage());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug("bad finally target");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.typeError1("msg.instanceof.bad.prototype",
                                       getFunctionName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.notFunctionError(thisObj);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                       f.getFunctionName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw x;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope,
                            "Module \"" + mainModuleId + "\" not found.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                    "require() needs one argument");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                        "Can't resolve relative module ID \"" + id +
                                "\" when require() is used outside of a module");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                            "Module \"" + id + "\" is not contained in sandbox.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                "require() can not be invoked as a constructor");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope, "Module \""
                        + id + "\" is not contained in sandbox.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope, "Module \""
                        + id + "\" not found.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw Context.throwAsScriptRuntimeEx(e);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1("msg.access.prohibited",
                                                  cl.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw reportMemberNotFound(name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw reportMemberNotFound(name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1(str, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(accessEx);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError3(
                    "msg.java.internal.field.type",
                    value.getClass().getName(), field,
                    javaObject.getClass().getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1(
                "msg.java.internal.private", field.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw f.unknown();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw Context.reportRuntimeError0("msg.bad.esc.mask");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw (ContinuationPending) e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(e);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
throw Context.reportRuntimeError(
            "VMBridge.getInterfaceProxyHelper is not supported");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
throw Context.reportRuntimeError(
            "VMBridge.newInterfaceProxy is not supported");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw ScriptRuntime.undefReadError(object, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Context.reportRuntimeError1(
                                "msg.cyclic.value", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw Context.reportRuntimeError(msg, sourceURI,
                                                 ts.lineno, null, 0);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw errorReporter.runtimeError(msg, sourceURI, baseLineno,
                                                 null, 0);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw Kit.codeBug("ts.cursor=" + ts.cursor
                          + ", ts.tokenBeg=" + ts.tokenBeg
                          + ", currentToken=" + currentToken);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.set.prop.no.setter", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.readonly", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                        "msg.invalid.type", typeHint.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.default.value", arg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                      "msg.zero.arg.ctor", clazz.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                          "msg.ctor.multiple.parms", clazz.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1
                ("msg.varargs.ctor", ctorMember.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2("duplicate.defineClass.name",
                        name, propName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2(
                        "msg.extend.scriptable",
                        proto.getClass().toString(), name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError(
                        "jsStaticFunction must be used with static method.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1
                    ("msg.varargs.fun", ctorMember.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(errorId, getter.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.setter.return",
                                                  setter.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(errorId, setter.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(getter);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(setter);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError0("msg.both.data.and.accessor.desc");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError0("msg.not.extensible");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                        "msg.change.configurable.false.to.true", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                        "msg.change.enumerable.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                                "msg.change.writable.false.to.true.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                                "msg.change.value.with.writable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.setter.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.getter.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.property.data.to.accessor.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.property.accessor.to.data.with.configurable.false", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.arg.not.object", ScriptRuntime.typeof(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.arg.not.object", ScriptRuntime.typeof(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2(
                    "msg.method.not.found", name, clazz.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed", str);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.const.redecl", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.var.redecl", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(obj, methodName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.var.redecl", name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.prop.not.found", str);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                        "msg.no.empty.interface.conversion", cl.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                                    "msg.no.function.interface.conversion",
                                    cl.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                        "msg.not.function.interface",methodName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
throw Context.reportRuntimeError1("msg.only.from.new", "Call");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
throw ex;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
throw ex;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
throw ScriptRuntime.typeError1("msg.no.properties",
                                           ScriptRuntime.toString(argument));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
throw ScriptRuntime.constructError("RangeError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
throw Context.reportRuntimeError0("msg.pkg.int");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.constructError("RangeError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.constructError("RangeError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw Context.reportRuntimeError1(
                "msg.arraylength.too.big", String.valueOf(llength));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.notFunctionError(callbackArg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.notFunctionError(callbackArg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.typeError0("msg.empty.array.reduce");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw f.unknown();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError0("msg.adapter.zero.args");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError2("msg.not.java.class.arg",
                                               String.valueOf(classCount),
                                               ScriptRuntime.toString(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError2("msg.only.one.super",
                              superClass.getName(), c.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.reportRuntimeError2(
                            "msg.no.java.ctor", adapterClass.getName(), sig);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.notFunctionError(x, functionName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.reportRuntimeError0(
                "JavaAdapter can not subclass methods with more then"
                +" 64 arguments.");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                        "msg.varargs.ctor", methodName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                        "msg.varargs.fun", methodName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError2(
                            "msg.bad.parms", types[i].getName(), methodName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                    "msg.bad.ctor.return", ctorType.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError2(
                        "msg.no.overload", name,
                        method.getDeclaringClass().getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1
                ("msg.cant.convert", desired.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                                       functionName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.constructError("SyntaxError", ex.getMessage());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.typeError0("msg.cyclic.value");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.typeError0("msg.cyclic.value");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefaultErrorReporter.java
throw ScriptRuntime.constructError(error, message, sourceURI,
                                               line, lineText, lineOffset);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefaultErrorReporter.java
throw runtimeError(
                message, sourceURI, line, lineText, lineOffset);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
throw Context.throwAsScriptRuntimeEx(ex);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaTopPackage.java
throw f.unknown();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaTopPackage.java
throw Context.reportRuntimeError0("msg.not.java.obj");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError2(
                        "msg.ambig.import", result.toString(), v.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.class.not.pkg", Context.toString(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.class", Context.toString(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.pkg", Context.toString(arg));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1("msg.prop.defined", n);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError2("msg.function.not.found.in",
                            toISOString,
                            ScriptRuntime.toString(o));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError3("msg.isnt.function.in",
                            toISOString,
                            ScriptRuntime.toString(o),
                            ScriptRuntime.toString(toISO));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive",
                            ScriptRuntime.toString(result));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.constructError("RangeError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw incompatibleCallError(f);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw ScriptRuntime.typeError0("msg.send.newborn");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw ScriptRuntime.typeError0("msg.already.exec.gen");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, size);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, size);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onEmptyStackTopRead();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onEmptyStackTopRead();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, N + 1);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, N);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed",
                                                  name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed",
                                                      name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw ScriptRuntime.constructError("InternalError",
                "Changing attributes not supported for " + getClassName()
                + " " + getInstanceIdName(id) + " property");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw f.unknown();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                       f.getFunctionName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw members.reportMemberNotFound(name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError2(
                    "msg.no.java.ctor", classObject.getName(), sig);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError0("msg.adapter.zero.args");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError2(
                "msg.cant.instantiate", msg, classObject.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw generatorState.returnedException;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw ScriptRuntime.notFunctionError(lhs);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw (RuntimeException)throwable;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw (Error)throwable;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Context.reportRuntimeError1("msg.var.redecl",
                                                  frame.idata.argNames[indexReg]);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw ScriptRuntime.typeError0("msg.yield.closing");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Context.reportRuntimeError("Exceeded maximum stack depth");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.op.not.allowed");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.bad.radix", Integer.toString(base));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.null.to.object");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.undef.to.object");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.invalid.type", val);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(toString(fun));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(thisObj, "function");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.ctor.not.found", constructorName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.not.ctor", constructorName);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, elem);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, toString(dblIndex));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, elem, value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, property, value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, String.valueOf(dblIndex), value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError2("msg.undef.prop.delete", toString(obj), idStr);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(result, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.invalid.iterator");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.iterator.primitive");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(result, name);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(obj, String.valueOf(index));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(value, elem);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(obj, property);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(thisObj, value, property);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(fun);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1("msg.only.from.new",
                                                  "With");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.not.ctor", "eval");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw ScriptRuntime.typeError0("msg.arg.isnt.array");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw ScriptRuntime.notFunctionError(value, thisObj);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError0("msg.eval.nonstring.strict");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.invalid.type", value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scopeChain, id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.bad.default.value");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.instanceof.not.object");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.in.not.object");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.undef.with", toString(obj));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(value);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError(msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.isnt.xml.object", toString(value));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError0("msg.no.regexp");

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(obj);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(obj);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
throw (RuntimeException)target;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError2(
                "msg.java.member.not.found", array.getClass().getName(), id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError1(
                "msg.java.array.member.not.found", id);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError2(
                "msg.java.array.index.out.of.bounds", String.valueOf(index),
                String.valueOf(length - 1));

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError1("msg.java.no_such_method", sig);

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError3(
                        "msg.nonjava.method", getFunctionName(),
                        ScriptRuntime.toString(thisObj), c.getName());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError3(
                "msg.constructor.ambiguous",
                memberName, scriptSignature(args), buf.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError4(
                "msg.method.ambiguous", memberClass,
                memberName, scriptSignature(args), buf.toString());

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw rex;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw ex2;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw (Error)e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw (RhinoException)e;

              
//in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdFunctionObject.java
throw ScriptRuntime.typeError1("msg.not.ctor", functionName);

            
- -
- Builder 361
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(caseNode);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw badTree(node);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UniqueTag.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
throw Context.reportRuntimeError("Direct call is not supported");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
throw Context.reportRuntimeError("Direct call is not supported");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
throw Context.reportRuntimeError(msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BoundFunction.java
throw ScriptRuntime.typeError0("msg.not.ctor");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BoundFunction.java
throw ScriptRuntime.typeError0("msg.not.ctor");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
throw Context.reportRuntimeError1("msg.cant.call.indirect", "With");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
throw f.unknown();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw Context.reportRuntimeError0("msg.script.is.not.constructor");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw Context.reportRuntimeError1(
                "msg.cant.call.indirect", "exec");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
throw ScriptRuntime.notFunctionError(badArg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
throw Context.reportRuntimeError2(
                        "msg.extend.scriptable",
                        thisObj.getClass().getName(),
                        String.valueOf(args[0]));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.typeError0("msg.bad.regexp.compile");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Context.reportRuntimeError("Too complex regexp");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError",
                    "invalid range in character class");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError",
                    "invalid range in character class");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw Kit.codeBug("invalid bytecode");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw ScriptRuntime.constructError("SyntaxError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/RegExpImpl.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw members.reportMemberNotFound(Integer.toString(index));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw members.reportMemberNotFound(Integer.toString(index));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw Context.reportRuntimeError0("msg.default.value");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
throw Context.reportRuntimeError2(
            "msg.conversion.not.allowed",
            String.valueOf(value),
            JavaMembers.javaSignature(type));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptFunctionNode.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptFunctionNode.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw reportClassFileFormatException(scriptOrFn, e.getMessage());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw reportClassFileFormatException(n, e.getMessage());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug("bad finally target");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Codegen.badTree();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
throw Context.reportRuntimeError("Program too complex " +
                                         "(out of locals)");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.typeError1("msg.instanceof.bad.prototype",
                                       getFunctionName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.notFunctionError(thisObj);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                       f.getFunctionName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope,
                            "Module \"" + mainModuleId + "\" not found.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                    "require() needs one argument");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                        "Can't resolve relative module ID \"" + id +
                                "\" when require() is used outside of a module");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                            "Module \"" + id + "\" is not contained in sandbox.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, scope,
                "require() can not be invoked as a constructor");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope, "Module \""
                        + id + "\" is not contained in sandbox.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw ScriptRuntime.throwError(cx, nativeScope, "Module \""
                        + id + "\" not found.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw Context.throwAsScriptRuntimeEx(e);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1("msg.access.prohibited",
                                                  cl.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw reportMemberNotFound(name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw reportMemberNotFound(name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1(str, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.throwAsScriptRuntimeEx(accessEx);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError3(
                    "msg.java.internal.field.type",
                    value.getClass().getName(), field,
                    javaObject.getClass().getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw Context.reportRuntimeError1(
                "msg.java.internal.private", field.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw f.unknown();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw Context.reportRuntimeError0("msg.bad.esc.mask");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
throw uriError();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(e);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
throw Context.reportRuntimeError(
            "VMBridge.getInterfaceProxyHelper is not supported");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
throw Context.reportRuntimeError(
            "VMBridge.newInterfaceProxy is not supported");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw ScriptRuntime.undefReadError(object, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Context.reportRuntimeError1(
                                "msg.cyclic.value", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw Context.reportRuntimeError(msg, sourceURI,
                                                 ts.lineno, null, 0);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw errorReporter.runtimeError(msg, sourceURI, baseLineno,
                                                 null, 0);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
throw Kit.codeBug("ts.cursor=" + ts.cursor
                          + ", ts.tokenBeg=" + ts.tokenBeg
                          + ", currentToken=" + currentToken);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.set.prop.no.setter", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.readonly", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                        "msg.invalid.type", typeHint.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.default.value", arg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                      "msg.zero.arg.ctor", clazz.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(
                          "msg.ctor.multiple.parms", clazz.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1
                ("msg.varargs.ctor", ctorMember.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2("duplicate.defineClass.name",
                        name, propName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2(
                        "msg.extend.scriptable",
                        proto.getClass().toString(), name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError(
                        "jsStaticFunction must be used with static method.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1
                    ("msg.varargs.fun", ctorMember.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(errorId, getter.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.setter.return",
                                                  setter.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1(errorId, setter.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(getter);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(setter);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError0("msg.both.data.and.accessor.desc");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError0("msg.not.extensible");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                        "msg.change.configurable.false.to.true", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                        "msg.change.enumerable.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                                "msg.change.writable.false.to.true.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                                "msg.change.value.with.writable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.setter.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.getter.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.property.data.to.accessor.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1(
                            "msg.change.property.accessor.to.data.with.configurable.false", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.arg.not.object", ScriptRuntime.typeof(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.typeError1("msg.arg.not.object", ScriptRuntime.typeof(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError2(
                    "msg.method.not.found", name, clazz.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed", str);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.const.redecl", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.var.redecl", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw ScriptRuntime.notFunctionError(obj, methodName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.var.redecl", name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Context.reportRuntimeError1("msg.prop.not.found", str);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                        "msg.no.empty.interface.conversion", cl.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                                    "msg.no.function.interface.conversion",
                                    cl.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
throw Context.reportRuntimeError1(
                        "msg.not.function.interface",methodName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
throw Context.reportRuntimeError1("msg.only.from.new", "Call");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
throw ScriptRuntime.typeError1("msg.no.properties",
                                           ScriptRuntime.toString(argument));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
throw ScriptRuntime.constructError("RangeError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
throw Context.reportRuntimeError0("msg.pkg.int");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.constructError("RangeError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.constructError("RangeError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw Context.reportRuntimeError1(
                "msg.arraylength.too.big", String.valueOf(llength));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.notFunctionError(callbackArg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.notFunctionError(callbackArg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
throw ScriptRuntime.typeError0("msg.empty.array.reduce");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
throw Kit.initCause(new IllegalStateException(), ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NodeTransformer.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw f.unknown();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError0("msg.adapter.zero.args");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError2("msg.not.java.class.arg",
                                               String.valueOf(classCount),
                                               ScriptRuntime.toString(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.typeError2("msg.only.one.super",
                              superClass.getName(), c.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.reportRuntimeError2(
                            "msg.no.java.ctor", adapterClass.getName(), sig);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw ScriptRuntime.notFunctionError(x, functionName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Context.reportRuntimeError0(
                "JavaAdapter can not subclass methods with more then"
                +" 64 arguments.");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                        "msg.varargs.ctor", methodName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                        "msg.varargs.fun", methodName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError2(
                            "msg.bad.parms", types[i].getName(), methodName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1(
                    "msg.bad.ctor.return", ctorType.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError2(
                        "msg.no.overload", name,
                        method.getDeclaringClass().getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.reportRuntimeError1
                ("msg.cant.convert", desired.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                                       functionName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.constructError("SyntaxError", ex.getMessage());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.typeError0("msg.cyclic.value");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
throw ScriptRuntime.typeError0("msg.cyclic.value");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefaultErrorReporter.java
throw ScriptRuntime.constructError(error, message, sourceURI,
                                               line, lineText, lineOffset);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefaultErrorReporter.java
throw runtimeError(
                message, sourceURI, line, lineText, lineOffset);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
throw Context.throwAsScriptRuntimeEx(ex);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaTopPackage.java
throw f.unknown();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaTopPackage.java
throw Context.reportRuntimeError0("msg.not.java.obj");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError2(
                        "msg.ambig.import", result.toString(), v.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.class.not.pkg", Context.toString(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.class", Context.toString(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1(
                    "msg.not.pkg", Context.toString(arg));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw Context.reportRuntimeError1("msg.prop.defined", n);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError2("msg.function.not.found.in",
                            toISOString,
                            ScriptRuntime.toString(o));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError3("msg.isnt.function.in",
                            toISOString,
                            ScriptRuntime.toString(o),
                            ScriptRuntime.toString(toISO));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive",
                            ScriptRuntime.toString(result));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw ScriptRuntime.constructError("RangeError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw incompatibleCallError(f);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw ScriptRuntime.typeError0("msg.send.newborn");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw ScriptRuntime.typeError0("msg.already.exec.gen");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, size);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, size);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onEmptyStackTopRead();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onEmptyStackTopRead();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, N + 1);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onInvalidIndex(index, N);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
throw onSeledMutation();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed",
                                                  name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw Context.reportRuntimeError1("msg.modify.sealed",
                                                      name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw ScriptRuntime.constructError("InternalError",
                "Changing attributes not supported for " + getClassName()
                + " " + getInstanceIdName(id) + " property");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw f.unknown();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
throw ScriptRuntime.typeError1("msg.incompat.call",
                                       f.getFunctionName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw members.reportMemberNotFound(name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError2(
                    "msg.no.java.ctor", classObject.getName(), sig);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError0("msg.adapter.zero.args");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
throw Context.reportRuntimeError2(
                "msg.cant.instantiate", msg, classObject.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw ScriptRuntime.notFunctionError(lhs);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Context.reportRuntimeError1("msg.var.redecl",
                                                  frame.idata.argNames[indexReg]);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw ScriptRuntime.typeError0("msg.yield.closing");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw Context.reportRuntimeError("Exceeded maximum stack depth");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.op.not.allowed");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.primitive.expected", val);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.bad.radix", Integer.toString(base));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.null.to.object");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.undef.to.object");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.invalid.type", val);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(toString(fun));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(thisObj, "function");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.ctor.not.found", constructorName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1(
                "msg.not.ctor", constructorName);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, elem);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, property);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, toString(dblIndex));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, elem, value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, property, value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefWriteError(obj, String.valueOf(dblIndex), value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError2("msg.undef.prop.delete", toString(obj), idStr);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(result, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.invalid.iterator");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.iterator.primitive");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scope, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(result, name);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(obj, String.valueOf(index));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(value, elem);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefCallError(obj, property);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(thisObj, value, property);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFunctionError(fun);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError1("msg.only.from.new",
                                                  "With");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.not.ctor", "eval");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw ScriptRuntime.typeError0("msg.arg.isnt.array");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw ScriptRuntime.notFunctionError(value, thisObj);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError0("msg.eval.nonstring.strict");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw errorWithClassName("msg.invalid.type", value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notFoundError(scopeChain, id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw undefReadError(obj, id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.bad.default.value");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.instanceof.not.object");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError0("msg.in.not.object");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.undef.with", toString(obj));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(value);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Kit.codeBug();

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError(msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw constructError("ReferenceError", msg);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw typeError1("msg.isnt.xml.object", toString(value));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw Context.reportRuntimeError0("msg.no.regexp");

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(obj);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw notXmlError(obj);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError2(
                "msg.java.member.not.found", array.getClass().getName(), id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError1(
                "msg.java.array.member.not.found", id);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaArray.java
throw Context.reportRuntimeError2(
                "msg.java.array.index.out.of.bounds", String.valueOf(index),
                String.valueOf(length - 1));

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError1("msg.java.no_such_method", sig);

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError3(
                        "msg.nonjava.method", getFunctionName(),
                        ScriptRuntime.toString(thisObj), c.getName());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError3(
                "msg.constructor.ambiguous",
                memberName, scriptSignature(args), buf.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
throw Context.reportRuntimeError4(
                "msg.method.ambiguous", memberClass,
                memberName, scriptSignature(args), buf.toString());

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdFunctionObject.java
throw ScriptRuntime.typeError1("msg.not.ctor", functionName);

            
- -
- Variable 21
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw x;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
throw (ContinuationPending) e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
throw ex;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
throw ex;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw generatorState.returnedException;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw (RuntimeException)throwable;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
throw (Error)throwable;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
throw e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
throw (RuntimeException)target;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw rex;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw ex2;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw (Error)e;

              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
throw (RhinoException)e;

            
- -
(Lib) IllegalArgumentException 179
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=0; s="constructor"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(FTAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(FTAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: throw Context.reportRuntimeError("Direct call is not supported"); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_exec: arity=0; s="exec"; break; case Id_compile: arity=1; s="compile"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(SCRIPT_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(SCRIPT_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: { String source = (args.length == 0) ? "" : ScriptRuntime.toString(args[0]); Script script = compile(cx, source); NativeScript nscript = new NativeScript(script); ScriptRuntime.setObjectProtoAndParent(nscript, scope); return nscript; } case Id_toString: { NativeScript real = realThis(thisObj, f); Script realScript = real.script; if (realScript == null) { return ""; } return cx.decompileScript(realScript, 0); } case Id_exec: { throw Context.reportRuntimeError1( "msg.cant.call.indirect", "exec"); } case Id_compile: { NativeScript real = realThis(thisObj, f); String source = ScriptRuntime.toString(args, 0); real.script = compile(cx, source); return real; } } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_hasOwnProperty: arity=1; s="hasOwnProperty"; break; case Id_propertyIsEnumerable: arity=1; s="propertyIsEnumerable"; break; case Id_isPrototypeOf: arity=1; s="isPrototypeOf"; break; case Id_toSource: arity=0; s="toSource"; break; case Id___defineGetter__: arity=2; s="__defineGetter__"; break; case Id___defineSetter__: arity=2; s="__defineSetter__"; break; case Id___lookupGetter__: arity=1; s="__lookupGetter__"; break; case Id___lookupSetter__: arity=1; s="__lookupSetter__"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(OBJECT_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(OBJECT_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: { if (thisObj != null) { // BaseFunction.construct will set up parent, proto return f.construct(cx, scope, args); } if (args.length == 0 || args[0] == null || args[0] == Undefined.instance) { return new NativeObject(); } return ScriptRuntime.toObject(cx, scope, args[0]); } case Id_toLocaleString: // For now just alias toString case Id_toString: { if (cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE)) { String s = ScriptRuntime.defaultObjectToSource(cx, scope, thisObj, args); int L = s.length(); if (L != 0 && s.charAt(0) == '(' && s.charAt(L - 1) == ')') { // Strip () that surrounds toSource s = s.substring(1, L - 1); } return s; } return ScriptRuntime.defaultObjectToString(thisObj); } case Id_valueOf: return thisObj; case Id_hasOwnProperty: { boolean result; if (args.length == 0) { result = false; } else { String s = ScriptRuntime.toStringIdOrIndex(cx, args[0]); if (s == null) { int index = ScriptRuntime.lastIndexResult(cx); result = thisObj.has(index, thisObj); } else { result = thisObj.has(s, thisObj); } } return ScriptRuntime.wrapBoolean(result); } case Id_propertyIsEnumerable: { boolean result; if (args.length == 0) { result = false; } else { String s = ScriptRuntime.toStringIdOrIndex(cx, args[0]); if (s == null) { int index = ScriptRuntime.lastIndexResult(cx); result = thisObj.has(index, thisObj); if (result && thisObj instanceof ScriptableObject) { ScriptableObject so = (ScriptableObject)thisObj; int attrs = so.getAttributes(index); result = ((attrs & ScriptableObject.DONTENUM) == 0); } } else { result = thisObj.has(s, thisObj); if (result && thisObj instanceof ScriptableObject) { ScriptableObject so = (ScriptableObject)thisObj; int attrs = so.getAttributes(s); result = ((attrs & ScriptableObject.DONTENUM) == 0); } } } return ScriptRuntime.wrapBoolean(result); } case Id_isPrototypeOf: { boolean result = false; if (args.length != 0 && args[0] instanceof Scriptable) { Scriptable v = (Scriptable) args[0]; do { v = v.getPrototype(); if (v == thisObj) { result = true; break; } } while (v != null); } return ScriptRuntime.wrapBoolean(result); } case Id_toSource: return ScriptRuntime.defaultObjectToSource(cx, scope, thisObj, args); case Id___defineGetter__: case Id___defineSetter__: { if (args.length < 2 || !(args[1] instanceof Callable)) { Object badArg = (args.length >= 2 ? args[1] : Undefined.instance); throw ScriptRuntime.notFunctionError(badArg); } if (!(thisObj instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", thisObj.getClass().getName(), String.valueOf(args[0])); } ScriptableObject so = (ScriptableObject)thisObj; String name = ScriptRuntime.toStringIdOrIndex(cx, args[0]); int index = (name != null ? 0 : ScriptRuntime.lastIndexResult(cx)); Callable getterOrSetter = (Callable)args[1]; boolean isSetter = (id == Id___defineSetter__); so.setGetterOrSetter(name, index, getterOrSetter, isSetter); if (so instanceof NativeArray) ((NativeArray)so).setDenseOnly(false); } return Undefined.instance; case Id___lookupGetter__: case Id___lookupSetter__: { if (args.length < 1 || !(thisObj instanceof ScriptableObject)) return Undefined.instance; ScriptableObject so = (ScriptableObject)thisObj; String name = ScriptRuntime.toStringIdOrIndex(cx, args[0]); int index = (name != null ? 0 : ScriptRuntime.lastIndexResult(cx)); boolean isSetter = (id == Id___lookupSetter__); Object gs; for (;;) { gs = so.getGetterOrSetter(name, index, isSetter); if (gs != null) break; // If there is no getter or setter for the object itself, // how about the prototype? Scriptable v = so.getPrototype(); if (v == null) break; if (v instanceof ScriptableObject) so = (ScriptableObject)v; else break; } if (gs != null) return gs; } return Undefined.instance; case ConstructorId_getPrototypeOf: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = ensureScriptable(arg); return obj.getPrototype(); } case ConstructorId_keys: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = ensureScriptable(arg); Object[] ids = obj.getIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); } return cx.newArray(scope, ids); } case ConstructorId_getOwnPropertyNames: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); } return cx.newArray(scope, ids); } case ConstructorId_getOwnPropertyDescriptor: { Object arg = args.length < 1 ? Undefined.instance : args[0]; // TODO(norris): There's a deeper issue here if // arg instanceof Scriptable. Should we create a new // interface to admit the new ECMAScript 5 operations? ScriptableObject obj = ensureScriptableObject(arg); Object nameArg = args.length < 2 ? Undefined.instance : args[1]; String name = ScriptRuntime.toString(nameArg); Scriptable desc = obj.getOwnPropertyDescriptor(cx, name); return desc == null ? Undefined.instance : desc; } case ConstructorId_defineProperty: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object name = args.length < 2 ? Undefined.instance : args[1]; Object descArg = args.length < 3 ? Undefined.instance : args[2]; ScriptableObject desc = ensureScriptableObject(descArg); obj.defineOwnProperty(cx, name, desc); return obj; } case ConstructorId_isExtensible: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); return Boolean.valueOf(obj.isExtensible()); } case ConstructorId_preventExtensions: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); obj.preventExtensions(); return obj; } case ConstructorId_defineProperties: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object propsObj = args.length < 2 ? Undefined.instance : args[1]; Scriptable props = Context.toObject(propsObj, getParentScope()); obj.defineOwnProperties(cx, ensureScriptableObject(props)); return obj; } case ConstructorId_create: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = (arg == null) ? null : ensureScriptable(arg); ScriptableObject newObject = new NativeObject(); newObject.setParentScope(this.getParentScope()); newObject.setPrototype(obj); if (args.length > 1 && args[1] != Undefined.instance) { Scriptable props = Context.toObject(args[1], getParentScope()); newObject.defineOwnProperties(cx, ensureScriptableObject(props)); } return newObject; } case ConstructorId_isSealed: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); if (obj.isExtensible()) return Boolean.FALSE; for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) return Boolean.FALSE; } return Boolean.TRUE; } case ConstructorId_isFrozen: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); if (obj.isExtensible()) return Boolean.FALSE; for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) return Boolean.FALSE; if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable"))) return Boolean.FALSE; } return Boolean.TRUE; } case ConstructorId_seal: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { desc.put("configurable", desc, Boolean.FALSE); obj.defineOwnProperty(cx, name, desc, false); } } obj.preventExtensions(); return obj; } case ConstructorId_freeze: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable"))) desc.put("writable", desc, Boolean.FALSE); if (Boolean.TRUE.equals(desc.get("configurable"))) desc.put("configurable", desc, Boolean.FALSE); obj.defineOwnProperty(cx, name, desc, false); } obj.preventExtensions(); return obj; } default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_compile: arity=1; s="compile"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_exec: arity=1; s="exec"; break; case Id_test: arity=1; s="test"; break; case Id_prefix: arity=1; s="prefix"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(REGEXP_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(REGEXP_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_compile: return realThis(thisObj, f).compile(cx, scope, args); case Id_toString: case Id_toSource: return realThis(thisObj, f).toString(); case Id_exec: return realThis(thisObj, f).execSub(cx, scope, args, MATCH); case Id_test: { Object x = realThis(thisObj, f).execSub(cx, scope, args, TEST); return Boolean.TRUE.equals(x) ? Boolean.TRUE : Boolean.FALSE; } case Id_prefix: return realThis(thisObj, f).execSub(cx, scope, args, PREFIX); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptRuntime.java
private static int[] decodeIntArray(String str, int arraySize) { // XXX: this extremely inefficient for small integers if (arraySize == 0) { if (str != null) throw new IllegalArgumentException(); return null; } if (str.length() != 1 + arraySize * 2 && str.charAt(0) != 1) { throw new IllegalArgumentException(); } int[] array = new int[arraySize]; for (int i = 0; i != arraySize; ++i) { int shift = 1 + i * 2; array[i] = (str.charAt(shift) << 16) | str.charAt(shift + 1); } return array; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=1; s="toString"; break; case Id_toSource: arity=1; s="toSource"; break; case Id_apply: arity=2; s="apply"; break; case Id_call: arity=1; s="call"; break; case Id_bind: arity=1; s="bind"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(FUNCTION_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(FUNCTION_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return jsConstructor(cx, scope, args); case Id_toString: { BaseFunction realf = realFunction(thisObj, f); int indent = ScriptRuntime.toInt32(args, 0); return realf.decompile(indent, 0); } case Id_toSource: { BaseFunction realf = realFunction(thisObj, f); int indent = 0; int flags = Decompiler.TO_SOURCE_FLAG; if (args.length != 0) { indent = ScriptRuntime.toInt32(args[0]); if (indent >= 0) { flags = 0; } else { indent = 0; } } return realf.decompile(indent, flags); } case Id_apply: case Id_call: return ScriptRuntime.applyOrCall(id == Id_apply, cx, scope, thisObj, args); case Id_bind: if ( !(thisObj instanceof Callable) ) { throw ScriptRuntime.notFunctionError(thisObj); } Callable targetFunction = (Callable) thisObj; int argc = args.length; final Scriptable boundThis; final Object[] boundArgs; if (argc > 0) { boundThis = ScriptRuntime.toObjectOrNull(cx, args[0], scope); boundArgs = new Object[argc-1]; System.arraycopy(args, 1, boundArgs, 0, argc-1); } else { boundThis = null; boundArgs = ScriptRuntime.emptyArgs; } return new BoundFunction(cx, scope, targetFunction, boundThis, boundArgs); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeMember(ObjectOutputStream out, Member member) throws IOException { if (member == null) { out.writeBoolean(false); return; } out.writeBoolean(true); if (!(member instanceof Method || member instanceof Constructor)) throw new IllegalArgumentException("not Method or Constructor"); out.writeBoolean(member instanceof Method); out.writeObject(member.getName()); out.writeObject(member.getDeclaringClass()); if (member instanceof Method) { writeParameters(out, ((Method) member).getParameterTypes()); } else { writeParameters(out, ((Constructor<?>) member).getParameterTypes()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_charAt: arity=1; s="charAt"; break; case Id_charCodeAt: arity=1; s="charCodeAt"; break; case Id_indexOf: arity=1; s="indexOf"; break; case Id_lastIndexOf: arity=1; s="lastIndexOf"; break; case Id_split: arity=2; s="split"; break; case Id_substring: arity=2; s="substring"; break; case Id_toLowerCase: arity=0; s="toLowerCase"; break; case Id_toUpperCase: arity=0; s="toUpperCase"; break; case Id_substr: arity=2; s="substr"; break; case Id_concat: arity=1; s="concat"; break; case Id_slice: arity=2; s="slice"; break; case Id_bold: arity=0; s="bold"; break; case Id_italics: arity=0; s="italics"; break; case Id_fixed: arity=0; s="fixed"; break; case Id_strike: arity=0; s="strike"; break; case Id_small: arity=0; s="small"; break; case Id_big: arity=0; s="big"; break; case Id_blink: arity=0; s="blink"; break; case Id_sup: arity=0; s="sup"; break; case Id_sub: arity=0; s="sub"; break; case Id_fontsize: arity=0; s="fontsize"; break; case Id_fontcolor: arity=0; s="fontcolor"; break; case Id_link: arity=0; s="link"; break; case Id_anchor: arity=0; s="anchor"; break; case Id_equals: arity=1; s="equals"; break; case Id_equalsIgnoreCase: arity=1; s="equalsIgnoreCase"; break; case Id_match: arity=1; s="match"; break; case Id_search: arity=1; s="search"; break; case Id_replace: arity=1; s="replace"; break; case Id_localeCompare: arity=1; s="localeCompare"; break; case Id_toLocaleLowerCase: arity=0; s="toLocaleLowerCase"; break; case Id_toLocaleUpperCase: arity=0; s="toLocaleUpperCase"; break; case Id_trim: arity=0; s="trim"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(STRING_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(STRING_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); again: for(;;) { switch (id) { case ConstructorId_charAt: case ConstructorId_charCodeAt: case ConstructorId_indexOf: case ConstructorId_lastIndexOf: case ConstructorId_split: case ConstructorId_substring: case ConstructorId_toLowerCase: case ConstructorId_toUpperCase: case ConstructorId_substr: case ConstructorId_concat: case ConstructorId_slice: case ConstructorId_equalsIgnoreCase: case ConstructorId_match: case ConstructorId_search: case ConstructorId_replace: case ConstructorId_localeCompare: case ConstructorId_toLocaleLowerCase: { if (args.length > 0) { thisObj = ScriptRuntime.toObject(scope, ScriptRuntime.toCharSequence(args[0])); Object[] newArgs = new Object[args.length-1]; for (int i=0; i < newArgs.length; i++) newArgs[i] = args[i+1]; args = newArgs; } else { thisObj = ScriptRuntime.toObject(scope, ScriptRuntime.toCharSequence(thisObj)); } id = -id; continue again; } case ConstructorId_fromCharCode: { int N = args.length; if (N < 1) return ""; StringBuffer sb = new StringBuffer(N); for (int i = 0; i != N; ++i) { sb.append(ScriptRuntime.toUint16(args[i])); } return sb.toString(); } case Id_constructor: { CharSequence s = (args.length >= 1) ? ScriptRuntime.toCharSequence(args[0]) : ""; if (thisObj == null) { // new String(val) creates a new String object. return new NativeString(s); } // String(val) converts val to a string value. return s instanceof String ? s : s.toString(); } case Id_toString: case Id_valueOf: // ECMA 15.5.4.2: 'the toString function is not generic. CharSequence cs = realThis(thisObj, f).string; return cs instanceof String ? cs : cs.toString(); case Id_toSource: { CharSequence s = realThis(thisObj, f).string; return "(new String(\""+ScriptRuntime.escapeString(s.toString())+"\"))"; } case Id_charAt: case Id_charCodeAt: { // See ECMA 15.5.4.[4,5] CharSequence target = ScriptRuntime.toCharSequence(thisObj); double pos = ScriptRuntime.toInteger(args, 0); if (pos < 0 || pos >= target.length()) { if (id == Id_charAt) return ""; else return ScriptRuntime.NaNobj; } char c = target.charAt((int)pos); if (id == Id_charAt) return String.valueOf(c); else return ScriptRuntime.wrapInt(c); } case Id_indexOf: return ScriptRuntime.wrapInt(js_indexOf( ScriptRuntime.toString(thisObj), args)); case Id_lastIndexOf: return ScriptRuntime.wrapInt(js_lastIndexOf( ScriptRuntime.toString(thisObj), args)); case Id_split: return ScriptRuntime.checkRegExpProxy(cx). js_split(cx, scope, ScriptRuntime.toString(thisObj), args); case Id_substring: return js_substring(cx, ScriptRuntime.toCharSequence(thisObj), args); case Id_toLowerCase: // See ECMA 15.5.4.11 return ScriptRuntime.toString(thisObj).toLowerCase( ScriptRuntime.ROOT_LOCALE); case Id_toUpperCase: // See ECMA 15.5.4.12 return ScriptRuntime.toString(thisObj).toUpperCase( ScriptRuntime.ROOT_LOCALE); case Id_substr: return js_substr(ScriptRuntime.toCharSequence(thisObj), args); case Id_concat: return js_concat(ScriptRuntime.toString(thisObj), args); case Id_slice: return js_slice(ScriptRuntime.toCharSequence(thisObj), args); case Id_bold: return tagify(thisObj, "b", null, null); case Id_italics: return tagify(thisObj, "i", null, null); case Id_fixed: return tagify(thisObj, "tt", null, null); case Id_strike: return tagify(thisObj, "strike", null, null); case Id_small: return tagify(thisObj, "small", null, null); case Id_big: return tagify(thisObj, "big", null, null); case Id_blink: return tagify(thisObj, "blink", null, null); case Id_sup: return tagify(thisObj, "sup", null, null); case Id_sub: return tagify(thisObj, "sub", null, null); case Id_fontsize: return tagify(thisObj, "font", "size", args); case Id_fontcolor: return tagify(thisObj, "font", "color", args); case Id_link: return tagify(thisObj, "a", "href", args); case Id_anchor: return tagify(thisObj, "a", "name", args); case Id_equals: case Id_equalsIgnoreCase: { String s1 = ScriptRuntime.toString(thisObj); String s2 = ScriptRuntime.toString(args, 0); return ScriptRuntime.wrapBoolean( (id == Id_equals) ? s1.equals(s2) : s1.equalsIgnoreCase(s2)); } case Id_match: case Id_search: case Id_replace: { int actionType; if (id == Id_match) { actionType = RegExpProxy.RA_MATCH; } else if (id == Id_search) { actionType = RegExpProxy.RA_SEARCH; } else { actionType = RegExpProxy.RA_REPLACE; } return ScriptRuntime.checkRegExpProxy(cx). action(cx, scope, thisObj, args, actionType); } // ECMA-262 1 5.5.4.9 case Id_localeCompare: { // For now, create and configure a collator instance. I can't // actually imagine that this'd be slower than caching them // a la ClassCache, so we aren't trying to outsmart ourselves // with a caching mechanism for now. Collator collator = Collator.getInstance(cx.getLocale()); collator.setStrength(Collator.IDENTICAL); collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); return ScriptRuntime.wrapNumber(collator.compare( ScriptRuntime.toString(thisObj), ScriptRuntime.toString(args, 0))); } case Id_toLocaleLowerCase: { return ScriptRuntime.toString(thisObj) .toLowerCase(cx.getLocale()); } case Id_toLocaleUpperCase: { return ScriptRuntime.toString(thisObj) .toUpperCase(cx.getLocale()); } case Id_trim: { String str = ScriptRuntime.toString(thisObj); char[] chars = str.toCharArray(); int start = 0; while (start < chars.length && ScriptRuntime.isJSWhitespaceOrLineTerminator(chars[start])) { start++; } int end = chars.length; while (end > start && ScriptRuntime.isJSWhitespaceOrLineTerminator(chars[end-1])) { end--; } return str.substring(start, end); } } throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
static Ref createSpecial(Context cx, Object object, String name) { Scriptable target = ScriptRuntime.toObjectOrNull(cx, object); if (target == null) { throw ScriptRuntime.undefReadError(object, name); } int type; if (name.equals("__proto__")) { type = SPECIAL_PROTO; } else if (name.equals("__parent__")) { type = SPECIAL_PARENT; } else { throw new IllegalArgumentException(name); } if (!cx.hasFeature(Context.FEATURE_PARENT_PROTO_PROPERTIES)) { // Clear special after checking for valid name! type = SPECIAL_NONE; } return new SpecialRef(target, type, name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static void checkValidAttributes(int attributes) { final int mask = READONLY | DONTENUM | PERMANENT | UNINITIALIZED_CONST; if ((attributes & ~mask) != 0) { throw new IllegalArgumentException(String.valueOf(attributes)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void setGetterOrSetter(String name, int index, Callable getterOrSetter, boolean isSetter, boolean force) { if (name != null && index != 0) throw new IllegalArgumentException(name); if (!force) { checkNotSealed(name, index); } final GetterSlot gslot; if (isExtensible()) { gslot = (GetterSlot)getSlot(name, index, SLOT_MODIFY_GETTER_SETTER); } else { Slot slot = unwrapSlot(getSlot(name, index, SLOT_QUERY)); if (!(slot instanceof GetterSlot)) return; gslot = (GetterSlot) slot; } if (!force) { int attributes = gslot.getAttributes(); if ((attributes & READONLY) != 0) { throw Context.reportRuntimeError1("msg.modify.readonly", name); } } if (isSetter) { gslot.setter = getterOrSetter; } else { gslot.getter = getterOrSetter; } gslot.value = Undefined.instance; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public Object getGetterOrSetter(String name, int index, boolean isSetter) { if (name != null && index != 0) throw new IllegalArgumentException(name); Slot slot = unwrapSlot(getSlot(name, index, SLOT_QUERY)); if (slot == null) return null; if (slot instanceof GetterSlot) { GetterSlot gslot = (GetterSlot)slot; Object result = isSetter ? gslot.setter : gslot.getter; return result != null ? result : Undefined.instance; } else return Undefined.instance; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
void addLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes) { if (name != null && index != 0) throw new IllegalArgumentException(name); checkNotSealed(name, index); GetterSlot gslot = (GetterSlot)getSlot(name, index, SLOT_MODIFY_GETTER_SETTER); gslot.setAttributes(attributes); gslot.getter = null; gslot.setter = null; gslot.value = init; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public void defineProperty(String propertyName, Class<?> clazz, int attributes) { int length = propertyName.length(); if (length == 0) throw new IllegalArgumentException(); char[] buf = new char[3 + length]; propertyName.getChars(0, length, buf, 3); buf[3] = Character.toUpperCase(buf[3]); buf[0] = 'g'; buf[1] = 'e'; buf[2] = 't'; String getterName = new String(buf); buf[0] = 's'; String setterName = new String(buf); Method[] methods = FunctionObject.getMethodList(clazz); Method getter = FunctionObject.findSingleMethod(methods, getterName); Method setter = FunctionObject.findSingleMethod(methods, setterName); if (setter == null) attributes |= ScriptableObject.READONLY; defineProperty(propertyName, null, getter, setter == null ? null : setter, attributes); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public synchronized final Object associateValue(Object key, Object value) { if (value == null) throw new IllegalArgumentException(); Map<Object,Object> h = associatedValues; if (h == null) { h = new HashMap<Object,Object>(); associatedValues = h; } return Kit.initHash(h, key, value); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
static Object create(Context cx, Class<?> cl, ScriptableObject object) { if (!cl.isInterface()) throw new IllegalArgumentException(); Scriptable topScope = ScriptRuntime.getTopCallScope(cx); ClassCache cache = ClassCache.get(topScope); InterfaceAdapter adapter; adapter = (InterfaceAdapter)cache.getInterfaceAdapter(cl); ContextFactory cf = cx.getFactory(); if (adapter == null) { Method[] methods = cl.getMethods(); if ( object instanceof Callable) { // Check if interface can be implemented by a single function. // We allow this if the interface has only one method or multiple // methods with the same name (in which case they'd result in // the same function to be invoked anyway). int length = methods.length; if (length == 0) { throw Context.reportRuntimeError1( "msg.no.empty.interface.conversion", cl.getName()); } if (length > 1) { String methodName = methods[0].getName(); for (int i = 1; i < length; i++) { if (!methodName.equals(methods[i].getName())) { throw Context.reportRuntimeError1( "msg.no.function.interface.conversion", cl.getName()); } } } } adapter = new InterfaceAdapter(cf, cl); cache.cacheInterfaceAdapter(cl, adapter); } return VMBridge.instance.newInterfaceProxy( adapter.proxyHelper, cf, adapter, object, topScope); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(BOOLEAN_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(BOOLEAN_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { boolean b; if (args.length == 0) { b = false; } else { b = args[0] instanceof ScriptableObject && ((ScriptableObject) args[0]).avoidObjectDetection() ? true : ScriptRuntime.toBoolean(args[0]); } if (thisObj == null) { // new Boolean(val) creates a new boolean object. return new NativeBoolean(b); } // Boolean(val) converts val to a boolean. return ScriptRuntime.wrapBoolean(b); } // The rest of Boolean.prototype methods require thisObj to be Boolean if (!(thisObj instanceof NativeBoolean)) throw incompatibleCallError(f); boolean value = ((NativeBoolean)thisObj).booleanValue; switch (id) { case Id_toString: return value ? "true" : "false"; case Id_toSource: return value ? "(new Boolean(true))" : "(new Boolean(false))"; case Id_valueOf: return ScriptRuntime.wrapBoolean(value); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
Override protected void initPrototypeId(int id) { String s; int arity; if (id == Id_constructor) { arity=1; s="constructor"; } else { throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(CALL_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(CALL_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { if (thisObj != null) { throw Context.reportRuntimeError1("msg.only.from.new", "Call"); } ScriptRuntime.checkDeprecated(cx, "Call"); NativeCall result = new NativeCall(); result.setPrototype(getObjectPrototype(scope)); return result; } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object addListener(Object bag, Object listener) { if (listener == null) throw new IllegalArgumentException(); if (listener instanceof Object[]) throw new IllegalArgumentException(); if (bag == null) { bag = listener; } else if (!(bag instanceof Object[])) { bag = new Object[] { bag, listener }; } else { Object[] array = (Object[])bag; int L = array.length; // bag has at least 2 elements if it is array if (L < 2) throw new IllegalArgumentException(); Object[] tmp = new Object[L + 1]; System.arraycopy(array, 0, tmp, 0, L); tmp[L] = listener; bag = tmp; } return bag; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object removeListener(Object bag, Object listener) { if (listener == null) throw new IllegalArgumentException(); if (listener instanceof Object[]) throw new IllegalArgumentException(); if (bag == listener) { bag = null; } else if (bag instanceof Object[]) { Object[] array = (Object[])bag; int L = array.length; // bag has at least 2 elements if it is array if (L < 2) throw new IllegalArgumentException(); if (L == 2) { if (array[1] == listener) { bag = array[0]; } else if (array[0] == listener) { bag = array[1]; } } else { int i = L; do { --i; if (array[i] == listener) { Object[] tmp = new Object[L - 1]; System.arraycopy(array, 0, tmp, 0, i); System.arraycopy(array, i + 1, tmp, i, L - (i + 1)); bag = tmp; break; } } while (i != 0); } } return bag; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object getListener(Object bag, int index) { if (index == 0) { if (bag == null) return null; if (!(bag instanceof Object[])) return bag; Object[] array = (Object[])bag; // bag has at least 2 elements if it is array if (array.length < 2) throw new IllegalArgumentException(); return array[0]; } else if (index == 1) { if (!(bag instanceof Object[])) { if (bag == null) throw new IllegalArgumentException(); return null; } Object[] array = (Object[])bag; // the array access will check for index on its own return array[1]; } else { // bag has to array Object[] array = (Object[])bag; int L = array.length; if (L < 2) throw new IllegalArgumentException(); if (index == L) return null; return array[index]; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object makeHashKeyFromPair(Object key1, Object key2) { if (key1 == null) throw new IllegalArgumentException(); if (key2 == null) throw new IllegalArgumentException(); return new ComplexKey(key1, key2); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException { if (initialBufferCapacity <= 0) { throw new IllegalArgumentException( "Bad initialBufferCapacity: "+initialBufferCapacity); } byte[] buffer = new byte[initialBufferCapacity]; int cursor = 0; for (;;) { int n = is.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { byte[] tmp = new byte[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } if (cursor != buffer.length) { byte[] tmp = new byte[cursor]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } return buffer; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=2; s="constructor"; break; case Id_next: arity=0; s="next"; break; case Id___iterator__: arity=1; s=ITERATOR_PROPERTY_NAME; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ITERATOR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ITERATOR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { return jsConstructor(cx, scope, thisObj, args); } if (!(thisObj instanceof NativeIterator)) throw incompatibleCallError(f); NativeIterator iterator = (NativeIterator) thisObj; switch (id) { case Id_next: return iterator.next(cx, scope); case Id___iterator__: /// XXX: what about argument? SpiderMonkey apparently ignores it return thisObj; default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=1; s="toString"; break; case Id_toLocaleString: arity=1; s="toLocaleString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_toFixed: arity=1; s="toFixed"; break; case Id_toExponential: arity=1; s="toExponential"; break; case Id_toPrecision: arity=1; s="toPrecision"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(NUMBER_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(NUMBER_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { double val = (args.length >= 1) ? ScriptRuntime.toNumber(args[0]) : 0.0; if (thisObj == null) { // new Number(val) creates a new Number object. return new NativeNumber(val); } // Number(val) converts val to a number value. return ScriptRuntime.wrapNumber(val); } // The rest of Number.prototype methods require thisObj to be Number if (!(thisObj instanceof NativeNumber)) throw incompatibleCallError(f); double value = ((NativeNumber)thisObj).doubleValue; switch (id) { case Id_toString: case Id_toLocaleString: { // toLocaleString is just an alias for toString for now int base = (args.length == 0 || args[0] == Undefined.instance) ? 10 : ScriptRuntime.toInt32(args[0]); return ScriptRuntime.numberToString(value, base); } case Id_toSource: return "(new Number("+ScriptRuntime.toString(value)+"))"; case Id_valueOf: return ScriptRuntime.wrapNumber(value); case Id_toFixed: return num_to(value, args, DToA.DTOSTR_FIXED, DToA.DTOSTR_FIXED, -20, 0); case Id_toExponential: { // Handle special values before range check if(Double.isNaN(value)) { return "NaN"; } if(Double.isInfinite(value)) { if(value >= 0) { return "Infinity"; } else { return "-Infinity"; } } // General case return num_to(value, args, DToA.DTOSTR_STANDARD_EXPONENTIAL, DToA.DTOSTR_EXPONENTIAL, 0, 1); } case Id_toPrecision: { // Undefined precision, fall back to ToString() if(args.length == 0 || args[0] == Undefined.instance) { return ScriptRuntime.numberToString(value, 10); } // Handle special values before range check if(Double.isNaN(value)) { return "NaN"; } if(Double.isInfinite(value)) { if(value >= 0) { return "Infinity"; } else { return "-Infinity"; } } return num_to(value, args, DToA.DTOSTR_STANDARD, DToA.DTOSTR_PRECISION, 1, 0); } default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
protected boolean hasFeature(Context cx, int featureIndex) { int version; switch (featureIndex) { case Context.FEATURE_NON_ECMA_GET_YEAR: /* * During the great date rewrite of 1.3, we tried to track the * evolving ECMA standard, which then had a definition of * getYear which always subtracted 1900. Which we * implemented, not realizing that it was incompatible with * the old behavior... now, rather than thrash the behavior * yet again, we've decided to leave it with the - 1900 * behavior and point people to the getFullYear method. But * we try to protect existing scripts that have specified a * version... */ version = cx.getLanguageVersion(); return (version == Context.VERSION_1_0 || version == Context.VERSION_1_1 || version == Context.VERSION_1_2); case Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME: return false; case Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER: return true; case Context.FEATURE_TO_STRING_AS_SOURCE: version = cx.getLanguageVersion(); return version == Context.VERSION_1_2; case Context.FEATURE_PARENT_PROTO_PROPERTIES: return true; case Context.FEATURE_E4X: version = cx.getLanguageVersion(); return (version == Context.VERSION_DEFAULT || version >= Context.VERSION_1_6); case Context.FEATURE_DYNAMIC_SCOPE: return false; case Context.FEATURE_STRICT_VARS: return false; case Context.FEATURE_STRICT_EVAL: return false; case Context.FEATURE_LOCATION_INFORMATION_IN_ERROR: return false; case Context.FEATURE_STRICT_MODE: return false; case Context.FEATURE_WARNING_AS_ERROR: return false; case Context.FEATURE_ENHANCED_JAVA_ACCESS: return false; } // It is a bug to call the method with unknown featureIndex throw new IllegalArgumentException(String.valueOf(featureIndex)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_join: arity=1; s="join"; break; case Id_reverse: arity=0; s="reverse"; break; case Id_sort: arity=1; s="sort"; break; case Id_push: arity=1; s="push"; break; case Id_pop: arity=0; s="pop"; break; case Id_shift: arity=0; s="shift"; break; case Id_unshift: arity=1; s="unshift"; break; case Id_splice: arity=2; s="splice"; break; case Id_concat: arity=1; s="concat"; break; case Id_slice: arity=2; s="slice"; break; case Id_indexOf: arity=1; s="indexOf"; break; case Id_lastIndexOf: arity=1; s="lastIndexOf"; break; case Id_every: arity=1; s="every"; break; case Id_filter: arity=1; s="filter"; break; case Id_forEach: arity=1; s="forEach"; break; case Id_map: arity=1; s="map"; break; case Id_some: arity=1; s="some"; break; case Id_reduce: arity=1; s="reduce"; break; case Id_reduceRight: arity=1; s="reduceRight"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ARRAY_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ARRAY_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); again: for (;;) { switch (id) { case ConstructorId_join: case ConstructorId_reverse: case ConstructorId_sort: case ConstructorId_push: case ConstructorId_pop: case ConstructorId_shift: case ConstructorId_unshift: case ConstructorId_splice: case ConstructorId_concat: case ConstructorId_slice: case ConstructorId_indexOf: case ConstructorId_lastIndexOf: case ConstructorId_every: case ConstructorId_filter: case ConstructorId_forEach: case ConstructorId_map: case ConstructorId_some: case ConstructorId_reduce: case ConstructorId_reduceRight: { if (args.length > 0) { thisObj = ScriptRuntime.toObject(scope, args[0]); Object[] newArgs = new Object[args.length-1]; for (int i=0; i < newArgs.length; i++) newArgs[i] = args[i+1]; args = newArgs; } id = -id; continue again; } case ConstructorId_isArray: return args.length > 0 && (args[0] instanceof NativeArray); case Id_constructor: { boolean inNewExpr = (thisObj == null); if (!inNewExpr) { // IdFunctionObject.construct will set up parent, proto return f.construct(cx, scope, args); } return jsConstructor(cx, scope, args); } case Id_toString: return toStringHelper(cx, scope, thisObj, cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE), false); case Id_toLocaleString: return toStringHelper(cx, scope, thisObj, false, true); case Id_toSource: return toStringHelper(cx, scope, thisObj, true, false); case Id_join: return js_join(cx, thisObj, args); case Id_reverse: return js_reverse(cx, thisObj, args); case Id_sort: return js_sort(cx, scope, thisObj, args); case Id_push: return js_push(cx, thisObj, args); case Id_pop: return js_pop(cx, thisObj, args); case Id_shift: return js_shift(cx, thisObj, args); case Id_unshift: return js_unshift(cx, thisObj, args); case Id_splice: return js_splice(cx, scope, thisObj, args); case Id_concat: return js_concat(cx, scope, thisObj, args); case Id_slice: return js_slice(cx, thisObj, args); case Id_indexOf: return indexOfHelper(cx, thisObj, args, false); case Id_lastIndexOf: return indexOfHelper(cx, thisObj, args, true); case Id_every: case Id_filter: case Id_forEach: case Id_map: case Id_some: return iterativeMethod(cx, id, scope, thisObj, args); case Id_reduce: case Id_reduceRight: return reduceMethod(cx, id, scope, thisObj, args); } throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
void setDenseOnly(boolean denseOnly) { if (denseOnly && !this.denseOnly) throw new IllegalArgumentException(); this.denseOnly = denseOnly; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CompilerEnvirons.java
public void setErrorReporter(ErrorReporter errorReporter) { if (errorReporter == null) throw new IllegalArgumentException(); this.errorReporter = errorReporter; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ERROR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ERROR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return make(cx, scope, f, args); case Id_toString: return js_toString(thisObj); case Id_toSource: return js_toSource(cx, scope, thisObj); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DToA.java
static String JS_dtobasestr(int base, double d) { if (!(2 <= base && base <= 36)) throw new IllegalArgumentException("Bad base: "+base); /* Check for Infinity and NaN */ if (Double.isNaN(d)) { return "NaN"; } else if (Double.isInfinite(d)) { return (d > 0.0) ? "Infinity" : "-Infinity"; } else if (d == 0) { // ALERT: should it distinguish -0.0 from +0.0 ? return "0"; } boolean negative; if (d >= 0.0) { negative = false; } else { negative = true; d = -d; } /* Get the integer part of d including '-' sign. */ String intDigits; double dfloor = Math.floor(d); long lfloor = (long)dfloor; if (lfloor == dfloor) { // int part fits long intDigits = Long.toString((negative) ? -lfloor : lfloor, base); } else { // BigInteger should be used long floorBits = Double.doubleToLongBits(dfloor); int exp = (int)(floorBits >> Exp_shiftL) & Exp_mask_shifted; long mantissa; if (exp == 0) { mantissa = (floorBits & Frac_maskL) << 1; } else { mantissa = (floorBits & Frac_maskL) | Exp_msk1L; } if (negative) { mantissa = -mantissa; } exp -= 1075; BigInteger x = BigInteger.valueOf(mantissa); if (exp > 0) { x = x.shiftLeft(exp); } else if (exp < 0) { x = x.shiftRight(-exp); } intDigits = x.toString(base); } if (d == dfloor) { // No fraction part return intDigits; } else { /* We have a fraction. */ StringBuilder buffer; /* The output string */ int digit; double df; /* The fractional part of d */ BigInteger b; buffer = new StringBuilder(); buffer.append(intDigits).append('.'); df = d - dfloor; long dBits = Double.doubleToLongBits(d); int word0 = (int)(dBits >> 32); int word1 = (int)(dBits); int[] e = new int[1]; int[] bbits = new int[1]; b = d2b(df, e, bbits); // JS_ASSERT(e < 0); /* At this point df = b * 2^e. e must be less than zero because 0 < df < 1. */ int s2 = -(word0 >>> Exp_shift1 & Exp_mask >> Exp_shift1); if (s2 == 0) s2 = -1; s2 += Bias + P; /* 1/2^s2 = (nextDouble(d) - d)/2 */ // JS_ASSERT(-s2 < e); BigInteger mlo = BigInteger.valueOf(1); BigInteger mhi = mlo; if ((word1 == 0) && ((word0 & Bndry_mask) == 0) && ((word0 & (Exp_mask & Exp_mask << 1)) != 0)) { /* The special case. Here we want to be within a quarter of the last input significant digit instead of one half of it when the output string's value is less than d. */ s2 += Log2P; mhi = BigInteger.valueOf(1<<Log2P); } b = b.shiftLeft(e[0] + s2); BigInteger s = BigInteger.valueOf(1); s = s.shiftLeft(s2); /* At this point we have the following: * s = 2^s2; * 1 > df = b/2^s2 > 0; * (d - prevDouble(d))/2 = mlo/2^s2; * (nextDouble(d) - d)/2 = mhi/2^s2. */ BigInteger bigBase = BigInteger.valueOf(base); boolean done = false; do { b = b.multiply(bigBase); BigInteger[] divResult = b.divideAndRemainder(s); b = divResult[1]; digit = (char)(divResult[0].intValue()); if (mlo == mhi) mlo = mhi = mlo.multiply(bigBase); else { mlo = mlo.multiply(bigBase); mhi = mhi.multiply(bigBase); } /* Do we yet have the shortest string that will round to d? */ int j = b.compareTo(mlo); /* j is b/2^s2 compared with mlo/2^s2. */ BigInteger delta = s.subtract(mhi); int j1 = (delta.signum() <= 0) ? 1 : b.compareTo(delta); /* j1 is b/2^s2 compared with 1 - mhi/2^s2. */ if (j1 == 0 && ((word1 & 1) == 0)) { if (j > 0) digit++; done = true; } else if (j < 0 || (j == 0 && ((word1 & 1) == 0))) { if (j1 > 0) { /* Either dig or dig+1 would work here as the least significant digit. Use whichever would produce an output value closer to d. */ b = b.shiftLeft(1); j1 = b.compareTo(s); if (j1 > 0) /* The even test (|| (j1 == 0 && (digit & 1))) is not here because it messes up odd base output * such as 3.5 in base 3. */ digit++; } done = true; } else if (j1 > 0) { digit++; done = true; } // JS_ASSERT(digit < (uint32)base); buffer.append(BASEDIGIT(digit)); } while (!done); return buffer.toString(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Icode.java
static String bytecodeName(int bytecode) { if (!validBytecode(bytecode)) { throw new IllegalArgumentException(String.valueOf(bytecode)); } if (!Token.printICode) { return String.valueOf(bytecode); } if (validTokenCode(bytecode)) { return Token.name(bytecode); } switch (bytecode) { case Icode_DUP: return "DUP"; case Icode_DUP2: return "DUP2"; case Icode_SWAP: return "SWAP"; case Icode_POP: return "POP"; case Icode_POP_RESULT: return "POP_RESULT"; case Icode_IFEQ_POP: return "IFEQ_POP"; case Icode_VAR_INC_DEC: return "VAR_INC_DEC"; case Icode_NAME_INC_DEC: return "NAME_INC_DEC"; case Icode_PROP_INC_DEC: return "PROP_INC_DEC"; case Icode_ELEM_INC_DEC: return "ELEM_INC_DEC"; case Icode_REF_INC_DEC: return "REF_INC_DEC"; case Icode_SCOPE_LOAD: return "SCOPE_LOAD"; case Icode_SCOPE_SAVE: return "SCOPE_SAVE"; case Icode_TYPEOFNAME: return "TYPEOFNAME"; case Icode_NAME_AND_THIS: return "NAME_AND_THIS"; case Icode_PROP_AND_THIS: return "PROP_AND_THIS"; case Icode_ELEM_AND_THIS: return "ELEM_AND_THIS"; case Icode_VALUE_AND_THIS: return "VALUE_AND_THIS"; case Icode_CLOSURE_EXPR: return "CLOSURE_EXPR"; case Icode_CLOSURE_STMT: return "CLOSURE_STMT"; case Icode_CALLSPECIAL: return "CALLSPECIAL"; case Icode_RETUNDEF: return "RETUNDEF"; case Icode_GOSUB: return "GOSUB"; case Icode_STARTSUB: return "STARTSUB"; case Icode_RETSUB: return "RETSUB"; case Icode_LINE: return "LINE"; case Icode_SHORTNUMBER: return "SHORTNUMBER"; case Icode_INTNUMBER: return "INTNUMBER"; case Icode_LITERAL_NEW: return "LITERAL_NEW"; case Icode_LITERAL_SET: return "LITERAL_SET"; case Icode_SPARE_ARRAYLIT: return "SPARE_ARRAYLIT"; case Icode_REG_IND_C0: return "REG_IND_C0"; case Icode_REG_IND_C1: return "REG_IND_C1"; case Icode_REG_IND_C2: return "REG_IND_C2"; case Icode_REG_IND_C3: return "REG_IND_C3"; case Icode_REG_IND_C4: return "REG_IND_C4"; case Icode_REG_IND_C5: return "REG_IND_C5"; case Icode_REG_IND1: return "LOAD_IND1"; case Icode_REG_IND2: return "LOAD_IND2"; case Icode_REG_IND4: return "LOAD_IND4"; case Icode_REG_STR_C0: return "REG_STR_C0"; case Icode_REG_STR_C1: return "REG_STR_C1"; case Icode_REG_STR_C2: return "REG_STR_C2"; case Icode_REG_STR_C3: return "REG_STR_C3"; case Icode_REG_STR1: return "LOAD_STR1"; case Icode_REG_STR2: return "LOAD_STR2"; case Icode_REG_STR4: return "LOAD_STR4"; case Icode_GETVAR1: return "GETVAR1"; case Icode_SETVAR1: return "SETVAR1"; case Icode_UNDEF: return "UNDEF"; case Icode_ZERO: return "ZERO"; case Icode_ONE: return "ONE"; case Icode_ENTERDQ: return "ENTERDQ"; case Icode_LEAVEDQ: return "LEAVEDQ"; case Icode_TAIL_CALL: return "TAIL_CALL"; case Icode_LOCAL_CLEAR: return "LOCAL_CLEAR"; case Icode_LITERAL_GETTER: return "LITERAL_GETTER"; case Icode_LITERAL_SETTER: return "LITERAL_SETTER"; case Icode_SETCONST: return "SETCONST"; case Icode_SETCONSTVAR: return "SETCONSTVAR"; case Icode_SETCONSTVAR1: return "SETCONSTVAR1"; case Icode_GENERATOR: return "GENERATOR"; case Icode_GENERATOR_END: return "GENERATOR_END"; case Icode_DEBUGGER: return "DEBUGGER"; } // icode without name throw new IllegalStateException(String.valueOf(bytecode)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
public Node transform(AstNode node) { switch (node.getType()) { case Token.ARRAYCOMP: return transformArrayComp((ArrayComprehension)node); case Token.ARRAYLIT: return transformArrayLiteral((ArrayLiteral)node); case Token.BLOCK: return transformBlock(node); case Token.BREAK: return transformBreak((BreakStatement)node); case Token.CALL: return transformFunctionCall((FunctionCall)node); case Token.CONTINUE: return transformContinue((ContinueStatement)node); case Token.DO: return transformDoLoop((DoLoop)node); case Token.EMPTY: return node; case Token.FOR: if (node instanceof ForInLoop) { return transformForInLoop((ForInLoop)node); } else { return transformForLoop((ForLoop)node); } case Token.FUNCTION: return transformFunction((FunctionNode)node); case Token.GENEXPR: return transformGenExpr((GeneratorExpression)node); case Token.GETELEM: return transformElementGet((ElementGet)node); case Token.GETPROP: return transformPropertyGet((PropertyGet)node); case Token.HOOK: return transformCondExpr((ConditionalExpression)node); case Token.IF: return transformIf((IfStatement)node); case Token.TRUE: case Token.FALSE: case Token.THIS: case Token.NULL: case Token.DEBUGGER: return transformLiteral(node); case Token.NAME: return transformName((Name)node); case Token.NUMBER: return transformNumber((NumberLiteral)node); case Token.NEW: return transformNewExpr((NewExpression)node); case Token.OBJECTLIT: return transformObjectLiteral((ObjectLiteral)node); case Token.REGEXP: return transformRegExp((RegExpLiteral)node); case Token.RETURN: return transformReturn((ReturnStatement)node); case Token.SCRIPT: return transformScript((ScriptNode)node); case Token.STRING: return transformString((StringLiteral)node); case Token.SWITCH: return transformSwitch((SwitchStatement)node); case Token.THROW: return transformThrow((ThrowStatement)node); case Token.TRY: return transformTry((TryStatement)node); case Token.WHILE: return transformWhileLoop((WhileLoop)node); case Token.WITH: return transformWith((WithStatement)node); case Token.YIELD: return transformYield((Yield)node); default: if (node instanceof ExpressionStatement) { return transformExprStmt((ExpressionStatement)node); } if (node instanceof Assignment) { return transformAssignment((Assignment)node); } if (node instanceof UnaryExpression) { return transformUnary((UnaryExpression)node); } if (node instanceof XmlMemberGet) { return transformXmlMemberGet((XmlMemberGet)node); } if (node instanceof InfixExpression) { return transformInfix((InfixExpression)node); } if (node instanceof VariableDeclaration) { return transformVariables((VariableDeclaration)node); } if (node instanceof ParenthesizedExpression) { return transformParenExpr((ParenthesizedExpression)node); } if (node instanceof LabeledStatement) { return transformLabeledStatement((LabeledStatement)node); } if (node instanceof LetNode) { return transformLetNode((LetNode)node); } if (node instanceof XmlRef) { return transformXmlRef((XmlRef)node); } if (node instanceof XmlLiteral) { return transformXmlLiteral((XmlLiteral)node); } throw new IllegalArgumentException("Can't transform: " + node); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Label.java
public void setName(String name) { name = name == null ? null : name.trim(); if (name == null || "".equals(name)) throw new IllegalArgumentException("invalid label name"); this.name = name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/KeywordLiteral.java
Override public KeywordLiteral setType(int nodeType) { if (!(nodeType == Token.THIS || nodeType == Token.NULL || nodeType == Token.TRUE || nodeType == Token.FALSE || nodeType == Token.DEBUGGER)) throw new IllegalArgumentException("Invalid node type: " + nodeType); type = nodeType; return this; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Symbol.java
public void setDeclType(int declType) { if (!(declType == Token.FUNCTION || declType == Token.LP || declType == Token.VAR || declType == Token.LET || declType == Token.CONST)) throw new IllegalArgumentException("Invalid declType: " + declType); this.declType = declType; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ObjectProperty.java
public void setNodeType(int nodeType) { if (nodeType != Token.COLON && nodeType != Token.GET && nodeType != Token.SET) throw new IllegalArgumentException("invalid node type: " + nodeType); setType(nodeType); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/InfixExpression.java
public void setOperator(int operator) { if (!Token.isValidToken(operator)) throw new IllegalArgumentException("Invalid token: " + operator); setType(operator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/UnaryExpression.java
public void setOperator(int operator) { if (!Token.isValidToken(operator)) throw new IllegalArgumentException("Invalid token: " + operator); setType(operator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Scope.java
public void putSymbol(Symbol symbol) { if (symbol.getName() == null) throw new IllegalArgumentException("null symbol name"); ensureSymbolTable(); symbolTable.put(symbol.getName(), symbol); symbol.setContainingTable(this); top.addSymbol(symbol); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableDeclaration.java
Override public org.mozilla.javascript.Node setType(int type) { if (type != Token.VAR && type != Token.CONST && type != Token.LET) throw new IllegalArgumentException("invalid decl type: " + type); return super.setType(type); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableInitializer.java
public void setNodeType(int nodeType) { if (nodeType != Token.VAR && nodeType != Token.CONST && nodeType != Token.LET) throw new IllegalArgumentException("invalid node type"); setType(nodeType); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableInitializer.java
public void setTarget(AstNode target) { // Don't throw exception if target is an "invalid" node type. // See mozilla/js/tests/js1_7/block/regress-350279.js if (target == null) throw new IllegalArgumentException("invalid target arg"); this.target = target; target.setParent(this); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
public static String operatorToString(int op) { String result = operatorNames.get(op); if (result == null) throw new IllegalArgumentException("Invalid operator: " + op); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
protected void assertNotNull(Object arg) { if (arg == null) throw new IllegalArgumentException("arg cannot be null"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
public static Object convertArg(Context cx, Scriptable scope, Object arg, int typeTag) { switch (typeTag) { case JAVA_STRING_TYPE: if (arg instanceof String) return arg; return ScriptRuntime.toString(arg); case JAVA_INT_TYPE: if (arg instanceof Integer) return arg; return Integer.valueOf(ScriptRuntime.toInt32(arg)); case JAVA_BOOLEAN_TYPE: if (arg instanceof Boolean) return arg; return ScriptRuntime.toBoolean(arg) ? Boolean.TRUE : Boolean.FALSE; case JAVA_DOUBLE_TYPE: if (arg instanceof Double) return arg; return new Double(ScriptRuntime.toNumber(arg)); case JAVA_SCRIPTABLE_TYPE: return ScriptRuntime.toObjectOrNull(cx, arg, scope); case JAVA_OBJECT_TYPE: return arg; default: throw new IllegalArgumentException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initSourceName(String sourceName) { if (sourceName == null) throw new IllegalArgumentException(); if (this.sourceName != null) throw new IllegalStateException(); this.sourceName = sourceName; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineNumber(int lineNumber) { if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber)); if (this.lineNumber > 0) throw new IllegalStateException(); this.lineNumber = lineNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initColumnNumber(int columnNumber) { if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber)); if (this.columnNumber > 0) throw new IllegalStateException(); this.columnNumber = columnNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineSource(String lineSource) { if (lineSource == null) throw new IllegalArgumentException(); if (this.lineSource != null) throw new IllegalStateException(); this.lineSource = lineSource; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public static void initGlobal(SecurityController controller) { if (controller == null) throw new IllegalArgumentException(); if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=0; s="constructor"; break; case Id_importClass: arity=1; s="importClass"; break; case Id_importPackage: arity=1; s="importPackage"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(IMPORTER_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(IMPORTER_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return js_construct(scope, args); case Id_importClass: return realThis(thisObj, f).js_importClass(args); case Id_importPackage: return realThis(thisObj, f).js_importPackage(args); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toTimeString: arity=0; s="toTimeString"; break; case Id_toDateString: arity=0; s="toDateString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_toLocaleTimeString: arity=0; s="toLocaleTimeString"; break; case Id_toLocaleDateString: arity=0; s="toLocaleDateString"; break; case Id_toUTCString: arity=0; s="toUTCString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_getTime: arity=0; s="getTime"; break; case Id_getYear: arity=0; s="getYear"; break; case Id_getFullYear: arity=0; s="getFullYear"; break; case Id_getUTCFullYear: arity=0; s="getUTCFullYear"; break; case Id_getMonth: arity=0; s="getMonth"; break; case Id_getUTCMonth: arity=0; s="getUTCMonth"; break; case Id_getDate: arity=0; s="getDate"; break; case Id_getUTCDate: arity=0; s="getUTCDate"; break; case Id_getDay: arity=0; s="getDay"; break; case Id_getUTCDay: arity=0; s="getUTCDay"; break; case Id_getHours: arity=0; s="getHours"; break; case Id_getUTCHours: arity=0; s="getUTCHours"; break; case Id_getMinutes: arity=0; s="getMinutes"; break; case Id_getUTCMinutes: arity=0; s="getUTCMinutes"; break; case Id_getSeconds: arity=0; s="getSeconds"; break; case Id_getUTCSeconds: arity=0; s="getUTCSeconds"; break; case Id_getMilliseconds: arity=0; s="getMilliseconds"; break; case Id_getUTCMilliseconds: arity=0; s="getUTCMilliseconds"; break; case Id_getTimezoneOffset: arity=0; s="getTimezoneOffset"; break; case Id_setTime: arity=1; s="setTime"; break; case Id_setMilliseconds: arity=1; s="setMilliseconds"; break; case Id_setUTCMilliseconds: arity=1; s="setUTCMilliseconds"; break; case Id_setSeconds: arity=2; s="setSeconds"; break; case Id_setUTCSeconds: arity=2; s="setUTCSeconds"; break; case Id_setMinutes: arity=3; s="setMinutes"; break; case Id_setUTCMinutes: arity=3; s="setUTCMinutes"; break; case Id_setHours: arity=4; s="setHours"; break; case Id_setUTCHours: arity=4; s="setUTCHours"; break; case Id_setDate: arity=1; s="setDate"; break; case Id_setUTCDate: arity=1; s="setUTCDate"; break; case Id_setMonth: arity=2; s="setMonth"; break; case Id_setUTCMonth: arity=2; s="setUTCMonth"; break; case Id_setFullYear: arity=3; s="setFullYear"; break; case Id_setUTCFullYear: arity=3; s="setUTCFullYear"; break; case Id_setYear: arity=1; s="setYear"; break; case Id_toISOString: arity=0; s="toISOString"; break; case Id_toJSON: arity=1; s="toJSON"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(DATE_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(DATE_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case ConstructorId_now: return ScriptRuntime.wrapNumber(now()); case ConstructorId_parse: { String dataStr = ScriptRuntime.toString(args, 0); return ScriptRuntime.wrapNumber(date_parseString(dataStr)); } case ConstructorId_UTC: return ScriptRuntime.wrapNumber(jsStaticFunction_UTC(args)); case Id_constructor: { // if called as a function, just return a string // representing the current time. if (thisObj != null) return date_format(now(), Id_toString); return jsConstructor(args); } case Id_toJSON: { if (thisObj instanceof NativeDate) { return ((NativeDate) thisObj).toISOString(); } final String toISOString = "toISOString"; Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj); Object tv = ScriptRuntime.toPrimitive(o, ScriptRuntime.NumberClass); if (tv instanceof Number) { double d = ((Number) tv).doubleValue(); if (d != d || Double.isInfinite(d)) { return null; } } Object toISO = o.get(toISOString, o); if (toISO == NOT_FOUND) { throw ScriptRuntime.typeError2("msg.function.not.found.in", toISOString, ScriptRuntime.toString(o)); } if ( !(toISO instanceof Callable) ) { throw ScriptRuntime.typeError3("msg.isnt.function.in", toISOString, ScriptRuntime.toString(o), ScriptRuntime.toString(toISO)); } Object result = ((Callable) toISO).call(cx, scope, o, ScriptRuntime.emptyArgs); if ( !ScriptRuntime.isPrimitive(result) ) { throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive", ScriptRuntime.toString(result)); } return result; } } // The rest of Date.prototype methods require thisObj to be Date if (!(thisObj instanceof NativeDate)) throw incompatibleCallError(f); NativeDate realThis = (NativeDate)thisObj; double t = realThis.date; switch (id) { case Id_toString: case Id_toTimeString: case Id_toDateString: if (t == t) { return date_format(t, id); } return js_NaN_date_str; case Id_toLocaleString: case Id_toLocaleTimeString: case Id_toLocaleDateString: if (t == t) { return toLocale_helper(t, id); } return js_NaN_date_str; case Id_toUTCString: if (t == t) { return js_toUTCString(t); } return js_NaN_date_str; case Id_toSource: return "(new Date("+ScriptRuntime.toString(t)+"))"; case Id_valueOf: case Id_getTime: return ScriptRuntime.wrapNumber(t); case Id_getYear: case Id_getFullYear: case Id_getUTCFullYear: if (t == t) { if (id != Id_getUTCFullYear) t = LocalTime(t); t = YearFromTime(t); if (id == Id_getYear) { if (cx.hasFeature(Context.FEATURE_NON_ECMA_GET_YEAR)) { if (1900 <= t && t < 2000) { t -= 1900; } } else { t -= 1900; } } } return ScriptRuntime.wrapNumber(t); case Id_getMonth: case Id_getUTCMonth: if (t == t) { if (id == Id_getMonth) t = LocalTime(t); t = MonthFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getDate: case Id_getUTCDate: if (t == t) { if (id == Id_getDate) t = LocalTime(t); t = DateFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getDay: case Id_getUTCDay: if (t == t) { if (id == Id_getDay) t = LocalTime(t); t = WeekDay(t); } return ScriptRuntime.wrapNumber(t); case Id_getHours: case Id_getUTCHours: if (t == t) { if (id == Id_getHours) t = LocalTime(t); t = HourFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getMinutes: case Id_getUTCMinutes: if (t == t) { if (id == Id_getMinutes) t = LocalTime(t); t = MinFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getSeconds: case Id_getUTCSeconds: if (t == t) { if (id == Id_getSeconds) t = LocalTime(t); t = SecFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getMilliseconds: case Id_getUTCMilliseconds: if (t == t) { if (id == Id_getMilliseconds) t = LocalTime(t); t = msFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getTimezoneOffset: if (t == t) { t = (t - LocalTime(t)) / msPerMinute; } return ScriptRuntime.wrapNumber(t); case Id_setTime: t = TimeClip(ScriptRuntime.toNumber(args, 0)); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setMilliseconds: case Id_setUTCMilliseconds: case Id_setSeconds: case Id_setUTCSeconds: case Id_setMinutes: case Id_setUTCMinutes: case Id_setHours: case Id_setUTCHours: t = makeTime(t, args, id); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setDate: case Id_setUTCDate: case Id_setMonth: case Id_setUTCMonth: case Id_setFullYear: case Id_setUTCFullYear: t = makeDate(t, args, id); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setYear: { double year = ScriptRuntime.toNumber(args, 0); if (year != year || Double.isInfinite(year)) { t = ScriptRuntime.NaN; } else { if (t != t) { t = 0; } else { t = LocalTime(t); } if (year >= 0 && year <= 99) year += 1900; double day = MakeDay(year, MonthFromTime(t), DateFromTime(t)); t = MakeDate(day, TimeWithinDay(t)); t = internalUTC(t); t = TimeClip(t); } } realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_toISOString: return realThis.toISOString(); default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_close: arity=1; s="close"; break; case Id_next: arity=1; s="next"; break; case Id_send: arity=0; s="send"; break; case Id_throw: arity=0; s="throw"; break; case Id___iterator__: arity=1; s="__iterator__"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(GENERATOR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(GENERATOR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (!(thisObj instanceof NativeGenerator)) throw incompatibleCallError(f); NativeGenerator generator = (NativeGenerator) thisObj; switch (id) { case Id_close: // need to run any pending finally clauses return generator.resume(cx, scope, GENERATOR_CLOSE, new GeneratorClosedException()); case Id_next: // arguments to next() are ignored generator.firstTime = false; return generator.resume(cx, scope, GENERATOR_SEND, Undefined.instance); case Id_send: { Object arg = args.length > 0 ? args[0] : Undefined.instance; if (generator.firstTime && !arg.equals(Undefined.instance)) { throw ScriptRuntime.typeError0("msg.send.newborn"); } return generator.resume(cx, scope, GENERATOR_SEND, arg); } case Id_throw: return generator.resume(cx, scope, GENERATOR_THROW, args.length > 0 ? args[0] : Undefined.instance); case Id___iterator__: return thisObj; default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
public final void setSize(int newSize) { if (newSize < 0) throw new IllegalArgumentException(); if (sealed) throw onSeledMutation(); int N = size; if (newSize < N) { for (int i = newSize; i != N; ++i) { setImpl(i, null); } } else if (newSize > N) { if (newSize > FIELDS_STORE_SIZE) { ensureCapacity(newSize); } } size = newSize; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void ensureCapacity(int minimalCapacity) { int required = minimalCapacity - FIELDS_STORE_SIZE; if (required <= 0) throw new IllegalArgumentException(); if (data == null) { int alloc = FIELDS_STORE_SIZE * 2; if (alloc < required) { alloc = required; } data = new Object[alloc]; } else { int alloc = data.length; if (alloc < required) { if (alloc <= FIELDS_STORE_SIZE) { alloc = FIELDS_STORE_SIZE * 2; } else { alloc *= 2; } if (alloc < required) { alloc = required; } Object[] tmp = new Object[alloc]; if (size > FIELDS_STORE_SIZE) { System.arraycopy(data, 0, tmp, 0, size - FIELDS_STORE_SIZE); } data = tmp; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final void initValue(int id, String name, Object value, int attributes) { if (!(1 <= id && id <= maxId)) throw new IllegalArgumentException(); if (name == null) throw new IllegalArgumentException(); if (value == NOT_FOUND) throw new IllegalArgumentException(); ScriptableObject.checkValidAttributes(attributes); if (obj.findPrototypeId(name) != id) throw new IllegalArgumentException(name); if (id == constructorId) { if (!(value instanceof IdFunctionObject)) { throw new IllegalArgumentException("consructor should be initialized with IdFunctionObject"); } constructor = (IdFunctionObject)value; constructorAttrs = (short)attributes; return; } initSlot(id, name, value, attributes); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final void set(int id, Scriptable start, Object value) { if (value == NOT_FOUND) throw new IllegalArgumentException(); ensureId(id); int attr = attributeArray[id - 1]; if ((attr & READONLY) == 0) { if (start == obj) { if (value == null) { value = UniqueTag.NULL_VALUE; } int valueSlot = (id - 1) * SLOT_SPAN; synchronized (this) { valueArray[valueSlot] = value; } } else { int nameSlot = (id - 1) * SLOT_SPAN + NAME_SLOT; String name = (String)valueArray[nameSlot]; start.put(name, start, value); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected String getInstanceIdName(int id) { throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void initPrototypeConstructor(IdFunctionObject f) { int id = prototypeValues.constructorId; if (id == 0) throw new IllegalStateException(); if (f.methodId() != id) throw new IllegalArgumentException(); if (isSealed()) { f.sealObject(); } prototypeValues.initValue(id, "constructor", f, DONTENUM); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ClassCache.java
public boolean associate(ScriptableObject topScope) { if (topScope.getParentScope() != null) { // Can only associate cache with top level scope throw new IllegalArgumentException(); } if (this == topScope.associateValue(AKEY, this)) { associatedScope = topScope; return true; } return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
public void addOptionalExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if(obj != null && obj != UniqueTag.NOT_FOUND) { if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException( "Object for excluded name " + name + " is not a Scriptable, it is " + obj.getClass().getName()); } table.put(obj, name); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
void addToken(int token) { if (!(0 <= token && token <= Token.LAST_TOKEN)) throw new IllegalArgumentException(); append((char)token); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
void addEOL(int token) { if (!(0 <= token && token <= Token.LAST_TOKEN)) throw new IllegalArgumentException(); append((char)token); append((char)Token.EOL); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
public static String decompile(String source, int flags, UintMap properties) { int length = source.length(); if (length == 0) { return ""; } int indent = properties.getInt(INITIAL_INDENT_PROP, 0); if (indent < 0) throw new IllegalArgumentException(); int indentGap = properties.getInt(INDENT_GAP_PROP, 4); if (indentGap < 0) throw new IllegalArgumentException(); int caseGap = properties.getInt(CASE_GAP_PROP, 2); if (caseGap < 0) throw new IllegalArgumentException(); StringBuffer result = new StringBuffer(); boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG)); boolean toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG)); // Spew tokens in source, for debugging. // as TYPE number char if (printSource) { System.err.println("length:" + length); for (int i = 0; i < length; ++i) { // Note that tokenToName will fail unless Context.printTrees // is true. String tokenname = null; if (Token.printNames) { tokenname = Token.name(source.charAt(i)); } if (tokenname == null) { tokenname = "---"; } String pad = tokenname.length() > 7 ? "\t" : "\t\t"; System.err.println (tokenname + pad + (int)source.charAt(i) + "\t'" + ScriptRuntime.escapeString (source.substring(i, i+1)) + "'"); } System.err.println(); } int braceNesting = 0; boolean afterFirstEOL = false; int i = 0; int topFunctionType; if (source.charAt(i) == Token.SCRIPT) { ++i; topFunctionType = -1; } else { topFunctionType = source.charAt(i + 1); } if (!toSource) { // add an initial newline to exactly match js. result.append('\n'); for (int j = 0; j < indent; j++) result.append(' '); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append('('); } } while (i < length) { switch(source.charAt(i)) { case Token.GET: case Token.SET: result.append(source.charAt(i) == Token.GET ? "get " : "set "); ++i; i = printSourceString(source, i + 1, false, result); // Now increment one more to get past the FUNCTION token ++i; break; case Token.NAME: case Token.REGEXP: // re-wrapped in '/'s in parser... i = printSourceString(source, i + 1, false, result); continue; case Token.STRING: i = printSourceString(source, i + 1, true, result); continue; case Token.NUMBER: i = printSourceNumber(source, i + 1, result); continue; case Token.TRUE: result.append("true"); break; case Token.FALSE: result.append("false"); break; case Token.NULL: result.append("null"); break; case Token.THIS: result.append("this"); break; case Token.FUNCTION: ++i; // skip function type result.append("function "); break; case FUNCTION_END: // Do nothing break; case Token.COMMA: result.append(", "); break; case Token.LC: ++braceNesting; if (Token.EOL == getNext(source, length, i)) indent += indentGap; result.append('{'); break; case Token.RC: { --braceNesting; /* don't print the closing RC if it closes the * toplevel function and we're called from * decompileFunctionBody. */ if (justFunctionBody && braceNesting == 0) break; result.append('}'); switch (getNext(source, length, i)) { case Token.EOL: case FUNCTION_END: indent -= indentGap; break; case Token.WHILE: case Token.ELSE: indent -= indentGap; result.append(' '); break; } break; } case Token.LP: result.append('('); break; case Token.RP: result.append(')'); if (Token.LC == getNext(source, length, i)) result.append(' '); break; case Token.LB: result.append('['); break; case Token.RB: result.append(']'); break; case Token.EOL: { if (toSource) break; boolean newLine = true; if (!afterFirstEOL) { afterFirstEOL = true; if (justFunctionBody) { /* throw away just added 'function name(...) {' * and restore the original indent */ result.setLength(0); indent -= indentGap; newLine = false; } } if (newLine) { result.append('\n'); } /* add indent if any tokens remain, * less setback if next token is * a label, case or default. */ if (i + 1 < length) { int less = 0; int nextToken = source.charAt(i + 1); if (nextToken == Token.CASE || nextToken == Token.DEFAULT) { less = indentGap - caseGap; } else if (nextToken == Token.RC) { less = indentGap; } /* elaborate check against label... skip past a * following inlined NAME and look for a COLON. */ else if (nextToken == Token.NAME) { int afterName = getSourceStringEnd(source, i + 2); if (source.charAt(afterName) == Token.COLON) less = indentGap; } for (; less < indent; less++) result.append(' '); } break; } case Token.DOT: result.append('.'); break; case Token.NEW: result.append("new "); break; case Token.DELPROP: result.append("delete "); break; case Token.IF: result.append("if "); break; case Token.ELSE: result.append("else "); break; case Token.FOR: result.append("for "); break; case Token.IN: result.append(" in "); break; case Token.WITH: result.append("with "); break; case Token.WHILE: result.append("while "); break; case Token.DO: result.append("do "); break; case Token.TRY: result.append("try "); break; case Token.CATCH: result.append("catch "); break; case Token.FINALLY: result.append("finally "); break; case Token.THROW: result.append("throw "); break; case Token.SWITCH: result.append("switch "); break; case Token.BREAK: result.append("break"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CONTINUE: result.append("continue"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CASE: result.append("case "); break; case Token.DEFAULT: result.append("default"); break; case Token.RETURN: result.append("return"); if (Token.SEMI != getNext(source, length, i)) result.append(' '); break; case Token.VAR: result.append("var "); break; case Token.LET: result.append("let "); break; case Token.SEMI: result.append(';'); if (Token.EOL != getNext(source, length, i)) { // separators in FOR result.append(' '); } break; case Token.ASSIGN: result.append(" = "); break; case Token.ASSIGN_ADD: result.append(" += "); break; case Token.ASSIGN_SUB: result.append(" -= "); break; case Token.ASSIGN_MUL: result.append(" *= "); break; case Token.ASSIGN_DIV: result.append(" /= "); break; case Token.ASSIGN_MOD: result.append(" %= "); break; case Token.ASSIGN_BITOR: result.append(" |= "); break; case Token.ASSIGN_BITXOR: result.append(" ^= "); break; case Token.ASSIGN_BITAND: result.append(" &= "); break; case Token.ASSIGN_LSH: result.append(" <<= "); break; case Token.ASSIGN_RSH: result.append(" >>= "); break; case Token.ASSIGN_URSH: result.append(" >>>= "); break; case Token.HOOK: result.append(" ? "); break; case Token.OBJECTLIT: // pun OBJECTLIT to mean colon in objlit property // initialization. // This needs to be distinct from COLON in the general case // to distinguish from the colon in a ternary... which needs // different spacing. result.append(':'); break; case Token.COLON: if (Token.EOL == getNext(source, length, i)) // it's the end of a label result.append(':'); else // it's the middle part of a ternary result.append(" : "); break; case Token.OR: result.append(" || "); break; case Token.AND: result.append(" && "); break; case Token.BITOR: result.append(" | "); break; case Token.BITXOR: result.append(" ^ "); break; case Token.BITAND: result.append(" & "); break; case Token.SHEQ: result.append(" === "); break; case Token.SHNE: result.append(" !== "); break; case Token.EQ: result.append(" == "); break; case Token.NE: result.append(" != "); break; case Token.LE: result.append(" <= "); break; case Token.LT: result.append(" < "); break; case Token.GE: result.append(" >= "); break; case Token.GT: result.append(" > "); break; case Token.INSTANCEOF: result.append(" instanceof "); break; case Token.LSH: result.append(" << "); break; case Token.RSH: result.append(" >> "); break; case Token.URSH: result.append(" >>> "); break; case Token.TYPEOF: result.append("typeof "); break; case Token.VOID: result.append("void "); break; case Token.CONST: result.append("const "); break; case Token.YIELD: result.append("yield "); break; case Token.NOT: result.append('!'); break; case Token.BITNOT: result.append('~'); break; case Token.POS: result.append('+'); break; case Token.NEG: result.append('-'); break; case Token.INC: result.append("++"); break; case Token.DEC: result.append("--"); break; case Token.ADD: result.append(" + "); break; case Token.SUB: result.append(" - "); break; case Token.MUL: result.append(" * "); break; case Token.DIV: result.append(" / "); break; case Token.MOD: result.append(" % "); break; case Token.COLONCOLON: result.append("::"); break; case Token.DOTDOT: result.append(".."); break; case Token.DOTQUERY: result.append(".("); break; case Token.XMLATTR: result.append('@'); break; case Token.DEBUGGER: result.append("debugger;\n"); break; default: // If we don't know how to decompile it, raise an exception. throw new RuntimeException("Token: " + Token.name(source.charAt(i))); } ++i; } if (!toSource) { // add that trailing newline if it's an outermost function. if (!justFunctionBody) result.append('\n'); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append(')'); } } return result.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (scope == null) throw new IllegalArgumentException(); if (cx.topCallScope != null) throw new IllegalStateException(); Object result; cx.topCallScope = ScriptableObject.getTopLevelScope(scope); cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE); ContextFactory f = cx.getFactory(); try { result = f.doTopCall(callable, cx, scope, thisObj, args); } finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object[] getArrayElements(Scriptable object) { Context cx = Context.getContext(); long longLen = NativeArray.getLengthProperty(cx, object); if (longLen > Integer.MAX_VALUE) { // arrays beyond MAX_INT is not in Java in any case throw new IllegalArgumentException(); } int len = (int) longLen; if (len == 0) { return ScriptRuntime.emptyArgs; } else { Object[] result = new Object[len]; for (int i=0; i < len; i++) { Object elem = ScriptableObject.getProperty(object, i); result[i] = (elem == Scriptable.NOT_FOUND) ? Undefined.instance : elem; } return result; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void setRegExpProxy(Context cx, RegExpProxy proxy) { if (proxy == null) throw new IllegalArgumentException(); cx.regExpProxy = proxy; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void storeUint32Result(Context cx, long value) { if ((value >>> 32) != 0) throw new IllegalArgumentException(); cx.scratchUint32 = value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void unseal(Object sealKey) { if (sealKey == null) throw new IllegalArgumentException(); if (this.sealKey != sealKey) throw new IllegalArgumentException(); if (!sealed) throw new IllegalStateException(); sealed = false; this.sealKey = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void checkLanguageVersion(int version) { if (isValidLanguageVersion(version)) { return; } throw new IllegalArgumentException("Bad language version: "+version); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object executeScriptWithContinuations(Script script, Scriptable scope) throws ContinuationPending { if (!(script instanceof InterpretedFunction) || !((InterpretedFunction)script).isScript()) { // Can only be applied to scripts throw new IllegalArgumentException("Script argument was not" + " a script or was not created by interpreted mode "); } return callFunctionWithContinuations((InterpretedFunction) script, scope, ScriptRuntime.emptyArgs); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object callFunctionWithContinuations(Callable function, Scriptable scope, Object[] args) throws ContinuationPending { if (!(function instanceof InterpretedFunction)) { // Can only be applied to scripts throw new IllegalArgumentException("Function argument was not" + " created by interpreted mode "); } if (ScriptRuntime.hasTopCall(this)) { throw new IllegalStateException("Cannot have any pending top " + "calls when executing a script with continuations"); } // Annotate so we can check later to ensure no java code in // intervening frames isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Scriptable newArray(Scriptable scope, Object[] elements) { if (elements.getClass().getComponentType() != ScriptRuntime.ObjectClass) throw new IllegalArgumentException(); NativeArray result = new NativeArray(elements); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Array); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void checkOptimizationLevel(int optimizationLevel) { if (isValidOptimizationLevel(optimizationLevel)) { return; } throw new IllegalArgumentException( "Optimization level outside [-1..9]: "+optimizationLevel); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setMaximumInterpreterStackDepth(int max) { if(sealed) onSealedMutation(); if(optimizationLevel != -1) { throw new IllegalStateException("Cannot set maximumInterpreterStackDepth when optimizationLevel != -1"); } if(max < 1) { throw new IllegalArgumentException("Cannot set maximumInterpreterStackDepth to less than 1"); } maximumInterpreterStackDepth = max; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setSecurityController(SecurityController controller) { if (sealed) onSealedMutation(); if (controller == null) throw new IllegalArgumentException(); if (securityController != null) { throw new SecurityException("Can not overwrite existing SecurityController object"); } if (SecurityController.hasGlobal()) { throw new SecurityException("Can not overwrite existing global SecurityController object"); } securityController = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public synchronized final void setClassShutter(ClassShutter shutter) { if (sealed) onSealedMutation(); if (shutter == null) throw new IllegalArgumentException(); if (hasClassShutter) { throw new SecurityException("Cannot overwrite existing " + "ClassShutter object"); } classShutter = shutter; hasClassShutter = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setWrapFactory(WrapFactory wrapFactory) { if (sealed) onSealedMutation(); if (wrapFactory == null) throw new IllegalArgumentException(); this.wrapFactory = wrapFactory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setInstructionObserverThreshold(int threshold) { if (sealed) onSealedMutation(); if (threshold < 0) throw new IllegalArgumentException(); instructionThreshold = threshold; setGenerateObserverCount(threshold > 0); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setApplicationClassLoader(ClassLoader loader) { if (sealed) onSealedMutation(); if (loader == null) { // restore default behaviour applicationClassLoader = null; return; } if (!Kit.testIfCanLoadRhinoClasses(loader)) { throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); } applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdFunctionObject.java
public void initFunction(String name, Scriptable scope) { if (name == null) throw new IllegalArgumentException(); if (scope == null) throw new IllegalArgumentException(); this.functionName = name; setParentScope(scope); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode) { if (opcodeCount(theOpCode) != 0) throw new IllegalArgumentException("Unexpected operands"); int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (DEBUGCODE) System.out.println("Add " + bytecodeStr(theOpCode)); addToCodeBuffer(theOpCode); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } if (theOpCode == ByteCode.ATHROW) { addSuperBlockStart(itsCodeBufferTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.GOTO : // This is necessary because dead code is seemingly being // generated and Sun's verifier is expecting type state to be // placed even at dead blocks of code. addSuperBlockStart(itsCodeBufferTop + 3); // fallthru... case ByteCode.IFEQ : case ByteCode.IFNE : case ByteCode.IFLT : case ByteCode.IFGE : case ByteCode.IFGT : case ByteCode.IFLE : case ByteCode.IF_ICMPEQ : case ByteCode.IF_ICMPNE : case ByteCode.IF_ICMPLT : case ByteCode.IF_ICMPGE : case ByteCode.IF_ICMPGT : case ByteCode.IF_ICMPLE : case ByteCode.IF_ACMPEQ : case ByteCode.IF_ACMPNE : case ByteCode.JSR : case ByteCode.IFNULL : case ByteCode.IFNONNULL : { if ((theOperand & 0x80000000) != 0x80000000) { if ((theOperand < 0) || (theOperand > 65535)) throw new IllegalArgumentException( "Bad label for branch"); } int branchPC = itsCodeBufferTop; addToCodeBuffer(theOpCode); if ((theOperand & 0x80000000) != 0x80000000) { // hard displacement addToCodeInt16(theOperand); int target = theOperand + branchPC; addSuperBlockStart(target); itsJumpFroms.put(target, branchPC); } else { // a label int targetPC = getLabelPC(theOperand); if (DEBUGLABELS) { int theLabel = theOperand & 0x7FFFFFFF; System.out.println("Fixing branch to " + theLabel + " at " + targetPC + " from " + branchPC); } if (targetPC != -1) { int offset = targetPC - branchPC; addToCodeInt16(offset); addSuperBlockStart(targetPC); itsJumpFroms.put(targetPC, branchPC); } else { addLabelFixup(theOperand, branchPC + 1); addToCodeInt16(0); } } } break; case ByteCode.BIPUSH : if ((byte)theOperand != theOperand) throw new IllegalArgumentException("out of range byte"); addToCodeBuffer(theOpCode); addToCodeBuffer((byte)theOperand); break; case ByteCode.SIPUSH : if ((short)theOperand != theOperand) throw new IllegalArgumentException("out of range short"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.NEWARRAY : if (!(0 <= theOperand && theOperand < 256)) throw new IllegalArgumentException("out of range index"); addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); break; case ByteCode.GETFIELD : case ByteCode.PUTFIELD : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range field"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.LDC : case ByteCode.LDC_W : case ByteCode.LDC2_W : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range index"); if (theOperand >= 256 || theOpCode == ByteCode.LDC_W || theOpCode == ByteCode.LDC2_W) { if (theOpCode == ByteCode.LDC) { addToCodeBuffer(ByteCode.LDC_W); } else { addToCodeBuffer(theOpCode); } addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; case ByteCode.RET : case ByteCode.ILOAD : case ByteCode.LLOAD : case ByteCode.FLOAD : case ByteCode.DLOAD : case ByteCode.ALOAD : case ByteCode.ISTORE : case ByteCode.LSTORE : case ByteCode.FSTORE : case ByteCode.DSTORE : case ByteCode.ASTORE : if (!(0 <= theOperand && theOperand < 65536)) throw new ClassFileFormatException("out of range variable"); if (theOperand >= 256) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; default : throw new IllegalArgumentException( "Unexpected opcode for 1 operand"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand1, int theOperand2) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand1) +", "+Integer.toHexString(theOperand2)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (theOpCode == ByteCode.IINC) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new ClassFileFormatException("out of range variable"); if (!(0 <= theOperand2 && theOperand2 < 65536)) throw new ClassFileFormatException("out of range increment"); if (theOperand1 > 255 || theOperand2 < -128 || theOperand2 > 127) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(ByteCode.IINC); addToCodeInt16(theOperand1); addToCodeInt16(theOperand2); } else { addToCodeBuffer(ByteCode.IINC); addToCodeBuffer(theOperand1); addToCodeBuffer(theOperand2); } } else if (theOpCode == ByteCode.MULTIANEWARRAY) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new IllegalArgumentException("out of range index"); if (!(0 <= theOperand2 && theOperand2 < 256)) throw new IllegalArgumentException("out of range dimensions"); addToCodeBuffer(ByteCode.MULTIANEWARRAY); addToCodeInt16(theOperand1); addToCodeBuffer(theOperand2); } else { throw new IllegalArgumentException( "Unexpected opcode for 2 operands"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, String className) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.NEW : case ByteCode.ANEWARRAY : case ByteCode.CHECKCAST : case ByteCode.INSTANCEOF : { short classIndex = itsConstantPool.addClass(className); addToCodeBuffer(theOpCode); addToCodeInt16(classIndex); } break; default : throw new IllegalArgumentException( "bad opcode for class reference"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, String className, String fieldName, String fieldType) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className+", "+fieldName+", "+fieldType); } int newStack = itsStackTop + stackChange(theOpCode); char fieldTypeChar = fieldType.charAt(0); int fieldSize = (fieldTypeChar == 'J' || fieldTypeChar == 'D') ? 2 : 1; switch (theOpCode) { case ByteCode.GETFIELD : case ByteCode.GETSTATIC : newStack += fieldSize; break; case ByteCode.PUTSTATIC : case ByteCode.PUTFIELD : newStack -= fieldSize; break; default : throw new IllegalArgumentException( "bad opcode for field reference"); } if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); short fieldRefIndex = itsConstantPool.addFieldRef(className, fieldName, fieldType); addToCodeBuffer(theOpCode); addToCodeInt16(fieldRefIndex); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addInvoke(int theOpCode, String className, String methodName, String methodType) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className+", "+methodName+", " +methodType); } int parameterInfo = sizeOfParameters(methodType); int parameterCount = parameterInfo >>> 16; int stackDiff = (short)parameterInfo; int newStack = itsStackTop + stackDiff; newStack += stackChange(theOpCode); // adjusts for 'this' if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.INVOKEVIRTUAL : case ByteCode.INVOKESPECIAL : case ByteCode.INVOKESTATIC : case ByteCode.INVOKEINTERFACE : { addToCodeBuffer(theOpCode); if (theOpCode == ByteCode.INVOKEINTERFACE) { short ifMethodRefIndex = itsConstantPool.addInterfaceMethodRef( className, methodName, methodType); addToCodeInt16(ifMethodRefIndex); addToCodeBuffer(parameterCount + 1); addToCodeBuffer(0); } else { short methodRefIndex = itsConstantPool.addMethodRef( className, methodName, methodType); addToCodeInt16(methodRefIndex); } } break; default : throw new IllegalArgumentException( "bad opcode for method reference"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public final void markTableSwitchCase(int switchStart, int caseIndex, int stackTop) { if (!(0 <= stackTop && stackTop <= itsMaxStack)) throw new IllegalArgumentException("Bad stack index: "+stackTop); itsStackTop = (short)stackTop; addSuperBlockStart(itsCodeBufferTop); itsJumpFroms.put(itsCodeBufferTop, switchStart); setTableSwitchJump(switchStart, caseIndex, itsCodeBufferTop); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget) { if (!(0 <= jumpTarget && jumpTarget <= itsCodeBufferTop)) throw new IllegalArgumentException("Bad jump target: "+jumpTarget); if (!(caseIndex >= -1)) throw new IllegalArgumentException("Bad case index: "+caseIndex); int padSize = 3 & ~switchStart; // == 3 - switchStart % 4 int caseOffset; if (caseIndex < 0) { // default label caseOffset = switchStart + 1 + padSize; } else { caseOffset = switchStart + 1 + padSize + 4 * (3 + caseIndex); } if (!(0 <= switchStart && switchStart <= itsCodeBufferTop - 4 * 4 - padSize - 1)) { throw new IllegalArgumentException( switchStart+" is outside a possible range of tableswitch" +" in already generated code"); } if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) { throw new IllegalArgumentException( switchStart+" is not offset of tableswitch statement"); } if (!(0 <= caseOffset && caseOffset + 4 <= itsCodeBufferTop)) { // caseIndex >= -1 does not guarantee that caseOffset >= 0 due // to a possible overflow. throw new ClassFileFormatException( "Too big case index: "+caseIndex); } // ALERT: perhaps check against case bounds? putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void markLabel(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (label > itsLabelTableTop) throw new IllegalArgumentException("Bad label"); if (itsLabelTable[label] != -1) { throw new IllegalStateException("Can only mark label once"); } itsLabelTable[label] = itsCodeBufferTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public int getLabelPC(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (!(label < itsLabelTableTop)) throw new IllegalArgumentException("Bad label"); return itsLabelTable[label]; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void addLabelFixup(int label, int fixupSite) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (!(label < itsLabelTableTop)) throw new IllegalArgumentException("Bad label"); int top = itsFixupTableTop; if (itsFixupTable == null || top == itsFixupTable.length) { if (itsFixupTable == null) { itsFixupTable = new long[MIN_FIXUP_TABLE_SIZE]; }else { long[] tmp = new long[itsFixupTable.length * 2]; System.arraycopy(itsFixupTable, 0, tmp, 0, top); itsFixupTable = tmp; } } itsFixupTableTop = top + 1; itsFixupTable[top] = ((long)label << 32) | fixupSite; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int addReservedCodeSpace(int size) { if (itsCurrentMethod == null) throw new IllegalArgumentException("No method to add to"); int oldTop = itsCodeBufferTop; int newTop = oldTop + size; if (newTop > itsCodeBuffer.length) { int newSize = itsCodeBuffer.length * 2; if (newTop > newSize) { newSize = newTop; } byte[] tmp = new byte[newSize]; System.arraycopy(itsCodeBuffer, 0, tmp, 0, oldTop); itsCodeBuffer = tmp; } itsCodeBufferTop = newTop; return oldTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addExceptionHandler(int startLabel, int endLabel, int handlerLabel, String catchClassName) { if ((startLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad startLabel"); if ((endLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad endLabel"); if ((handlerLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad handlerLabel"); /* * If catchClassName is null, use 0 for the catch_type_index; which * means catch everything. (Even when the verifier has let you throw * something other than a Throwable.) */ short catch_type_index = (catchClassName == null) ? 0 : itsConstantPool.addClass(catchClassName); ExceptionTableEntry newEntry = new ExceptionTableEntry( startLabel, endLabel, handlerLabel, catch_type_index); int N = itsExceptionTableTop; if (N == 0) { itsExceptionTable = new ExceptionTableEntry[ExceptionTableSize]; } else if (N == itsExceptionTable.length) { ExceptionTableEntry[] tmp = new ExceptionTableEntry[N * 2]; System.arraycopy(itsExceptionTable, 0, tmp, 0, N); itsExceptionTable = tmp; } itsExceptionTable[N] = newEntry; itsExceptionTableTop = N + 1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addLineNumberEntry(short lineNumber) { if (itsCurrentMethod == null) throw new IllegalArgumentException("No method to stop"); int N = itsLineNumberTableTop; if (N == 0) { itsLineNumberTable = new int[LineNumberTableSize]; } else if (N == itsLineNumberTable.length) { int[] tmp = new int[N * 2]; System.arraycopy(itsLineNumberTable, 0, tmp, 0, N); itsLineNumberTable = tmp; } itsLineNumberTable[N] = (itsCodeBufferTop << 16) + lineNumber; itsLineNumberTableTop = N + 1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private SuperBlock getSuperBlockFromOffset(int offset) { for (int i = 0; i < superBlocks.length; i++) { SuperBlock sb = superBlocks[i]; if (sb == null) { break; } else if (offset >= sb.getStart() && offset < sb.getEnd()) { return sb; } } throw new IllegalArgumentException("bad offset: " + offset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int getOperand(int start, int size) { int result = 0; if (size > 4) { throw new IllegalArgumentException("bad operand size"); } for (int i = 0; i < size; i++) { result = (result << 8) | (itsCodeBuffer[start + i] & 0xFF); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int execute(int bci) { int bc = itsCodeBuffer[bci] & 0xFF; int type, type2, index; int length = 0; long lType, lType2; String className; switch (bc) { case ByteCode.NOP: case ByteCode.IINC: case ByteCode.GOTO: case ByteCode.GOTO_W: // No change break; case ByteCode.CHECKCAST: pop(); push(TypeInfo.OBJECT(getOperand(bci + 1, 2))); break; case ByteCode.IASTORE: // pop; pop; pop case ByteCode.LASTORE: case ByteCode.FASTORE: case ByteCode.DASTORE: case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: pop(); case ByteCode.PUTFIELD: // pop; pop case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPNE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: pop(); case ByteCode.IFEQ: // pop case ByteCode.IFNE: case ByteCode.IFLT: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFNULL: case ByteCode.IFNONNULL: case ByteCode.POP: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.PUTSTATIC: pop(); break; case ByteCode.POP2: pop2(); break; case ByteCode.ACONST_NULL: push(TypeInfo.NULL); break; case ByteCode.IALOAD: // pop; pop; push(INTEGER) case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: case ByteCode.IADD: case ByteCode.ISUB: case ByteCode.IMUL: case ByteCode.IDIV: case ByteCode.IREM: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.IUSHR: case ByteCode.IAND: case ByteCode.IOR: case ByteCode.IXOR: case ByteCode.LCMP: case ByteCode.FCMPL: case ByteCode.FCMPG: case ByteCode.DCMPL: case ByteCode.DCMPG: pop(); case ByteCode.INEG: // pop; push(INTEGER) case ByteCode.L2I: case ByteCode.F2I: case ByteCode.D2I: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2S: case ByteCode.ARRAYLENGTH: case ByteCode.INSTANCEOF: pop(); case ByteCode.ICONST_M1: // push(INTEGER) case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.BIPUSH: case ByteCode.SIPUSH: push(TypeInfo.INTEGER); break; case ByteCode.LALOAD: // pop; pop; push(LONG) case ByteCode.LADD: case ByteCode.LSUB: case ByteCode.LMUL: case ByteCode.LDIV: case ByteCode.LREM: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.LAND: case ByteCode.LOR: case ByteCode.LXOR: pop(); case ByteCode.LNEG: // pop; push(LONG) case ByteCode.I2L: case ByteCode.F2L: case ByteCode.D2L: pop(); case ByteCode.LCONST_0: // push(LONG) case ByteCode.LCONST_1: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: push(TypeInfo.LONG); break; case ByteCode.FALOAD: // pop; pop; push(FLOAT) case ByteCode.FADD: case ByteCode.FSUB: case ByteCode.FMUL: case ByteCode.FDIV: case ByteCode.FREM: pop(); case ByteCode.FNEG: // pop; push(FLOAT) case ByteCode.I2F: case ByteCode.L2F: case ByteCode.D2F: pop(); case ByteCode.FCONST_0: // push(FLOAT) case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: push(TypeInfo.FLOAT); break; case ByteCode.DALOAD: // pop; pop; push(DOUBLE) case ByteCode.DADD: case ByteCode.DSUB: case ByteCode.DMUL: case ByteCode.DDIV: case ByteCode.DREM: pop(); case ByteCode.DNEG: // pop; push(DOUBLE) case ByteCode.I2D: case ByteCode.L2D: case ByteCode.F2D: pop(); case ByteCode.DCONST_0: // push(DOUBLE) case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: push(TypeInfo.DOUBLE); break; case ByteCode.ISTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.INTEGER); break; case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: executeStore(bc - ByteCode.ISTORE_0, TypeInfo.INTEGER); break; case ByteCode.LSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.LONG); break; case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: executeStore(bc - ByteCode.LSTORE_0, TypeInfo.LONG); break; case ByteCode.FSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.FLOAT); break; case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: executeStore(bc - ByteCode.FSTORE_0, TypeInfo.FLOAT); break; case ByteCode.DSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.DOUBLE); break; case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: executeStore(bc - ByteCode.DSTORE_0, TypeInfo.DOUBLE); break; case ByteCode.ALOAD: executeALoad(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: executeALoad(bc - ByteCode.ALOAD_0); break; case ByteCode.ASTORE: executeAStore(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: executeAStore(bc - ByteCode.ASTORE_0); break; case ByteCode.IRETURN: case ByteCode.LRETURN: case ByteCode.FRETURN: case ByteCode.DRETURN: case ByteCode.ARETURN: case ByteCode.RETURN: clearStack(); break; case ByteCode.ATHROW: type = pop(); clearStack(); push(type); break; case ByteCode.SWAP: type = pop(); type2 = pop(); push(type); push(type2); break; case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.LDC2_W: if (bc == ByteCode.LDC) { index = getOperand(bci + 1); } else { index = getOperand(bci + 1, 2); } byte constType = itsConstantPool.getConstantType(index); switch (constType) { case ConstantPool.CONSTANT_Double: push(TypeInfo.DOUBLE); break; case ConstantPool.CONSTANT_Float: push(TypeInfo.FLOAT); break; case ConstantPool.CONSTANT_Long: push(TypeInfo.LONG); break; case ConstantPool.CONSTANT_Integer: push(TypeInfo.INTEGER); break; case ConstantPool.CONSTANT_String: push(TypeInfo.OBJECT("java/lang/String", itsConstantPool)); break; default: throw new IllegalArgumentException( "bad const type " + constType); } break; case ByteCode.NEW: push(TypeInfo.UNINITIALIZED_VARIABLE(bci)); break; case ByteCode.NEWARRAY: pop(); char componentType = arrayTypeToName(itsCodeBuffer[bci + 1]); index = itsConstantPool.addClass("[" + componentType); push(TypeInfo.OBJECT((short) index)); break; case ByteCode.ANEWARRAY: index = getOperand(bci + 1, 2); className = (String) itsConstantPool.getConstantData(index); pop(); push(TypeInfo.OBJECT("[L" + className + ';', itsConstantPool)); break; case ByteCode.INVOKEVIRTUAL: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEINTERFACE: index = getOperand(bci + 1, 2); FieldOrMethodRef m = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String methodType = m.getType(); String methodName = m.getName(); int parameterCount = sizeOfParameters(methodType) >>> 16; for (int i = 0; i < parameterCount; i++) { pop(); } if (bc != ByteCode.INVOKESTATIC) { int instType = pop(); int tag = TypeInfo.getTag(instType); if (tag == TypeInfo.UNINITIALIZED_VARIABLE(0) || tag == TypeInfo.UNINITIALIZED_THIS) { if ("<init>".equals(methodName)) { int newType = TypeInfo.OBJECT(itsThisClassIndex); initializeTypeInfo(instType, newType); } else { throw new IllegalStateException("bad instance"); } } } int rParen = methodType.indexOf(')'); String returnType = methodType.substring(rParen + 1); returnType = descriptorToInternalName(returnType); if (!returnType.equals("V")) { push(TypeInfo.fromType(returnType, itsConstantPool)); } break; case ByteCode.GETFIELD: pop(); case ByteCode.GETSTATIC: index = getOperand(bci + 1, 2); FieldOrMethodRef f = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String fieldType = descriptorToInternalName(f.getType()); push(TypeInfo.fromType(fieldType, itsConstantPool)); break; case ByteCode.DUP: type = pop(); push(type); push(type); break; case ByteCode.DUP_X1: type = pop(); type2 = pop(); push(type); push(type2); push(type); break; case ByteCode.DUP_X2: type = pop(); lType = pop2(); push(type); push2(lType); push(type); break; case ByteCode.DUP2: lType = pop2(); push2(lType); push2(lType); break; case ByteCode.DUP2_X1: lType = pop2(); type = pop(); push2(lType); push(type); push2(lType); break; case ByteCode.DUP2_X2: lType = pop2(); lType2 = pop2(); push2(lType); push2(lType2); push2(lType); break; case ByteCode.TABLESWITCH: int switchStart = bci + 1 + (3 & ~bci); int low = getOperand(switchStart + 4, 4); int high = getOperand(switchStart + 8, 4); length = 4 * (high - low + 4) + switchStart - bci; pop(); break; case ByteCode.AALOAD: pop(); int typeIndex = pop() >>> 8; className = (String) itsConstantPool.getConstantData(typeIndex); String arrayType = className; if (arrayType.charAt(0) != '[') { throw new IllegalStateException("bad array type"); } String elementDesc = arrayType.substring(1); String elementType = descriptorToInternalName(elementDesc); typeIndex = itsConstantPool.addClass(elementType); push(TypeInfo.OBJECT(typeIndex)); break; case ByteCode.WIDE: // Alters behaviour of next instruction wide = true; break; case ByteCode.MULTIANEWARRAY: case ByteCode.LOOKUPSWITCH: // Currently not used in any part of Rhino, so ignore it case ByteCode.JSR: // TODO: JSR is deprecated case ByteCode.RET: case ByteCode.JSR_W: default: throw new IllegalArgumentException("bad opcode: " + bc); } if (length == 0) { length = opcodeLength(bc, wide); } if (wide && bc != ByteCode.WIDE) { wide = false; } return length; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static char arrayTypeToName(int type) { switch (type) { case ByteCode.T_BOOLEAN: return 'Z'; case ByteCode.T_CHAR: return 'C'; case ByteCode.T_FLOAT: return 'F'; case ByteCode.T_DOUBLE: return 'D'; case ByteCode.T_BYTE: return 'B'; case ByteCode.T_SHORT: return 'S'; case ByteCode.T_INT: return 'I'; case ByteCode.T_LONG: return 'J'; default: throw new IllegalArgumentException("bad operand"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static String descriptorToInternalName(String descriptor) { switch (descriptor.charAt(0)) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 'V': case '[': return descriptor; case 'L': return classDescriptorToInternalName(descriptor); default: throw new IllegalArgumentException("bad descriptor:" + descriptor); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int[] createInitialLocals() { int[] initialLocals = new int[itsMaxLocals]; int localsTop = 0; // Instance methods require the first local variable in the array // to be "this". However, if the method being created is a // constructor, aka the method is <init>, then the type of "this" // should be StackMapTable.UNINITIALIZED_THIS if ((itsCurrentMethod.getFlags() & ACC_STATIC) == 0) { if ("<init>".equals(itsCurrentMethod.getName())) { initialLocals[localsTop++] = TypeInfo.UNINITIALIZED_THIS; } else { initialLocals[localsTop++] = TypeInfo.OBJECT(itsThisClassIndex); } } // No error checking should be necessary, sizeOfParameters does this String type = itsCurrentMethod.getType(); int lParenIndex = type.indexOf('('); int rParenIndex = type.indexOf(')'); if (lParenIndex != 0 || rParenIndex < 0) { throw new IllegalArgumentException("bad method type"); } int start = lParenIndex + 1; StringBuilder paramType = new StringBuilder(); while (start < rParenIndex) { switch (type.charAt(start)) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': paramType.append(type.charAt(start)); ++start; break; case 'L': int end = type.indexOf(';', start) + 1; String name = type.substring(start, end); paramType.append(name); start = end; break; case '[': paramType.append('['); ++start; continue; } String internalType = descriptorToInternalName(paramType.toString()); int typeInfo = TypeInfo.fromType(internalType, itsConstantPool); initialLocals[localsTop++] = typeInfo; if (TypeInfo.isTwoWords(typeInfo)) { localsTop++; } paramType.setLength(0); } return initialLocals; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static int sizeOfParameters(String pString) { int length = pString.length(); int rightParenthesis = pString.lastIndexOf(')'); if (3 <= length /* minimal signature takes at least 3 chars: ()V */ && pString.charAt(0) == '(' && 1 <= rightParenthesis && rightParenthesis + 1 < length) { boolean ok = true; int index = 1; int stackDiff = 0; int count = 0; stringLoop: while (index != rightParenthesis) { switch (pString.charAt(index)) { default: ok = false; break stringLoop; case 'J' : case 'D' : --stackDiff; // fall thru case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : --stackDiff; ++count; ++index; continue; case '[' : ++index; int c = pString.charAt(index); while (c == '[') { ++index; c = pString.charAt(index); } switch (c) { default: ok = false; break stringLoop; case 'J' : case 'D' : case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : --stackDiff; ++count; ++index; continue; case 'L': // fall thru } // fall thru case 'L' : { --stackDiff; ++count; ++index; int semicolon = pString.indexOf(';', index); if (!(index + 1 <= semicolon && semicolon < rightParenthesis)) { ok = false; break stringLoop; } index = semicolon + 1; continue; } } } if (ok) { switch (pString.charAt(rightParenthesis + 1)) { default: ok = false; break; case 'J' : case 'D' : ++stackDiff; // fall thru case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : case 'L' : case '[' : ++stackDiff; // fall thru case 'V' : break; } if (ok) { return ((count << 16) | (0xFFFF & stackDiff)); } } } throw new IllegalArgumentException( "Bad parameter signature: "+pString); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int opcodeLength(int opcode, boolean wide) { switch (opcode) { case ByteCode.AALOAD: case ByteCode.AASTORE: case ByteCode.ACONST_NULL: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.ARETURN: case ByteCode.ARRAYLENGTH: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.BASTORE: case ByteCode.BREAKPOINT: case ByteCode.CALOAD: case ByteCode.CASTORE: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.D2L: case ByteCode.DADD: case ByteCode.DALOAD: case ByteCode.DASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DDIV: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DMUL: case ByteCode.DNEG: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.DUP: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2I: case ByteCode.F2L: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FASTORE: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FDIV: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.FMUL: case ByteCode.FNEG: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2D: case ByteCode.I2F: case ByteCode.I2L: case ByteCode.I2S: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IASTORE: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.IDIV: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.IMUL: case ByteCode.INEG: case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2D: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LADD: case ByteCode.LALOAD: case ByteCode.LAND: case ByteCode.LASTORE: case ByteCode.LCMP: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDIV: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: case ByteCode.LMUL: case ByteCode.LNEG: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LUSHR: case ByteCode.LXOR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.NOP: case ByteCode.POP: case ByteCode.POP2: case ByteCode.RETURN: case ByteCode.SALOAD: case ByteCode.SASTORE: case ByteCode.SWAP: case ByteCode.WIDE: return 1; case ByteCode.BIPUSH: case ByteCode.LDC: case ByteCode.NEWARRAY: return 2; case ByteCode.ALOAD: case ByteCode.ASTORE: case ByteCode.DLOAD: case ByteCode.DSTORE: case ByteCode.FLOAD: case ByteCode.FSTORE: case ByteCode.ILOAD: case ByteCode.ISTORE: case ByteCode.LLOAD: case ByteCode.LSTORE: case ByteCode.RET: return wide ? 3 : 2; case ByteCode.ANEWARRAY: case ByteCode.CHECKCAST: case ByteCode.GETFIELD: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.INSTANCEOF: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEVIRTUAL: case ByteCode.JSR: case ByteCode.LDC_W: case ByteCode.LDC2_W: case ByteCode.NEW: case ByteCode.PUTFIELD: case ByteCode.PUTSTATIC: case ByteCode.SIPUSH: return 3; case ByteCode.IINC: return wide ? 5 : 3; case ByteCode.MULTIANEWARRAY: return 4; case ByteCode.GOTO_W: case ByteCode.INVOKEINTERFACE: case ByteCode.JSR_W: return 5; /* case ByteCode.LOOKUPSWITCH: case ByteCode.TABLESWITCH: return -1; */ } throw new IllegalArgumentException("Bad opcode: " + opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int opcodeCount(int opcode) { switch (opcode) { case ByteCode.AALOAD: case ByteCode.AASTORE: case ByteCode.ACONST_NULL: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.ARETURN: case ByteCode.ARRAYLENGTH: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.BASTORE: case ByteCode.BREAKPOINT: case ByteCode.CALOAD: case ByteCode.CASTORE: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.D2L: case ByteCode.DADD: case ByteCode.DALOAD: case ByteCode.DASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DDIV: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DMUL: case ByteCode.DNEG: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.DUP: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2I: case ByteCode.F2L: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FASTORE: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FDIV: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.FMUL: case ByteCode.FNEG: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2D: case ByteCode.I2F: case ByteCode.I2L: case ByteCode.I2S: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IASTORE: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.IDIV: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.IMUL: case ByteCode.INEG: case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2D: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LADD: case ByteCode.LALOAD: case ByteCode.LAND: case ByteCode.LASTORE: case ByteCode.LCMP: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDIV: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: case ByteCode.LMUL: case ByteCode.LNEG: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LUSHR: case ByteCode.LXOR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.NOP: case ByteCode.POP: case ByteCode.POP2: case ByteCode.RETURN: case ByteCode.SALOAD: case ByteCode.SASTORE: case ByteCode.SWAP: case ByteCode.WIDE: return 0; case ByteCode.ALOAD: case ByteCode.ANEWARRAY: case ByteCode.ASTORE: case ByteCode.BIPUSH: case ByteCode.CHECKCAST: case ByteCode.DLOAD: case ByteCode.DSTORE: case ByteCode.FLOAD: case ByteCode.FSTORE: case ByteCode.GETFIELD: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.GOTO_W: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.ILOAD: case ByteCode.INSTANCEOF: case ByteCode.INVOKEINTERFACE: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEVIRTUAL: case ByteCode.ISTORE: case ByteCode.JSR: case ByteCode.JSR_W: case ByteCode.LDC: case ByteCode.LDC2_W: case ByteCode.LDC_W: case ByteCode.LLOAD: case ByteCode.LSTORE: case ByteCode.NEW: case ByteCode.NEWARRAY: case ByteCode.PUTFIELD: case ByteCode.PUTSTATIC: case ByteCode.RET: case ByteCode.SIPUSH: return 1; case ByteCode.IINC: case ByteCode.MULTIANEWARRAY: return 2; case ByteCode.LOOKUPSWITCH: case ByteCode.TABLESWITCH: return -1; } throw new IllegalArgumentException("Bad opcode: "+opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int stackChange(int opcode) { // For INVOKE... accounts only for popping this (unless static), // ignoring parameters and return type switch (opcode) { case ByteCode.DASTORE: case ByteCode.LASTORE: return -4; case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.FASTORE: case ByteCode.IASTORE: case ByteCode.LCMP: case ByteCode.SASTORE: return -3; case ByteCode.DADD: case ByteCode.DDIV: case ByteCode.DMUL: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.LADD: case ByteCode.LAND: case ByteCode.LDIV: case ByteCode.LMUL: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSTORE: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LXOR: case ByteCode.POP2: return -2; case ByteCode.AALOAD: case ByteCode.ARETURN: case ByteCode.ASTORE: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FDIV: case ByteCode.FMUL: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.GETFIELD: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IDIV: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IMUL: case ByteCode.INVOKEINTERFACE: // case ByteCode.INVOKESPECIAL: // but needs to account for case ByteCode.INVOKEVIRTUAL: // pops 'this' (unless static) case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LOOKUPSWITCH: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.POP: case ByteCode.PUTFIELD: case ByteCode.SALOAD: case ByteCode.TABLESWITCH: return -1; case ByteCode.ANEWARRAY: case ByteCode.ARRAYLENGTH: case ByteCode.BREAKPOINT: case ByteCode.CHECKCAST: case ByteCode.D2L: case ByteCode.DALOAD: case ByteCode.DNEG: case ByteCode.F2I: case ByteCode.FNEG: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.GOTO_W: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2F: case ByteCode.I2S: case ByteCode.IINC: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.INEG: case ByteCode.INSTANCEOF: case ByteCode.INVOKESTATIC: case ByteCode.L2D: case ByteCode.LALOAD: case ByteCode.LNEG: case ByteCode.NEWARRAY: case ByteCode.NOP: case ByteCode.PUTSTATIC: case ByteCode.RET: case ByteCode.RETURN: case ByteCode.SWAP: case ByteCode.WIDE: return 0; case ByteCode.ACONST_NULL: case ByteCode.ALOAD: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.BIPUSH: case ByteCode.DUP: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2L: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.I2D: case ByteCode.I2L: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.JSR: case ByteCode.JSR_W: case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.MULTIANEWARRAY: case ByteCode.NEW: case ByteCode.SIPUSH: return 1; case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDC2_W: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: return 2; } throw new IllegalArgumentException("Bad opcode: "+opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
short addUtf8(String k) { int theIndex = itsUtf8Hash.get(k, -1); if (theIndex == -1) { int strLen = k.length(); boolean tooBigString; if (strLen > MAX_UTF_ENCODING_SIZE) { tooBigString = true; } else { tooBigString = false; // Ask for worst case scenario buffer when each char takes 3 // bytes ensure(1 + 2 + strLen * 3); int top = itsTop; itsPool[top++] = CONSTANT_Utf8; top += 2; // skip length char[] chars = cfw.getCharBuffer(strLen); k.getChars(0, strLen, chars, 0); for (int i = 0; i != strLen; i++) { int c = chars[i]; if (c != 0 && c <= 0x7F) { itsPool[top++] = (byte)c; } else if (c > 0x7FF) { itsPool[top++] = (byte)(0xE0 | (c >> 12)); itsPool[top++] = (byte)(0x80 | ((c >> 6) & 0x3F)); itsPool[top++] = (byte)(0x80 | (c & 0x3F)); } else { itsPool[top++] = (byte)(0xC0 | (c >> 6)); itsPool[top++] = (byte)(0x80 | (c & 0x3F)); } } int utfLen = top - (itsTop + 1 + 2); if (utfLen > MAX_UTF_ENCODING_SIZE) { tooBigString = true; } else { // Write back length itsPool[itsTop + 1] = (byte)(utfLen >>> 8); itsPool[itsTop + 2] = (byte)utfLen; itsTop = top; theIndex = itsTopIndex++; itsUtf8Hash.put(k, theIndex); } } if (tooBigString) { throw new IllegalArgumentException("Too big string"); } } setConstantData(theIndex, k); itsPoolTypes.put(theIndex, CONSTANT_Utf8); return (short)theIndex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
boolean merge(int[] locals, int localsTop, int[] stack, int stackTop, ConstantPool pool) { if (!isInitialized) { System.arraycopy(locals, 0, this.locals, 0, localsTop); this.stack = new int[stackTop]; System.arraycopy(stack, 0, this.stack, 0, stackTop); isInitialized = true; return true; } else if (this.locals.length == localsTop && this.stack.length == stackTop) { boolean localsChanged = mergeState(this.locals, locals, localsTop, pool); boolean stackChanged = mergeState(this.stack, stack, stackTop, pool); return localsChanged || stackChanged; } else { if (ClassFileWriter.StackMapTable.DEBUGSTACKMAP) { System.out.println("bad merge"); System.out.println("current type state:"); TypeInfo.print(this.locals, this.stack, pool); System.out.println("incoming type state:"); TypeInfo.print(locals, localsTop, stack, stackTop, pool); } throw new IllegalArgumentException("bad merge attempt"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static final String getPayloadAsType(int typeInfo, ConstantPool pool) { if (getTag(typeInfo) == OBJECT_TAG) { return (String) pool.getConstantData(getPayload(typeInfo)); } throw new IllegalArgumentException("expecting object type"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static final int fromType(String type, ConstantPool pool) { if (type.length() == 1) { switch (type.charAt(0)) { case 'B': // sbyte case 'C': // unicode char case 'S': // short case 'Z': // boolean case 'I': // all of the above are verified as integers return INTEGER; case 'D': return DOUBLE; case 'F': return FLOAT; case 'J': return LONG; default: throw new IllegalArgumentException("bad type"); } } return TypeInfo.OBJECT(type, pool); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int merge(int current, int incoming, ConstantPool pool) { int currentTag = getTag(current); int incomingTag = getTag(incoming); boolean currentIsObject = currentTag == TypeInfo.OBJECT_TAG; boolean incomingIsObject = incomingTag == TypeInfo.OBJECT_TAG; if (current == incoming || (currentIsObject && incoming == NULL)) { return current; } else if (currentTag == TypeInfo.TOP || incomingTag == TypeInfo.TOP) { return TypeInfo.TOP; } else if (current == NULL && incomingIsObject) { return incoming; } else if (currentIsObject && incomingIsObject) { String currentName = getPayloadAsType(current, pool); String incomingName = getPayloadAsType(incoming, pool); // The class file always has the class and super names in the same // spot. The constant order is: class_data, class_name, super_data, // super_name. String currentlyGeneratedName = (String) pool.getConstantData(2); String currentlyGeneratedSuperName = (String) pool.getConstantData(4); // If any of the merged types are the class that's currently being // generated, automatically start at the super class instead. At // this point, we already know the classes are different, so we // don't need to handle that case. if (currentName.equals(currentlyGeneratedName)) { currentName = currentlyGeneratedSuperName; } if (incomingName.equals(currentlyGeneratedName)) { incomingName = currentlyGeneratedSuperName; } Class<?> currentClass = getClassFromInternalName(currentName); Class<?> incomingClass = getClassFromInternalName(incomingName); if (currentClass.isAssignableFrom(incomingClass)) { return current; } else if (incomingClass.isAssignableFrom(currentClass)) { return incoming; } else if (incomingClass.isInterface() || currentClass.isInterface()) { // For verification purposes, Sun specifies that interfaces are // subtypes of Object. Therefore, we know that the merge result // involving interfaces where one is not assignable to the // other results in Object. return OBJECT("java/lang/Object", pool); } else { Class<?> commonClass = incomingClass.getSuperclass(); while (commonClass != null) { if (commonClass.isAssignableFrom(currentClass)) { String name = commonClass.getName(); name = ClassFileWriter.getSlashedForm(name); return OBJECT(name, pool); } commonClass = commonClass.getSuperclass(); } } } throw new IllegalArgumentException("bad merge attempt between " + toString(current, pool) + " and " + toString(incoming, pool)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static String toString(int type, ConstantPool pool) { int tag = getTag(type); switch (tag) { case TypeInfo.TOP: return "top"; case TypeInfo.INTEGER: return "int"; case TypeInfo.FLOAT: return "float"; case TypeInfo.DOUBLE: return "double"; case TypeInfo.LONG: return "long"; case TypeInfo.NULL: return "null"; case TypeInfo.UNINITIALIZED_THIS: return "uninitialized_this"; default: if (tag == TypeInfo.OBJECT_TAG) { return getPayloadAsType(type, pool); } else if (tag == TypeInfo.UNINITIALIZED_VAR_TAG) { return "uninitialized"; } else { throw new IllegalArgumentException("bad type"); } } }
0 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static Object toType(Object value, Class<?> desiredType) throws IllegalArgumentException { try { return jsToJava(value, desiredType); } catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; } }
(Lib) IllegalStateException 96
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UniqueTag.java
public Object readResolve() { switch (tagId) { case ID_NOT_FOUND: return NOT_FOUND; case ID_NULL_VALUE: return NULL_VALUE; case ID_DOUBLE_MARK: return DOUBLE_MARK; } throw new IllegalStateException(String.valueOf(tagId)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Token.java
public static String typeToName(int token) { switch (token) { case ERROR: return "ERROR"; case EOF: return "EOF"; case EOL: return "EOL"; case ENTERWITH: return "ENTERWITH"; case LEAVEWITH: return "LEAVEWITH"; case RETURN: return "RETURN"; case GOTO: return "GOTO"; case IFEQ: return "IFEQ"; case IFNE: return "IFNE"; case SETNAME: return "SETNAME"; case BITOR: return "BITOR"; case BITXOR: return "BITXOR"; case BITAND: return "BITAND"; case EQ: return "EQ"; case NE: return "NE"; case LT: return "LT"; case LE: return "LE"; case GT: return "GT"; case GE: return "GE"; case LSH: return "LSH"; case RSH: return "RSH"; case URSH: return "URSH"; case ADD: return "ADD"; case SUB: return "SUB"; case MUL: return "MUL"; case DIV: return "DIV"; case MOD: return "MOD"; case NOT: return "NOT"; case BITNOT: return "BITNOT"; case POS: return "POS"; case NEG: return "NEG"; case NEW: return "NEW"; case DELPROP: return "DELPROP"; case TYPEOF: return "TYPEOF"; case GETPROP: return "GETPROP"; case GETPROPNOWARN: return "GETPROPNOWARN"; case SETPROP: return "SETPROP"; case GETELEM: return "GETELEM"; case SETELEM: return "SETELEM"; case CALL: return "CALL"; case NAME: return "NAME"; case NUMBER: return "NUMBER"; case STRING: return "STRING"; case NULL: return "NULL"; case THIS: return "THIS"; case FALSE: return "FALSE"; case TRUE: return "TRUE"; case SHEQ: return "SHEQ"; case SHNE: return "SHNE"; case REGEXP: return "REGEXP"; case BINDNAME: return "BINDNAME"; case THROW: return "THROW"; case RETHROW: return "RETHROW"; case IN: return "IN"; case INSTANCEOF: return "INSTANCEOF"; case LOCAL_LOAD: return "LOCAL_LOAD"; case GETVAR: return "GETVAR"; case SETVAR: return "SETVAR"; case CATCH_SCOPE: return "CATCH_SCOPE"; case ENUM_INIT_KEYS: return "ENUM_INIT_KEYS"; case ENUM_INIT_VALUES:return "ENUM_INIT_VALUES"; case ENUM_INIT_ARRAY: return "ENUM_INIT_ARRAY"; case ENUM_NEXT: return "ENUM_NEXT"; case ENUM_ID: return "ENUM_ID"; case THISFN: return "THISFN"; case RETURN_RESULT: return "RETURN_RESULT"; case ARRAYLIT: return "ARRAYLIT"; case OBJECTLIT: return "OBJECTLIT"; case GET_REF: return "GET_REF"; case SET_REF: return "SET_REF"; case DEL_REF: return "DEL_REF"; case REF_CALL: return "REF_CALL"; case REF_SPECIAL: return "REF_SPECIAL"; case DEFAULTNAMESPACE:return "DEFAULTNAMESPACE"; case ESCXMLTEXT: return "ESCXMLTEXT"; case ESCXMLATTR: return "ESCXMLATTR"; case REF_MEMBER: return "REF_MEMBER"; case REF_NS_MEMBER: return "REF_NS_MEMBER"; case REF_NAME: return "REF_NAME"; case REF_NS_NAME: return "REF_NS_NAME"; case TRY: return "TRY"; case SEMI: return "SEMI"; case LB: return "LB"; case RB: return "RB"; case LC: return "LC"; case RC: return "RC"; case LP: return "LP"; case RP: return "RP"; case COMMA: return "COMMA"; case ASSIGN: return "ASSIGN"; case ASSIGN_BITOR: return "ASSIGN_BITOR"; case ASSIGN_BITXOR: return "ASSIGN_BITXOR"; case ASSIGN_BITAND: return "ASSIGN_BITAND"; case ASSIGN_LSH: return "ASSIGN_LSH"; case ASSIGN_RSH: return "ASSIGN_RSH"; case ASSIGN_URSH: return "ASSIGN_URSH"; case ASSIGN_ADD: return "ASSIGN_ADD"; case ASSIGN_SUB: return "ASSIGN_SUB"; case ASSIGN_MUL: return "ASSIGN_MUL"; case ASSIGN_DIV: return "ASSIGN_DIV"; case ASSIGN_MOD: return "ASSIGN_MOD"; case HOOK: return "HOOK"; case COLON: return "COLON"; case OR: return "OR"; case AND: return "AND"; case INC: return "INC"; case DEC: return "DEC"; case DOT: return "DOT"; case FUNCTION: return "FUNCTION"; case EXPORT: return "EXPORT"; case IMPORT: return "IMPORT"; case IF: return "IF"; case ELSE: return "ELSE"; case SWITCH: return "SWITCH"; case CASE: return "CASE"; case DEFAULT: return "DEFAULT"; case WHILE: return "WHILE"; case DO: return "DO"; case FOR: return "FOR"; case BREAK: return "BREAK"; case CONTINUE: return "CONTINUE"; case VAR: return "VAR"; case WITH: return "WITH"; case CATCH: return "CATCH"; case FINALLY: return "FINALLY"; case VOID: return "VOID"; case RESERVED: return "RESERVED"; case EMPTY: return "EMPTY"; case BLOCK: return "BLOCK"; case LABEL: return "LABEL"; case TARGET: return "TARGET"; case LOOP: return "LOOP"; case EXPR_VOID: return "EXPR_VOID"; case EXPR_RESULT: return "EXPR_RESULT"; case JSR: return "JSR"; case SCRIPT: return "SCRIPT"; case TYPEOFNAME: return "TYPEOFNAME"; case USE_STACK: return "USE_STACK"; case SETPROP_OP: return "SETPROP_OP"; case SETELEM_OP: return "SETELEM_OP"; case LOCAL_BLOCK: return "LOCAL_BLOCK"; case SET_REF_OP: return "SET_REF_OP"; case DOTDOT: return "DOTDOT"; case COLONCOLON: return "COLONCOLON"; case XML: return "XML"; case DOTQUERY: return "DOTQUERY"; case XMLATTR: return "XMLATTR"; case XMLEND: return "XMLEND"; case TO_OBJECT: return "TO_OBJECT"; case TO_DOUBLE: return "TO_DOUBLE"; case GET: return "GET"; case SET: return "SET"; case LET: return "LET"; case YIELD: return "YIELD"; case CONST: return "CONST"; case SETCONST: return "SETCONST"; case ARRAYCOMP: return "ARRAYCOMP"; case WITHEXPR: return "WITHEXPR"; case LETEXPR: return "LETEXPR"; case DEBUGGER: return "DEBUGGER"; case COMMENT: return "COMMENT"; case GENEXPR: return "GENEXPR"; } // Token without name throw new IllegalStateException(String.valueOf(token)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
protected Object updateDotQuery(boolean value) { // NativeWith itself does not support it throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2007-05-09 08:16:24 EDT L0: { id = 0; String X = null; int c; int s_length = s.length(); if (s_length==6) { c=s.charAt(0); if (c=='g') { X="global";id=Id_global; } else if (c=='s') { X="source";id=Id_source; } } else if (s_length==9) { c=s.charAt(0); if (c=='l') { X="lastIndex";id=Id_lastIndex; } else if (c=='m') { X="multiline";id=Id_multiline; } } else if (s_length==10) { X="ignoreCase";id=Id_ignoreCase; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# // #/string_id_map# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_lastIndex: attr = PERMANENT | DONTENUM; break; case Id_source: case Id_global: case Id_ignoreCase: case Id_multiline: attr = PERMANENT | READONLY | DONTENUM; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private void endCatch(ExceptionInfo ei, int exceptionType, int catchEnd) { if (ei.exceptionStarts[exceptionType] == 0) { throw new IllegalStateException("bad exception start"); } int currentStart = ei.exceptionStarts[exceptionType]; int currentStartPC = cfw.getLabelPC(currentStart); int catchEndPC = cfw.getLabelPC(catchEnd); if (currentStartPC != catchEndPC) { cfw.addExceptionHandler(ei.exceptionStarts[exceptionType], catchEnd, ei.handlerLabels[exceptionType], exceptionTypeToName(exceptionType)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2007-05-09 08:15:15 EDT L0: { id = 0; String X = null; int c; L: switch (s.length()) { case 4: X="name";id=Id_name; break L; case 5: X="arity";id=Id_arity; break L; case 6: X="length";id=Id_length; break L; case 9: c=s.charAt(0); if (c=='a') { X="arguments";id=Id_arguments; } else if (c=='p') { X="prototype";id=Id_prototype; } break L; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# // #/string_id_map# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_length: case Id_arity: case Id_name: attr = DONTENUM | READONLY | PERMANENT; break; case Id_prototype: // some functions such as built-ins don't have a prototype property if (!hasPrototypeProperty()) { return 0; } attr = prototypePropertyAttributes; break; case Id_arguments: attr = DONTENUM | PERMANENT; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
public void setImmunePrototypeProperty(Object value) { if ((prototypePropertyAttributes & READONLY) != 0) { throw new IllegalStateException(); } prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE; prototypePropertyAttributes = DONTENUM | PERMANENT | READONLY; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
public Scriptable construct(Context cx, Scriptable scope, Object[] args) { Scriptable result = createObject(cx, scope); if (result != null) { Object val = call(cx, scope, result, args); if (val instanceof Scriptable) { result = (Scriptable)val; } } else { Object val = call(cx, scope, null, args); if (!(val instanceof Scriptable)) { // It is program error not to return Scriptable from // the call method if createObject returns null. throw new IllegalStateException( "Bad implementaion of call as constructor, name=" +getFunctionName()+" in "+getClass().getName()); } result = (Scriptable)val; if (result.getPrototype() == null) { result.setPrototype(getClassPrototype()); } if (result.getParentScope() == null) { Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
public Scriptable requireMain(Context cx, String mainModuleId) { if(this.mainModuleId != null) { if (!this.mainModuleId.equals(mainModuleId)) { throw new IllegalStateException("Main module already set to " + this.mainModuleId); } return mainExports; } ModuleScript moduleScript; try { // try to get the module script to see if it is on the module path moduleScript = moduleScriptProvider.getModuleScript( cx, mainModuleId, null, paths); } catch (RuntimeException x) { throw x; } catch (Exception x) { throw new RuntimeException(x); } if (moduleScript != null) { mainExports = getExportedModuleInterface(cx, mainModuleId, null, true); } else if (!sandboxed) { URI mainUri = null; // try to resolve to an absolute URI or file path try { mainUri = new URI(mainModuleId); } catch (URISyntaxException usx) { // fall through } // if not an absolute uri resolve to a file path if (mainUri == null || !mainUri.isAbsolute()) { File file = new File(mainModuleId); if (!file.isFile()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + mainModuleId + "\" not found."); } mainUri = file.toURI(); } mainExports = getExportedModuleInterface(cx, mainUri.toString(), mainUri, true); } this.mainModuleId = mainModuleId; return mainExports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
private Scriptable getExportedModuleInterface(Context cx, String id, URI uri, boolean isMain) { // Check if the requested module is already completely loaded Scriptable exports = exportedModuleInterfaces.get(id); if(exports != null) { if(isMain) { throw new IllegalStateException( "Attempt to set main module after it was loaded"); } return exports; } // Check if it is currently being loaded on the current thread // (supporting circular dependencies). Map<String, Scriptable> threadLoadingModules = loadingModuleInterfaces.get(); if(threadLoadingModules != null) { exports = threadLoadingModules.get(id); if(exports != null) { return exports; } } // The requested module is neither already loaded, nor is it being // loaded on the current thread. End of fast path. We must synchronize // now, as we have to guarantee that at most one thread can load // modules at any one time. Otherwise, two threads could end up // attempting to load two circularly dependent modules in opposite // order, which would lead to either unacceptable non-determinism or // deadlock, depending on whether we underprotected or overprotected it // with locks. synchronized(loadLock) { // Recheck if it is already loaded - other thread might've // completed loading it just as we entered the synchronized block. exports = exportedModuleInterfaces.get(id); if(exports != null) { return exports; } // Nope, still not loaded; we're loading it then. final ModuleScript moduleScript = getModule(cx, id, uri); if (sandboxed && !moduleScript.isSandboxed()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + id + "\" is not contained in sandbox."); } exports = cx.newObject(nativeScope); // Are we the outermost locked invocation on this thread? final boolean outermostLocked = threadLoadingModules == null; if(outermostLocked) { threadLoadingModules = new HashMap<String, Scriptable>(); loadingModuleInterfaces.set(threadLoadingModules); } // Must make the module exports available immediately on the // current thread, to satisfy the CommonJS Modules/1.1 requirement // that "If there is a dependency cycle, the foreign module may not // have finished executing at the time it is required by one of its // transitive dependencies; in this case, the object returned by // "require" must contain at least the exports that the foreign // module has prepared before the call to require that led to the // current module's execution." threadLoadingModules.put(id, exports); try { // Support non-standard Node.js feature to allow modules to // replace the exports object by setting module.exports. Scriptable newExports = executeModuleScript(cx, id, exports, moduleScript, isMain); if (exports != newExports) { threadLoadingModules.put(id, newExports); exports = newExports; } } catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; } finally { if(outermostLocked) { // Make loaded modules visible to other threads only after // the topmost triggering load has completed. This strategy // (compared to the one where we'd make each module // globally available as soon as it loads) prevents other // threads from observing a partially loaded circular // dependency of a module that completed loading. exportedModuleInterfaces.putAll(threadLoadingModules); loadingModuleInterfaces.set(null); } } } return exports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeMath.java
Override protected void initPrototypeId(int id) { if (id <= LAST_METHOD_ID) { String name; int arity; switch (id) { case Id_toSource: arity = 0; name = "toSource"; break; case Id_abs: arity = 1; name = "abs"; break; case Id_acos: arity = 1; name = "acos"; break; case Id_asin: arity = 1; name = "asin"; break; case Id_atan: arity = 1; name = "atan"; break; case Id_atan2: arity = 2; name = "atan2"; break; case Id_ceil: arity = 1; name = "ceil"; break; case Id_cos: arity = 1; name = "cos"; break; case Id_exp: arity = 1; name = "exp"; break; case Id_floor: arity = 1; name = "floor"; break; case Id_log: arity = 1; name = "log"; break; case Id_max: arity = 2; name = "max"; break; case Id_min: arity = 2; name = "min"; break; case Id_pow: arity = 2; name = "pow"; break; case Id_random: arity = 0; name = "random"; break; case Id_round: arity = 1; name = "round"; break; case Id_sin: arity = 1; name = "sin"; break; case Id_sqrt: arity = 1; name = "sqrt"; break; case Id_tan: arity = 1; name = "tan"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeMethod(MATH_TAG, id, name, arity); } else { String name; double x; switch (id) { case Id_E: x = Math.E; name = "E"; break; case Id_PI: x = Math.PI; name = "PI"; break; case Id_LN10: x = 2.302585092994046; name = "LN10"; break; case Id_LN2: x = 0.6931471805599453; name = "LN2"; break; case Id_LOG2E: x = 1.4426950408889634; name = "LOG2E"; break; case Id_LOG10E: x = 0.4342944819032518; name = "LOG10E"; break; case Id_SQRT1_2: x = 0.7071067811865476; name = "SQRT1_2"; break; case Id_SQRT2: x = 1.4142135623730951; name = "SQRT2"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeValue(id, name, ScriptRuntime.wrapNumber(x), DONTENUM | READONLY | PERMANENT); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeMath.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(MATH_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } double x; int methodId = f.methodId(); switch (methodId) { case Id_toSource: return "Math"; case Id_abs: x = ScriptRuntime.toNumber(args, 0); // abs(-0.0) should be 0.0, but -0.0 < 0.0 == false x = (x == 0.0) ? 0.0 : (x < 0.0) ? -x : x; break; case Id_acos: case Id_asin: x = ScriptRuntime.toNumber(args, 0); if (x == x && -1.0 <= x && x <= 1.0) { x = (methodId == Id_acos) ? Math.acos(x) : Math.asin(x); } else { x = Double.NaN; } break; case Id_atan: x = ScriptRuntime.toNumber(args, 0); x = Math.atan(x); break; case Id_atan2: x = ScriptRuntime.toNumber(args, 0); x = Math.atan2(x, ScriptRuntime.toNumber(args, 1)); break; case Id_ceil: x = ScriptRuntime.toNumber(args, 0); x = Math.ceil(x); break; case Id_cos: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) ? Double.NaN : Math.cos(x); break; case Id_exp: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY) ? x : (x == Double.NEGATIVE_INFINITY) ? 0.0 : Math.exp(x); break; case Id_floor: x = ScriptRuntime.toNumber(args, 0); x = Math.floor(x); break; case Id_log: x = ScriptRuntime.toNumber(args, 0); // Java's log(<0) = -Infinity; we need NaN x = (x < 0) ? Double.NaN : Math.log(x); break; case Id_max: case Id_min: x = (methodId == Id_max) ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; for (int i = 0; i != args.length; ++i) { double d = ScriptRuntime.toNumber(args[i]); if (d != d) { x = d; // NaN break; } if (methodId == Id_max) { // if (x < d) x = d; does not work due to -0.0 >= +0.0 x = Math.max(x, d); } else { x = Math.min(x, d); } } break; case Id_pow: x = ScriptRuntime.toNumber(args, 0); x = js_pow(x, ScriptRuntime.toNumber(args, 1)); break; case Id_random: x = Math.random(); break; case Id_round: x = ScriptRuntime.toNumber(args, 0); if (x == x && x != Double.POSITIVE_INFINITY && x != Double.NEGATIVE_INFINITY) { // Round only finite x long l = Math.round(x); if (l != 0) { x = l; } else { // We must propagate the sign of d into the result if (x < 0.0) { x = ScriptRuntime.negativeZero; } else if (x != 0.0) { x = 0.0; } } } break; case Id_sin: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) ? Double.NaN : Math.sin(x); break; case Id_sqrt: x = ScriptRuntime.toNumber(args, 0); x = Math.sqrt(x); break; case Id_tan: x = ScriptRuntime.toNumber(args, 0); x = Math.tan(x); break; default: throw new IllegalStateException(String.valueOf(methodId)); } return ScriptRuntime.wrapNumber(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void remove() { if (prev == NOT_SET) { throw new IllegalStateException("next() has not been called"); } if (removed) { throw new IllegalStateException( "remove() already called for current element"); } if (prev == first) { first = prev.next; } else if (prev == last) { prev2.next = null; last = prev2; } else { prev2.next = cursor; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
private static VMBridge makeInstance() { String[] classNames = { "org.mozilla.javascript.VMBridge_custom", "org.mozilla.javascript.jdk15.VMBridge_jdk15", "org.mozilla.javascript.jdk13.VMBridge_jdk13", "org.mozilla.javascript.jdk11.VMBridge_jdk11", }; for (int i = 0; i != classNames.length; ++i) { String className = classNames[i]; Class<?> cl = Kit.classOrNull(className); if (cl != null) { VMBridge bridge = (VMBridge)Kit.newInstanceOrNull(cl); if (bridge != null) { return bridge; } } } throw new IllegalStateException("Failed to create VMBridge instance"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Arguments.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2010-01-06 05:48:21 ARST L0: { id = 0; String X = null; int c; int s_length = s.length(); if (s_length==6) { c=s.charAt(5); if (c=='e') { X="callee";id=Id_callee; } else if (c=='h') { X="length";id=Id_length; } else if (c=='r') { X="caller";id=Id_caller; } } else if (s_length==11) { X="constructor";id=Id_constructor; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_callee: case Id_caller: case Id_length: case Id_constructor: attr = DONTENUM; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(String sourceString, String sourceURI, int lineno) { if (parseFinished) throw new IllegalStateException("parser reused"); this.sourceURI = sourceURI; if (compilerEnv.isIdeMode()) { this.sourceChars = sourceString.toCharArray(); } this.ts = new TokenStream(this, null, sourceString, lineno); try { return parse(); } catch (IOException iox) { // Should never happen throw new IllegalStateException(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(Reader sourceReader, String sourceURI, int lineno) throws IOException { if (parseFinished) throw new IllegalStateException("parser reused"); if (compilerEnv.isIdeMode()) { return parse(readFully(sourceReader), sourceURI, lineno); } try { this.sourceURI = sourceURI; ts = new TokenStream(this, sourceReader, null, lineno); return parse(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static GlobalSetter getGlobalSetter() { if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; class GlobalSetterImpl implements GlobalSetter { public void setContextFactoryGlobal(ContextFactory factory) { global = factory == null ? new ContextFactory() : factory; } public ContextFactory getContextFactoryGlobal() { return global; } } return new GlobalSetterImpl(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void addListener(Listener listener) { checkNotSealed(); synchronized (listenersLock) { if (disabledListening) { throw new IllegalStateException(); } listeners = Kit.addListener(listeners, listener); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void removeListener(Listener listener) { checkNotSealed(); synchronized (listenersLock) { if (disabledListening) { throw new IllegalStateException(); } listeners = Kit.removeListener(listeners, listener); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
protected final void checkNotSealed() { if (sealed) throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object[] toArray(Object[] a) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; Object[] array = a.length >= len ? a : (Object[]) java.lang.reflect.Array .newInstance(a.getClass().getComponentType(), len); for (int i = 0; i < len; i++) { array[i] = get(i); } return array; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int size() { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } return (int) longLen; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int indexOf(Object o) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; if (o == null) { for (int i = 0; i < len; i++) { if (get(i) == null) { return i; } } } else { for (int i = 0; i < len; i++) { if (o.equals(get(i))) { return i; } } } return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int lastIndexOf(Object o) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; if (o == null) { for (int i = len - 1; i >= 0; i--) { if (get(i) == null) { return i; } } } else { for (int i = len - 1; i >= 0; i--) { if (o.equals(get(i))) { return i; } } } return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public ListIterator listIterator(final int start) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; if (start < 0 || start > len) { throw new IndexOutOfBoundsException("Index: " + start); } return new ListIterator() { int cursor = start; public boolean hasNext() { return cursor < len; } public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); } public boolean hasPrevious() { return cursor > 0; } public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); } public int nextIndex() { return cursor; } public int previousIndex() { return cursor - 1; } public void remove() { throw new UnsupportedOperationException(); } public void add(Object o) { throw new UnsupportedOperationException(); } public void set(Object o) { throw new UnsupportedOperationException(); } }; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterpretedFunction.java
public Object exec(Context cx, Scriptable scope) { if (!isScript()) { // Can only be applied to scripts throw new IllegalStateException(); } if (!ScriptRuntime.hasTopCall(cx)) { // It will go through "call" path. but they are equivalent return ScriptRuntime.doTopCall( this, cx, scope, scope, ScriptRuntime.emptyArgs); } return Interpreter.interpret( this, cx, scope, scope, ScriptRuntime.emptyArgs); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Icode.java
static String bytecodeName(int bytecode) { if (!validBytecode(bytecode)) { throw new IllegalArgumentException(String.valueOf(bytecode)); } if (!Token.printICode) { return String.valueOf(bytecode); } if (validTokenCode(bytecode)) { return Token.name(bytecode); } switch (bytecode) { case Icode_DUP: return "DUP"; case Icode_DUP2: return "DUP2"; case Icode_SWAP: return "SWAP"; case Icode_POP: return "POP"; case Icode_POP_RESULT: return "POP_RESULT"; case Icode_IFEQ_POP: return "IFEQ_POP"; case Icode_VAR_INC_DEC: return "VAR_INC_DEC"; case Icode_NAME_INC_DEC: return "NAME_INC_DEC"; case Icode_PROP_INC_DEC: return "PROP_INC_DEC"; case Icode_ELEM_INC_DEC: return "ELEM_INC_DEC"; case Icode_REF_INC_DEC: return "REF_INC_DEC"; case Icode_SCOPE_LOAD: return "SCOPE_LOAD"; case Icode_SCOPE_SAVE: return "SCOPE_SAVE"; case Icode_TYPEOFNAME: return "TYPEOFNAME"; case Icode_NAME_AND_THIS: return "NAME_AND_THIS"; case Icode_PROP_AND_THIS: return "PROP_AND_THIS"; case Icode_ELEM_AND_THIS: return "ELEM_AND_THIS"; case Icode_VALUE_AND_THIS: return "VALUE_AND_THIS"; case Icode_CLOSURE_EXPR: return "CLOSURE_EXPR"; case Icode_CLOSURE_STMT: return "CLOSURE_STMT"; case Icode_CALLSPECIAL: return "CALLSPECIAL"; case Icode_RETUNDEF: return "RETUNDEF"; case Icode_GOSUB: return "GOSUB"; case Icode_STARTSUB: return "STARTSUB"; case Icode_RETSUB: return "RETSUB"; case Icode_LINE: return "LINE"; case Icode_SHORTNUMBER: return "SHORTNUMBER"; case Icode_INTNUMBER: return "INTNUMBER"; case Icode_LITERAL_NEW: return "LITERAL_NEW"; case Icode_LITERAL_SET: return "LITERAL_SET"; case Icode_SPARE_ARRAYLIT: return "SPARE_ARRAYLIT"; case Icode_REG_IND_C0: return "REG_IND_C0"; case Icode_REG_IND_C1: return "REG_IND_C1"; case Icode_REG_IND_C2: return "REG_IND_C2"; case Icode_REG_IND_C3: return "REG_IND_C3"; case Icode_REG_IND_C4: return "REG_IND_C4"; case Icode_REG_IND_C5: return "REG_IND_C5"; case Icode_REG_IND1: return "LOAD_IND1"; case Icode_REG_IND2: return "LOAD_IND2"; case Icode_REG_IND4: return "LOAD_IND4"; case Icode_REG_STR_C0: return "REG_STR_C0"; case Icode_REG_STR_C1: return "REG_STR_C1"; case Icode_REG_STR_C2: return "REG_STR_C2"; case Icode_REG_STR_C3: return "REG_STR_C3"; case Icode_REG_STR1: return "LOAD_STR1"; case Icode_REG_STR2: return "LOAD_STR2"; case Icode_REG_STR4: return "LOAD_STR4"; case Icode_GETVAR1: return "GETVAR1"; case Icode_SETVAR1: return "SETVAR1"; case Icode_UNDEF: return "UNDEF"; case Icode_ZERO: return "ZERO"; case Icode_ONE: return "ONE"; case Icode_ENTERDQ: return "ENTERDQ"; case Icode_LEAVEDQ: return "LEAVEDQ"; case Icode_TAIL_CALL: return "TAIL_CALL"; case Icode_LOCAL_CLEAR: return "LOCAL_CLEAR"; case Icode_LITERAL_GETTER: return "LITERAL_GETTER"; case Icode_LITERAL_SETTER: return "LITERAL_SETTER"; case Icode_SETCONST: return "SETCONST"; case Icode_SETCONSTVAR: return "SETCONSTVAR"; case Icode_SETCONSTVAR1: return "SETCONSTVAR1"; case Icode_GENERATOR: return "GENERATOR"; case Icode_GENERATOR_END: return "GENERATOR_END"; case Icode_DEBUGGER: return "DEBUGGER"; } // icode without name throw new IllegalStateException(String.valueOf(bytecode)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/KeywordLiteral.java
Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); switch (getType()) { case Token.THIS: sb.append("this"); break; case Token.NULL: sb.append("null"); break; case Token.TRUE: sb.append("true"); break; case Token.FALSE: sb.append("false"); break; case Token.DEBUGGER: sb.append("debugger;\n"); break; default: throw new IllegalStateException("Invalid keyword literal type: " + getType()); } return sb.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ScriptNode.java
public void setCompilerData(Object data) { assertNotNull(data); // Can only call once if (compilerData != null) throw new IllegalStateException(); compilerData = data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstRoot.java
public boolean visit(AstNode node) { int type = node.getType(); if (type == Token.SCRIPT) return true; if (node.getParent() == null) throw new IllegalStateException ("No parent for node: " + node + "\n" + node.toSource(0)); return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
Override protected void initPrototypeId(int id) { if (id <= LAST_METHOD_ID) { String name; int arity; switch (id) { case Id_toSource: arity = 0; name = "toSource"; break; case Id_parse: arity = 2; name = "parse"; break; case Id_stringify: arity = 3; name = "stringify"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeMethod(JSON_TAG, id, name, arity); } else { throw new IllegalStateException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(JSON_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int methodId = f.methodId(); switch (methodId) { case Id_toSource: return "JSON"; case Id_parse: { String jtext = ScriptRuntime.toString(args, 0); Object reviver = null; if (args.length > 1) { reviver = args[1]; } if (reviver instanceof Callable) { return parse(cx, scope, jtext, (Callable) reviver); } else { return parse(cx, scope, jtext); } } case Id_stringify: { Object value = null, replacer = null, space = null; switch (args.length) { default: case 3: space = args[2]; case 2: replacer = args[1]; case 1: value = args[0]; case 0: } return stringify(cx, scope, value, replacer, space); } default: throw new IllegalStateException(String.valueOf(methodId)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initSourceName(String sourceName) { if (sourceName == null) throw new IllegalArgumentException(); if (this.sourceName != null) throw new IllegalStateException(); this.sourceName = sourceName; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineNumber(int lineNumber) { if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber)); if (this.lineNumber > 0) throw new IllegalStateException(); this.lineNumber = lineNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initColumnNumber(int columnNumber) { if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber)); if (this.columnNumber > 0) throw new IllegalStateException(); this.columnNumber = columnNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineSource(String lineSource) { if (lineSource == null) throw new IllegalArgumentException(); if (this.lineSource != null) throw new IllegalStateException(); this.lineSource = lineSource; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public Object execWithDomain(Context cx, Scriptable scope, Script script, Object securityDomain) { throw new IllegalStateException("callWithDomain should be overridden"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onSeledMutation() { throw new IllegalStateException("Attempt to modify sealed array"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void initSlot(int id, String name, Object value, int attributes) { Object[] array = valueArray; if (array == null) throw new IllegalStateException(); if (value == null) { value = UniqueTag.NULL_VALUE; } int index = (id - 1) * SLOT_SPAN; synchronized (this) { Object value2 = array[index]; if (value2 == null) { array[index] = value; array[index + NAME_SLOT] = name; attributeArray[id - 1] = (short)attributes; } else { if (!name.equals(array[index + NAME_SLOT])) throw new IllegalStateException(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final IdFunctionObject createPrecachedConstructor() { if (constructorId != 0) throw new IllegalStateException(); constructorId = obj.findPrototypeId("constructor"); if (constructorId == 0) { throw new IllegalStateException( "No id for constructor property"); } obj.initPrototypeId(constructorId); if (constructor == null) { throw new IllegalStateException( obj.getClass().getName()+".initPrototypeId() did not " +"initialize id="+constructorId); } constructor.initFunction(obj.getClassName(), ScriptableObject.getTopLevelScope(obj)); constructor.markAsConstructor(obj); return constructor; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private Object ensureId(int id) { Object[] array = valueArray; if (array == null) { synchronized (this) { array = valueArray; if (array == null) { array = new Object[maxId * SLOT_SPAN]; valueArray = array; attributeArray = new short[maxId]; } } } int valueSlot = (id - 1) * SLOT_SPAN; Object value = array[valueSlot]; if (value == null) { if (id == constructorId) { initSlot(constructorId, "constructor", constructor, constructorAttrs); constructor = null; // no need to refer it any longer } else { obj.initPrototypeId(id); } value = array[valueSlot]; if (value == null) { throw new IllegalStateException( obj.getClass().getName()+".initPrototypeId(int id) " +"did not initialize id="+id); } } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected Object getInstanceIdValue(int id) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected void setInstanceIdValue(int id, Object value) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void activatePrototypeMap(int maxPrototypeId) { PrototypeValues values = new PrototypeValues(this, maxPrototypeId); synchronized (this) { if (prototypeValues != null) throw new IllegalStateException(); prototypeValues = values; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void initPrototypeConstructor(IdFunctionObject f) { int id = prototypeValues.constructorId; if (id == 0) throw new IllegalStateException(); if (f.methodId() != id) throw new IllegalArgumentException(); if (isSealed()) { f.sealObject(); } prototypeValues.initValue(id, "constructor", f, DONTENUM); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected void initPrototypeId(int id) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected int findPrototypeId(String name) { throw new IllegalStateException(name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
CallFrame cloneFrozen() { if (!frozen) Kit.codeBug(); CallFrame copy; try { copy = (CallFrame)clone(); } catch (CloneNotSupportedException ex) { throw new IllegalStateException(); } // clone stack but keep varSource to point to values // from this frame to share variables. copy.stack = stack.clone(); copy.stackAttributes = stackAttributes.clone(); copy.sDbl = sDbl.clone(); copy.frozen = false; return copy; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static Object interpretLoop(Context cx, CallFrame frame, Object throwable) { // throwable holds exception object to rethrow or catch // It is also used for continuation restart in which case // it holds ContinuationJump final Object DBL_MRK = DOUBLE_MARK; final Object undefined = Undefined.instance; final boolean instructionCounting = (cx.instructionThreshold != 0); // arbitrary number to add to instructionCount when calling // other functions final int INVOCATION_COST = 100; // arbitrary exception cost for instruction counting final int EXCEPTION_COST = 100; String stringReg = null; int indexReg = -1; if (cx.lastInterpreterFrame != null) { // save the top frame from the previous interpretLoop // invocation on the stack if (cx.previousInterpreterInvocations == null) { cx.previousInterpreterInvocations = new ObjArray(); } cx.previousInterpreterInvocations.push(cx.lastInterpreterFrame); } // When restarting continuation throwable is not null and to jump // to the code that rewind continuation state indexReg should be set // to -1. // With the normal call throwable == null and indexReg == -1 allows to // catch bugs with using indeReg to access array elements before // initializing indexReg. GeneratorState generatorState = null; if (throwable != null) { if (throwable instanceof GeneratorState) { generatorState = (GeneratorState) throwable; // reestablish this call frame enterFrame(cx, frame, ScriptRuntime.emptyArgs, true); throwable = null; } else if (!(throwable instanceof ContinuationJump)) { // It should be continuation Kit.codeBug(); } } Object interpreterResult = null; double interpreterResultDbl = 0.0; StateLoop: for (;;) { withoutExceptions: try { if (throwable != null) { // Need to return both 'frame' and 'throwable' from // 'processThrowable', so just added a 'throwable' // member in 'frame'. frame = processThrowable(cx, throwable, frame, indexReg, instructionCounting); throwable = frame.throwable; frame.throwable = null; } else { if (generatorState == null && frame.frozen) Kit.codeBug(); } // Use local variables for constant values in frame // for faster access Object[] stack = frame.stack; double[] sDbl = frame.sDbl; Object[] vars = frame.varSource.stack; double[] varDbls = frame.varSource.sDbl; int[] varAttributes = frame.varSource.stackAttributes; byte[] iCode = frame.idata.itsICode; String[] strings = frame.idata.itsStringTable; // Use local for stackTop as well. Since execption handlers // can only exist at statement level where stack is empty, // it is necessary to save/restore stackTop only across // function calls and normal returns. int stackTop = frame.savedStackTop; // Store new frame in cx which is used for error reporting etc. cx.lastInterpreterFrame = frame; Loop: for (;;) { // Exception handler assumes that PC is already incremented // pass the instruction start when it searches the // exception handler int op = iCode[frame.pc++]; jumplessRun: { // Back indent to ease implementation reading switch (op) { case Icode_GENERATOR: { if (!frame.frozen) { // First time encountering this opcode: create new generator // object and return frame.pc--; // we want to come back here when we resume CallFrame generatorFrame = captureFrameForGenerator(frame); generatorFrame.frozen = true; NativeGenerator generator = new NativeGenerator(frame.scope, generatorFrame.fnOrScript, generatorFrame); frame.result = generator; break Loop; } else { // We are now resuming execution. Fall through to YIELD case. } } // fall through... case Token.YIELD: { if (!frame.frozen) { return freezeGenerator(cx, frame, stackTop, generatorState); } else { Object obj = thawGenerator(frame, stackTop, generatorState, op); if (obj != Scriptable.NOT_FOUND) { throwable = obj; break withoutExceptions; } continue Loop; } } case Icode_GENERATOR_END: { // throw StopIteration frame.frozen = true; int sourceLine = getIndex(iCode, frame.pc); generatorState.returnedException = new JavaScriptException( NativeIterator.getStopIterationObject(frame.scope), frame.idata.itsSourceFile, sourceLine); break Loop; } case Token.THROW: { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int sourceLine = getIndex(iCode, frame.pc); throwable = new JavaScriptException(value, frame.idata.itsSourceFile, sourceLine); break withoutExceptions; } case Token.RETHROW: { indexReg += frame.localShift; throwable = stack[indexReg]; break withoutExceptions; } case Token.GE : case Token.LE : case Token.GT : case Token.LT : { stackTop = doCompare(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.IN : case Token.INSTANCEOF : { stackTop = doInOrInstanceof(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.EQ : case Token.NE : { --stackTop; boolean valBln = doEquals(stack, sDbl, stackTop); valBln ^= (op == Token.NE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.SHEQ : case Token.SHNE : { --stackTop; boolean valBln = doShallowEquals(stack, sDbl, stackTop); valBln ^= (op == Token.SHNE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.IFNE : if (stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Token.IFEQ : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Icode_IFEQ_POP : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } stack[stackTop--] = null; break jumplessRun; case Token.GOTO : break jumplessRun; case Icode_GOSUB : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.pc + 2; break jumplessRun; case Icode_STARTSUB : if (stackTop == frame.emptyStackTop + 1) { // Call from Icode_GOSUB: store return PC address in the local indexReg += frame.localShift; stack[indexReg] = stack[stackTop]; sDbl[indexReg] = sDbl[stackTop]; --stackTop; } else { // Call from exception handler: exception object is already stored // in the local if (stackTop != frame.emptyStackTop) Kit.codeBug(); } continue Loop; case Icode_RETSUB : { // indexReg: local to store return address if (instructionCounting) { addInstructionCount(cx, frame, 0); } indexReg += frame.localShift; Object value = stack[indexReg]; if (value != DBL_MRK) { // Invocation from exception handler, restore object to rethrow throwable = value; break withoutExceptions; } // Normal return from GOSUB frame.pc = (int)sDbl[indexReg]; if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } case Icode_POP : stack[stackTop] = null; stackTop--; continue Loop; case Icode_POP_RESULT : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; stack[stackTop] = null; --stackTop; continue Loop; case Icode_DUP : stack[stackTop + 1] = stack[stackTop]; sDbl[stackTop + 1] = sDbl[stackTop]; stackTop++; continue Loop; case Icode_DUP2 : stack[stackTop + 1] = stack[stackTop - 1]; sDbl[stackTop + 1] = sDbl[stackTop - 1]; stack[stackTop + 2] = stack[stackTop]; sDbl[stackTop + 2] = sDbl[stackTop]; stackTop += 2; continue Loop; case Icode_SWAP : { Object o = stack[stackTop]; stack[stackTop] = stack[stackTop - 1]; stack[stackTop - 1] = o; double d = sDbl[stackTop]; sDbl[stackTop] = sDbl[stackTop - 1]; sDbl[stackTop - 1] = d; continue Loop; } case Token.RETURN : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; --stackTop; break Loop; case Token.RETURN_RESULT : break Loop; case Icode_RETUNDEF : frame.result = undefined; break Loop; case Token.BITNOT : { int rIntValue = stack_int32(frame, stackTop); stack[stackTop] = DBL_MRK; sDbl[stackTop] = ~rIntValue; continue Loop; } case Token.BITAND : case Token.BITOR : case Token.BITXOR : case Token.LSH : case Token.RSH : { stackTop = doBitOp(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.URSH : { double lDbl = stack_double(frame, stackTop - 1); int rIntValue = stack_int32(frame, stackTop) & 0x1F; stack[--stackTop] = DBL_MRK; sDbl[stackTop] = ScriptRuntime.toUint32(lDbl) >>> rIntValue; continue Loop; } case Token.NEG : case Token.POS : { double rDbl = stack_double(frame, stackTop); stack[stackTop] = DBL_MRK; if (op == Token.NEG) { rDbl = -rDbl; } sDbl[stackTop] = rDbl; continue Loop; } case Token.ADD : --stackTop; doAdd(stack, sDbl, stackTop, cx); continue Loop; case Token.SUB : case Token.MUL : case Token.DIV : case Token.MOD : { stackTop = doArithmetic(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.NOT : stack[stackTop] = ScriptRuntime.wrapBoolean( !stack_boolean(frame, stackTop)); continue Loop; case Token.BINDNAME : stack[++stackTop] = ScriptRuntime.bind(cx, frame.scope, stringReg); continue Loop; case Token.STRICT_SETNAME: case Token.SETNAME : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = op == Token.SETNAME ? ScriptRuntime.setName(lhs, rhs, cx, frame.scope, stringReg) : ScriptRuntime.strictSetName(lhs, rhs, cx, frame.scope, stringReg); continue Loop; } case Icode_SETCONST: { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = ScriptRuntime.setConst(lhs, rhs, cx, stringReg); continue Loop; } case Token.DELPROP : case Icode_DELNAME : { stackTop = doDelName(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.GETPROPNOWARN : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectPropNoWarn(lhs, stringReg, cx); continue Loop; } case Token.GETPROP : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx, frame.scope); continue Loop; } case Token.SETPROP : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setObjectProp(lhs, stringReg, rhs, cx); continue Loop; } case Icode_PROP_INC_DEC : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.propIncrDecr(lhs, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.GETELEM : { stackTop = doGetElem(cx, frame, stack, sDbl, stackTop); continue Loop; } case Token.SETELEM : { stackTop = doSetElem(cx, stack, sDbl, stackTop); continue Loop; } case Icode_ELEM_INC_DEC: { stackTop = doElemIncDec(cx, frame, iCode, stack, sDbl, stackTop); continue Loop; } case Token.GET_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refGet(ref, cx); continue Loop; } case Token.SET_REF : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refSet(ref, value, cx); continue Loop; } case Token.DEL_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refDel(ref, cx); continue Loop; } case Icode_REF_INC_DEC : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refIncrDecr(ref, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.LOCAL_LOAD : ++stackTop; indexReg += frame.localShift; stack[stackTop] = stack[indexReg]; sDbl[stackTop] = sDbl[indexReg]; continue Loop; case Icode_LOCAL_CLEAR : indexReg += frame.localShift; stack[indexReg] = null; continue Loop; case Icode_NAME_AND_THIS : // stringReg: name ++stackTop; stack[stackTop] = ScriptRuntime.getNameFunctionAndThis(stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; case Icode_PROP_AND_THIS: { Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); // stringReg: property stack[stackTop] = ScriptRuntime.getPropFunctionAndThis(obj, stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_ELEM_AND_THIS: { Object obj = stack[stackTop - 1]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop - 1]); Object id = stack[stackTop]; if (id == DBL_MRK) id = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id, cx); stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_VALUE_AND_THIS : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getValueFunctionAndThis(value, cx); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_CALLSPECIAL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } stackTop = doCallSpecial(cx, frame, stack, sDbl, stackTop, iCode, indexReg); continue Loop; } case Token.CALL : case Icode_TAIL_CALL : case Token.REF_CALL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function thisObj arg0 .. argN -> result // indexReg: number of arguments stackTop -= 1 + indexReg; // CALL generation ensures that fun and funThisObj // are already Scriptable and Callable objects respectively Callable fun = (Callable)stack[stackTop]; Scriptable funThisObj = (Scriptable)stack[stackTop + 1]; if (op == Token.REF_CALL) { Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 2, indexReg); stack[stackTop] = ScriptRuntime.callRef(fun, funThisObj, outArgs, cx); continue Loop; } Scriptable calleeScope = frame.scope; if (frame.useActivation) { calleeScope = ScriptableObject.getTopLevelScope(frame.scope); } if (fun instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction)fun; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { CallFrame callParentFrame = frame; CallFrame calleeFrame = new CallFrame(); if (op == Icode_TAIL_CALL) { // In principle tail call can re-use the current // frame and its stack arrays but it is hard to // do properly. Any exceptions that can legally // happen during frame re-initialization including // StackOverflowException during innocent looking // System.arraycopy may leave the current frame // data corrupted leading to undefined behaviour // in the catch code bellow that unwinds JS stack // on exceptions. Then there is issue about frame release // end exceptions there. // To avoid frame allocation a released frame // can be cached for re-use which would also benefit // non-tail calls but it is not clear that this caching // would gain in performance due to potentially // bad interaction with GC. callParentFrame = frame.parentFrame; // Release the current frame. See Bug #344501 to see why // it is being done here. exitFrame(cx, frame, null); } initFrame(cx, calleeScope, funThisObj, stack, sDbl, stackTop + 2, indexReg, ifun, callParentFrame, calleeFrame); if (op != Icode_TAIL_CALL) { frame.savedStackTop = stackTop; frame.savedCallOp = op; } frame = calleeFrame; continue StateLoop; } } if (fun instanceof NativeContinuation) { // Jump to the captured continuation ContinuationJump cjump; cjump = new ContinuationJump((NativeContinuation)fun, frame); // continuation result is the first argument if any // of continuation call if (indexReg == 0) { cjump.result = undefined; } else { cjump.result = stack[stackTop + 2]; cjump.resultDbl = sDbl[stackTop + 2]; } // Start the real unwind job throwable = cjump; break withoutExceptions; } if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } // Bug 405654 -- make best effort to keep Function.apply and // Function.call within this interpreter loop invocation if (BaseFunction.isApplyOrCall(ifun)) { Callable applyCallable = ScriptRuntime.getCallable(funThisObj); if (applyCallable instanceof InterpretedFunction) { InterpretedFunction iApplyCallable = (InterpretedFunction)applyCallable; if (frame.fnOrScript.securityDomain == iApplyCallable.securityDomain) { frame = initFrameForApplyOrCall(cx, frame, indexReg, stack, sDbl, stackTop, op, calleeScope, ifun, iApplyCallable); continue StateLoop; } } } } // Bug 447697 -- make best effort to keep __noSuchMethod__ within this // interpreter loop invocation if (fun instanceof NoSuchMethodShim) { // get the shim and the actual method NoSuchMethodShim noSuchMethodShim = (NoSuchMethodShim) fun; Callable noSuchMethodMethod = noSuchMethodShim.noSuchMethodMethod; // if the method is in fact an InterpretedFunction if (noSuchMethodMethod instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction) noSuchMethodMethod; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { frame = initFrameForNoSuchMethod(cx, frame, indexReg, stack, sDbl, stackTop, op, funThisObj, calleeScope, noSuchMethodShim, ifun); continue StateLoop; } } } cx.lastInterpreterFrame = frame; frame.savedCallOp = op; frame.savedStackTop = stackTop; stack[stackTop] = fun.call(cx, calleeScope, funThisObj, getArgsArray(stack, sDbl, stackTop + 2, indexReg)); continue Loop; } case Token.NEW : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function arg0 .. argN -> newResult // indexReg: number of arguments stackTop -= indexReg; Object lhs = stack[stackTop]; if (lhs instanceof InterpretedFunction) { InterpretedFunction f = (InterpretedFunction)lhs; if (frame.fnOrScript.securityDomain == f.securityDomain) { Scriptable newInstance = f.createObject(cx, frame.scope); CallFrame calleeFrame = new CallFrame(); initFrame(cx, frame.scope, newInstance, stack, sDbl, stackTop + 1, indexReg, f, frame, calleeFrame); stack[stackTop] = newInstance; frame.savedStackTop = stackTop; frame.savedCallOp = op; frame = calleeFrame; continue StateLoop; } } if (!(lhs instanceof Function)) { if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); throw ScriptRuntime.notFunctionError(lhs); } Function fun = (Function)lhs; if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } } Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 1, indexReg); stack[stackTop] = fun.construct(cx, frame.scope, outArgs); continue Loop; } case Token.TYPEOF : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.typeof(lhs); continue Loop; } case Icode_TYPEOFNAME : stack[++stackTop] = ScriptRuntime.typeofName(frame.scope, stringReg); continue Loop; case Token.STRING : stack[++stackTop] = stringReg; continue Loop; case Icode_SHORTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getShort(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_INTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Token.NUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.idata.itsDoubleTable[indexReg]; continue Loop; case Token.NAME : stack[++stackTop] = ScriptRuntime.name(cx, frame.scope, stringReg); continue Loop; case Icode_NAME_INC_DEC : stack[++stackTop] = ScriptRuntime.nameIncrDecr(frame.scope, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; case Icode_SETCONSTVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETCONSTVAR : stackTop = doSetConstVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_SETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETVAR : stackTop = doSetVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_GETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.GETVAR : stackTop = doGetVar(frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; case Icode_VAR_INC_DEC : { stackTop = doVarIncDec(cx, frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; } case Icode_ZERO : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 0; continue Loop; case Icode_ONE : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 1; continue Loop; case Token.NULL : stack[++stackTop] = null; continue Loop; case Token.THIS : stack[++stackTop] = frame.thisObj; continue Loop; case Token.THISFN : stack[++stackTop] = frame.fnOrScript; continue Loop; case Token.FALSE : stack[++stackTop] = Boolean.FALSE; continue Loop; case Token.TRUE : stack[++stackTop] = Boolean.TRUE; continue Loop; case Icode_UNDEF : stack[++stackTop] = undefined; continue Loop; case Token.ENTERWITH : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterWith(lhs, cx, frame.scope); continue Loop; } case Token.LEAVEWITH : frame.scope = ScriptRuntime.leaveWith(frame.scope); continue Loop; case Token.CATCH_SCOPE : { // stack top: exception object // stringReg: name of exception variable // indexReg: local for exception scope --stackTop; indexReg += frame.localShift; boolean afterFirstScope = (frame.idata.itsICode[frame.pc] != 0); Throwable caughtException = (Throwable)stack[stackTop + 1]; Scriptable lastCatchScope; if (!afterFirstScope) { lastCatchScope = null; } else { lastCatchScope = (Scriptable)stack[indexReg]; } stack[indexReg] = ScriptRuntime.newCatchScope(caughtException, lastCatchScope, stringReg, cx, frame.scope); ++frame.pc; continue Loop; } case Token.ENUM_INIT_KEYS : case Token.ENUM_INIT_VALUES : case Token.ENUM_INIT_ARRAY : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; indexReg += frame.localShift; int enumType = op == Token.ENUM_INIT_KEYS ? ScriptRuntime.ENUMERATE_KEYS : op == Token.ENUM_INIT_VALUES ? ScriptRuntime.ENUMERATE_VALUES : ScriptRuntime.ENUMERATE_ARRAY; stack[indexReg] = ScriptRuntime.enumInit(lhs, cx, enumType); continue Loop; } case Token.ENUM_NEXT : case Token.ENUM_ID : { indexReg += frame.localShift; Object val = stack[indexReg]; ++stackTop; stack[stackTop] = (op == Token.ENUM_NEXT) ? (Object)ScriptRuntime.enumNext(val) : (Object)ScriptRuntime.enumId(val, cx); continue Loop; } case Token.REF_SPECIAL : { //stringReg: name of special property Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg, cx); continue Loop; } case Token.REF_MEMBER: { //indexReg: flags stackTop = doRefMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NS_MEMBER: { //indexReg: flags stackTop = doRefNsMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NAME: { //indexReg: flags Object name = stack[stackTop]; if (name == DBL_MRK) name = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.nameRef(name, cx, frame.scope, indexReg); continue Loop; } case Token.REF_NS_NAME: { //indexReg: flags stackTop = doRefNsName(cx, frame, stack, sDbl, stackTop, indexReg); continue Loop; } case Icode_SCOPE_LOAD : indexReg += frame.localShift; frame.scope = (Scriptable)stack[indexReg]; continue Loop; case Icode_SCOPE_SAVE : indexReg += frame.localShift; stack[indexReg] = frame.scope; continue Loop; case Icode_CLOSURE_EXPR : stack[++stackTop] = InterpretedFunction.createFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Icode_CLOSURE_STMT : initFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Token.REGEXP : Object re = frame.idata.itsRegExpLiterals[indexReg]; stack[++stackTop] = ScriptRuntime.wrapRegExp(cx, frame.scope, re); continue Loop; case Icode_LITERAL_NEW : // indexReg: number of values in the literal ++stackTop; stack[stackTop] = new int[indexReg]; ++stackTop; stack[stackTop] = new Object[indexReg]; sDbl[stackTop] = 0; continue Loop; case Icode_LITERAL_SET : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_GETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = -1; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_SETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = +1; sDbl[stackTop] = i + 1; continue Loop; } case Token.ARRAYLIT : case Icode_SPARE_ARRAYLIT : case Token.OBJECTLIT : { Object[] data = (Object[])stack[stackTop]; --stackTop; int[] getterSetters = (int[])stack[stackTop]; Object val; if (op == Token.OBJECTLIT) { Object[] ids = (Object[])frame.idata.literalIds[indexReg]; val = ScriptRuntime.newObjectLiteral(ids, data, getterSetters, cx, frame.scope); } else { int[] skipIndexces = null; if (op == Icode_SPARE_ARRAYLIT) { skipIndexces = (int[])frame.idata.literalIds[indexReg]; } val = ScriptRuntime.newArrayLiteral(data, skipIndexces, cx, frame.scope); } stack[stackTop] = val; continue Loop; } case Icode_ENTERDQ : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterDotQuery(lhs, frame.scope); continue Loop; } case Icode_LEAVEDQ : { boolean valBln = stack_boolean(frame, stackTop); Object x = ScriptRuntime.updateDotQuery(valBln, frame.scope); if (x != null) { stack[stackTop] = x; frame.scope = ScriptRuntime.leaveDotQuery(frame.scope); frame.pc += 2; continue Loop; } // reset stack and PC to code after ENTERDQ --stackTop; break jumplessRun; } case Token.DEFAULTNAMESPACE : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setDefaultNamespace(value, cx); continue Loop; } case Token.ESCXMLATTR : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeAttributeValue(value, cx); } continue Loop; } case Token.ESCXMLTEXT : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeTextValue(value, cx); } continue Loop; } case Icode_DEBUGGER: if (frame.debuggerFrame != null) { frame.debuggerFrame.onDebuggerStatement(cx); } continue Loop; case Icode_LINE : frame.pcSourceLineStart = frame.pc; if (frame.debuggerFrame != null) { int line = getIndex(iCode, frame.pc); frame.debuggerFrame.onLineChange(cx, line); } frame.pc += 2; continue Loop; case Icode_REG_IND_C0: indexReg = 0; continue Loop; case Icode_REG_IND_C1: indexReg = 1; continue Loop; case Icode_REG_IND_C2: indexReg = 2; continue Loop; case Icode_REG_IND_C3: indexReg = 3; continue Loop; case Icode_REG_IND_C4: indexReg = 4; continue Loop; case Icode_REG_IND_C5: indexReg = 5; continue Loop; case Icode_REG_IND1: indexReg = 0xFF & iCode[frame.pc]; ++frame.pc; continue Loop; case Icode_REG_IND2: indexReg = getIndex(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_REG_IND4: indexReg = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Icode_REG_STR_C0: stringReg = strings[0]; continue Loop; case Icode_REG_STR_C1: stringReg = strings[1]; continue Loop; case Icode_REG_STR_C2: stringReg = strings[2]; continue Loop; case Icode_REG_STR_C3: stringReg = strings[3]; continue Loop; case Icode_REG_STR1: stringReg = strings[0xFF & iCode[frame.pc]]; ++frame.pc; continue Loop; case Icode_REG_STR2: stringReg = strings[getIndex(iCode, frame.pc)]; frame.pc += 2; continue Loop; case Icode_REG_STR4: stringReg = strings[getInt(iCode, frame.pc)]; frame.pc += 4; continue Loop; default : dumpICode(frame.idata); throw new RuntimeException("Unknown icode : " + op + " @ pc : " + (frame.pc-1)); } // end of interpreter switch } // end of jumplessRun label block // This should be reachable only for jump implementation // when pc points to encoded target offset if (instructionCounting) { addInstructionCount(cx, frame, 2); } int offset = getShort(iCode, frame.pc); if (offset != 0) { // -1 accounts for pc pointing to jump opcode + 1 frame.pc += offset - 1; } else { frame.pc = frame.idata.longJumps. getExistingInt(frame.pc); } if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } // end of Loop: for exitFrame(cx, frame, null); interpreterResult = frame.result; interpreterResultDbl = frame.resultDbl; if (frame.parentFrame != null) { frame = frame.parentFrame; if (frame.frozen) { frame = frame.cloneFrozen(); } setCallResult( frame, interpreterResult, interpreterResultDbl); interpreterResult = null; // Help GC continue StateLoop; } break StateLoop; } // end of interpreter withoutExceptions: try catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; } // This should be reachable only after above catch or from // finally when it needs to propagate exception or from // explicit throw if (throwable == null) Kit.codeBug(); // Exception type final int EX_CATCH_STATE = 2; // Can execute JS catch final int EX_FINALLY_STATE = 1; // Can execute JS finally final int EX_NO_JS_STATE = 0; // Terminate JS execution int exState; ContinuationJump cjump = null; if (generatorState != null && generatorState.operation == NativeGenerator.GENERATOR_CLOSE && throwable == generatorState.value) { exState = EX_FINALLY_STATE; } else if (throwable instanceof JavaScriptException) { exState = EX_CATCH_STATE; } else if (throwable instanceof EcmaError) { // an offical ECMA error object, exState = EX_CATCH_STATE; } else if (throwable instanceof EvaluatorException) { exState = EX_CATCH_STATE; } else if (throwable instanceof RuntimeException) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } else if (throwable instanceof Error) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_NO_JS_STATE; } else if (throwable instanceof ContinuationJump) { // It must be ContinuationJump exState = EX_FINALLY_STATE; cjump = (ContinuationJump)throwable; } else { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } if (instructionCounting) { try { addInstructionCount(cx, frame, EXCEPTION_COST); } catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; } catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } if (frame.debuggerFrame != null && throwable instanceof RuntimeException) { // Call debugger only for RuntimeException RuntimeException rex = (RuntimeException)throwable; try { frame.debuggerFrame.onExceptionThrown(cx, rex); } catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } for (;;) { if (exState != EX_NO_JS_STATE) { boolean onlyFinally = (exState != EX_CATCH_STATE); indexReg = getExceptionHandler(frame, onlyFinally); if (indexReg >= 0) { // We caught an exception, restart the loop // with exception pending the processing at the loop // start continue StateLoop; } } // No allowed exception handlers in this frame, unwind // to parent and try to look there exitFrame(cx, frame, throwable); frame = frame.parentFrame; if (frame == null) { break; } if (cjump != null && cjump.branchFrame == frame) { // Continuation branch point was hit, // restart the state loop to reenter continuation indexReg = -1; continue StateLoop; } } // No more frames, rethrow the exception or deal with continuation if (cjump != null) { if (cjump.branchFrame != null) { // The above loop should locate the top frame Kit.codeBug(); } if (cjump.capturedFrame != null) { // Restarting detached continuation indexReg = -1; continue StateLoop; } // Return continuation result to the caller interpreterResult = cjump.result; interpreterResultDbl = cjump.resultDbl; throwable = null; } break StateLoop; } // end of StateLoop: for(;;) // Do cleanups/restorations before the final return or throw if (cx.previousInterpreterInvocations != null && cx.previousInterpreterInvocations.size() != 0) { cx.lastInterpreterFrame = cx.previousInterpreterInvocations.pop(); } else { // It was the last interpreter frame on the stack cx.lastInterpreterFrame = null; // Force GC of the value cx.previousInterpreterInvocations cx.previousInterpreterInvocations = null; } if (throwable != null) { if (throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else { // Must be instance of Error or code bug throw (Error)throwable; } } return (interpreterResult != DBL_MRK) ? interpreterResult : ScriptRuntime.wrapNumber(interpreterResultDbl); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
public static NativeContinuation captureContinuation(Context cx) { if (cx.lastInterpreterFrame == null || !(cx.lastInterpreterFrame instanceof CallFrame)) { throw new IllegalStateException("Interpreter frames not found"); } return captureContinuation(cx, (CallFrame)cx.lastInterpreterFrame, true); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static NativeContinuation captureContinuation(Context cx, CallFrame frame, boolean requireContinuationsTopFrame) { NativeContinuation c = new NativeContinuation(); ScriptRuntime.setObjectProtoAndParent( c, ScriptRuntime.getTopCallScope(cx)); // Make sure that all frames are frozen CallFrame x = frame; CallFrame outermost = frame; while (x != null && !x.frozen) { x.frozen = true; // Allow to GC unused stack space for (int i = x.savedStackTop + 1; i != x.stack.length; ++i) { // Allow to GC unused stack space x.stack[i] = null; x.stackAttributes[i] = ScriptableObject.EMPTY; } if (x.savedCallOp == Token.CALL) { // the call will always overwrite the stack top with the result x.stack[x.savedStackTop] = null; } else { if (x.savedCallOp != Token.NEW) Kit.codeBug(); // the new operator uses stack top to store the constructed // object so it shall not be cleared: see comments in // setCallResult } outermost = x; x = x.parentFrame; } if (requireContinuationsTopFrame) { while (outermost.parentFrame != null) outermost = outermost.parentFrame; if (!outermost.isContinuationsTopFrame) { throw new IllegalStateException("Cannot capture continuation " + "from JavaScript code not called directly by " + "executeScriptWithContinuations or " + "callFunctionWithContinuations"); } } c.initImplementation(frame); return c; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Callable getValueFunctionAndThis(Object value, Context cx) { if (!(value instanceof Callable)) { throw notFunctionError(value); } Callable f = (Callable)value; Scriptable thisObj = null; if (f instanceof Scriptable) { thisObj = ((Scriptable)f).getParentScope(); } if (thisObj == null) { if (cx.topCallScope == null) throw new IllegalStateException(); thisObj = cx.topCallScope; } if (thisObj.getParentScope() != null) { if (thisObj instanceof NativeWith) { // functions defined inside with should have with target // as their thisObj } else if (thisObj instanceof NativeCall) { // nested functions should have top scope as their thisObj thisObj = ScriptableObject.getTopLevelScope(thisObj); } } storeScriptable(cx, thisObj); return f; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Ref callRef(Callable function, Scriptable thisObj, Object[] args, Context cx) { if (function instanceof RefCallable) { RefCallable rfunction = (RefCallable)function; Ref ref = rfunction.refCall(cx, thisObj, args); if (ref == null) { throw new IllegalStateException(rfunction.getClass().getName()+".refCall() returned null"); } return ref; } // No runtime support for now String msg = getMessage1("msg.no.ref.from.function", toString(function)); throw constructError("ReferenceError", msg); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Scriptable getTopCallScope(Context cx) { Scriptable scope = cx.topCallScope; if (scope == null) { throw new IllegalStateException(); } return scope; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (scope == null) throw new IllegalArgumentException(); if (cx.topCallScope != null) throw new IllegalStateException(); Object result; cx.topCallScope = ScriptableObject.getTopLevelScope(scope); cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE); ContextFactory f = cx.getFactory(); try { result = f.doTopCall(callable, cx, scope, thisObj, args); } finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void initScript(NativeFunction funObj, Scriptable thisObj, Context cx, Scriptable scope, boolean evalScript) { if (cx.topCallScope == null) throw new IllegalStateException(); int varCount = funObj.getParamAndVarCount(); if (varCount != 0) { Scriptable varScope = scope; // Never define any variables from var statements inside with // object. See bug 38590. while (varScope instanceof NativeWith) { varScope = varScope.getParentScope(); } for (int i = varCount; i-- != 0;) { String name = funObj.getParamOrVarName(i); boolean isConst = funObj.getParamOrVarConst(i); // Don't overwrite existing def if already defined in object // or prototypes of object. if (!ScriptableObject.hasProperty(scope, name)) { if (!evalScript) { // Global var definitions are supposed to be DONTDELETE if (isConst) ScriptableObject.defineConstProperty(varScope, name); else ScriptableObject.defineProperty( varScope, name, Undefined.instance, ScriptableObject.PERMANENT); } else { varScope.put(name, varScope, Undefined.instance); } } else { ScriptableObject.redefineProperty(scope, name, isConst); } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void enterActivationFunction(Context cx, Scriptable scope) { if (cx.topCallScope == null) throw new IllegalStateException(); NativeCall call = (NativeCall)scope; call.parentActivationCall = cx.currentActivationCall; cx.currentActivationCall = call; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
private static XMLLib currentXMLLib(Context cx) { // Scripts should be running to access this if (cx.topCallScope == null) throw new IllegalStateException(); XMLLib xmlLib = cx.cachedXMLLib; if (xmlLib == null) { xmlLib = XMLLib.extractFromScope(cx.topCallScope); if (xmlLib == null) throw new IllegalStateException(); cx.cachedXMLLib = xmlLib; } return xmlLib; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static long lastUint32Result(Context cx) { long value = cx.scratchUint32; if ((value >>> 32) != 0) throw new IllegalStateException(); return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
private static void storeScriptable(Context cx, Scriptable value) { // The previously stored scratchScriptable should be consumed if (cx.scratchScriptable != null) throw new IllegalStateException(); cx.scratchScriptable = value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
void init() { synchronized (this) { if (state == STATE_INITIALIZING) throw new IllegalStateException( "Recursive initialization for "+propertyName); if (state == STATE_BEFORE_INIT) { state = STATE_INITIALIZING; // Set value now to have something to set in finally block if // buildValue throws. Object value = Scriptable.NOT_FOUND; try { value = buildValue(); } finally { initializedValue = value; state = STATE_WITH_VALUE; } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
Object getValue() { if (state != STATE_WITH_VALUE) throw new IllegalStateException(propertyName); return initializedValue; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static final Context enter(Context cx, ContextFactory factory) { Object helper = VMBridge.instance.getThreadContextHelper(); Context old = VMBridge.instance.getContext(helper); if (old != null) { cx = old; } else { if (cx == null) { cx = factory.makeContext(); if (cx.enterCount != 0) { throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread"); } factory.onContextCreated(cx); if (factory.isSealed() && !cx.isSealed()) { cx.seal(null); } } else { if (cx.enterCount != 0) { throw new IllegalStateException("can not use Context instance already associated with some thread"); } } VMBridge.instance.setContext(helper, cx); } ++cx.enterCount; return cx; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void unseal(Object sealKey) { if (sealKey == null) throw new IllegalArgumentException(); if (this.sealKey != sealKey) throw new IllegalArgumentException(); if (!sealed) throw new IllegalStateException(); sealed = false; this.sealKey = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static void onSealedMutation() { throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object callFunctionWithContinuations(Callable function, Scriptable scope, Object[] args) throws ContinuationPending { if (!(function instanceof InterpretedFunction)) { // Can only be applied to scripts throw new IllegalArgumentException("Function argument was not" + " created by interpreted mode "); } if (ScriptRuntime.hasTopCall(this)) { throw new IllegalStateException("Cannot have any pending top " + "calls when executing a script with continuations"); } // Annotate so we can check later to ensure no java code in // intervening frames isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setMaximumInterpreterStackDepth(int max) { if(sealed) onSealedMutation(); if(optimizationLevel != -1) { throw new IllegalStateException("Cannot set maximumInterpreterStackDepth when optimizationLevel != -1"); } if(max < 1) { throw new IllegalArgumentException("Cannot set maximumInterpreterStackDepth to less than 1"); } maximumInterpreterStackDepth = max; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void stopMethod(short maxLocals) { if (itsCurrentMethod == null) throw new IllegalStateException("No method to stop"); fixLabelGotos(); itsMaxLocals = maxLocals; StackMapTable stackMap = null; if (GenerateStackMap) { finalizeSuperBlockStarts(); stackMap = new StackMapTable(); stackMap.generate(); } int lineNumberTableLength = 0; if (itsLineNumberTable != null) { // 6 bytes for the attribute header // 2 bytes for the line number count // 4 bytes for each entry lineNumberTableLength = 6 + 2 + (itsLineNumberTableTop * 4); } int variableTableLength = 0; if (itsVarDescriptors != null) { // 6 bytes for the attribute header // 2 bytes for the variable count // 10 bytes for each entry variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10); } int stackMapTableLength = 0; if (stackMap != null) { int stackMapWriteSize = stackMap.computeWriteSize(); if (stackMapWriteSize > 0) { stackMapTableLength = 6 + stackMapWriteSize; } } int attrLength = 2 + // attribute_name_index 4 + // attribute_length 2 + // max_stack 2 + // max_locals 4 + // code_length itsCodeBufferTop + 2 + // exception_table_length (itsExceptionTableTop * 8) + 2 + // attributes_count lineNumberTableLength + variableTableLength + stackMapTableLength; if (attrLength > 65536) { // See http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html, // section 4.10, "The amount of code per non-native, non-abstract // method is limited to 65536 bytes... throw new ClassFileFormatException( "generated bytecode for method exceeds 64K limit."); } byte[] codeAttribute = new byte[attrLength]; int index = 0; int codeAttrIndex = itsConstantPool.addUtf8("Code"); index = putInt16(codeAttrIndex, codeAttribute, index); attrLength -= 6; // discount the attribute header index = putInt32(attrLength, codeAttribute, index); index = putInt16(itsMaxStack, codeAttribute, index); index = putInt16(itsMaxLocals, codeAttribute, index); index = putInt32(itsCodeBufferTop, codeAttribute, index); System.arraycopy(itsCodeBuffer, 0, codeAttribute, index, itsCodeBufferTop); index += itsCodeBufferTop; if (itsExceptionTableTop > 0) { index = putInt16(itsExceptionTableTop, codeAttribute, index); for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short)getLabelPC(ete.itsStartLabel); short endPC = (short)getLabelPC(ete.itsEndLabel); short handlerPC = (short)getLabelPC(ete.itsHandlerLabel); short catchType = ete.itsCatchType; if (startPC == -1) throw new IllegalStateException("start label not defined"); if (endPC == -1) throw new IllegalStateException("end label not defined"); if (handlerPC == -1) throw new IllegalStateException( "handler label not defined"); index = putInt16(startPC, codeAttribute, index); index = putInt16(endPC, codeAttribute, index); index = putInt16(handlerPC, codeAttribute, index); index = putInt16(catchType, codeAttribute, index); } } else { // write 0 as exception table length index = putInt16(0, codeAttribute, index); } int attributeCount = 0; if (itsLineNumberTable != null) attributeCount++; if (itsVarDescriptors != null) attributeCount++; if (stackMapTableLength > 0) { attributeCount++; } index = putInt16(attributeCount, codeAttribute, index); if (itsLineNumberTable != null) { int lineNumberTableAttrIndex = itsConstantPool.addUtf8("LineNumberTable"); index = putInt16(lineNumberTableAttrIndex, codeAttribute, index); int tableAttrLength = 2 + (itsLineNumberTableTop * 4); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(itsLineNumberTableTop, codeAttribute, index); for (int i = 0; i < itsLineNumberTableTop; i++) { index = putInt32(itsLineNumberTable[i], codeAttribute, index); } } if (itsVarDescriptors != null) { int variableTableAttrIndex = itsConstantPool.addUtf8("LocalVariableTable"); index = putInt16(variableTableAttrIndex, codeAttribute, index); int varCount = itsVarDescriptors.size(); int tableAttrLength = 2 + (varCount * 10); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(varCount, codeAttribute, index); for (int i = 0; i < varCount; i++) { int[] chunk = (int[])itsVarDescriptors.get(i); int nameIndex = chunk[0]; int descriptorIndex = chunk[1]; int startPC = chunk[2]; int register = chunk[3]; int length = itsCodeBufferTop - startPC; index = putInt16(startPC, codeAttribute, index); index = putInt16(length, codeAttribute, index); index = putInt16(nameIndex, codeAttribute, index); index = putInt16(descriptorIndex, codeAttribute, index); index = putInt16(register, codeAttribute, index); } } if (stackMapTableLength > 0) { int stackMapTableAttrIndex = itsConstantPool.addUtf8("StackMapTable"); int start = index; index = putInt16(stackMapTableAttrIndex, codeAttribute, index); index = stackMap.write(codeAttribute, index); } itsCurrentMethod.setCodeAttribute(codeAttribute); itsExceptionTable = null; itsExceptionTableTop = 0; itsLineNumberTableTop = 0; itsCodeBufferTop = 0; itsCurrentMethod = null; itsMaxStack = 0; itsStackTop = 0; itsLabelTableTop = 0; itsFixupTableTop = 0; itsVarDescriptors = null; itsSuperBlockStarts = null; itsSuperBlockStartsTop = 0; itsJumpFroms = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void markLabel(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (label > itsLabelTableTop) throw new IllegalArgumentException("Bad label"); if (itsLabelTable[label] != -1) { throw new IllegalStateException("Can only mark label once"); } itsLabelTable[label] = itsCodeBufferTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int execute(int bci) { int bc = itsCodeBuffer[bci] & 0xFF; int type, type2, index; int length = 0; long lType, lType2; String className; switch (bc) { case ByteCode.NOP: case ByteCode.IINC: case ByteCode.GOTO: case ByteCode.GOTO_W: // No change break; case ByteCode.CHECKCAST: pop(); push(TypeInfo.OBJECT(getOperand(bci + 1, 2))); break; case ByteCode.IASTORE: // pop; pop; pop case ByteCode.LASTORE: case ByteCode.FASTORE: case ByteCode.DASTORE: case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: pop(); case ByteCode.PUTFIELD: // pop; pop case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPNE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: pop(); case ByteCode.IFEQ: // pop case ByteCode.IFNE: case ByteCode.IFLT: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFNULL: case ByteCode.IFNONNULL: case ByteCode.POP: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.PUTSTATIC: pop(); break; case ByteCode.POP2: pop2(); break; case ByteCode.ACONST_NULL: push(TypeInfo.NULL); break; case ByteCode.IALOAD: // pop; pop; push(INTEGER) case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: case ByteCode.IADD: case ByteCode.ISUB: case ByteCode.IMUL: case ByteCode.IDIV: case ByteCode.IREM: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.IUSHR: case ByteCode.IAND: case ByteCode.IOR: case ByteCode.IXOR: case ByteCode.LCMP: case ByteCode.FCMPL: case ByteCode.FCMPG: case ByteCode.DCMPL: case ByteCode.DCMPG: pop(); case ByteCode.INEG: // pop; push(INTEGER) case ByteCode.L2I: case ByteCode.F2I: case ByteCode.D2I: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2S: case ByteCode.ARRAYLENGTH: case ByteCode.INSTANCEOF: pop(); case ByteCode.ICONST_M1: // push(INTEGER) case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.BIPUSH: case ByteCode.SIPUSH: push(TypeInfo.INTEGER); break; case ByteCode.LALOAD: // pop; pop; push(LONG) case ByteCode.LADD: case ByteCode.LSUB: case ByteCode.LMUL: case ByteCode.LDIV: case ByteCode.LREM: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.LAND: case ByteCode.LOR: case ByteCode.LXOR: pop(); case ByteCode.LNEG: // pop; push(LONG) case ByteCode.I2L: case ByteCode.F2L: case ByteCode.D2L: pop(); case ByteCode.LCONST_0: // push(LONG) case ByteCode.LCONST_1: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: push(TypeInfo.LONG); break; case ByteCode.FALOAD: // pop; pop; push(FLOAT) case ByteCode.FADD: case ByteCode.FSUB: case ByteCode.FMUL: case ByteCode.FDIV: case ByteCode.FREM: pop(); case ByteCode.FNEG: // pop; push(FLOAT) case ByteCode.I2F: case ByteCode.L2F: case ByteCode.D2F: pop(); case ByteCode.FCONST_0: // push(FLOAT) case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: push(TypeInfo.FLOAT); break; case ByteCode.DALOAD: // pop; pop; push(DOUBLE) case ByteCode.DADD: case ByteCode.DSUB: case ByteCode.DMUL: case ByteCode.DDIV: case ByteCode.DREM: pop(); case ByteCode.DNEG: // pop; push(DOUBLE) case ByteCode.I2D: case ByteCode.L2D: case ByteCode.F2D: pop(); case ByteCode.DCONST_0: // push(DOUBLE) case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: push(TypeInfo.DOUBLE); break; case ByteCode.ISTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.INTEGER); break; case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: executeStore(bc - ByteCode.ISTORE_0, TypeInfo.INTEGER); break; case ByteCode.LSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.LONG); break; case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: executeStore(bc - ByteCode.LSTORE_0, TypeInfo.LONG); break; case ByteCode.FSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.FLOAT); break; case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: executeStore(bc - ByteCode.FSTORE_0, TypeInfo.FLOAT); break; case ByteCode.DSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.DOUBLE); break; case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: executeStore(bc - ByteCode.DSTORE_0, TypeInfo.DOUBLE); break; case ByteCode.ALOAD: executeALoad(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: executeALoad(bc - ByteCode.ALOAD_0); break; case ByteCode.ASTORE: executeAStore(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: executeAStore(bc - ByteCode.ASTORE_0); break; case ByteCode.IRETURN: case ByteCode.LRETURN: case ByteCode.FRETURN: case ByteCode.DRETURN: case ByteCode.ARETURN: case ByteCode.RETURN: clearStack(); break; case ByteCode.ATHROW: type = pop(); clearStack(); push(type); break; case ByteCode.SWAP: type = pop(); type2 = pop(); push(type); push(type2); break; case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.LDC2_W: if (bc == ByteCode.LDC) { index = getOperand(bci + 1); } else { index = getOperand(bci + 1, 2); } byte constType = itsConstantPool.getConstantType(index); switch (constType) { case ConstantPool.CONSTANT_Double: push(TypeInfo.DOUBLE); break; case ConstantPool.CONSTANT_Float: push(TypeInfo.FLOAT); break; case ConstantPool.CONSTANT_Long: push(TypeInfo.LONG); break; case ConstantPool.CONSTANT_Integer: push(TypeInfo.INTEGER); break; case ConstantPool.CONSTANT_String: push(TypeInfo.OBJECT("java/lang/String", itsConstantPool)); break; default: throw new IllegalArgumentException( "bad const type " + constType); } break; case ByteCode.NEW: push(TypeInfo.UNINITIALIZED_VARIABLE(bci)); break; case ByteCode.NEWARRAY: pop(); char componentType = arrayTypeToName(itsCodeBuffer[bci + 1]); index = itsConstantPool.addClass("[" + componentType); push(TypeInfo.OBJECT((short) index)); break; case ByteCode.ANEWARRAY: index = getOperand(bci + 1, 2); className = (String) itsConstantPool.getConstantData(index); pop(); push(TypeInfo.OBJECT("[L" + className + ';', itsConstantPool)); break; case ByteCode.INVOKEVIRTUAL: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEINTERFACE: index = getOperand(bci + 1, 2); FieldOrMethodRef m = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String methodType = m.getType(); String methodName = m.getName(); int parameterCount = sizeOfParameters(methodType) >>> 16; for (int i = 0; i < parameterCount; i++) { pop(); } if (bc != ByteCode.INVOKESTATIC) { int instType = pop(); int tag = TypeInfo.getTag(instType); if (tag == TypeInfo.UNINITIALIZED_VARIABLE(0) || tag == TypeInfo.UNINITIALIZED_THIS) { if ("<init>".equals(methodName)) { int newType = TypeInfo.OBJECT(itsThisClassIndex); initializeTypeInfo(instType, newType); } else { throw new IllegalStateException("bad instance"); } } } int rParen = methodType.indexOf(')'); String returnType = methodType.substring(rParen + 1); returnType = descriptorToInternalName(returnType); if (!returnType.equals("V")) { push(TypeInfo.fromType(returnType, itsConstantPool)); } break; case ByteCode.GETFIELD: pop(); case ByteCode.GETSTATIC: index = getOperand(bci + 1, 2); FieldOrMethodRef f = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String fieldType = descriptorToInternalName(f.getType()); push(TypeInfo.fromType(fieldType, itsConstantPool)); break; case ByteCode.DUP: type = pop(); push(type); push(type); break; case ByteCode.DUP_X1: type = pop(); type2 = pop(); push(type); push(type2); push(type); break; case ByteCode.DUP_X2: type = pop(); lType = pop2(); push(type); push2(lType); push(type); break; case ByteCode.DUP2: lType = pop2(); push2(lType); push2(lType); break; case ByteCode.DUP2_X1: lType = pop2(); type = pop(); push2(lType); push(type); push2(lType); break; case ByteCode.DUP2_X2: lType = pop2(); lType2 = pop2(); push2(lType); push2(lType2); push2(lType); break; case ByteCode.TABLESWITCH: int switchStart = bci + 1 + (3 & ~bci); int low = getOperand(switchStart + 4, 4); int high = getOperand(switchStart + 8, 4); length = 4 * (high - low + 4) + switchStart - bci; pop(); break; case ByteCode.AALOAD: pop(); int typeIndex = pop() >>> 8; className = (String) itsConstantPool.getConstantData(typeIndex); String arrayType = className; if (arrayType.charAt(0) != '[') { throw new IllegalStateException("bad array type"); } String elementDesc = arrayType.substring(1); String elementType = descriptorToInternalName(elementDesc); typeIndex = itsConstantPool.addClass(elementType); push(TypeInfo.OBJECT(typeIndex)); break; case ByteCode.WIDE: // Alters behaviour of next instruction wide = true; break; case ByteCode.MULTIANEWARRAY: case ByteCode.LOOKUPSWITCH: // Currently not used in any part of Rhino, so ignore it case ByteCode.JSR: // TODO: JSR is deprecated case ByteCode.RET: case ByteCode.JSR_W: default: throw new IllegalArgumentException("bad opcode: " + bc); } if (length == 0) { length = opcodeLength(bc, wide); } if (wide && bc != ByteCode.WIDE) { wide = false; } return length; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void executeALoad(int localIndex) { int type = getLocal(localIndex); int tag = TypeInfo.getTag(type); if (tag == TypeInfo.OBJECT_TAG || tag == TypeInfo.UNINITIALIZED_THIS || tag == TypeInfo.UNINITIALIZED_VAR_TAG || tag == TypeInfo.NULL) { push(type); } else { throw new IllegalStateException("bad local variable type: " + type + " at index: " + localIndex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static void badStack(int value) { String s; if (value < 0) { s = "Stack underflow: "+value; } else { s = "Too big stack: "+value; } throw new IllegalStateException(s); }
3
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
0
(Lib) UnsupportedOperationException 40
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreComments(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreWhitespace(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreProcessingInstructions(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setPrettyPrinting(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setPrettyIndent(int i) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreComments() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreProcessingInstructions() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreWhitespace() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isPrettyPrinting() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public int getPrettyIndent() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object put(Object key, Object value) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void putAll(Map m) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void clear() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object setValue(Object value) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public void captureStackInfo(RhinoException ex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public String getSourcePositionFromStack(Context cx, int[] linep) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public String getPatchedStack(RhinoException ex, String nativeStackTrace) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public List<String> getScriptStack(RhinoException ex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public void setEvalScriptFlag(Script script) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void remove() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void add(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void set(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean add(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean addAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean removeAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean retainAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void clear() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void add(int index, Object element) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean addAll(int index, Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object set(int index, Object element) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object remove(int index) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public List subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public void error(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Jump.java
Override public void visit(NodeVisitor visitor) { throw new UnsupportedOperationException(this.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Jump.java
Override public String toSource(int depth) { throw new UnsupportedOperationException(this.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ArrayComprehensionLoop.java
public void setBody(AstNode body) { throw new UnsupportedOperationException("this node type has no body"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/GeneratorExpressionLoop.java
Override public void setIsForEach(boolean isForEach) { throw new UnsupportedOperationException("this node type does not support for each"); }
0 0
(Lib) RuntimeException 29
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
private RuntimeException badTree(Node node) { throw new RuntimeException(node.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public Script createScriptObject(Object bytecode, Object staticSecurityDomain) { Class<?> cl = defineClass(bytecode, staticSecurityDomain); Script script; try { script = (Script)cl.newInstance(); } catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); } return script; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public Function createFunctionObject(Context cx, Scriptable scope, Object bytecode, Object staticSecurityDomain) { Class<?> cl = defineClass(bytecode, staticSecurityDomain); NativeFunction f; try { Constructor<?>ctor = cl.getConstructors()[0]; Object[] initArgs = { scope, cx, Integer.valueOf(0) }; f = (NativeFunction)ctor.newInstance(initArgs); } catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); } return f; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private Class<?> defineClass(Object bytecode, Object staticSecurityDomain) { Object[] nameBytesPair = (Object[])bytecode; String className = (String)nameBytesPair[0]; byte[] classBytes = (byte[])nameBytesPair[1]; // The generated classes in this case refer only to Rhino classes // which must be accessible through this class loader ClassLoader rhinoLoader = getClass().getClassLoader(); GeneratedClassLoader loader; loader = SecurityController.createLoader(rhinoLoader, staticSecurityDomain); Exception e; try { Class<?> cl = loader.defineClass(className, classBytes); loader.linkClass(cl); return cl; } catch (SecurityException x) { e = x; } catch (IllegalArgumentException x) { e = x; } throw new RuntimeException("Malformed optimizer package " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
static RuntimeException badTree() { throw new RuntimeException("Bad tree in codegen"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private void generateExpression(Node node, Node parent) { int type = node.getType(); Node child = node.getFirstChild(); switch (type) { case Token.USE_STACK: break; case Token.FUNCTION: if (fnCurrent != null || parent.getType() != Token.SCRIPT) { int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP); OptFunctionNode ofn = OptFunctionNode.get(scriptOrFn, fnIndex); int t = ofn.fnode.getFunctionType(); if (t != FunctionNode.FUNCTION_EXPRESSION) { throw Codegen.badTree(); } visitFunction(ofn, t); } break; case Token.NAME: { cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); cfw.addPush(node.getString()); addScriptRuntimeInvoke( "name", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/String;" +")Ljava/lang/Object;"); } break; case Token.CALL: case Token.NEW: { int specialType = node.getIntProp(Node.SPECIALCALL_PROP, Node.NON_SPECIALCALL); if (specialType == Node.NON_SPECIALCALL) { OptFunctionNode target; target = (OptFunctionNode)node.getProp( Node.DIRECTCALL_PROP); if (target != null) { visitOptimizedCall(node, target, type, child); } else if (type == Token.CALL) { visitStandardCall(node, child); } else { visitStandardNew(node, child); } } else { visitSpecialCall(node, type, specialType, child); } } break; case Token.REF_CALL: generateFunctionAndThisObj(child, node); // stack: ... functionObj thisObj child = child.getNext(); generateCallArgArray(node, child, false); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "callRef", "(Lorg/mozilla/javascript/Callable;" +"Lorg/mozilla/javascript/Scriptable;" +"[Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Lorg/mozilla/javascript/Ref;"); break; case Token.NUMBER: { double num = node.getDouble(); if (node.getIntProp(Node.ISNUMBER_PROP, -1) != -1) { cfw.addPush(num); } else { codegen.pushNumberAsObject(cfw, num); } } break; case Token.STRING: cfw.addPush(node.getString()); break; case Token.THIS: cfw.addALoad(thisObjLocal); break; case Token.THISFN: cfw.add(ByteCode.ALOAD_0); break; case Token.NULL: cfw.add(ByteCode.ACONST_NULL); break; case Token.TRUE: cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "TRUE", "Ljava/lang/Boolean;"); break; case Token.FALSE: cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "FALSE", "Ljava/lang/Boolean;"); break; case Token.REGEXP: { // Create a new wrapper around precompiled regexp cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); int i = node.getExistingIntProp(Node.REGEXP_PROP); cfw.add(ByteCode.GETSTATIC, codegen.mainClassName, codegen.getCompiledRegexpName(scriptOrFn, i), "Ljava/lang/Object;"); cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/ScriptRuntime", "wrapRegExp", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/Object;" +")Lorg/mozilla/javascript/Scriptable;"); } break; case Token.COMMA: { Node next = child.getNext(); while (next != null) { generateExpression(child, node); cfw.add(ByteCode.POP); child = next; next = next.getNext(); } generateExpression(child, node); break; } case Token.ENUM_NEXT: case Token.ENUM_ID: { int local = getLocalBlockRegister(node); cfw.addALoad(local); if (type == Token.ENUM_NEXT) { addScriptRuntimeInvoke( "enumNext", "(Ljava/lang/Object;)Ljava/lang/Boolean;"); } else { cfw.addALoad(contextLocal); addScriptRuntimeInvoke("enumId", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } break; } case Token.ARRAYLIT: visitArrayLiteral(node, child, false); break; case Token.OBJECTLIT: visitObjectLiteral(node, child, false); break; case Token.NOT: { int trueTarget = cfw.acquireLabel(); int falseTarget = cfw.acquireLabel(); int beyond = cfw.acquireLabel(); generateIfJump(child, node, trueTarget, falseTarget); cfw.markLabel(trueTarget); cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "FALSE", "Ljava/lang/Boolean;"); cfw.add(ByteCode.GOTO, beyond); cfw.markLabel(falseTarget); cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "TRUE", "Ljava/lang/Boolean;"); cfw.markLabel(beyond); cfw.adjustStackTop(-1); break; } case Token.BITNOT: generateExpression(child, node); addScriptRuntimeInvoke("toInt32", "(Ljava/lang/Object;)I"); cfw.addPush(-1); // implement ~a as (a ^ -1) cfw.add(ByteCode.IXOR); cfw.add(ByteCode.I2D); addDoubleWrap(); break; case Token.VOID: generateExpression(child, node); cfw.add(ByteCode.POP); Codegen.pushUndefined(cfw); break; case Token.TYPEOF: generateExpression(child, node); addScriptRuntimeInvoke("typeof", "(Ljava/lang/Object;" +")Ljava/lang/String;"); break; case Token.TYPEOFNAME: visitTypeofname(node); break; case Token.INC: case Token.DEC: visitIncDec(node); break; case Token.OR: case Token.AND: { generateExpression(child, node); cfw.add(ByteCode.DUP); addScriptRuntimeInvoke("toBoolean", "(Ljava/lang/Object;)Z"); int falseTarget = cfw.acquireLabel(); if (type == Token.AND) cfw.add(ByteCode.IFEQ, falseTarget); else cfw.add(ByteCode.IFNE, falseTarget); cfw.add(ByteCode.POP); generateExpression(child.getNext(), node); cfw.markLabel(falseTarget); } break; case Token.HOOK : { Node ifThen = child.getNext(); Node ifElse = ifThen.getNext(); generateExpression(child, node); addScriptRuntimeInvoke("toBoolean", "(Ljava/lang/Object;)Z"); int elseTarget = cfw.acquireLabel(); cfw.add(ByteCode.IFEQ, elseTarget); short stack = cfw.getStackTop(); generateExpression(ifThen, node); int afterHook = cfw.acquireLabel(); cfw.add(ByteCode.GOTO, afterHook); cfw.markLabel(elseTarget, stack); generateExpression(ifElse, node); cfw.markLabel(afterHook); } break; case Token.ADD: { generateExpression(child, node); generateExpression(child.getNext(), node); switch (node.getIntProp(Node.ISNUMBER_PROP, -1)) { case Node.BOTH: cfw.add(ByteCode.DADD); break; case Node.LEFT: addOptRuntimeInvoke("add", "(DLjava/lang/Object;)Ljava/lang/Object;"); break; case Node.RIGHT: addOptRuntimeInvoke("add", "(Ljava/lang/Object;D)Ljava/lang/Object;"); break; default: if (child.getType() == Token.STRING) { addScriptRuntimeInvoke("add", "(Ljava/lang/CharSequence;" +"Ljava/lang/Object;" +")Ljava/lang/CharSequence;"); } else if (child.getNext().getType() == Token.STRING) { addScriptRuntimeInvoke("add", "(Ljava/lang/Object;" +"Ljava/lang/CharSequence;" +")Ljava/lang/CharSequence;"); } else { cfw.addALoad(contextLocal); addScriptRuntimeInvoke("add", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } } } break; case Token.MUL: visitArithmetic(node, ByteCode.DMUL, child, parent); break; case Token.SUB: visitArithmetic(node, ByteCode.DSUB, child, parent); break; case Token.DIV: case Token.MOD: visitArithmetic(node, type == Token.DIV ? ByteCode.DDIV : ByteCode.DREM, child, parent); break; case Token.BITOR: case Token.BITXOR: case Token.BITAND: case Token.LSH: case Token.RSH: case Token.URSH: visitBitOp(node, type, child); break; case Token.POS: case Token.NEG: generateExpression(child, node); addObjectToDouble(); if (type == Token.NEG) { cfw.add(ByteCode.DNEG); } addDoubleWrap(); break; case Token.TO_DOUBLE: // cnvt to double (not Double) generateExpression(child, node); addObjectToDouble(); break; case Token.TO_OBJECT: { // convert from double int prop = -1; if (child.getType() == Token.NUMBER) { prop = child.getIntProp(Node.ISNUMBER_PROP, -1); } if (prop != -1) { child.removeProp(Node.ISNUMBER_PROP); generateExpression(child, node); child.putIntProp(Node.ISNUMBER_PROP, prop); } else { generateExpression(child, node); addDoubleWrap(); } break; } case Token.IN: case Token.INSTANCEOF: case Token.LE: case Token.LT: case Token.GE: case Token.GT: { int trueGOTO = cfw.acquireLabel(); int falseGOTO = cfw.acquireLabel(); visitIfJumpRelOp(node, child, trueGOTO, falseGOTO); addJumpedBooleanWrap(trueGOTO, falseGOTO); break; } case Token.EQ: case Token.NE: case Token.SHEQ: case Token.SHNE: { int trueGOTO = cfw.acquireLabel(); int falseGOTO = cfw.acquireLabel(); visitIfJumpEqOp(node, child, trueGOTO, falseGOTO); addJumpedBooleanWrap(trueGOTO, falseGOTO); break; } case Token.GETPROP: case Token.GETPROPNOWARN: visitGetProp(node, child); break; case Token.GETELEM: generateExpression(child, node); // object generateExpression(child.getNext(), node); // id cfw.addALoad(contextLocal); if (node.getIntProp(Node.ISNUMBER_PROP, -1) != -1) { addScriptRuntimeInvoke( "getObjectIndex", "(Ljava/lang/Object;D" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } else { cfw.addALoad(variableObjectLocal); addScriptRuntimeInvoke( "getObjectElem", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +")Ljava/lang/Object;"); } break; case Token.GET_REF: generateExpression(child, node); // reference cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refGet", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.GETVAR: visitGetVar(node); break; case Token.SETVAR: visitSetVar(node, child, true); break; case Token.SETNAME: visitSetName(node, child); break; case Token.STRICT_SETNAME: visitStrictSetName(node, child); break; case Token.SETCONST: visitSetConst(node, child); break; case Token.SETCONSTVAR: visitSetConstVar(node, child, true); break; case Token.SETPROP: case Token.SETPROP_OP: visitSetProp(type, node, child); break; case Token.SETELEM: case Token.SETELEM_OP: visitSetElem(type, node, child); break; case Token.SET_REF: case Token.SET_REF_OP: { generateExpression(child, node); child = child.getNext(); if (type == Token.SET_REF_OP) { cfw.add(ByteCode.DUP); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refGet", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refSet", "(Lorg/mozilla/javascript/Ref;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } break; case Token.DEL_REF: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("refDel", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.DELPROP: boolean isName = child.getType() == Token.BINDNAME; generateExpression(child, node); child = child.getNext(); generateExpression(child, node); cfw.addALoad(contextLocal); cfw.addPush(isName); addScriptRuntimeInvoke("delete", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Z)Ljava/lang/Object;"); break; case Token.BINDNAME: { while (child != null) { generateExpression(child, node); child = child.getNext(); } // Generate code for "ScriptRuntime.bind(varObj, "s")" cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); cfw.addPush(node.getString()); addScriptRuntimeInvoke( "bind", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/String;" +")Lorg/mozilla/javascript/Scriptable;"); } break; case Token.LOCAL_LOAD: cfw.addALoad(getLocalBlockRegister(node)); break; case Token.REF_SPECIAL: { String special = (String)node.getProp(Node.NAME_PROP); generateExpression(child, node); cfw.addPush(special); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "specialRef", "(Ljava/lang/Object;" +"Ljava/lang/String;" +"Lorg/mozilla/javascript/Context;" +")Lorg/mozilla/javascript/Ref;"); } break; case Token.REF_MEMBER: case Token.REF_NS_MEMBER: case Token.REF_NAME: case Token.REF_NS_NAME: { int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0); // generate possible target, possible namespace and member do { generateExpression(child, node); child = child.getNext(); } while (child != null); cfw.addALoad(contextLocal); String methodName, signature; switch (type) { case Token.REF_MEMBER: methodName = "memberRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"I" +")Lorg/mozilla/javascript/Ref;"; break; case Token.REF_NS_MEMBER: methodName = "memberRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"I" +")Lorg/mozilla/javascript/Ref;"; break; case Token.REF_NAME: methodName = "nameRef"; signature = "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"I" +")Lorg/mozilla/javascript/Ref;"; cfw.addALoad(variableObjectLocal); break; case Token.REF_NS_NAME: methodName = "nameRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"I" +")Lorg/mozilla/javascript/Ref;"; cfw.addALoad(variableObjectLocal); break; default: throw Kit.codeBug(); } cfw.addPush(memberTypeFlags); addScriptRuntimeInvoke(methodName, signature); } break; case Token.DOTQUERY: visitDotQuery(node, child); break; case Token.ESCXMLATTR: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("escapeAttributeValue", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/String;"); break; case Token.ESCXMLTEXT: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("escapeTextValue", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/String;"); break; case Token.DEFAULTNAMESPACE: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("setDefaultNamespace", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.YIELD: generateYieldPoint(node, true); break; case Token.WITHEXPR: { Node enterWith = child; Node with = enterWith.getNext(); Node leaveWith = with.getNext(); generateStatement(enterWith); generateExpression(with.getFirstChild(), with); generateStatement(leaveWith); break; } case Token.ARRAYCOMP: { Node initStmt = child; Node expr = child.getNext(); generateStatement(initStmt); generateExpression(expr, node); break; } default: throw new RuntimeException("Unexpected node type "+type); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
public Scriptable requireMain(Context cx, String mainModuleId) { if(this.mainModuleId != null) { if (!this.mainModuleId.equals(mainModuleId)) { throw new IllegalStateException("Main module already set to " + this.mainModuleId); } return mainExports; } ModuleScript moduleScript; try { // try to get the module script to see if it is on the module path moduleScript = moduleScriptProvider.getModuleScript( cx, mainModuleId, null, paths); } catch (RuntimeException x) { throw x; } catch (Exception x) { throw new RuntimeException(x); } if (moduleScript != null) { mainExports = getExportedModuleInterface(cx, mainModuleId, null, true); } else if (!sandboxed) { URI mainUri = null; // try to resolve to an absolute URI or file path try { mainUri = new URI(mainModuleId); } catch (URISyntaxException usx) { // fall through } // if not an absolute uri resolve to a file path if (mainUri == null || !mainUri.isAbsolute()) { File file = new File(mainModuleId); if (!file.isFile()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + mainModuleId + "\" not found."); } mainUri = file.toURI(); } mainExports = getExportedModuleInterface(cx, mainUri.toString(), mainUri, true); } this.mainModuleId = mainModuleId; return mainExports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public Node getChildBefore(Node child) { if (child == first) return null; Node n = first; while (n.next != child) { n = n.next; if (n == null) throw new RuntimeException("node is not a child"); } return n; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void addChildBefore(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildBefore"); if (first == node) { newChild.next = first; first = newChild; return; } Node prev = getChildBefore(node); addChildAfter(newChild, prev); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void addChildAfter(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildAfter"); newChild.next = node.next; node.next = newChild; if (last == node) last = newChild; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
public void setStackProvider(RhinoException re) { // We go some extra miles to make sure the stack property is only // generated on demand, is cached after the first access, and is // overwritable like an ordinary property. Hence this setup with // the getter and setter below. if (stackProvider == null) { stackProvider = re; try { defineProperty("stack", null, NativeError.class.getMethod("getStack"), NativeError.class.getMethod("setStack", Object.class), 0); } catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
static void generateReturnResult(ClassFileWriter cfw, Class<?> retType, boolean callConvertResult) { // wrap boolean values with java.lang.Boolean, convert all other // primitive values to java.lang.Double. if (retType == Void.TYPE) { cfw.add(ByteCode.POP); cfw.add(ByteCode.RETURN); } else if (retType == Boolean.TYPE) { cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toBoolean", "(Ljava/lang/Object;)Z"); cfw.add(ByteCode.IRETURN); } else if (retType == Character.TYPE) { // characters are represented as strings in JavaScript. // return the first character. // first convert the value to a string if possible. cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toString", "(Ljava/lang/Object;)Ljava/lang/String;"); cfw.add(ByteCode.ICONST_0); cfw.addInvoke(ByteCode.INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); cfw.add(ByteCode.IRETURN); } else if (retType.isPrimitive()) { cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toNumber", "(Ljava/lang/Object;)D"); String typeName = retType.getName(); switch (typeName.charAt(0)) { case 'b': case 's': case 'i': cfw.add(ByteCode.D2I); cfw.add(ByteCode.IRETURN); break; case 'l': cfw.add(ByteCode.D2L); cfw.add(ByteCode.LRETURN); break; case 'f': cfw.add(ByteCode.D2F); cfw.add(ByteCode.FRETURN); break; case 'd': cfw.add(ByteCode.DRETURN); break; default: throw new RuntimeException("Unexpected return type " + retType.toString()); } } else { String retTypeStr = retType.getName(); if (callConvertResult) { cfw.addLoadConstant(retTypeStr); cfw.addInvoke(ByteCode.INVOKESTATIC, "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;"); cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/JavaAdapter", "convertResult", "(Ljava/lang/Object;" +"Ljava/lang/Class;" +")Ljava/lang/Object;"); } // Now cast to return type cfw.add(ByteCode.CHECKCAST, retTypeStr); cfw.add(ByteCode.ARETURN); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
public DiyFp clone() { try { return (DiyFp) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onEmptyStackTopRead() { throw new RuntimeException("Empty stack"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ClassCache.java
public static ClassCache get(Scriptable scope) { ClassCache cache = (ClassCache) ScriptableObject.getTopScopeValue(scope, AKEY); if (cache == null) { throw new RuntimeException("Can't find top level scope for " + "ClassCache.get"); } return cache; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
public static String decompile(String source, int flags, UintMap properties) { int length = source.length(); if (length == 0) { return ""; } int indent = properties.getInt(INITIAL_INDENT_PROP, 0); if (indent < 0) throw new IllegalArgumentException(); int indentGap = properties.getInt(INDENT_GAP_PROP, 4); if (indentGap < 0) throw new IllegalArgumentException(); int caseGap = properties.getInt(CASE_GAP_PROP, 2); if (caseGap < 0) throw new IllegalArgumentException(); StringBuffer result = new StringBuffer(); boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG)); boolean toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG)); // Spew tokens in source, for debugging. // as TYPE number char if (printSource) { System.err.println("length:" + length); for (int i = 0; i < length; ++i) { // Note that tokenToName will fail unless Context.printTrees // is true. String tokenname = null; if (Token.printNames) { tokenname = Token.name(source.charAt(i)); } if (tokenname == null) { tokenname = "---"; } String pad = tokenname.length() > 7 ? "\t" : "\t\t"; System.err.println (tokenname + pad + (int)source.charAt(i) + "\t'" + ScriptRuntime.escapeString (source.substring(i, i+1)) + "'"); } System.err.println(); } int braceNesting = 0; boolean afterFirstEOL = false; int i = 0; int topFunctionType; if (source.charAt(i) == Token.SCRIPT) { ++i; topFunctionType = -1; } else { topFunctionType = source.charAt(i + 1); } if (!toSource) { // add an initial newline to exactly match js. result.append('\n'); for (int j = 0; j < indent; j++) result.append(' '); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append('('); } } while (i < length) { switch(source.charAt(i)) { case Token.GET: case Token.SET: result.append(source.charAt(i) == Token.GET ? "get " : "set "); ++i; i = printSourceString(source, i + 1, false, result); // Now increment one more to get past the FUNCTION token ++i; break; case Token.NAME: case Token.REGEXP: // re-wrapped in '/'s in parser... i = printSourceString(source, i + 1, false, result); continue; case Token.STRING: i = printSourceString(source, i + 1, true, result); continue; case Token.NUMBER: i = printSourceNumber(source, i + 1, result); continue; case Token.TRUE: result.append("true"); break; case Token.FALSE: result.append("false"); break; case Token.NULL: result.append("null"); break; case Token.THIS: result.append("this"); break; case Token.FUNCTION: ++i; // skip function type result.append("function "); break; case FUNCTION_END: // Do nothing break; case Token.COMMA: result.append(", "); break; case Token.LC: ++braceNesting; if (Token.EOL == getNext(source, length, i)) indent += indentGap; result.append('{'); break; case Token.RC: { --braceNesting; /* don't print the closing RC if it closes the * toplevel function and we're called from * decompileFunctionBody. */ if (justFunctionBody && braceNesting == 0) break; result.append('}'); switch (getNext(source, length, i)) { case Token.EOL: case FUNCTION_END: indent -= indentGap; break; case Token.WHILE: case Token.ELSE: indent -= indentGap; result.append(' '); break; } break; } case Token.LP: result.append('('); break; case Token.RP: result.append(')'); if (Token.LC == getNext(source, length, i)) result.append(' '); break; case Token.LB: result.append('['); break; case Token.RB: result.append(']'); break; case Token.EOL: { if (toSource) break; boolean newLine = true; if (!afterFirstEOL) { afterFirstEOL = true; if (justFunctionBody) { /* throw away just added 'function name(...) {' * and restore the original indent */ result.setLength(0); indent -= indentGap; newLine = false; } } if (newLine) { result.append('\n'); } /* add indent if any tokens remain, * less setback if next token is * a label, case or default. */ if (i + 1 < length) { int less = 0; int nextToken = source.charAt(i + 1); if (nextToken == Token.CASE || nextToken == Token.DEFAULT) { less = indentGap - caseGap; } else if (nextToken == Token.RC) { less = indentGap; } /* elaborate check against label... skip past a * following inlined NAME and look for a COLON. */ else if (nextToken == Token.NAME) { int afterName = getSourceStringEnd(source, i + 2); if (source.charAt(afterName) == Token.COLON) less = indentGap; } for (; less < indent; less++) result.append(' '); } break; } case Token.DOT: result.append('.'); break; case Token.NEW: result.append("new "); break; case Token.DELPROP: result.append("delete "); break; case Token.IF: result.append("if "); break; case Token.ELSE: result.append("else "); break; case Token.FOR: result.append("for "); break; case Token.IN: result.append(" in "); break; case Token.WITH: result.append("with "); break; case Token.WHILE: result.append("while "); break; case Token.DO: result.append("do "); break; case Token.TRY: result.append("try "); break; case Token.CATCH: result.append("catch "); break; case Token.FINALLY: result.append("finally "); break; case Token.THROW: result.append("throw "); break; case Token.SWITCH: result.append("switch "); break; case Token.BREAK: result.append("break"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CONTINUE: result.append("continue"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CASE: result.append("case "); break; case Token.DEFAULT: result.append("default"); break; case Token.RETURN: result.append("return"); if (Token.SEMI != getNext(source, length, i)) result.append(' '); break; case Token.VAR: result.append("var "); break; case Token.LET: result.append("let "); break; case Token.SEMI: result.append(';'); if (Token.EOL != getNext(source, length, i)) { // separators in FOR result.append(' '); } break; case Token.ASSIGN: result.append(" = "); break; case Token.ASSIGN_ADD: result.append(" += "); break; case Token.ASSIGN_SUB: result.append(" -= "); break; case Token.ASSIGN_MUL: result.append(" *= "); break; case Token.ASSIGN_DIV: result.append(" /= "); break; case Token.ASSIGN_MOD: result.append(" %= "); break; case Token.ASSIGN_BITOR: result.append(" |= "); break; case Token.ASSIGN_BITXOR: result.append(" ^= "); break; case Token.ASSIGN_BITAND: result.append(" &= "); break; case Token.ASSIGN_LSH: result.append(" <<= "); break; case Token.ASSIGN_RSH: result.append(" >>= "); break; case Token.ASSIGN_URSH: result.append(" >>>= "); break; case Token.HOOK: result.append(" ? "); break; case Token.OBJECTLIT: // pun OBJECTLIT to mean colon in objlit property // initialization. // This needs to be distinct from COLON in the general case // to distinguish from the colon in a ternary... which needs // different spacing. result.append(':'); break; case Token.COLON: if (Token.EOL == getNext(source, length, i)) // it's the end of a label result.append(':'); else // it's the middle part of a ternary result.append(" : "); break; case Token.OR: result.append(" || "); break; case Token.AND: result.append(" && "); break; case Token.BITOR: result.append(" | "); break; case Token.BITXOR: result.append(" ^ "); break; case Token.BITAND: result.append(" & "); break; case Token.SHEQ: result.append(" === "); break; case Token.SHNE: result.append(" !== "); break; case Token.EQ: result.append(" == "); break; case Token.NE: result.append(" != "); break; case Token.LE: result.append(" <= "); break; case Token.LT: result.append(" < "); break; case Token.GE: result.append(" >= "); break; case Token.GT: result.append(" > "); break; case Token.INSTANCEOF: result.append(" instanceof "); break; case Token.LSH: result.append(" << "); break; case Token.RSH: result.append(" >> "); break; case Token.URSH: result.append(" >>> "); break; case Token.TYPEOF: result.append("typeof "); break; case Token.VOID: result.append("void "); break; case Token.CONST: result.append("const "); break; case Token.YIELD: result.append("yield "); break; case Token.NOT: result.append('!'); break; case Token.BITNOT: result.append('~'); break; case Token.POS: result.append('+'); break; case Token.NEG: result.append('-'); break; case Token.INC: result.append("++"); break; case Token.DEC: result.append("--"); break; case Token.ADD: result.append(" + "); break; case Token.SUB: result.append(" - "); break; case Token.MUL: result.append(" * "); break; case Token.DIV: result.append(" / "); break; case Token.MOD: result.append(" % "); break; case Token.COLONCOLON: result.append("::"); break; case Token.DOTDOT: result.append(".."); break; case Token.DOTQUERY: result.append(".("); break; case Token.XMLATTR: result.append('@'); break; case Token.DEBUGGER: result.append("debugger;\n"); break; default: // If we don't know how to decompile it, raise an exception. throw new RuntimeException("Token: " + Token.name(source.charAt(i))); } ++i; } if (!toSource) { // add that trailing newline if it's an outermost function. if (!justFunctionBody) result.append('\n'); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append(')'); } } return result.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
private static int printSourceNumber(String source, int offset, StringBuffer sb) { double number = 0.0; char type = source.charAt(offset); ++offset; if (type == 'S') { if (sb != null) { int ival = source.charAt(offset); number = ival; } ++offset; } else if (type == 'J' || type == 'D') { if (sb != null) { long lbits; lbits = (long)source.charAt(offset) << 48; lbits |= (long)source.charAt(offset + 1) << 32; lbits |= (long)source.charAt(offset + 2) << 16; lbits |= source.charAt(offset + 3); if (type == 'J') { number = lbits; } else { number = Double.longBitsToDouble(lbits); } } offset += 4; } else { // Bad source throw new RuntimeException(); } if (sb != null) { sb.append(ScriptRuntime.numberToString(number, 10)); } return offset; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static Object interpretLoop(Context cx, CallFrame frame, Object throwable) { // throwable holds exception object to rethrow or catch // It is also used for continuation restart in which case // it holds ContinuationJump final Object DBL_MRK = DOUBLE_MARK; final Object undefined = Undefined.instance; final boolean instructionCounting = (cx.instructionThreshold != 0); // arbitrary number to add to instructionCount when calling // other functions final int INVOCATION_COST = 100; // arbitrary exception cost for instruction counting final int EXCEPTION_COST = 100; String stringReg = null; int indexReg = -1; if (cx.lastInterpreterFrame != null) { // save the top frame from the previous interpretLoop // invocation on the stack if (cx.previousInterpreterInvocations == null) { cx.previousInterpreterInvocations = new ObjArray(); } cx.previousInterpreterInvocations.push(cx.lastInterpreterFrame); } // When restarting continuation throwable is not null and to jump // to the code that rewind continuation state indexReg should be set // to -1. // With the normal call throwable == null and indexReg == -1 allows to // catch bugs with using indeReg to access array elements before // initializing indexReg. GeneratorState generatorState = null; if (throwable != null) { if (throwable instanceof GeneratorState) { generatorState = (GeneratorState) throwable; // reestablish this call frame enterFrame(cx, frame, ScriptRuntime.emptyArgs, true); throwable = null; } else if (!(throwable instanceof ContinuationJump)) { // It should be continuation Kit.codeBug(); } } Object interpreterResult = null; double interpreterResultDbl = 0.0; StateLoop: for (;;) { withoutExceptions: try { if (throwable != null) { // Need to return both 'frame' and 'throwable' from // 'processThrowable', so just added a 'throwable' // member in 'frame'. frame = processThrowable(cx, throwable, frame, indexReg, instructionCounting); throwable = frame.throwable; frame.throwable = null; } else { if (generatorState == null && frame.frozen) Kit.codeBug(); } // Use local variables for constant values in frame // for faster access Object[] stack = frame.stack; double[] sDbl = frame.sDbl; Object[] vars = frame.varSource.stack; double[] varDbls = frame.varSource.sDbl; int[] varAttributes = frame.varSource.stackAttributes; byte[] iCode = frame.idata.itsICode; String[] strings = frame.idata.itsStringTable; // Use local for stackTop as well. Since execption handlers // can only exist at statement level where stack is empty, // it is necessary to save/restore stackTop only across // function calls and normal returns. int stackTop = frame.savedStackTop; // Store new frame in cx which is used for error reporting etc. cx.lastInterpreterFrame = frame; Loop: for (;;) { // Exception handler assumes that PC is already incremented // pass the instruction start when it searches the // exception handler int op = iCode[frame.pc++]; jumplessRun: { // Back indent to ease implementation reading switch (op) { case Icode_GENERATOR: { if (!frame.frozen) { // First time encountering this opcode: create new generator // object and return frame.pc--; // we want to come back here when we resume CallFrame generatorFrame = captureFrameForGenerator(frame); generatorFrame.frozen = true; NativeGenerator generator = new NativeGenerator(frame.scope, generatorFrame.fnOrScript, generatorFrame); frame.result = generator; break Loop; } else { // We are now resuming execution. Fall through to YIELD case. } } // fall through... case Token.YIELD: { if (!frame.frozen) { return freezeGenerator(cx, frame, stackTop, generatorState); } else { Object obj = thawGenerator(frame, stackTop, generatorState, op); if (obj != Scriptable.NOT_FOUND) { throwable = obj; break withoutExceptions; } continue Loop; } } case Icode_GENERATOR_END: { // throw StopIteration frame.frozen = true; int sourceLine = getIndex(iCode, frame.pc); generatorState.returnedException = new JavaScriptException( NativeIterator.getStopIterationObject(frame.scope), frame.idata.itsSourceFile, sourceLine); break Loop; } case Token.THROW: { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int sourceLine = getIndex(iCode, frame.pc); throwable = new JavaScriptException(value, frame.idata.itsSourceFile, sourceLine); break withoutExceptions; } case Token.RETHROW: { indexReg += frame.localShift; throwable = stack[indexReg]; break withoutExceptions; } case Token.GE : case Token.LE : case Token.GT : case Token.LT : { stackTop = doCompare(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.IN : case Token.INSTANCEOF : { stackTop = doInOrInstanceof(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.EQ : case Token.NE : { --stackTop; boolean valBln = doEquals(stack, sDbl, stackTop); valBln ^= (op == Token.NE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.SHEQ : case Token.SHNE : { --stackTop; boolean valBln = doShallowEquals(stack, sDbl, stackTop); valBln ^= (op == Token.SHNE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.IFNE : if (stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Token.IFEQ : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Icode_IFEQ_POP : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } stack[stackTop--] = null; break jumplessRun; case Token.GOTO : break jumplessRun; case Icode_GOSUB : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.pc + 2; break jumplessRun; case Icode_STARTSUB : if (stackTop == frame.emptyStackTop + 1) { // Call from Icode_GOSUB: store return PC address in the local indexReg += frame.localShift; stack[indexReg] = stack[stackTop]; sDbl[indexReg] = sDbl[stackTop]; --stackTop; } else { // Call from exception handler: exception object is already stored // in the local if (stackTop != frame.emptyStackTop) Kit.codeBug(); } continue Loop; case Icode_RETSUB : { // indexReg: local to store return address if (instructionCounting) { addInstructionCount(cx, frame, 0); } indexReg += frame.localShift; Object value = stack[indexReg]; if (value != DBL_MRK) { // Invocation from exception handler, restore object to rethrow throwable = value; break withoutExceptions; } // Normal return from GOSUB frame.pc = (int)sDbl[indexReg]; if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } case Icode_POP : stack[stackTop] = null; stackTop--; continue Loop; case Icode_POP_RESULT : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; stack[stackTop] = null; --stackTop; continue Loop; case Icode_DUP : stack[stackTop + 1] = stack[stackTop]; sDbl[stackTop + 1] = sDbl[stackTop]; stackTop++; continue Loop; case Icode_DUP2 : stack[stackTop + 1] = stack[stackTop - 1]; sDbl[stackTop + 1] = sDbl[stackTop - 1]; stack[stackTop + 2] = stack[stackTop]; sDbl[stackTop + 2] = sDbl[stackTop]; stackTop += 2; continue Loop; case Icode_SWAP : { Object o = stack[stackTop]; stack[stackTop] = stack[stackTop - 1]; stack[stackTop - 1] = o; double d = sDbl[stackTop]; sDbl[stackTop] = sDbl[stackTop - 1]; sDbl[stackTop - 1] = d; continue Loop; } case Token.RETURN : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; --stackTop; break Loop; case Token.RETURN_RESULT : break Loop; case Icode_RETUNDEF : frame.result = undefined; break Loop; case Token.BITNOT : { int rIntValue = stack_int32(frame, stackTop); stack[stackTop] = DBL_MRK; sDbl[stackTop] = ~rIntValue; continue Loop; } case Token.BITAND : case Token.BITOR : case Token.BITXOR : case Token.LSH : case Token.RSH : { stackTop = doBitOp(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.URSH : { double lDbl = stack_double(frame, stackTop - 1); int rIntValue = stack_int32(frame, stackTop) & 0x1F; stack[--stackTop] = DBL_MRK; sDbl[stackTop] = ScriptRuntime.toUint32(lDbl) >>> rIntValue; continue Loop; } case Token.NEG : case Token.POS : { double rDbl = stack_double(frame, stackTop); stack[stackTop] = DBL_MRK; if (op == Token.NEG) { rDbl = -rDbl; } sDbl[stackTop] = rDbl; continue Loop; } case Token.ADD : --stackTop; doAdd(stack, sDbl, stackTop, cx); continue Loop; case Token.SUB : case Token.MUL : case Token.DIV : case Token.MOD : { stackTop = doArithmetic(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.NOT : stack[stackTop] = ScriptRuntime.wrapBoolean( !stack_boolean(frame, stackTop)); continue Loop; case Token.BINDNAME : stack[++stackTop] = ScriptRuntime.bind(cx, frame.scope, stringReg); continue Loop; case Token.STRICT_SETNAME: case Token.SETNAME : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = op == Token.SETNAME ? ScriptRuntime.setName(lhs, rhs, cx, frame.scope, stringReg) : ScriptRuntime.strictSetName(lhs, rhs, cx, frame.scope, stringReg); continue Loop; } case Icode_SETCONST: { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = ScriptRuntime.setConst(lhs, rhs, cx, stringReg); continue Loop; } case Token.DELPROP : case Icode_DELNAME : { stackTop = doDelName(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.GETPROPNOWARN : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectPropNoWarn(lhs, stringReg, cx); continue Loop; } case Token.GETPROP : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx, frame.scope); continue Loop; } case Token.SETPROP : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setObjectProp(lhs, stringReg, rhs, cx); continue Loop; } case Icode_PROP_INC_DEC : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.propIncrDecr(lhs, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.GETELEM : { stackTop = doGetElem(cx, frame, stack, sDbl, stackTop); continue Loop; } case Token.SETELEM : { stackTop = doSetElem(cx, stack, sDbl, stackTop); continue Loop; } case Icode_ELEM_INC_DEC: { stackTop = doElemIncDec(cx, frame, iCode, stack, sDbl, stackTop); continue Loop; } case Token.GET_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refGet(ref, cx); continue Loop; } case Token.SET_REF : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refSet(ref, value, cx); continue Loop; } case Token.DEL_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refDel(ref, cx); continue Loop; } case Icode_REF_INC_DEC : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refIncrDecr(ref, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.LOCAL_LOAD : ++stackTop; indexReg += frame.localShift; stack[stackTop] = stack[indexReg]; sDbl[stackTop] = sDbl[indexReg]; continue Loop; case Icode_LOCAL_CLEAR : indexReg += frame.localShift; stack[indexReg] = null; continue Loop; case Icode_NAME_AND_THIS : // stringReg: name ++stackTop; stack[stackTop] = ScriptRuntime.getNameFunctionAndThis(stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; case Icode_PROP_AND_THIS: { Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); // stringReg: property stack[stackTop] = ScriptRuntime.getPropFunctionAndThis(obj, stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_ELEM_AND_THIS: { Object obj = stack[stackTop - 1]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop - 1]); Object id = stack[stackTop]; if (id == DBL_MRK) id = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id, cx); stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_VALUE_AND_THIS : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getValueFunctionAndThis(value, cx); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_CALLSPECIAL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } stackTop = doCallSpecial(cx, frame, stack, sDbl, stackTop, iCode, indexReg); continue Loop; } case Token.CALL : case Icode_TAIL_CALL : case Token.REF_CALL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function thisObj arg0 .. argN -> result // indexReg: number of arguments stackTop -= 1 + indexReg; // CALL generation ensures that fun and funThisObj // are already Scriptable and Callable objects respectively Callable fun = (Callable)stack[stackTop]; Scriptable funThisObj = (Scriptable)stack[stackTop + 1]; if (op == Token.REF_CALL) { Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 2, indexReg); stack[stackTop] = ScriptRuntime.callRef(fun, funThisObj, outArgs, cx); continue Loop; } Scriptable calleeScope = frame.scope; if (frame.useActivation) { calleeScope = ScriptableObject.getTopLevelScope(frame.scope); } if (fun instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction)fun; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { CallFrame callParentFrame = frame; CallFrame calleeFrame = new CallFrame(); if (op == Icode_TAIL_CALL) { // In principle tail call can re-use the current // frame and its stack arrays but it is hard to // do properly. Any exceptions that can legally // happen during frame re-initialization including // StackOverflowException during innocent looking // System.arraycopy may leave the current frame // data corrupted leading to undefined behaviour // in the catch code bellow that unwinds JS stack // on exceptions. Then there is issue about frame release // end exceptions there. // To avoid frame allocation a released frame // can be cached for re-use which would also benefit // non-tail calls but it is not clear that this caching // would gain in performance due to potentially // bad interaction with GC. callParentFrame = frame.parentFrame; // Release the current frame. See Bug #344501 to see why // it is being done here. exitFrame(cx, frame, null); } initFrame(cx, calleeScope, funThisObj, stack, sDbl, stackTop + 2, indexReg, ifun, callParentFrame, calleeFrame); if (op != Icode_TAIL_CALL) { frame.savedStackTop = stackTop; frame.savedCallOp = op; } frame = calleeFrame; continue StateLoop; } } if (fun instanceof NativeContinuation) { // Jump to the captured continuation ContinuationJump cjump; cjump = new ContinuationJump((NativeContinuation)fun, frame); // continuation result is the first argument if any // of continuation call if (indexReg == 0) { cjump.result = undefined; } else { cjump.result = stack[stackTop + 2]; cjump.resultDbl = sDbl[stackTop + 2]; } // Start the real unwind job throwable = cjump; break withoutExceptions; } if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } // Bug 405654 -- make best effort to keep Function.apply and // Function.call within this interpreter loop invocation if (BaseFunction.isApplyOrCall(ifun)) { Callable applyCallable = ScriptRuntime.getCallable(funThisObj); if (applyCallable instanceof InterpretedFunction) { InterpretedFunction iApplyCallable = (InterpretedFunction)applyCallable; if (frame.fnOrScript.securityDomain == iApplyCallable.securityDomain) { frame = initFrameForApplyOrCall(cx, frame, indexReg, stack, sDbl, stackTop, op, calleeScope, ifun, iApplyCallable); continue StateLoop; } } } } // Bug 447697 -- make best effort to keep __noSuchMethod__ within this // interpreter loop invocation if (fun instanceof NoSuchMethodShim) { // get the shim and the actual method NoSuchMethodShim noSuchMethodShim = (NoSuchMethodShim) fun; Callable noSuchMethodMethod = noSuchMethodShim.noSuchMethodMethod; // if the method is in fact an InterpretedFunction if (noSuchMethodMethod instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction) noSuchMethodMethod; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { frame = initFrameForNoSuchMethod(cx, frame, indexReg, stack, sDbl, stackTop, op, funThisObj, calleeScope, noSuchMethodShim, ifun); continue StateLoop; } } } cx.lastInterpreterFrame = frame; frame.savedCallOp = op; frame.savedStackTop = stackTop; stack[stackTop] = fun.call(cx, calleeScope, funThisObj, getArgsArray(stack, sDbl, stackTop + 2, indexReg)); continue Loop; } case Token.NEW : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function arg0 .. argN -> newResult // indexReg: number of arguments stackTop -= indexReg; Object lhs = stack[stackTop]; if (lhs instanceof InterpretedFunction) { InterpretedFunction f = (InterpretedFunction)lhs; if (frame.fnOrScript.securityDomain == f.securityDomain) { Scriptable newInstance = f.createObject(cx, frame.scope); CallFrame calleeFrame = new CallFrame(); initFrame(cx, frame.scope, newInstance, stack, sDbl, stackTop + 1, indexReg, f, frame, calleeFrame); stack[stackTop] = newInstance; frame.savedStackTop = stackTop; frame.savedCallOp = op; frame = calleeFrame; continue StateLoop; } } if (!(lhs instanceof Function)) { if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); throw ScriptRuntime.notFunctionError(lhs); } Function fun = (Function)lhs; if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } } Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 1, indexReg); stack[stackTop] = fun.construct(cx, frame.scope, outArgs); continue Loop; } case Token.TYPEOF : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.typeof(lhs); continue Loop; } case Icode_TYPEOFNAME : stack[++stackTop] = ScriptRuntime.typeofName(frame.scope, stringReg); continue Loop; case Token.STRING : stack[++stackTop] = stringReg; continue Loop; case Icode_SHORTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getShort(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_INTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Token.NUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.idata.itsDoubleTable[indexReg]; continue Loop; case Token.NAME : stack[++stackTop] = ScriptRuntime.name(cx, frame.scope, stringReg); continue Loop; case Icode_NAME_INC_DEC : stack[++stackTop] = ScriptRuntime.nameIncrDecr(frame.scope, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; case Icode_SETCONSTVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETCONSTVAR : stackTop = doSetConstVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_SETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETVAR : stackTop = doSetVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_GETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.GETVAR : stackTop = doGetVar(frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; case Icode_VAR_INC_DEC : { stackTop = doVarIncDec(cx, frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; } case Icode_ZERO : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 0; continue Loop; case Icode_ONE : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 1; continue Loop; case Token.NULL : stack[++stackTop] = null; continue Loop; case Token.THIS : stack[++stackTop] = frame.thisObj; continue Loop; case Token.THISFN : stack[++stackTop] = frame.fnOrScript; continue Loop; case Token.FALSE : stack[++stackTop] = Boolean.FALSE; continue Loop; case Token.TRUE : stack[++stackTop] = Boolean.TRUE; continue Loop; case Icode_UNDEF : stack[++stackTop] = undefined; continue Loop; case Token.ENTERWITH : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterWith(lhs, cx, frame.scope); continue Loop; } case Token.LEAVEWITH : frame.scope = ScriptRuntime.leaveWith(frame.scope); continue Loop; case Token.CATCH_SCOPE : { // stack top: exception object // stringReg: name of exception variable // indexReg: local for exception scope --stackTop; indexReg += frame.localShift; boolean afterFirstScope = (frame.idata.itsICode[frame.pc] != 0); Throwable caughtException = (Throwable)stack[stackTop + 1]; Scriptable lastCatchScope; if (!afterFirstScope) { lastCatchScope = null; } else { lastCatchScope = (Scriptable)stack[indexReg]; } stack[indexReg] = ScriptRuntime.newCatchScope(caughtException, lastCatchScope, stringReg, cx, frame.scope); ++frame.pc; continue Loop; } case Token.ENUM_INIT_KEYS : case Token.ENUM_INIT_VALUES : case Token.ENUM_INIT_ARRAY : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; indexReg += frame.localShift; int enumType = op == Token.ENUM_INIT_KEYS ? ScriptRuntime.ENUMERATE_KEYS : op == Token.ENUM_INIT_VALUES ? ScriptRuntime.ENUMERATE_VALUES : ScriptRuntime.ENUMERATE_ARRAY; stack[indexReg] = ScriptRuntime.enumInit(lhs, cx, enumType); continue Loop; } case Token.ENUM_NEXT : case Token.ENUM_ID : { indexReg += frame.localShift; Object val = stack[indexReg]; ++stackTop; stack[stackTop] = (op == Token.ENUM_NEXT) ? (Object)ScriptRuntime.enumNext(val) : (Object)ScriptRuntime.enumId(val, cx); continue Loop; } case Token.REF_SPECIAL : { //stringReg: name of special property Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg, cx); continue Loop; } case Token.REF_MEMBER: { //indexReg: flags stackTop = doRefMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NS_MEMBER: { //indexReg: flags stackTop = doRefNsMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NAME: { //indexReg: flags Object name = stack[stackTop]; if (name == DBL_MRK) name = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.nameRef(name, cx, frame.scope, indexReg); continue Loop; } case Token.REF_NS_NAME: { //indexReg: flags stackTop = doRefNsName(cx, frame, stack, sDbl, stackTop, indexReg); continue Loop; } case Icode_SCOPE_LOAD : indexReg += frame.localShift; frame.scope = (Scriptable)stack[indexReg]; continue Loop; case Icode_SCOPE_SAVE : indexReg += frame.localShift; stack[indexReg] = frame.scope; continue Loop; case Icode_CLOSURE_EXPR : stack[++stackTop] = InterpretedFunction.createFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Icode_CLOSURE_STMT : initFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Token.REGEXP : Object re = frame.idata.itsRegExpLiterals[indexReg]; stack[++stackTop] = ScriptRuntime.wrapRegExp(cx, frame.scope, re); continue Loop; case Icode_LITERAL_NEW : // indexReg: number of values in the literal ++stackTop; stack[stackTop] = new int[indexReg]; ++stackTop; stack[stackTop] = new Object[indexReg]; sDbl[stackTop] = 0; continue Loop; case Icode_LITERAL_SET : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_GETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = -1; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_SETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = +1; sDbl[stackTop] = i + 1; continue Loop; } case Token.ARRAYLIT : case Icode_SPARE_ARRAYLIT : case Token.OBJECTLIT : { Object[] data = (Object[])stack[stackTop]; --stackTop; int[] getterSetters = (int[])stack[stackTop]; Object val; if (op == Token.OBJECTLIT) { Object[] ids = (Object[])frame.idata.literalIds[indexReg]; val = ScriptRuntime.newObjectLiteral(ids, data, getterSetters, cx, frame.scope); } else { int[] skipIndexces = null; if (op == Icode_SPARE_ARRAYLIT) { skipIndexces = (int[])frame.idata.literalIds[indexReg]; } val = ScriptRuntime.newArrayLiteral(data, skipIndexces, cx, frame.scope); } stack[stackTop] = val; continue Loop; } case Icode_ENTERDQ : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterDotQuery(lhs, frame.scope); continue Loop; } case Icode_LEAVEDQ : { boolean valBln = stack_boolean(frame, stackTop); Object x = ScriptRuntime.updateDotQuery(valBln, frame.scope); if (x != null) { stack[stackTop] = x; frame.scope = ScriptRuntime.leaveDotQuery(frame.scope); frame.pc += 2; continue Loop; } // reset stack and PC to code after ENTERDQ --stackTop; break jumplessRun; } case Token.DEFAULTNAMESPACE : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setDefaultNamespace(value, cx); continue Loop; } case Token.ESCXMLATTR : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeAttributeValue(value, cx); } continue Loop; } case Token.ESCXMLTEXT : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeTextValue(value, cx); } continue Loop; } case Icode_DEBUGGER: if (frame.debuggerFrame != null) { frame.debuggerFrame.onDebuggerStatement(cx); } continue Loop; case Icode_LINE : frame.pcSourceLineStart = frame.pc; if (frame.debuggerFrame != null) { int line = getIndex(iCode, frame.pc); frame.debuggerFrame.onLineChange(cx, line); } frame.pc += 2; continue Loop; case Icode_REG_IND_C0: indexReg = 0; continue Loop; case Icode_REG_IND_C1: indexReg = 1; continue Loop; case Icode_REG_IND_C2: indexReg = 2; continue Loop; case Icode_REG_IND_C3: indexReg = 3; continue Loop; case Icode_REG_IND_C4: indexReg = 4; continue Loop; case Icode_REG_IND_C5: indexReg = 5; continue Loop; case Icode_REG_IND1: indexReg = 0xFF & iCode[frame.pc]; ++frame.pc; continue Loop; case Icode_REG_IND2: indexReg = getIndex(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_REG_IND4: indexReg = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Icode_REG_STR_C0: stringReg = strings[0]; continue Loop; case Icode_REG_STR_C1: stringReg = strings[1]; continue Loop; case Icode_REG_STR_C2: stringReg = strings[2]; continue Loop; case Icode_REG_STR_C3: stringReg = strings[3]; continue Loop; case Icode_REG_STR1: stringReg = strings[0xFF & iCode[frame.pc]]; ++frame.pc; continue Loop; case Icode_REG_STR2: stringReg = strings[getIndex(iCode, frame.pc)]; frame.pc += 2; continue Loop; case Icode_REG_STR4: stringReg = strings[getInt(iCode, frame.pc)]; frame.pc += 4; continue Loop; default : dumpICode(frame.idata); throw new RuntimeException("Unknown icode : " + op + " @ pc : " + (frame.pc-1)); } // end of interpreter switch } // end of jumplessRun label block // This should be reachable only for jump implementation // when pc points to encoded target offset if (instructionCounting) { addInstructionCount(cx, frame, 2); } int offset = getShort(iCode, frame.pc); if (offset != 0) { // -1 accounts for pc pointing to jump opcode + 1 frame.pc += offset - 1; } else { frame.pc = frame.idata.longJumps. getExistingInt(frame.pc); } if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } // end of Loop: for exitFrame(cx, frame, null); interpreterResult = frame.result; interpreterResultDbl = frame.resultDbl; if (frame.parentFrame != null) { frame = frame.parentFrame; if (frame.frozen) { frame = frame.cloneFrozen(); } setCallResult( frame, interpreterResult, interpreterResultDbl); interpreterResult = null; // Help GC continue StateLoop; } break StateLoop; } // end of interpreter withoutExceptions: try catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; } // This should be reachable only after above catch or from // finally when it needs to propagate exception or from // explicit throw if (throwable == null) Kit.codeBug(); // Exception type final int EX_CATCH_STATE = 2; // Can execute JS catch final int EX_FINALLY_STATE = 1; // Can execute JS finally final int EX_NO_JS_STATE = 0; // Terminate JS execution int exState; ContinuationJump cjump = null; if (generatorState != null && generatorState.operation == NativeGenerator.GENERATOR_CLOSE && throwable == generatorState.value) { exState = EX_FINALLY_STATE; } else if (throwable instanceof JavaScriptException) { exState = EX_CATCH_STATE; } else if (throwable instanceof EcmaError) { // an offical ECMA error object, exState = EX_CATCH_STATE; } else if (throwable instanceof EvaluatorException) { exState = EX_CATCH_STATE; } else if (throwable instanceof RuntimeException) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } else if (throwable instanceof Error) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_NO_JS_STATE; } else if (throwable instanceof ContinuationJump) { // It must be ContinuationJump exState = EX_FINALLY_STATE; cjump = (ContinuationJump)throwable; } else { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } if (instructionCounting) { try { addInstructionCount(cx, frame, EXCEPTION_COST); } catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; } catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } if (frame.debuggerFrame != null && throwable instanceof RuntimeException) { // Call debugger only for RuntimeException RuntimeException rex = (RuntimeException)throwable; try { frame.debuggerFrame.onExceptionThrown(cx, rex); } catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } for (;;) { if (exState != EX_NO_JS_STATE) { boolean onlyFinally = (exState != EX_CATCH_STATE); indexReg = getExceptionHandler(frame, onlyFinally); if (indexReg >= 0) { // We caught an exception, restart the loop // with exception pending the processing at the loop // start continue StateLoop; } } // No allowed exception handlers in this frame, unwind // to parent and try to look there exitFrame(cx, frame, throwable); frame = frame.parentFrame; if (frame == null) { break; } if (cjump != null && cjump.branchFrame == frame) { // Continuation branch point was hit, // restart the state loop to reenter continuation indexReg = -1; continue StateLoop; } } // No more frames, rethrow the exception or deal with continuation if (cjump != null) { if (cjump.branchFrame != null) { // The above loop should locate the top frame Kit.codeBug(); } if (cjump.capturedFrame != null) { // Restarting detached continuation indexReg = -1; continue StateLoop; } // Return continuation result to the caller interpreterResult = cjump.result; interpreterResultDbl = cjump.resultDbl; throwable = null; } break StateLoop; } // end of StateLoop: for(;;) // Do cleanups/restorations before the final return or throw if (cx.previousInterpreterInvocations != null && cx.previousInterpreterInvocations.size() != 0) { cx.lastInterpreterFrame = cx.previousInterpreterInvocations.pop(); } else { // It was the last interpreter frame on the stack cx.lastInterpreterFrame = null; // Force GC of the value cx.previousInterpreterInvocations cx.previousInterpreterInvocations = null; } if (throwable != null) { if (throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else { // Must be instance of Error or code bug throw (Error)throwable; } } return (interpreterResult != DBL_MRK) ? interpreterResult : ScriptRuntime.wrapNumber(interpreterResultDbl); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public String getMessage(String messageId, Object[] arguments) { final String defaultResource = "org.mozilla.javascript.resources.Messages"; Context cx = Context.getCurrentContext(); Locale locale = cx != null ? cx.getLocale() : Locale.getDefault(); // ResourceBundle does caching. ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale); String formatString; try { formatString = rb.getString(messageId); } catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); } /* * It's OK to format the string, even if 'arguments' is null; * we need to format it anyway, to make double ''s collapse to * single 's. */ MessageFormat formatter = new MessageFormat(formatString); return formatter.format(arguments); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { // Find a method that matches the types given. if (methods.length == 0) { throw new RuntimeException("No methods defined for call"); } int index = findCachedFunction(cx, args); if (index < 0) { Class<?> c = methods[0].method().getDeclaringClass(); String sig = c.getName() + '.' + getFunctionName() + '(' + scriptSignature(args) + ')'; throw Context.reportRuntimeError1("msg.java.no_such_method", sig); } MemberBox meth = methods[index]; Class<?>[] argTypes = meth.argTypes; if (meth.vararg) { // marshall the explicit parameters Object[] newArgs = new Object[argTypes.length]; for (int i = 0; i < argTypes.length-1; i++) { newArgs[i] = Context.jsToJava(args[i], argTypes[i]); } Object varArgs; // Handle special situation where a single variable parameter // is given and it is a Java or ECMA array or is null. if (args.length == argTypes.length && (args[args.length-1] == null || args[args.length-1] instanceof NativeArray || args[args.length-1] instanceof NativeJavaArray)) { // convert the ECMA array into a native array varArgs = Context.jsToJava(args[args.length-1], argTypes[argTypes.length - 1]); } else { // marshall the variable parameters Class<?> componentType = argTypes[argTypes.length - 1]. getComponentType(); varArgs = Array.newInstance(componentType, args.length - argTypes.length + 1); for (int i = 0; i < Array.getLength(varArgs); i++) { Object value = Context.jsToJava(args[argTypes.length-1 + i], componentType); Array.set(varArgs, i, value); } } // add varargs newArgs[argTypes.length-1] = varArgs; // replace the original args with the new one args = newArgs; } else { // First, we marshall the args. Object[] origArgs = args; for (int i = 0; i < args.length; i++) { Object arg = args[i]; Object coerced = Context.jsToJava(arg, argTypes[i]); if (coerced != arg) { if (origArgs == args) { args = args.clone(); } args[i] = coerced; } } } Object javaObject; if (meth.isStatic()) { javaObject = null; // don't need an object } else { Scriptable o = thisObj; Class<?> c = meth.getDeclaringClass(); for (;;) { if (o == null) { throw Context.reportRuntimeError3( "msg.nonjava.method", getFunctionName(), ScriptRuntime.toString(thisObj), c.getName()); } if (o instanceof Wrapper) { javaObject = ((Wrapper)o).unwrap(); if (c.isInstance(javaObject)) { break; } } o = o.getPrototype(); } } if (debug) { printDebug("Calling ", meth, args); } Object retval = meth.invoke(javaObject, args); Class<?> staticType = meth.method().getReturnType(); if (debug) { Class<?> actualType = (retval == null) ? null : retval.getClass(); System.err.println(" ----- Returned " + retval + " actual = " + actualType + " expect = " + staticType); } Object wrapped = cx.getWrapFactory().wrap(cx, scope, retval, staticType); if (debug) { Class<?> actualType = (wrapped == null) ? null : wrapped.getClass(); System.err.println(" ----- Wrapped as " + wrapped + " class = " + actualType); } if (wrapped == null && staticType == Void.TYPE) { wrapped = Undefined.instance; } return wrapped; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
final Script compileString(String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain) { try { return (Script) compileImpl(null, null, source, sourceName, lineno, securityDomain, false, compiler, compilationErrorReporter); } catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
final Function compileFunction(Scriptable scope, String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain) { try { return (Function) compileImpl(scope, null, source, sourceName, lineno, securityDomain, true, compiler, compilationErrorReporter); } catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static Context getContext() { Context cx = getCurrentContext(); if (cx == null) { throw new RuntimeException( "No Context associated with current Thread"); } return cx; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void fixLabelGotos() { byte[] codeBuffer = itsCodeBuffer; for (int i = 0; i < itsFixupTableTop; i++) { long fixup = itsFixupTable[i]; int label = (int)(fixup >> 32); int fixupSite = (int)fixup; int pc = itsLabelTable[label]; if (pc == -1) { // Unlocated label throw new RuntimeException(); } // -1 to get delta from instruction start addSuperBlockStart(pc); itsJumpFroms.put(pc, fixupSite - 1); int offset = pc - (fixupSite - 1); if ((short)offset != offset) { throw new ClassFileFormatException ("Program too complex: too big jump offset"); } codeBuffer[fixupSite] = (byte)(offset >> 8); codeBuffer[fixupSite + 1] = (byte)offset; } itsFixupTableTop = 0; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public byte[] toByteArray() { int dataSize = getWriteSize(); byte[] data = new byte[dataSize]; int offset = 0; short sourceFileAttributeNameIndex = 0; if (itsSourceFileNameIndex != 0) { sourceFileAttributeNameIndex = itsConstantPool.addUtf8( "SourceFile"); } offset = putInt32(FileHeaderConstant, data, offset); offset = putInt16(MinorVersion, data, offset); offset = putInt16(MajorVersion, data, offset); offset = itsConstantPool.write(data, offset); offset = putInt16(itsFlags, data, offset); offset = putInt16(itsThisClassIndex, data, offset); offset = putInt16(itsSuperClassIndex, data, offset); offset = putInt16(itsInterfaces.size(), data, offset); for (int i = 0; i < itsInterfaces.size(); i++) { int interfaceIndex = ((Short)(itsInterfaces.get(i))).shortValue(); offset = putInt16(interfaceIndex, data, offset); } offset = putInt16(itsFields.size(), data, offset); for (int i = 0; i < itsFields.size(); i++) { ClassFileField field = (ClassFileField)itsFields.get(i); offset = field.write(data, offset); } offset = putInt16(itsMethods.size(), data, offset); for (int i = 0; i < itsMethods.size(); i++) { ClassFileMethod method = (ClassFileMethod)itsMethods.get(i); offset = method.write(data, offset); } if (itsSourceFileNameIndex != 0) { offset = putInt16(1, data, offset); // attributes count offset = putInt16(sourceFileAttributeNameIndex, data, offset); offset = putInt32(2, data, offset); offset = putInt16(itsSourceFileNameIndex, data, offset); } else { offset = putInt16(0, data, offset); // no attributes } if (offset != dataSize) { // Check getWriteSize is consistent with write! throw new RuntimeException(); } return data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static Class getClassFromInternalName(String internalName) { try { return Class.forName(internalName.replace('/', '.')); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
9
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
4
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private RuntimeException codeBug() throws RuntimeException { throw Kit.codeBug("ts.cursor=" + ts.cursor + ", ts.tokenBeg=" + ts.tokenBeg + ", currentToken=" + currentToken); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static RuntimeException codeBug() throws RuntimeException { RuntimeException ex = new IllegalStateException("FAILED ASSERTION"); // Print stack trace ASAP ex.printStackTrace(System.err); throw ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static RuntimeException codeBug(String msg) throws RuntimeException { msg = "FAILED ASSERTION: " + msg; RuntimeException ex = new IllegalStateException(msg); // Print stack trace ASAP ex.printStackTrace(System.err); throw ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
public static RuntimeException codeBug() throws RuntimeException { throw Kit.codeBug(); }
(Domain) ParseException 24
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readValue() throws ParseException { consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch (c) { case '{': return readObject(); case '[': return readArray(); case 't': return readTrue(); case 'f': return readFalse(); case '"': return readString(); case 'n': return readNull(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': case '-': return readNumber(c); default: throw new ParseException("Unexpected token: " + c); } } throw new ParseException("Empty JSON string"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readObject() throws ParseException { Scriptable object = cx.newObject(scope); String id; Object value; boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch(c) { case '}': return object; case ',': if (!needsComma) { throw new ParseException("Unexpected comma in object literal"); } needsComma = false; break; case '"': if (needsComma) { throw new ParseException("Missing comma in object literal"); } id = readString(); consume(':'); value = readValue(); long index = ScriptRuntime.indexFromString(id); if (index < 0) { object.put(id, object, value); } else { object.put((int)index, object, value); } needsComma = true; break; default: throw new ParseException("Unexpected token in object literal"); } consumeWhitespace(); } throw new ParseException("Unterminated object literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readArray() throws ParseException { List<Object> list = new ArrayList<Object>(); boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos); switch(c) { case ']': pos += 1; return cx.newArray(scope, list.toArray()); case ',': if (!needsComma) { throw new ParseException("Unexpected comma in array literal"); } needsComma = false; pos += 1; break; default: if (needsComma) { throw new ParseException("Missing comma in array literal"); } list.add(readValue()); needsComma = true; } consumeWhitespace(); } throw new ParseException("Unterminated array literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private String readString() throws ParseException { StringBuilder b = new StringBuilder(); while (pos < length) { char c = src.charAt(pos++); if (c <= '\u001F') { throw new ParseException("String contains control character"); } switch(c) { case '\\': if (pos >= length) { throw new ParseException("Unterminated string"); } c = src.charAt(pos++); switch (c) { case '"': b.append('"'); break; case '\\': b.append('\\'); break; case '/': b.append('/'); break; case 'b': b.append('\b'); break; case 'f': b.append('\f'); break; case 'n': b.append('\n'); break; case 'r': b.append('\r'); break; case 't': b.append('\t'); break; case 'u': if (length - pos < 5) { throw new ParseException("Invalid character code: \\u" + src.substring(pos)); } try { b.append((char) Integer.parseInt(src.substring(pos, pos + 4), 16)); pos += 4; } catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); } break; default: throw new ParseException("Unexcpected character in string: '\\" + c + "'"); } break; case '"': return b.toString(); default: b.append(c); break; } } throw new ParseException("Unterminated string literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Number readNumber(char first) throws ParseException { StringBuilder b = new StringBuilder(); b.append(first); while (pos < length) { char c = src.charAt(pos); if (!Character.isDigit(c) && c != '-' && c != '+' && c != '.' && c != 'e' && c != 'E') { break; } pos += 1; b.append(c); } String num = b.toString(); int numLength = num.length(); try { // check for leading zeroes for (int i = 0; i < numLength; i++) { char c = num.charAt(i); if (Character.isDigit(c)) { if (c == '0' && numLength > i + 1 && Character.isDigit(num.charAt(i + 1))) { throw new ParseException("Unsupported number format: " + num); } break; } } final double dval = Double.parseDouble(num); final int ival = (int)dval; if (ival == dval) { return Integer.valueOf(ival); } else { return Double.valueOf(dval); } } catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readFalse() throws ParseException { if (length - pos < 4 || src.charAt(pos) != 'a' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 's' || src.charAt(pos + 3) != 'e') { throw new ParseException("Unexpected token: f"); } pos += 4; return Boolean.FALSE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readNull() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'u' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 'l') { throw new ParseException("Unexpected token: n"); } pos += 3; return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
2
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
10
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readValue() throws ParseException { consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch (c) { case '{': return readObject(); case '[': return readArray(); case 't': return readTrue(); case 'f': return readFalse(); case '"': return readString(); case 'n': return readNull(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': case '-': return readNumber(c); default: throw new ParseException("Unexpected token: " + c); } } throw new ParseException("Empty JSON string"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readObject() throws ParseException { Scriptable object = cx.newObject(scope); String id; Object value; boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch(c) { case '}': return object; case ',': if (!needsComma) { throw new ParseException("Unexpected comma in object literal"); } needsComma = false; break; case '"': if (needsComma) { throw new ParseException("Missing comma in object literal"); } id = readString(); consume(':'); value = readValue(); long index = ScriptRuntime.indexFromString(id); if (index < 0) { object.put(id, object, value); } else { object.put((int)index, object, value); } needsComma = true; break; default: throw new ParseException("Unexpected token in object literal"); } consumeWhitespace(); } throw new ParseException("Unterminated object literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readArray() throws ParseException { List<Object> list = new ArrayList<Object>(); boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos); switch(c) { case ']': pos += 1; return cx.newArray(scope, list.toArray()); case ',': if (!needsComma) { throw new ParseException("Unexpected comma in array literal"); } needsComma = false; pos += 1; break; default: if (needsComma) { throw new ParseException("Missing comma in array literal"); } list.add(readValue()); needsComma = true; } consumeWhitespace(); } throw new ParseException("Unterminated array literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private String readString() throws ParseException { StringBuilder b = new StringBuilder(); while (pos < length) { char c = src.charAt(pos++); if (c <= '\u001F') { throw new ParseException("String contains control character"); } switch(c) { case '\\': if (pos >= length) { throw new ParseException("Unterminated string"); } c = src.charAt(pos++); switch (c) { case '"': b.append('"'); break; case '\\': b.append('\\'); break; case '/': b.append('/'); break; case 'b': b.append('\b'); break; case 'f': b.append('\f'); break; case 'n': b.append('\n'); break; case 'r': b.append('\r'); break; case 't': b.append('\t'); break; case 'u': if (length - pos < 5) { throw new ParseException("Invalid character code: \\u" + src.substring(pos)); } try { b.append((char) Integer.parseInt(src.substring(pos, pos + 4), 16)); pos += 4; } catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); } break; default: throw new ParseException("Unexcpected character in string: '\\" + c + "'"); } break; case '"': return b.toString(); default: b.append(c); break; } } throw new ParseException("Unterminated string literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Number readNumber(char first) throws ParseException { StringBuilder b = new StringBuilder(); b.append(first); while (pos < length) { char c = src.charAt(pos); if (!Character.isDigit(c) && c != '-' && c != '+' && c != '.' && c != 'e' && c != 'E') { break; } pos += 1; b.append(c); } String num = b.toString(); int numLength = num.length(); try { // check for leading zeroes for (int i = 0; i < numLength; i++) { char c = num.charAt(i); if (Character.isDigit(c)) { if (c == '0' && numLength > i + 1 && Character.isDigit(num.charAt(i + 1))) { throw new ParseException("Unsupported number format: " + num); } break; } } final double dval = Double.parseDouble(num); final int ival = (int)dval; if (ival == dval) { return Integer.valueOf(ival); } else { return Double.valueOf(dval); } } catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readFalse() throws ParseException { if (length - pos < 4 || src.charAt(pos) != 'a' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 's' || src.charAt(pos + 3) != 'e') { throw new ParseException("Unexpected token: f"); } pos += 4; return Boolean.FALSE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readNull() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'u' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 'l') { throw new ParseException("Unexpected token: n"); } pos += 3; return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
(Lib) IOException 8
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeBoolean(isAdapter); if (isAdapter) { if (adapter_writeAdapterObject == null) { throw new IOException(); } Object[] args = { javaObject, out }; try { adapter_writeAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { out.writeObject(javaObject); } if (staticType != null) { out.writeObject(staticType.getClass().getName()); } else { out.writeObject(null); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static void writeAdapterObject(Object javaObject, ObjectOutputStream out) throws IOException { Class<?> cl = javaObject.getClass(); out.writeObject(cl.getSuperclass().getName()); Class<?>[] interfaces = cl.getInterfaces(); String[] interfaceNames = new String[interfaces.length]; for (int i=0; i < interfaces.length; i++) interfaceNames[i] = interfaces[i].getName(); out.writeObject(interfaceNames); try { Object delegee = cl.getField("delegee").get(javaObject); out.writeObject(delegee); return; } catch (IllegalAccessException e) { } catch (NoSuchFieldException e) { } throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Object resolveObject(Object obj) throws IOException { if (obj instanceof ScriptableOutputStream.PendingLookup) { String name = ((ScriptableOutputStream.PendingLookup)obj).getName(); obj = ScriptableOutputStream.lookupQualifiedName(scope, name); if (obj == Scriptable.NOT_FOUND) { throw new IOException("Object " + name + " not found upon " + "deserialization."); } }else if (obj instanceof UniqueTag) { obj = ((UniqueTag)obj).readResolve(); }else if (obj instanceof Undefined) { obj = ((Undefined)obj).readResolve(); } return obj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
Override protected Object replaceObject(Object obj) throws IOException { if (false) throw new IOException(); // suppress warning String name = table.get(obj); if (name == null) return obj; return new PendingLookup(name); }
3
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
143
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeBoolean(isAdapter); if (isAdapter) { if (adapter_writeAdapterObject == null) { throw new IOException(); } Object[] args = { javaObject, out }; try { adapter_writeAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { out.writeObject(javaObject); } if (staticType != null) { out.writeObject(staticType.getClass().getName()); } else { out.writeObject(null); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, privilegedUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, fallbackUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private ModuleSource loadFromPathList(String moduleId, Object validator, Iterable<URI> paths) throws IOException, URISyntaxException { if(paths == null) { return null; } for (URI path : paths) { final ModuleSource moduleSource = loadFromUri( path.resolve(moduleId), path, validator); if (moduleSource != null) { return moduleSource; } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromUri(URI uri, URI base, Object validator) throws IOException, URISyntaxException { // We expect modules to have a ".js" file name extension ... URI fullUri = new URI(uri + ".js"); ModuleSource source = loadFromActualUri(fullUri, base, validator); // ... but for compatibility we support modules without extension, // or ids with explicit extension. return source != null ? source : loadFromActualUri(uri, base, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
protected ModuleSource loadFromActualUri(URI uri, URI base, Object validator) throws IOException { final URL url = new URL(base == null ? null : base.toURL(), uri.toString()); final long request_time = System.currentTimeMillis(); final URLConnection urlConnection = openUrlConnection(url); final URLValidator applicableValidator; if(validator instanceof URLValidator) { final URLValidator uriValidator = ((URLValidator)validator); applicableValidator = uriValidator.appliesTo(uri) ? uriValidator : null; } else { applicableValidator = null; } if(applicableValidator != null) { applicableValidator.applyConditionals(urlConnection); } try { urlConnection.connect(); if(applicableValidator != null && applicableValidator.updateValidator(urlConnection, request_time, urlConnectionExpiryCalculator)) { close(urlConnection); return NOT_MODIFIED; } return new ModuleSource(getReader(urlConnection), getSecurityDomain(urlConnection), uri, base, new URLValidator(uri, urlConnection, request_time, urlConnectionExpiryCalculator)); } catch(FileNotFoundException e) { return null; } catch(RuntimeException e) { close(urlConnection); throw e; } catch(IOException e) { close(urlConnection); throw e; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private static Reader getReader(URLConnection urlConnection) throws IOException { return new InputStreamReader(urlConnection.getInputStream(), getCharacterEncoding(urlConnection)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
protected URLConnection openUrlConnection(URL url) throws IOException { return url.openConnection(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
boolean updateValidator(URLConnection urlConnection, long request_time, UrlConnectionExpiryCalculator urlConnectionExpiryCalculator) throws IOException { boolean isResourceChanged = isResourceChanged(urlConnection); if(!isResourceChanged) { expiry = calculateExpiry(urlConnection, request_time, urlConnectionExpiryCalculator); } return isResourceChanged; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private boolean isResourceChanged(URLConnection urlConnection) throws IOException { if(urlConnection instanceof HttpURLConnection) { return ((HttpURLConnection)urlConnection).getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED; } return lastModified == urlConnection.getLastModified(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { scriptRefQueue = new ReferenceQueue<Script>(); scripts = new ConcurrentHashMap<String, ScriptReference>(); final Map<String, CachedModuleScript> serScripts = (Map)in.readObject(); for(Map.Entry<String, CachedModuleScript> entry: serScripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue(); putLoadedModule(entry.getKey(), cachedModuleScript.getModule(), cachedModuleScript.getValidator()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void writeObject(ObjectOutputStream out) throws IOException { final Map<String, CachedModuleScript> serScripts = new HashMap<String, CachedModuleScript>(); for(Map.Entry<String, ScriptReference> entry: scripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue().getCachedModuleScript(); if(cachedModuleScript != null) { serScripts.put(entry.getKey(), cachedModuleScript); } } out.writeObject(serScripts); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws IOException, URISyntaxException { if(!entityNeedsRevalidation(validator)) { return NOT_MODIFIED; } ModuleSource moduleSource = loadFromPrivilegedLocations( moduleId, validator); if(moduleSource != null) { return moduleSource; } if(paths != null) { moduleSource = loadFromPathArray(moduleId, paths, validator); if(moduleSource != null) { return moduleSource; } } return loadFromFallbackLocations(moduleId, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(URI uri, Object validator) throws IOException, URISyntaxException { return loadFromUri(uri, null, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator) throws IOException { final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { final String path = ensureTrailingSlash( ScriptableObject.getTypedProperty(paths, i, String.class)); try { URI uri = new URI(path); if (!uri.isAbsolute()) { uri = new File(path).toURI().resolve(""); } final ModuleSource moduleSource = loadFromUri( uri.resolve(moduleId), uri, validator); if(moduleSource != null) { return moduleSource; } } catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int count = keyCount; for (int i = 0; count != 0; ++i) { Object key = keys[i]; if (key != null && key != DELETED) { --count; out.writeObject(key); out.writeInt(values[i]); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; int N = 1 << power; keys = new Object[N]; values = new int[2 * N]; for (int i = 0; i != writtenKeyCount; ++i) { Object key = in.readObject(); int hash = key.hashCode(); int index = insertNewKey(key, hash); values[index] = in.readInt(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Member member = readMember(in); if (member instanceof Method) { init((Method)member); } else { init((Constructor<?>)member); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); writeMember(out, memberObject); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeMember(ObjectOutputStream out, Member member) throws IOException { if (member == null) { out.writeBoolean(false); return; } out.writeBoolean(true); if (!(member instanceof Method || member instanceof Constructor)) throw new IllegalArgumentException("not Method or Constructor"); out.writeBoolean(member instanceof Method); out.writeObject(member.getName()); out.writeObject(member.getDeclaringClass()); if (member instanceof Method) { writeParameters(out, ((Method) member).getParameterTypes()); } else { writeParameters(out, ((Constructor<?>) member).getParameterTypes()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Class<?>[] readParameters(ObjectInputStream in) throws IOException, ClassNotFoundException { Class<?>[] result = new Class[in.readShort()]; for (int i=0; i < result.length; i++) { if (!in.readBoolean()) { result[i] = (Class<?>) in.readObject(); continue; } result[i] = primitives[in.readByte()]; } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
final int getToken() throws IOException { int c; retry: for (;;) { // Eat whitespace, possibly sensitive to newlines. for (;;) { c = getChar(); if (c == EOF_CHAR) { tokenBeg = cursor - 1; tokenEnd = cursor; return Token.EOF; } else if (c == '\n') { dirtyLine = false; tokenBeg = cursor - 1; tokenEnd = cursor; return Token.EOL; } else if (!isJSSpace(c)) { if (c != '-') { dirtyLine = true; } break; } } // Assume the token will be 1 char - fixed up below. tokenBeg = cursor - 1; tokenEnd = cursor; if (c == '@') return Token.XMLATTR; // identifier/keyword/instanceof? // watch out for starting with a <backslash> boolean identifierStart; boolean isUnicodeEscapeStart = false; if (c == '\\') { c = getChar(); if (c == 'u') { identifierStart = true; isUnicodeEscapeStart = true; stringBufferTop = 0; } else { identifierStart = false; ungetChar(c); c = '\\'; } } else { identifierStart = Character.isJavaIdentifierStart((char)c); if (identifierStart) { stringBufferTop = 0; addToString(c); } } if (identifierStart) { boolean containsEscape = isUnicodeEscapeStart; for (;;) { if (isUnicodeEscapeStart) { // strictly speaking we should probably push-back // all the bad characters if the <backslash>uXXXX // sequence is malformed. But since there isn't a // correct context(is there?) for a bad Unicode // escape sequence in an identifier, we can report // an error here. int escapeVal = 0; for (int i = 0; i != 4; ++i) { c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); // Next check takes care about c < 0 and bad escape if (escapeVal < 0) { break; } } if (escapeVal < 0) { parser.addError("msg.invalid.escape"); return Token.ERROR; } addToString(escapeVal); isUnicodeEscapeStart = false; } else { c = getChar(); if (c == '\\') { c = getChar(); if (c == 'u') { isUnicodeEscapeStart = true; containsEscape = true; } else { parser.addError("msg.illegal.character"); return Token.ERROR; } } else { if (c == EOF_CHAR || c == BYTE_ORDER_MARK || !Character.isJavaIdentifierPart((char)c)) { break; } addToString(c); } } } ungetChar(c); String str = getStringFromBuffer(); if (!containsEscape) { // OPT we shouldn't have to make a string (object!) to // check if it's a keyword. // Return the corresponding token if it's a keyword int result = stringToKeyword(str); if (result != Token.EOF) { if ((result == Token.LET || result == Token.YIELD) && parser.compilerEnv.getLanguageVersion() < Context.VERSION_1_7) { // LET and YIELD are tokens only in 1.7 and later string = result == Token.LET ? "let" : "yield"; result = Token.NAME; } if (result != Token.RESERVED) { return result; } else if (!parser.compilerEnv. isReservedKeywordAsIdentifier()) { return result; } } } this.string = (String)allStrings.intern(str); return Token.NAME; } // is it a number? if (isDigit(c) || (c == '.' && isDigit(peekChar()))) { isOctal = false; stringBufferTop = 0; int base = 10; if (c == '0') { c = getChar(); if (c == 'x' || c == 'X') { base = 16; c = getChar(); } else if (isDigit(c)) { base = 8; isOctal = true; } else { addToString('0'); } } if (base == 16) { while (0 <= Kit.xDigitToInt(c, 0)) { addToString(c); c = getChar(); } } else { while ('0' <= c && c <= '9') { /* * We permit 08 and 09 as decimal numbers, which * makes our behavior a superset of the ECMA * numeric grammar. We might not always be so * permissive, so we warn about it. */ if (base == 8 && c >= '8') { parser.addWarning("msg.bad.octal.literal", c == '8' ? "8" : "9"); base = 10; } addToString(c); c = getChar(); } } boolean isInteger = true; if (base == 10 && (c == '.' || c == 'e' || c == 'E')) { isInteger = false; if (c == '.') { do { addToString(c); c = getChar(); } while (isDigit(c)); } if (c == 'e' || c == 'E') { addToString(c); c = getChar(); if (c == '+' || c == '-') { addToString(c); c = getChar(); } if (!isDigit(c)) { parser.addError("msg.missing.exponent"); return Token.ERROR; } do { addToString(c); c = getChar(); } while (isDigit(c)); } } ungetChar(c); String numString = getStringFromBuffer(); this.string = numString; double dval; if (base == 10 && !isInteger) { try { // Use Java conversion to number from string... dval = Double.parseDouble(numString); } catch (NumberFormatException ex) { parser.addError("msg.caught.nfe"); return Token.ERROR; } } else { dval = ScriptRuntime.stringToNumber(numString, 0, base); } this.number = dval; return Token.NUMBER; } // is it a string? if (c == '"' || c == '\'') { // We attempt to accumulate a string the fast way, by // building it directly out of the reader. But if there // are any escaped characters in the string, we revert to // building it out of a StringBuffer. quoteChar = c; stringBufferTop = 0; c = getChar(false); strLoop: while (c != quoteChar) { if (c == '\n' || c == EOF_CHAR) { ungetChar(c); tokenEnd = cursor; parser.addError("msg.unterminated.string.lit"); return Token.ERROR; } if (c == '\\') { // We've hit an escaped character int escapeVal; c = getChar(); switch (c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; // \v a late addition to the ECMA spec, // it is not in Java, so use 0xb case 'v': c = 0xb; break; case 'u': // Get 4 hex digits; if the u escape is not // followed by 4 hex digits, use 'u' + the // literal character sequence that follows. int escapeStart = stringBufferTop; addToString('u'); escapeVal = 0; for (int i = 0; i != 4; ++i) { c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); if (escapeVal < 0) { continue strLoop; } addToString(c); } // prepare for replace of stored 'u' sequence // by escape value stringBufferTop = escapeStart; c = escapeVal; break; case 'x': // Get 2 hex digits, defaulting to 'x'+literal // sequence, as above. c = getChar(); escapeVal = Kit.xDigitToInt(c, 0); if (escapeVal < 0) { addToString('x'); continue strLoop; } else { int c1 = c; c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); if (escapeVal < 0) { addToString('x'); addToString(c1); continue strLoop; } else { // got 2 hex digits c = escapeVal; } } break; case '\n': // Remove line terminator after escape to follow // SpiderMonkey and C/C++ c = getChar(); continue strLoop; default: if ('0' <= c && c < '8') { int val = c - '0'; c = getChar(); if ('0' <= c && c < '8') { val = 8 * val + c - '0'; c = getChar(); if ('0' <= c && c < '8' && val <= 037) { // c is 3rd char of octal sequence only // if the resulting val <= 0377 val = 8 * val + c - '0'; c = getChar(); } } ungetChar(c); c = val; } } } addToString(c); c = getChar(false); } String str = getStringFromBuffer(); this.string = (String)allStrings.intern(str); return Token.STRING; } switch (c) { case ';': return Token.SEMI; case '[': return Token.LB; case ']': return Token.RB; case '{': return Token.LC; case '}': return Token.RC; case '(': return Token.LP; case ')': return Token.RP; case ',': return Token.COMMA; case '?': return Token.HOOK; case ':': if (matchChar(':')) { return Token.COLONCOLON; } else { return Token.COLON; } case '.': if (matchChar('.')) { return Token.DOTDOT; } else if (matchChar('(')) { return Token.DOTQUERY; } else { return Token.DOT; } case '|': if (matchChar('|')) { return Token.OR; } else if (matchChar('=')) { return Token.ASSIGN_BITOR; } else { return Token.BITOR; } case '^': if (matchChar('=')) { return Token.ASSIGN_BITXOR; } else { return Token.BITXOR; } case '&': if (matchChar('&')) { return Token.AND; } else if (matchChar('=')) { return Token.ASSIGN_BITAND; } else { return Token.BITAND; } case '=': if (matchChar('=')) { if (matchChar('=')) { return Token.SHEQ; } else { return Token.EQ; } } else { return Token.ASSIGN; } case '!': if (matchChar('=')) { if (matchChar('=')) { return Token.SHNE; } else { return Token.NE; } } else { return Token.NOT; } case '<': /* NB:treat HTML begin-comment as comment-till-eol */ if (matchChar('!')) { if (matchChar('-')) { if (matchChar('-')) { tokenBeg = cursor - 4; skipLine(); commentType = Token.CommentType.HTML; return Token.COMMENT; } ungetCharIgnoreLineEnd('-'); } ungetCharIgnoreLineEnd('!'); } if (matchChar('<')) { if (matchChar('=')) { return Token.ASSIGN_LSH; } else { return Token.LSH; } } else { if (matchChar('=')) { return Token.LE; } else { return Token.LT; } } case '>': if (matchChar('>')) { if (matchChar('>')) { if (matchChar('=')) { return Token.ASSIGN_URSH; } else { return Token.URSH; } } else { if (matchChar('=')) { return Token.ASSIGN_RSH; } else { return Token.RSH; } } } else { if (matchChar('=')) { return Token.GE; } else { return Token.GT; } } case '*': if (matchChar('=')) { return Token.ASSIGN_MUL; } else { return Token.MUL; } case '/': markCommentStart(); // is it a // comment? if (matchChar('/')) { tokenBeg = cursor - 2; skipLine(); commentType = Token.CommentType.LINE; return Token.COMMENT; } // is it a /* or /** comment? if (matchChar('*')) { boolean lookForSlash = false; tokenBeg = cursor - 2; if (matchChar('*')) { lookForSlash = true; commentType = Token.CommentType.JSDOC; } else { commentType = Token.CommentType.BLOCK_COMMENT; } for (;;) { c = getChar(); if (c == EOF_CHAR) { tokenEnd = cursor - 1; parser.addError("msg.unterminated.comment"); return Token.COMMENT; } else if (c == '*') { lookForSlash = true; } else if (c == '/') { if (lookForSlash) { tokenEnd = cursor; return Token.COMMENT; } } else { lookForSlash = false; tokenEnd = cursor; } } } if (matchChar('=')) { return Token.ASSIGN_DIV; } else { return Token.DIV; } case '%': if (matchChar('=')) { return Token.ASSIGN_MOD; } else { return Token.MOD; } case '~': return Token.BITNOT; case '+': if (matchChar('=')) { return Token.ASSIGN_ADD; } else if (matchChar('+')) { return Token.INC; } else { return Token.ADD; } case '-': if (matchChar('=')) { c = Token.ASSIGN_SUB; } else if (matchChar('-')) { if (!dirtyLine) { // treat HTML end-comment after possible whitespace // after line start as comment-until-eol if (matchChar('>')) { markCommentStart("--"); skipLine(); commentType = Token.CommentType.HTML; return Token.COMMENT; } } c = Token.DEC; } else { c = Token.SUB; } dirtyLine = true; return c; default: parser.addError("msg.illegal.character"); return Token.ERROR; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
void readRegExp(int startToken) throws IOException { int start = tokenBeg; stringBufferTop = 0; if (startToken == Token.ASSIGN_DIV) { // Miss-scanned /= addToString('='); } else { if (startToken != Token.DIV) Kit.codeBug(); } boolean inCharSet = false; // true if inside a '['..']' pair int c; while ((c = getChar()) != '/' || inCharSet) { if (c == '\n' || c == EOF_CHAR) { ungetChar(c); tokenEnd = cursor - 1; this.string = new String(stringBuffer, 0, stringBufferTop); parser.reportError("msg.unterminated.re.lit"); return; } if (c == '\\') { addToString(c); c = getChar(); } else if (c == '[') { inCharSet = true; } else if (c == ']') { inCharSet = false; } addToString(c); } int reEnd = stringBufferTop; while (true) { if (matchChar('g')) addToString('g'); else if (matchChar('i')) addToString('i'); else if (matchChar('m')) addToString('m'); else if (matchChar('y')) // FireFox 3 addToString('y'); else break; } tokenEnd = start + stringBufferTop + 2; // include slashes if (isAlpha(peekChar())) { parser.reportError("msg.invalid.re.flag"); } this.string = new String(stringBuffer, 0, reEnd); this.regExpFlags = new String(stringBuffer, reEnd, stringBufferTop - reEnd); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
int getFirstXMLToken() throws IOException { xmlOpenTagsCount = 0; xmlIsAttribute = false; xmlIsTagContent = false; if (!canUngetChar()) return Token.ERROR; ungetChar('<'); return getNextXMLToken(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
int getNextXMLToken() throws IOException { tokenBeg = cursor; stringBufferTop = 0; // remember the XML for (int c = getChar(); c != EOF_CHAR; c = getChar()) { if (xmlIsTagContent) { switch (c) { case '>': addToString(c); xmlIsTagContent = false; xmlIsAttribute = false; break; case '/': addToString(c); if (peekChar() == '>') { c = getChar(); addToString(c); xmlIsTagContent = false; xmlOpenTagsCount--; } break; case '{': ungetChar(c); this.string = getStringFromBuffer(); return Token.XML; case '\'': case '"': addToString(c); if (!readQuotedString(c)) return Token.ERROR; break; case '=': addToString(c); xmlIsAttribute = true; break; case ' ': case '\t': case '\r': case '\n': addToString(c); break; default: addToString(c); xmlIsAttribute = false; break; } if (!xmlIsTagContent && xmlOpenTagsCount == 0) { this.string = getStringFromBuffer(); return Token.XMLEND; } } else { switch (c) { case '<': addToString(c); c = peekChar(); switch (c) { case '!': c = getChar(); // Skip ! addToString(c); c = peekChar(); switch (c) { case '-': c = getChar(); // Skip - addToString(c); c = getChar(); if (c == '-') { addToString(c); if(!readXmlComment()) return Token.ERROR; } else { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } break; case '[': c = getChar(); // Skip [ addToString(c); if (getChar() == 'C' && getChar() == 'D' && getChar() == 'A' && getChar() == 'T' && getChar() == 'A' && getChar() == '[') { addToString('C'); addToString('D'); addToString('A'); addToString('T'); addToString('A'); addToString('['); if (!readCDATA()) return Token.ERROR; } else { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } break; default: if(!readEntity()) return Token.ERROR; break; } break; case '?': c = getChar(); // Skip ? addToString(c); if (!readPI()) return Token.ERROR; break; case '/': // End tag c = getChar(); // Skip / addToString(c); if (xmlOpenTagsCount == 0) { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } xmlIsTagContent = true; xmlOpenTagsCount--; break; default: // Start tag xmlIsTagContent = true; xmlOpenTagsCount++; break; } break; case '{': ungetChar(c); this.string = getStringFromBuffer(); return Token.XML; default: addToString(c); break; } } } tokenEnd = cursor; stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readQuotedString(int quote) throws IOException { for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); if (c == quote) return true; } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readXmlComment() throws IOException { for (int c = getChar(); c != EOF_CHAR;) { addToString(c); if (c == '-' && peekChar() == '-') { c = getChar(); addToString(c); if (peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } else { continue; } } c = getChar(); } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readCDATA() throws IOException { for (int c = getChar(); c != EOF_CHAR;) { addToString(c); if (c == ']' && peekChar() == ']') { c = getChar(); addToString(c); if (peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } else { continue; } } c = getChar(); } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readEntity() throws IOException { int declTags = 1; for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); switch (c) { case '<': declTags++; break; case '>': declTags--; if (declTags == 0) return true; break; } } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readPI() throws IOException { for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); if (c == '?' && peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean matchChar(int test) throws IOException { int c = getCharIgnoreLineEnd(); if (c == test) { tokenEnd = cursor; return true; } else { ungetCharIgnoreLineEnd(c); return false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int peekChar() throws IOException { int c = getChar(); ungetChar(c); return c; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getChar() throws IOException { return getChar(true); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getChar(boolean skipFormattingChars) throws IOException { if (ungetCursor != 0) { cursor++; return ungetBuffer[--ungetCursor]; } for(;;) { int c; if (sourceString != null) { if (sourceCursor == sourceEnd) { hitEOF = true; return EOF_CHAR; } cursor++; c = sourceString.charAt(sourceCursor++); } else { if (sourceCursor == sourceEnd) { if (!fillSourceBuffer()) { hitEOF = true; return EOF_CHAR; } } cursor++; c = sourceBuffer[sourceCursor++]; } if (lineEndChar >= 0) { if (lineEndChar == '\r' && c == '\n') { lineEndChar = '\n'; continue; } lineEndChar = -1; lineStart = sourceCursor - 1; lineno++; } if (c <= 127) { if (c == '\n' || c == '\r') { lineEndChar = c; c = '\n'; } } else { if (c == BYTE_ORDER_MARK) return c; // BOM is considered whitespace if (skipFormattingChars && isJSFormatChar(c)) { continue; } if (ScriptRuntime.isJSLineTerminator(c)) { lineEndChar = c; c = '\n'; } } return c; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getCharIgnoreLineEnd() throws IOException { if (ungetCursor != 0) { cursor++; return ungetBuffer[--ungetCursor]; } for(;;) { int c; if (sourceString != null) { if (sourceCursor == sourceEnd) { hitEOF = true; return EOF_CHAR; } cursor++; c = sourceString.charAt(sourceCursor++); } else { if (sourceCursor == sourceEnd) { if (!fillSourceBuffer()) { hitEOF = true; return EOF_CHAR; } } cursor++; c = sourceBuffer[sourceCursor++]; } if (c <= 127) { if (c == '\n' || c == '\r') { lineEndChar = c; c = '\n'; } } else { if (c == BYTE_ORDER_MARK) return c; // BOM is considered whitespace if (isJSFormatChar(c)) { continue; } if (ScriptRuntime.isJSLineTerminator(c)) { lineEndChar = c; c = '\n'; } } return c; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private void skipLine() throws IOException { // skip to end of line int c; while ((c = getChar()) != EOF_CHAR && c != '\n') { } ungetChar(c); tokenEnd = cursor; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean fillSourceBuffer() throws IOException { if (sourceString != null) Kit.codeBug(); if (sourceEnd == sourceBuffer.length) { if (lineStart != 0 && !isMarkingComment()) { System.arraycopy(sourceBuffer, lineStart, sourceBuffer, 0, sourceEnd - lineStart); sourceEnd -= lineStart; sourceCursor -= lineStart; lineStart = 0; } else { char[] tmp = new char[sourceBuffer.length * 2]; System.arraycopy(sourceBuffer, 0, tmp, 0, sourceEnd); sourceBuffer = tmp; } } int n = sourceReader.read(sourceBuffer, sourceEnd, sourceBuffer.length - sourceEnd); if (n < 0) { return false; } sourceEnd += n; return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekToken() throws IOException { // By far the most common case: last token hasn't been consumed, // so return already-peeked token. if (currentFlaggedToken != Token.EOF) { return currentToken; } int lineno = ts.getLineno(); int tt = ts.getToken(); boolean sawEOL = false; // process comments and whitespace while (tt == Token.EOL || tt == Token.COMMENT) { if (tt == Token.EOL) { lineno++; sawEOL = true; } else { if (compilerEnv.isRecordingComments()) { String comment = ts.getAndResetCurrentComment(); recordComment(lineno, comment); // Comments may contain multiple lines, get the number // of EoLs and increase the lineno lineno += getNumberOfEols(comment); } } tt = ts.getToken(); } currentToken = tt; currentFlaggedToken = tt | (sawEOL ? TI_AFTER_EOL : 0); return currentToken; // return unflagged token }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekFlaggedToken() throws IOException { peekToken(); return currentFlaggedToken; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int nextToken() throws IOException { int tt = peekToken(); consumeToken(); return tt; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int nextFlaggedToken() throws IOException { peekToken(); int ttFlagged = currentFlaggedToken; consumeToken(); return ttFlagged; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean matchToken(int toMatch) throws IOException { if (peekToken() != toMatch) { return false; } consumeToken(); return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekTokenOrEOL() throws IOException { int tt = peekToken(); // Check for last peeked token flags if ((currentFlaggedToken & TI_AFTER_EOL) != 0) { tt = Token.EOL; } return tt; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean mustMatchToken(int toMatch, String messageId) throws IOException { return mustMatchToken(toMatch, messageId, ts.tokenBeg, ts.tokenEnd - ts.tokenBeg); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean mustMatchToken(int toMatch, String msgId, int pos, int len) throws IOException { if (matchToken(toMatch)) { return true; } reportError(msgId, pos, len); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(Reader sourceReader, String sourceURI, int lineno) throws IOException { if (parseFinished) throw new IllegalStateException("parser reused"); if (compilerEnv.isIdeMode()) { return parse(readFully(sourceReader), sourceURI, lineno); } try { this.sourceURI = sourceURI; ts = new TokenStream(this, sourceReader, null, lineno); return parse(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstRoot parse() throws IOException { int pos = 0; AstRoot root = new AstRoot(pos); currentScope = currentScriptOrFn = root; int baseLineno = ts.lineno; // line number where source starts int end = pos; // in case source is empty boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // TODO: eval code should get strict mode from invoking code inUseStrictDirective = false; try { for (;;) { int tt = peekToken(); if (tt <= Token.EOF) { break; } AstNode n; if (tt == Token.FUNCTION) { consumeToken(); try { n = function(calledByCompileFunction ? FunctionNode.FUNCTION_EXPRESSION : FunctionNode.FUNCTION_STATEMENT); } catch (ParserException e) { break; } } else { n = statement(); if (inDirectivePrologue) { String directive = getDirective(n); if (directive == null) { inDirectivePrologue = false; } else if (directive.equals("use strict")) { inUseStrictDirective = true; root.setInStrictMode(true); } } } end = getNodeEnd(n); root.addChildToBack(n); n.setParent(root); } } catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); } finally { inUseStrictDirective = savedStrictMode; } if (this.syntaxErrorCount != 0) { String msg = String.valueOf(this.syntaxErrorCount); msg = lookupMessage("msg.got.syntax.errors", msg); if (!compilerEnv.isIdeMode()) throw errorReporter.runtimeError(msg, sourceURI, baseLineno, null, 0); } // add comments to root in lexical order if (scannedComments != null) { // If we find a comment beyond end of our last statement or // function, extend the root bounds to the end of that comment. int last = scannedComments.size() - 1; end = Math.max(end, getNodeEnd(scannedComments.get(last))); for (Comment c : scannedComments) { root.addComment(c); } } root.setLength(end - pos); root.setSourceName(sourceURI); root.setBaseLineno(baseLineno); root.setEndLineno(ts.lineno); return root; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode parseFunctionBody() throws IOException { boolean isExpressionClosure = false; if (!matchToken(Token.LC)) { if (compilerEnv.getLanguageVersion() < Context.VERSION_1_8) { reportError("msg.no.brace.body"); } else { isExpressionClosure = true; } } ++nestingOfFunction; int pos = ts.tokenBeg; Block pn = new Block(pos); // starts at LC position boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // Don't set 'inUseStrictDirective' to false: inherit strict mode. pn.setLineno(ts.lineno); try { if (isExpressionClosure) { ReturnStatement n = new ReturnStatement(ts.lineno); n.setReturnValue(assignExpr()); // expression closure flag is required on both nodes n.putProp(Node.EXPRESSION_CLOSURE_PROP, Boolean.TRUE); pn.putProp(Node.EXPRESSION_CLOSURE_PROP, Boolean.TRUE); pn.addStatement(n); } else { bodyLoop: for (;;) { AstNode n; int tt = peekToken(); switch (tt) { case Token.ERROR: case Token.EOF: case Token.RC: break bodyLoop; case Token.FUNCTION: consumeToken(); n = function(FunctionNode.FUNCTION_STATEMENT); break; default: n = statement(); if (inDirectivePrologue) { String directive = getDirective(n); if (directive == null) { inDirectivePrologue = false; } else if (directive.equals("use strict")) { inUseStrictDirective = true; } } break; } pn.addStatement(n); } } } catch (ParserException e) { // Ignore it } finally { --nestingOfFunction; inUseStrictDirective = savedStrictMode; } int end = ts.tokenEnd; getAndResetJsDoc(); if (!isExpressionClosure && mustMatchToken(Token.RC, "msg.no.brace.after.body")) end = ts.tokenEnd; pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void parseFunctionParams(FunctionNode fnNode) throws IOException { if (matchToken(Token.RP)) { fnNode.setRp(ts.tokenBeg - fnNode.getPosition()); return; } // Would prefer not to call createDestructuringAssignment until codegen, // but the symbol definitions have to happen now, before body is parsed. Map<String, Node> destructuring = null; Set<String> paramNames = new HashSet<String>(); do { int tt = peekToken(); if (tt == Token.LB || tt == Token.LC) { AstNode expr = destructuringPrimaryExpr(); markDestructuring(expr); fnNode.addParam(expr); // Destructuring assignment for parameters: add a dummy // parameter name, and add a statement to the body to initialize // variables from the destructuring assignment if (destructuring == null) { destructuring = new HashMap<String, Node>(); } String pname = currentScriptOrFn.getNextTempName(); defineSymbol(Token.LP, pname, false); destructuring.put(pname, expr); } else { if (mustMatchToken(Token.NAME, "msg.no.parm")) { fnNode.addParam(createNameNode()); String paramName = ts.getString(); defineSymbol(Token.LP, paramName); if (this.inUseStrictDirective) { if ("eval".equals(paramName) || "arguments".equals(paramName)) { reportError("msg.bad.id.strict", paramName); } if (paramNames.contains(paramName)) addError("msg.dup.param.strict", paramName); paramNames.add(paramName); } } else { fnNode.addParam(makeErrorNode()); } } } while (matchToken(Token.COMMA)); if (destructuring != null) { Node destructuringNode = new Node(Token.COMMA); // Add assignment helper for each destructuring parameter for (Map.Entry<String, Node> param: destructuring.entrySet()) { Node assign = createDestructuringAssignment(Token.VAR, param.getValue(), createName(param.getKey())); destructuringNode.addChildToBack(assign); } fnNode.putProp(Node.DESTRUCTURING_PARAMS, destructuringNode); } if (mustMatchToken(Token.RP, "msg.no.paren.after.parms")) { fnNode.setRp(ts.tokenBeg - fnNode.getPosition()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private FunctionNode function(int type) throws IOException { int syntheticType = type; int baseLineno = ts.lineno; // line number where source starts int functionSourceStart = ts.tokenBeg; // start of "function" kwd Name name = null; AstNode memberExprNode = null; if (matchToken(Token.NAME)) { name = createNameNode(true, Token.NAME); if (inUseStrictDirective) { String id = name.getIdentifier(); if ("eval".equals(id)|| "arguments".equals(id)) { reportError("msg.bad.id.strict", id); } } if (!matchToken(Token.LP)) { if (compilerEnv.isAllowMemberExprAsFunctionName()) { AstNode memberExprHead = name; name = null; memberExprNode = memberExprTail(false, memberExprHead); } mustMatchToken(Token.LP, "msg.no.paren.parms"); } } else if (matchToken(Token.LP)) { // Anonymous function: leave name as null } else { if (compilerEnv.isAllowMemberExprAsFunctionName()) { // Note that memberExpr can not start with '(' like // in function (1+2).toString(), because 'function (' already // processed as anonymous function memberExprNode = memberExpr(false); } mustMatchToken(Token.LP, "msg.no.paren.parms"); } int lpPos = currentToken == Token.LP ? ts.tokenBeg : -1; if (memberExprNode != null) { syntheticType = FunctionNode.FUNCTION_EXPRESSION; } if (syntheticType != FunctionNode.FUNCTION_EXPRESSION && name != null && name.length() > 0) { // Function statements define a symbol in the enclosing scope defineSymbol(Token.FUNCTION, name.getIdentifier()); } FunctionNode fnNode = new FunctionNode(functionSourceStart, name); fnNode.setFunctionType(type); if (lpPos != -1) fnNode.setLp(lpPos - functionSourceStart); fnNode.setJsDocNode(getAndResetJsDoc()); PerFunctionVariables savedVars = new PerFunctionVariables(fnNode); try { parseFunctionParams(fnNode); fnNode.setBody(parseFunctionBody()); fnNode.setEncodedSourceBounds(functionSourceStart, ts.tokenEnd); fnNode.setLength(ts.tokenEnd - functionSourceStart); if (compilerEnv.isStrictMode() && !fnNode.getBody().hasConsistentReturnUsage()) { String msg = (name != null && name.length() > 0) ? "msg.no.return.value" : "msg.anon.no.return.value"; addStrictWarning(msg, name == null ? "" : name.getIdentifier()); } } finally { savedVars.restore(); } if (memberExprNode != null) { // TODO(stevey): fix missing functionality Kit.codeBug(); fnNode.setMemberExprNode(memberExprNode); // rewrite later /* old code: if (memberExprNode != null) { pn = nf.createAssignment(Token.ASSIGN, memberExprNode, pn); if (functionType != FunctionNode.FUNCTION_EXPRESSION) { // XXX check JScript behavior: should it be createExprStatement? pn = nf.createExprStatementNoReturn(pn, baseLineno); } } */ } fnNode.setSourceName(sourceURI); fnNode.setBaseLineno(baseLineno); fnNode.setEndLineno(ts.lineno); // Set the parent scope. Needed for finding undeclared vars. // Have to wait until after parsing the function to set its parent // scope, since defineSymbol needs the defining-scope check to stop // at the function boundary when checking for redeclarations. if (compilerEnv.isIdeMode()) { fnNode.setParentScope(currentScope); } return fnNode; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statements(AstNode parent) throws IOException { if (currentToken != Token.LC // assertion can be invalid in bad code && !compilerEnv.isIdeMode()) codeBug(); int pos = ts.tokenBeg; AstNode block = parent != null ? parent : new Block(pos); block.setLineno(ts.lineno); int tt; while ((tt = peekToken()) > Token.EOF && tt != Token.RC) { block.addChild(statement()); } block.setLength(ts.tokenBeg - pos); return block; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statements() throws IOException { return statements(null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ConditionData condition() throws IOException { ConditionData data = new ConditionData(); if (mustMatchToken(Token.LP, "msg.no.paren.cond")) data.lp = ts.tokenBeg; data.condition = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.after.cond")) data.rp = ts.tokenBeg; // Report strict warning on code like "if (a = 7) ...". Suppress the // warning if the condition is parenthesized, like "if ((a = 7)) ...". if (data.condition instanceof Assignment) { addStrictWarning("msg.equal.as.assign", "", data.condition.getPosition(), data.condition.getLength()); } return data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statement() throws IOException { int pos = ts.tokenBeg; try { AstNode pn = statementHelper(); if (pn != null) { if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) { int beg = pn.getPosition(); beg = Math.max(beg, lineBeginningFor(beg)); addStrictWarning(pn instanceof EmptyStatement ? "msg.extra.trailing.semi" : "msg.no.side.effects", "", beg, nodeEnd(pn) - beg); } return pn; } } catch (ParserException e) { // an ErrorNode was added to the ErrorReporter } // error: skip ahead to a probable statement boundary guessingStatementEnd: for (;;) { int tt = peekTokenOrEOL(); consumeToken(); switch (tt) { case Token.ERROR: case Token.EOF: case Token.EOL: case Token.SEMI: break guessingStatementEnd; } } // We don't make error nodes explicitly part of the tree; // they get added to the ErrorReporter. May need to do // something different here. return new EmptyStatement(pos, ts.tokenBeg - pos); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statementHelper() throws IOException { // If the statement is set, then it's been told its label by now. if (currentLabel != null && currentLabel.getStatement() != null) currentLabel = null; AstNode pn = null; int tt = peekToken(), pos = ts.tokenBeg; switch (tt) { case Token.IF: return ifStatement(); case Token.SWITCH: return switchStatement(); case Token.WHILE: return whileLoop(); case Token.DO: return doLoop(); case Token.FOR: return forLoop(); case Token.TRY: return tryStatement(); case Token.THROW: pn = throwStatement(); break; case Token.BREAK: pn = breakStatement(); break; case Token.CONTINUE: pn = continueStatement(); break; case Token.WITH: if (this.inUseStrictDirective) { reportError("msg.no.with.strict"); } return withStatement(); case Token.CONST: case Token.VAR: consumeToken(); int lineno = ts.lineno; pn = variables(currentToken, ts.tokenBeg, true); pn.setLineno(lineno); break; case Token.LET: pn = letStatement(); if (pn instanceof VariableDeclaration && peekToken() == Token.SEMI) break; return pn; case Token.RETURN: case Token.YIELD: pn = returnOrYield(tt, false); break; case Token.DEBUGGER: consumeToken(); pn = new KeywordLiteral(ts.tokenBeg, ts.tokenEnd - ts.tokenBeg, tt); pn.setLineno(ts.lineno); break; case Token.LC: return block(); case Token.ERROR: consumeToken(); return makeErrorNode(); case Token.SEMI: consumeToken(); pos = ts.tokenBeg; pn = new EmptyStatement(pos, ts.tokenEnd - pos); pn.setLineno(ts.lineno); return pn; case Token.FUNCTION: consumeToken(); return function(FunctionNode.FUNCTION_EXPRESSION_STATEMENT); case Token.DEFAULT : pn = defaultXmlNamespace(); break; case Token.NAME: pn = nameOrLabel(); if (pn instanceof ExpressionStatement) break; return pn; // LabeledStatement default: lineno = ts.lineno; pn = new ExpressionStatement(expr(), !insideFunction()); pn.setLineno(lineno); break; } autoInsertSemicolon(pn); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void autoInsertSemicolon(AstNode pn) throws IOException { int ttFlagged = peekFlaggedToken(); int pos = pn.getPosition(); switch (ttFlagged & CLEAR_TI_MASK) { case Token.SEMI: // Consume ';' as a part of expression consumeToken(); // extend the node bounds to include the semicolon. pn.setLength(ts.tokenEnd - pos); break; case Token.ERROR: case Token.EOF: case Token.RC: // Autoinsert ; warnMissingSemi(pos, nodeEnd(pn)); break; default: if ((ttFlagged & TI_AFTER_EOL) == 0) { // Report error if no EOL or autoinsert ; otherwise reportError("msg.no.semi.stmt"); } else { warnMissingSemi(pos, nodeEnd(pn)); } break; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private IfStatement ifStatement() throws IOException { if (currentToken != Token.IF) codeBug(); consumeToken(); int pos = ts.tokenBeg, lineno = ts.lineno, elsePos = -1; ConditionData data = condition(); AstNode ifTrue = statement(), ifFalse = null; if (matchToken(Token.ELSE)) { elsePos = ts.tokenBeg - pos; ifFalse = statement(); } int end = getNodeEnd(ifFalse != null ? ifFalse : ifTrue); IfStatement pn = new IfStatement(pos, end - pos); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); pn.setThenPart(ifTrue); pn.setElsePart(ifFalse); pn.setElsePosition(elsePos); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private SwitchStatement switchStatement() throws IOException { if (currentToken != Token.SWITCH) codeBug(); consumeToken(); int pos = ts.tokenBeg; SwitchStatement pn = new SwitchStatement(pos); if (mustMatchToken(Token.LP, "msg.no.paren.switch")) pn.setLp(ts.tokenBeg - pos); pn.setLineno(ts.lineno); AstNode discriminant = expr(); pn.setExpression(discriminant); enterSwitch(pn); try { if (mustMatchToken(Token.RP, "msg.no.paren.after.switch")) pn.setRp(ts.tokenBeg - pos); mustMatchToken(Token.LC, "msg.no.brace.switch"); boolean hasDefault = false; int tt; switchLoop: for (;;) { tt = nextToken(); int casePos = ts.tokenBeg; int caseLineno = ts.lineno; AstNode caseExpression = null; switch (tt) { case Token.RC: pn.setLength(ts.tokenEnd - pos); break switchLoop; case Token.CASE: caseExpression = expr(); mustMatchToken(Token.COLON, "msg.no.colon.case"); break; case Token.DEFAULT: if (hasDefault) { reportError("msg.double.switch.default"); } hasDefault = true; caseExpression = null; mustMatchToken(Token.COLON, "msg.no.colon.case"); break; default: reportError("msg.bad.switch"); break switchLoop; } SwitchCase caseNode = new SwitchCase(casePos); caseNode.setExpression(caseExpression); caseNode.setLength(ts.tokenEnd - pos); // include colon caseNode.setLineno(caseLineno); while ((tt = peekToken()) != Token.RC && tt != Token.CASE && tt != Token.DEFAULT && tt != Token.EOF) { caseNode.addStatement(statement()); // updates length } pn.addCase(caseNode); } } finally { exitSwitch(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private WhileLoop whileLoop() throws IOException { if (currentToken != Token.WHILE) codeBug(); consumeToken(); int pos = ts.tokenBeg; WhileLoop pn = new WhileLoop(pos); pn.setLineno(ts.lineno); enterLoop(pn); try { ConditionData data = condition(); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); AstNode body = statement(); pn.setLength(getNodeEnd(body) - pos); pn.setBody(body); } finally { exitLoop(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private DoLoop doLoop() throws IOException { if (currentToken != Token.DO) codeBug(); consumeToken(); int pos = ts.tokenBeg, end; DoLoop pn = new DoLoop(pos); pn.setLineno(ts.lineno); enterLoop(pn); try { AstNode body = statement(); mustMatchToken(Token.WHILE, "msg.no.while.do"); pn.setWhilePosition(ts.tokenBeg - pos); ConditionData data = condition(); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); end = getNodeEnd(body); pn.setBody(body); } finally { exitLoop(); } // Always auto-insert semicolon to follow SpiderMonkey: // It is required by ECMAScript but is ignored by the rest of // world, see bug 238945 if (matchToken(Token.SEMI)) { end = ts.tokenEnd; } pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private Loop forLoop() throws IOException { if (currentToken != Token.FOR) codeBug(); consumeToken(); int forPos = ts.tokenBeg, lineno = ts.lineno; boolean isForEach = false, isForIn = false; int eachPos = -1, inPos = -1, lp = -1, rp = -1; AstNode init = null; // init is also foo in 'foo in object' AstNode cond = null; // cond is also object in 'foo in object' AstNode incr = null; Loop pn = null; Scope tempScope = new Scope(); pushScope(tempScope); // decide below what AST class to use try { // See if this is a for each () instead of just a for () if (matchToken(Token.NAME)) { if ("each".equals(ts.getString())) { isForEach = true; eachPos = ts.tokenBeg - forPos; } else { reportError("msg.no.paren.for"); } } if (mustMatchToken(Token.LP, "msg.no.paren.for")) lp = ts.tokenBeg - forPos; int tt = peekToken(); init = forLoopInit(tt); if (matchToken(Token.IN)) { isForIn = true; inPos = ts.tokenBeg - forPos; cond = expr(); // object over which we're iterating } else { // ordinary for-loop mustMatchToken(Token.SEMI, "msg.no.semi.for"); if (peekToken() == Token.SEMI) { // no loop condition cond = new EmptyExpression(ts.tokenBeg, 1); cond.setLineno(ts.lineno); } else { cond = expr(); } mustMatchToken(Token.SEMI, "msg.no.semi.for.cond"); int tmpPos = ts.tokenEnd; if (peekToken() == Token.RP) { incr = new EmptyExpression(tmpPos, 1); incr.setLineno(ts.lineno); } else { incr = expr(); } } if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - forPos; if (isForIn) { ForInLoop fis = new ForInLoop(forPos); if (init instanceof VariableDeclaration) { // check that there was only one variable given if (((VariableDeclaration)init).getVariables().size() > 1) { reportError("msg.mult.index"); } } fis.setIterator(init); fis.setIteratedObject(cond); fis.setInPosition(inPos); fis.setIsForEach(isForEach); fis.setEachPosition(eachPos); pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl; } // replace temp scope with the new loop object currentScope.replaceWith(pn); popScope(); // We have to parse the body -after- creating the loop node, // so that the loop node appears in the loopSet, allowing // break/continue statements to find the enclosing loop. enterLoop(pn); try { AstNode body = statement(); pn.setLength(getNodeEnd(body) - forPos); pn.setBody(body); } finally { exitLoop(); } } finally { if (currentScope == tempScope) { popScope(); } } pn.setParens(lp, rp); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode forLoopInit(int tt) throws IOException { try { inForInit = true; // checked by variables() and relExpr() AstNode init = null; if (tt == Token.SEMI) { init = new EmptyExpression(ts.tokenBeg, 1); init.setLineno(ts.lineno); } else if (tt == Token.VAR || tt == Token.LET) { consumeToken(); init = variables(tt, ts.tokenBeg, false); } else { init = expr(); markDestructuring(init); } return init; } finally { inForInit = false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private TryStatement tryStatement() throws IOException { if (currentToken != Token.TRY) codeBug(); consumeToken(); // Pull out JSDoc info and reset it before recursing. Comment jsdocNode = getAndResetJsDoc(); int tryPos = ts.tokenBeg, lineno = ts.lineno, finallyPos = -1; if (peekToken() != Token.LC) { reportError("msg.no.brace.try"); } AstNode tryBlock = statement(); int tryEnd = getNodeEnd(tryBlock); List<CatchClause> clauses = null; boolean sawDefaultCatch = false; int peek = peekToken(); if (peek == Token.CATCH) { while (matchToken(Token.CATCH)) { int catchLineNum = ts.lineno; if (sawDefaultCatch) { reportError("msg.catch.unreachable"); } int catchPos = ts.tokenBeg, lp = -1, rp = -1, guardPos = -1; if (mustMatchToken(Token.LP, "msg.no.paren.catch")) lp = ts.tokenBeg; mustMatchToken(Token.NAME, "msg.bad.catchcond"); Name varName = createNameNode(); String varNameString = varName.getIdentifier(); if (inUseStrictDirective) { if ("eval".equals(varNameString) || "arguments".equals(varNameString)) { reportError("msg.bad.id.strict", varNameString); } } AstNode catchCond = null; if (matchToken(Token.IF)) { guardPos = ts.tokenBeg; catchCond = expr(); } else { sawDefaultCatch = true; } if (mustMatchToken(Token.RP, "msg.bad.catchcond")) rp = ts.tokenBeg; mustMatchToken(Token.LC, "msg.no.brace.catchblock"); Block catchBlock = (Block)statements(); tryEnd = getNodeEnd(catchBlock); CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); } catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); if (mustMatchToken(Token.RC, "msg.no.brace.after.body")) tryEnd = ts.tokenEnd; catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>(); clauses.add(catchNode); } } else if (peek != Token.FINALLY) { mustMatchToken(Token.FINALLY, "msg.try.no.catchfinally"); } AstNode finallyBlock = null; if (matchToken(Token.FINALLY)) { finallyPos = ts.tokenBeg; finallyBlock = statement(); tryEnd = getNodeEnd(finallyBlock); } TryStatement pn = new TryStatement(tryPos, tryEnd - tryPos); pn.setTryBlock(tryBlock); pn.setCatchClauses(clauses); pn.setFinallyBlock(finallyBlock); if (finallyPos != -1) { pn.setFinallyPosition(finallyPos - tryPos); } pn.setLineno(lineno); if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ThrowStatement throwStatement() throws IOException { if (currentToken != Token.THROW) codeBug(); consumeToken(); int pos = ts.tokenBeg, lineno = ts.lineno; if (peekTokenOrEOL() == Token.EOL) { // ECMAScript does not allow new lines before throw expression, // see bug 256617 reportError("msg.bad.throw.eol"); } AstNode expr = expr(); ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private LabeledStatement matchJumpLabelName() throws IOException { LabeledStatement label = null; if (peekTokenOrEOL() == Token.NAME) { consumeToken(); if (labelSet != null) { label = labelSet.get(ts.getString()); } if (label == null) { reportError("msg.undef.label"); } } return label; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private BreakStatement breakStatement() throws IOException { if (currentToken != Token.BREAK) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; Name breakLabel = null; if (peekTokenOrEOL() == Token.NAME) { breakLabel = createNameNode(); end = getNodeEnd(breakLabel); } // matchJumpLabelName only matches if there is one LabeledStatement labels = matchJumpLabelName(); // always use first label as target Jump breakTarget = labels == null ? null : labels.getFirstLabel(); if (breakTarget == null && breakLabel == null) { if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) { if (breakLabel == null) { reportError("msg.bad.break", pos, end - pos); } } else { breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1); } } BreakStatement pn = new BreakStatement(pos, end - pos); pn.setBreakLabel(breakLabel); // can be null if it's a bad break in error-recovery mode if (breakTarget != null) pn.setBreakTarget(breakTarget); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ContinueStatement continueStatement() throws IOException { if (currentToken != Token.CONTINUE) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; Name label = null; if (peekTokenOrEOL() == Token.NAME) { label = createNameNode(); end = getNodeEnd(label); } // matchJumpLabelName only matches if there is one LabeledStatement labels = matchJumpLabelName(); Loop target = null; if (labels == null && label == null) { if (loopSet == null || loopSet.size() == 0) { reportError("msg.continue.outside"); } else { target = loopSet.get(loopSet.size() - 1); } } else { if (labels == null || !(labels.getStatement() instanceof Loop)) { reportError("msg.continue.nonloop", pos, end - pos); } target = labels == null ? null : (Loop)labels.getStatement(); } ContinueStatement pn = new ContinueStatement(pos, end - pos); if (target != null) // can be null in error-recovery mode pn.setTarget(target); pn.setLabel(label); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private WithStatement withStatement() throws IOException { if (currentToken != Token.WITH) codeBug(); consumeToken(); Comment withComment = getAndResetJsDoc(); int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1; if (mustMatchToken(Token.LP, "msg.no.paren.with")) lp = ts.tokenBeg; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.after.with")) rp = ts.tokenBeg; AstNode body = statement(); WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos); pn.setJsDocNode(withComment); pn.setExpression(obj); pn.setStatement(body); pn.setParens(lp, rp); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode letStatement() throws IOException { if (currentToken != Token.LET) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg; AstNode pn; if (peekToken() == Token.LP) { pn = let(true, pos); } else { pn = variables(Token.LET, pos, true); // else, e.g.: let x=6, y=7; } pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode returnOrYield(int tt, boolean exprContext) throws IOException { if (!insideFunction()) { reportError(tt == Token.RETURN ? "msg.bad.return" : "msg.bad.yield"); } consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; AstNode e = null; // This is ugly, but we don't want to require a semicolon. switch (peekTokenOrEOL()) { case Token.SEMI: case Token.RC: case Token.RB: case Token.RP: case Token.EOF: case Token.EOL: case Token.ERROR: case Token.YIELD: break; default: e = expr(); end = getNodeEnd(e); } int before = endFlags; AstNode ret; if (tt == Token.RETURN) { endFlags |= e == null ? Node.END_RETURNS : Node.END_RETURNS_VALUE; ret = new ReturnStatement(pos, end - pos, e); // see if we need a strict mode warning if (nowAllSet(before, endFlags, Node.END_RETURNS|Node.END_RETURNS_VALUE)) addStrictWarning("msg.return.inconsistent", "", pos, end - pos); } else { if (!insideFunction()) reportError("msg.bad.yield"); endFlags |= Node.END_YIELDS; ret = new Yield(pos, end - pos, e); setRequiresActivation(); setIsGenerator(); if (!exprContext) { ret = new ExpressionStatement(ret); } } // see if we are mixing yields and value returns. if (insideFunction() && nowAllSet(before, endFlags, Node.END_YIELDS|Node.END_RETURNS_VALUE)) { Name name = ((FunctionNode)currentScriptOrFn).getFunctionName(); if (name == null || name.length() == 0) addError("msg.anon.generator.returns", ""); else addError("msg.generator.returns", name.getIdentifier()); } ret.setLineno(lineno); return ret; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode block() throws IOException { if (currentToken != Token.LC) codeBug(); consumeToken(); int pos = ts.tokenBeg; Scope block = new Scope(pos); block.setLineno(ts.lineno); pushScope(block); try { statements(block); mustMatchToken(Token.RC, "msg.no.brace.block"); block.setLength(ts.tokenEnd - pos); return block; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode defaultXmlNamespace() throws IOException { if (currentToken != Token.DEFAULT) codeBug(); consumeToken(); mustHaveXML(); setRequiresActivation(); int lineno = ts.lineno, pos = ts.tokenBeg; if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) { reportError("msg.bad.namespace"); } if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) { reportError("msg.bad.namespace"); } if (!matchToken(Token.ASSIGN)) { reportError("msg.bad.namespace"); } AstNode e = expr(); UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos); dxmln.setOperator(Token.DEFAULTNAMESPACE); dxmln.setOperand(e); dxmln.setLineno(lineno); ExpressionStatement es = new ExpressionStatement(dxmln, true); return es; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void recordLabel(Label label, LabeledStatement bundle) throws IOException { // current token should be colon that primaryExpr left untouched if (peekToken() != Token.COLON) codeBug(); consumeToken(); String name = label.getName(); if (labelSet == null) { labelSet = new HashMap<String,LabeledStatement>(); } else { LabeledStatement ls = labelSet.get(name); if (ls != null) { if (compilerEnv.isIdeMode()) { Label dup = ls.getLabelByName(name); reportError("msg.dup.label", dup.getAbsolutePosition(), dup.getLength()); } reportError("msg.dup.label", label.getPosition(), label.getLength()); } } bundle.addLabel(label); labelSet.put(name, bundle); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode nameOrLabel() throws IOException { if (currentToken != Token.NAME) throw codeBug(); int pos = ts.tokenBeg; // set check for label and call down to primaryExpr currentFlaggedToken |= TI_CHECK_LABEL; AstNode expr = expr(); if (expr.getType() != Token.LABEL) { AstNode n = new ExpressionStatement(expr, !insideFunction()); n.lineno = expr.lineno; return n; } LabeledStatement bundle = new LabeledStatement(pos); recordLabel((Label)expr, bundle); bundle.setLineno(ts.lineno); // look for more labels AstNode stmt = null; while (peekToken() == Token.NAME) { currentFlaggedToken |= TI_CHECK_LABEL; expr = expr(); if (expr.getType() != Token.LABEL) { stmt = new ExpressionStatement(expr, !insideFunction()); autoInsertSemicolon(stmt); break; } recordLabel((Label)expr, bundle); } // no more labels; now parse the labeled statement try { currentLabel = bundle; if (stmt == null) { stmt = statementHelper(); } } finally { currentLabel = null; // remove the labels for this statement from the global set for (Label lb : bundle.getLabels()) { labelSet.remove(lb.getName()); } } // If stmt has parent assigned its position already is relative // (See bug #710225) bundle.setLength(stmt.getParent() == null ? getNodeEnd(stmt) - pos : getNodeEnd(stmt)); bundle.setStatement(stmt); return bundle; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private VariableDeclaration variables(int declType, int pos, boolean isStatement) throws IOException { int end; VariableDeclaration pn = new VariableDeclaration(pos); pn.setType(declType); pn.setLineno(ts.lineno); Comment varjsdocNode = getAndResetJsDoc(); if (varjsdocNode != null) { pn.setJsDocNode(varjsdocNode); } // Example: // var foo = {a: 1, b: 2}, bar = [3, 4]; // var {b: s2, a: s1} = foo, x = 6, y, [s3, s4] = bar; for (;;) { AstNode destructuring = null; Name name = null; int tt = peekToken(), kidPos = ts.tokenBeg; end = ts.tokenEnd; if (tt == Token.LB || tt == Token.LC) { // Destructuring assignment, e.g., var [a,b] = ... destructuring = destructuringPrimaryExpr(); end = getNodeEnd(destructuring); if (!(destructuring instanceof DestructuringForm)) reportError("msg.bad.assign.left", kidPos, end - kidPos); markDestructuring(destructuring); } else { // Simple variable name mustMatchToken(Token.NAME, "msg.bad.var"); name = createNameNode(); name.setLineno(ts.getLineno()); if (inUseStrictDirective) { String id = ts.getString(); if ("eval".equals(id) || "arguments".equals(ts.getString())) { reportError("msg.bad.id.strict", id); } } defineSymbol(declType, ts.getString(), inForInit); } int lineno = ts.lineno; Comment jsdocNode = getAndResetJsDoc(); AstNode init = null; if (matchToken(Token.ASSIGN)) { init = assignExpr(); end = getNodeEnd(init); } VariableInitializer vi = new VariableInitializer(kidPos, end - kidPos); if (destructuring != null) { if (init == null && !inForInit) { reportError("msg.destruct.assign.no.init"); } vi.setTarget(destructuring); } else { vi.setTarget(name); } vi.setInitializer(init); vi.setType(declType); vi.setJsDocNode(jsdocNode); vi.setLineno(lineno); pn.addVariable(vi); if (!matchToken(Token.COMMA)) break; } pn.setLength(end - pos); pn.setIsStatement(isStatement); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode let(boolean isStatement, int pos) throws IOException { LetNode pn = new LetNode(pos); pn.setLineno(ts.lineno); if (mustMatchToken(Token.LP, "msg.no.paren.after.let")) pn.setLp(ts.tokenBeg - pos); pushScope(pn); try { VariableDeclaration vars = variables(Token.LET, ts.tokenBeg, isStatement); pn.setVariables(vars); if (mustMatchToken(Token.RP, "msg.no.paren.let")) { pn.setRp(ts.tokenBeg - pos); } if (isStatement && peekToken() == Token.LC) { // let statement consumeToken(); int beg = ts.tokenBeg; // position stmt at LC AstNode stmt = statements(); mustMatchToken(Token.RC, "msg.no.curly.let"); stmt.setLength(ts.tokenEnd - beg); pn.setLength(ts.tokenEnd - pos); pn.setBody(stmt); pn.setType(Token.LET); } else { // let expression AstNode expr = expr(); pn.setLength(getNodeEnd(expr) - pos); pn.setBody(expr); if (isStatement) { // let expression in statement context ExpressionStatement es = new ExpressionStatement(pn, !insideFunction()); es.setLineno(pn.getLineno()); return es; } } } finally { popScope(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode expr() throws IOException { AstNode pn = assignExpr(); int pos = pn.getPosition(); while (matchToken(Token.COMMA)) { int opPos = ts.tokenBeg; if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) addStrictWarning("msg.no.side.effects", "", pos, nodeEnd(pn) - pos); if (peekToken() == Token.YIELD) reportError("msg.yield.parenthesized"); pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode assignExpr() throws IOException { int tt = peekToken(); if (tt == Token.YIELD) { return returnOrYield(tt, true); } AstNode pn = condExpr(); tt = peekToken(); if (Token.FIRST_ASSIGN <= tt && tt <= Token.LAST_ASSIGN) { consumeToken(); // Pull out JSDoc info and reset it before recursing. Comment jsdocNode = getAndResetJsDoc(); markDestructuring(pn); int opPos = ts.tokenBeg; pn = new Assignment(tt, pn, assignExpr(), opPos); if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } } else if (tt == Token.SEMI) { // This may be dead code added intentionally, for JSDoc purposes. // For example: /** @type Number */ C.prototype.x; if (currentJsDocComment != null) { pn.setJsDocNode(getAndResetJsDoc()); } } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode condExpr() throws IOException { AstNode pn = orExpr(); if (matchToken(Token.HOOK)) { int line = ts.lineno; int qmarkPos = ts.tokenBeg, colonPos = -1; AstNode ifTrue = assignExpr(); if (mustMatchToken(Token.COLON, "msg.no.colon.cond")) colonPos = ts.tokenBeg; AstNode ifFalse = assignExpr(); int beg = pn.getPosition(), len = getNodeEnd(ifFalse) - beg; ConditionalExpression ce = new ConditionalExpression(beg, len); ce.setLineno(line); ce.setTestExpression(pn); ce.setTrueExpression(ifTrue); ce.setFalseExpression(ifFalse); ce.setQuestionMarkPosition(qmarkPos - beg); ce.setColonPosition(colonPos - beg); pn = ce; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode orExpr() throws IOException { AstNode pn = andExpr(); if (matchToken(Token.OR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.OR, pn, orExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode andExpr() throws IOException { AstNode pn = bitOrExpr(); if (matchToken(Token.AND)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.AND, pn, andExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitOrExpr() throws IOException { AstNode pn = bitXorExpr(); while (matchToken(Token.BITOR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITOR, pn, bitXorExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitXorExpr() throws IOException { AstNode pn = bitAndExpr(); while (matchToken(Token.BITXOR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITXOR, pn, bitAndExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitAndExpr() throws IOException { AstNode pn = eqExpr(); while (matchToken(Token.BITAND)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITAND, pn, eqExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode eqExpr() throws IOException { AstNode pn = relExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.EQ: case Token.NE: case Token.SHEQ: case Token.SHNE: consumeToken(); int parseToken = tt; if (compilerEnv.getLanguageVersion() == Context.VERSION_1_2) { // JavaScript 1.2 uses shallow equality for == and != . if (tt == Token.EQ) parseToken = Token.SHEQ; else if (tt == Token.NE) parseToken = Token.SHNE; } pn = new InfixExpression(parseToken, pn, relExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode relExpr() throws IOException { AstNode pn = shiftExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.IN: if (inForInit) break; // fall through case Token.INSTANCEOF: case Token.LE: case Token.LT: case Token.GE: case Token.GT: consumeToken(); pn = new InfixExpression(tt, pn, shiftExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode shiftExpr() throws IOException { AstNode pn = addExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.LSH: case Token.URSH: case Token.RSH: consumeToken(); pn = new InfixExpression(tt, pn, addExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode addExpr() throws IOException { AstNode pn = mulExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; if (tt == Token.ADD || tt == Token.SUB) { consumeToken(); pn = new InfixExpression(tt, pn, mulExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode mulExpr() throws IOException { AstNode pn = unaryExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.MUL: case Token.DIV: case Token.MOD: consumeToken(); pn = new InfixExpression(tt, pn, unaryExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode unaryExpr() throws IOException { AstNode node; int tt = peekToken(); int line = ts.lineno; switch(tt) { case Token.VOID: case Token.NOT: case Token.BITNOT: case Token.TYPEOF: consumeToken(); node = new UnaryExpression(tt, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.ADD: consumeToken(); // Convert to special POS token in parse tree node = new UnaryExpression(Token.POS, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.SUB: consumeToken(); // Convert to special NEG token in parse tree node = new UnaryExpression(Token.NEG, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.INC: case Token.DEC: consumeToken(); UnaryExpression expr = new UnaryExpression(tt, ts.tokenBeg, memberExpr(true)); expr.setLineno(line); checkBadIncDec(expr); return expr; case Token.DELPROP: consumeToken(); node = new UnaryExpression(tt, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.ERROR: consumeToken(); return makeErrorNode(); case Token.LT: // XML stream encountered in expression. if (compilerEnv.isXmlAvailable()) { consumeToken(); return memberExprTail(true, xmlInitializer()); } // Fall thru to the default handling of RELOP default: AstNode pn = memberExpr(true); // Don't look across a newline boundary for a postfix incop. tt = peekTokenOrEOL(); if (!(tt == Token.INC || tt == Token.DEC)) { return pn; } consumeToken(); UnaryExpression uexpr = new UnaryExpression(tt, ts.tokenBeg, pn, true); uexpr.setLineno(line); checkBadIncDec(uexpr); return uexpr; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode xmlInitializer() throws IOException { if (currentToken != Token.LT) codeBug(); int pos = ts.tokenBeg, tt = ts.getFirstXMLToken(); if (tt != Token.XML && tt != Token.XMLEND) { reportError("msg.syntax"); return makeErrorNode(); } XmlLiteral pn = new XmlLiteral(pos); pn.setLineno(ts.lineno); for (;;tt = ts.getNextXMLToken()) { switch (tt) { case Token.XML: pn.addFragment(new XmlString(ts.tokenBeg, ts.getString())); mustMatchToken(Token.LC, "msg.syntax"); int beg = ts.tokenBeg; AstNode expr = (peekToken() == Token.RC) ? new EmptyExpression(beg, ts.tokenEnd - beg) : expr(); mustMatchToken(Token.RC, "msg.syntax"); XmlExpression xexpr = new XmlExpression(beg, expr); xexpr.setIsXmlAttribute(ts.isXMLAttribute()); xexpr.setLength(ts.tokenEnd - beg); pn.addFragment(xexpr); break; case Token.XMLEND: pn.addFragment(new XmlString(ts.tokenBeg, ts.getString())); return pn; default: reportError("msg.syntax"); return makeErrorNode(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private List<AstNode> argumentList() throws IOException { if (matchToken(Token.RP)) return null; List<AstNode> result = new ArrayList<AstNode>(); boolean wasInForInit = inForInit; inForInit = false; try { do { if (peekToken() == Token.YIELD) { reportError("msg.yield.parenthesized"); } AstNode en = assignExpr(); if (peekToken() == Token.FOR) { try { result.add(generatorExpression(en, 0, true)); } catch(IOException ex) { // #TODO } } else { result.add(en); } } while (matchToken(Token.COMMA)); } finally { inForInit = wasInForInit; } mustMatchToken(Token.RP, "msg.no.paren.arg"); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode memberExpr(boolean allowCallSyntax) throws IOException { int tt = peekToken(), lineno = ts.lineno; AstNode pn; if (tt != Token.NEW) { pn = primaryExpr(); } else { consumeToken(); int pos = ts.tokenBeg; NewExpression nx = new NewExpression(pos); AstNode target = memberExpr(false); int end = getNodeEnd(target); nx.setTarget(target); int lp = -1; if (matchToken(Token.LP)) { lp = ts.tokenBeg; List<AstNode> args = argumentList(); if (args != null && args.size() > ARGC_LIMIT) reportError("msg.too.many.constructor.args"); int rp = ts.tokenBeg; end = ts.tokenEnd; if (args != null) nx.setArguments(args); nx.setParens(lp - pos, rp - pos); } // Experimental syntax: allow an object literal to follow a new // expression, which will mean a kind of anonymous class built with // the JavaAdapter. the object literal will be passed as an // additional argument to the constructor. if (matchToken(Token.LC)) { ObjectLiteral initializer = objectLiteral(); end = getNodeEnd(initializer); nx.setInitializer(initializer); } nx.setLength(end - pos); pn = nx; } pn.setLineno(lineno); AstNode tail = memberExprTail(allowCallSyntax, pn); return tail; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode memberExprTail(boolean allowCallSyntax, AstNode pn) throws IOException { // we no longer return null for errors, so this won't be null if (pn == null) codeBug(); int pos = pn.getPosition(); int lineno; tailLoop: for (;;) { int tt = peekToken(); switch (tt) { case Token.DOT: case Token.DOTDOT: lineno = ts.lineno; pn = propertyAccess(tt, pn); pn.setLineno(lineno); break; case Token.DOTQUERY: consumeToken(); int opPos = ts.tokenBeg, rp = -1; lineno = ts.lineno; mustHaveXML(); setRequiresActivation(); AstNode filter = expr(); int end = getNodeEnd(filter); if (mustMatchToken(Token.RP, "msg.no.paren")) { rp = ts.tokenBeg; end = ts.tokenEnd; } XmlDotQuery q = new XmlDotQuery(pos, end - pos); q.setLeft(pn); q.setRight(filter); q.setOperatorPosition(opPos); q.setRp(rp - pos); q.setLineno(lineno); pn = q; break; case Token.LB: consumeToken(); int lb = ts.tokenBeg, rb = -1; lineno = ts.lineno; AstNode expr = expr(); end = getNodeEnd(expr); if (mustMatchToken(Token.RB, "msg.no.bracket.index")) { rb = ts.tokenBeg; end = ts.tokenEnd; } ElementGet g = new ElementGet(pos, end - pos); g.setTarget(pn); g.setElement(expr); g.setParens(lb, rb); g.setLineno(lineno); pn = g; break; case Token.LP: if (!allowCallSyntax) { break tailLoop; } lineno = ts.lineno; consumeToken(); checkCallRequiresActivation(pn); FunctionCall f = new FunctionCall(pos); f.setTarget(pn); // Assign the line number for the function call to where // the paren appeared, not where the name expression started. f.setLineno(lineno); f.setLp(ts.tokenBeg - pos); List<AstNode> args = argumentList(); if (args != null && args.size() > ARGC_LIMIT) reportError("msg.too.many.function.args"); f.setArguments(args); f.setRp(ts.tokenBeg - pos); f.setLength(ts.tokenEnd - pos); pn = f; break; default: break tailLoop; } } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode propertyAccess(int tt, AstNode pn) throws IOException { if (pn == null) codeBug(); int memberTypeFlags = 0, lineno = ts.lineno, dotPos = ts.tokenBeg; consumeToken(); if (tt == Token.DOTDOT) { mustHaveXML(); memberTypeFlags = Node.DESCENDANTS_FLAG; } if (!compilerEnv.isXmlAvailable()) { mustMatchToken(Token.NAME, "msg.no.name.after.dot"); Name name = createNameNode(true, Token.GETPROP); PropertyGet pg = new PropertyGet(pn, name, dotPos); pg.setLineno(lineno); return pg; } AstNode ref = null; // right side of . or .. operator int token = nextToken(); switch (token) { case Token.THROW: // needed for generator.throw(); saveNameTokenData(ts.tokenBeg, "throw", ts.lineno); ref = propertyName(-1, "throw", memberTypeFlags); break; case Token.NAME: // handles: name, ns::name, ns::*, ns::[expr] ref = propertyName(-1, ts.getString(), memberTypeFlags); break; case Token.MUL: // handles: *, *::name, *::*, *::[expr] saveNameTokenData(ts.tokenBeg, "*", ts.lineno); ref = propertyName(-1, "*", memberTypeFlags); break; case Token.XMLATTR: // handles: '@attr', '@ns::attr', '@ns::*', '@ns::*', // '@::attr', '@::*', '@*', '@*::attr', '@*::*' ref = attributeAccess(); break; default: if (compilerEnv.isReservedKeywordAsIdentifier()) { // allow keywords as property names, e.g. ({if: 1}) String name = Token.keywordToName(token); if (name != null) { saveNameTokenData(ts.tokenBeg, name, ts.lineno); ref = propertyName(-1, name, memberTypeFlags); break; } } reportError("msg.no.name.after.dot"); return makeErrorNode(); } boolean xml = ref instanceof XmlRef; InfixExpression result = xml ? new XmlMemberGet() : new PropertyGet(); if (xml && tt == Token.DOT) result.setType(Token.DOT); int pos = pn.getPosition(); result.setPosition(pos); result.setLength(getNodeEnd(ref) - pos); result.setOperatorPosition(dotPos - pos); result.setLineno(pn.getLineno()); result.setLeft(pn); // do this after setting position result.setRight(ref); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode attributeAccess() throws IOException { int tt = nextToken(), atPos = ts.tokenBeg; switch (tt) { // handles: @name, @ns::name, @ns::*, @ns::[expr] case Token.NAME: return propertyName(atPos, ts.getString(), 0); // handles: @*, @*::name, @*::*, @*::[expr] case Token.MUL: saveNameTokenData(ts.tokenBeg, "*", ts.lineno); return propertyName(atPos, "*", 0); // handles @[expr] case Token.LB: return xmlElemRef(atPos, null, -1); default: reportError("msg.no.name.after.xmlAttr"); return makeErrorNode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode propertyName(int atPos, String s, int memberTypeFlags) throws IOException { int pos = atPos != -1 ? atPos : ts.tokenBeg, lineno = ts.lineno; int colonPos = -1; Name name = createNameNode(true, currentToken); Name ns = null; if (matchToken(Token.COLONCOLON)) { ns = name; colonPos = ts.tokenBeg; switch (nextToken()) { // handles name::name case Token.NAME: name = createNameNode(); break; // handles name::* case Token.MUL: saveNameTokenData(ts.tokenBeg, "*", ts.lineno); name = createNameNode(false, -1); break; // handles name::[expr] or *::[expr] case Token.LB: return xmlElemRef(atPos, ns, colonPos); default: reportError("msg.no.name.after.coloncolon"); return makeErrorNode(); } } if (ns == null && memberTypeFlags == 0 && atPos == -1) { return name; } XmlPropRef ref = new XmlPropRef(pos, getNodeEnd(name) - pos); ref.setAtPos(atPos); ref.setNamespace(ns); ref.setColonPos(colonPos); ref.setPropName(name); ref.setLineno(lineno); return ref; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private XmlElemRef xmlElemRef(int atPos, Name namespace, int colonPos) throws IOException { int lb = ts.tokenBeg, rb = -1, pos = atPos != -1 ? atPos : lb; AstNode expr = expr(); int end = getNodeEnd(expr); if (mustMatchToken(Token.RB, "msg.no.bracket.index")) { rb = ts.tokenBeg; end = ts.tokenEnd; } XmlElemRef ref = new XmlElemRef(pos, end - pos); ref.setNamespace(namespace); ref.setColonPos(colonPos); ref.setAtPos(atPos); ref.setExpression(expr); ref.setBrackets(lb, rb); return ref; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode destructuringPrimaryExpr() throws IOException, ParserException { try { inDestructuringAssignment = true; return primaryExpr(); } finally { inDestructuringAssignment = false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode primaryExpr() throws IOException { int ttFlagged = nextFlaggedToken(); int tt = ttFlagged & CLEAR_TI_MASK; switch(tt) { case Token.FUNCTION: return function(FunctionNode.FUNCTION_EXPRESSION); case Token.LB: return arrayLiteral(); case Token.LC: return objectLiteral(); case Token.LET: return let(false, ts.tokenBeg); case Token.LP: return parenExpr(); case Token.XMLATTR: mustHaveXML(); return attributeAccess(); case Token.NAME: return name(ttFlagged, tt); case Token.NUMBER: { String s = ts.getString(); if (this.inUseStrictDirective && ts.isNumberOctal()) { reportError("msg.no.octal.strict"); } return new NumberLiteral(ts.tokenBeg, s, ts.getNumber()); } case Token.STRING: return createStringLiteral(); case Token.DIV: case Token.ASSIGN_DIV: // Got / or /= which in this context means a regexp ts.readRegExp(tt); int pos = ts.tokenBeg, end = ts.tokenEnd; RegExpLiteral re = new RegExpLiteral(pos, end - pos); re.setValue(ts.getString()); re.setFlags(ts.readAndClearRegExpFlags()); return re; case Token.NULL: case Token.THIS: case Token.FALSE: case Token.TRUE: pos = ts.tokenBeg; end = ts.tokenEnd; return new KeywordLiteral(pos, end - pos, tt); case Token.RESERVED: reportError("msg.reserved.id"); break; case Token.ERROR: // the scanner or one of its subroutines reported the error. break; case Token.EOF: reportError("msg.unexpected.eof"); break; default: reportError("msg.syntax"); break; } // should only be reachable in IDE/error-recovery mode return makeErrorNode(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode parenExpr() throws IOException { boolean wasInForInit = inForInit; inForInit = false; try { Comment jsdocNode = getAndResetJsDoc(); int lineno = ts.lineno; int begin = ts.tokenBeg; AstNode e = expr(); if (peekToken() == Token.FOR) { return generatorExpression(e, begin); } ParenthesizedExpression pn = new ParenthesizedExpression(e); if (jsdocNode == null) { jsdocNode = getAndResetJsDoc(); } if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } mustMatchToken(Token.RP, "msg.no.paren"); pn.setLength(ts.tokenEnd - pn.getPosition()); pn.setLineno(lineno); return pn; } finally { inForInit = wasInForInit; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode name(int ttFlagged, int tt) throws IOException { String nameString = ts.getString(); int namePos = ts.tokenBeg, nameLineno = ts.lineno; if (0 != (ttFlagged & TI_CHECK_LABEL) && peekToken() == Token.COLON) { // Do not consume colon. It is used as an unwind indicator // to return to statementHelper. Label label = new Label(namePos, ts.tokenEnd - namePos); label.setName(nameString); label.setLineno(ts.lineno); return label; } // Not a label. Unfortunately peeking the next token to check for // a colon has biffed ts.tokenBeg, ts.tokenEnd. We store the name's // bounds in instance vars and createNameNode uses them. saveNameTokenData(namePos, nameString, nameLineno); if (compilerEnv.isXmlAvailable()) { return propertyName(-1, nameString, 0); } else { return createNameNode(true, Token.NAME); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode arrayLiteral() throws IOException { if (currentToken != Token.LB) codeBug(); int pos = ts.tokenBeg, end = ts.tokenEnd; List<AstNode> elements = new ArrayList<AstNode>(); ArrayLiteral pn = new ArrayLiteral(pos); boolean after_lb_or_comma = true; int afterComma = -1; int skipCount = 0; for (;;) { int tt = peekToken(); if (tt == Token.COMMA) { consumeToken(); afterComma = ts.tokenEnd; if (!after_lb_or_comma) { after_lb_or_comma = true; } else { elements.add(new EmptyExpression(ts.tokenBeg, 1)); skipCount++; } } else if (tt == Token.RB) { consumeToken(); // for ([a,] in obj) is legal, but for ([a] in obj) is // not since we have both key and value supplied. The // trick is that [a,] and [a] are equivalent in other // array literal contexts. So we calculate a special // length value just for destructuring assignment. end = ts.tokenEnd; pn.setDestructuringLength(elements.size() + (after_lb_or_comma ? 1 : 0)); pn.setSkipCount(skipCount); if (afterComma != -1) warnTrailingComma(pos, elements, afterComma); break; } else if (tt == Token.FOR && !after_lb_or_comma && elements.size() == 1) { return arrayComprehension(elements.get(0), pos); } else if (tt == Token.EOF) { reportError("msg.no.bracket.arg"); break; } else { if (!after_lb_or_comma) { reportError("msg.no.bracket.arg"); } elements.add(assignExpr()); after_lb_or_comma = false; afterComma = -1; } } for (AstNode e : elements) { pn.addElement(e); } pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode arrayComprehension(AstNode result, int pos) throws IOException { List<ArrayComprehensionLoop> loops = new ArrayList<ArrayComprehensionLoop>(); while (peekToken() == Token.FOR) { loops.add(arrayComprehensionLoop()); } int ifPos = -1; ConditionData data = null; if (peekToken() == Token.IF) { consumeToken(); ifPos = ts.tokenBeg - pos; data = condition(); } mustMatchToken(Token.RB, "msg.no.bracket.arg"); ArrayComprehension pn = new ArrayComprehension(pos, ts.tokenEnd - pos); pn.setResult(result); pn.setLoops(loops); if (data != null) { pn.setIfPosition(ifPos); pn.setFilter(data.condition); pn.setFilterLp(data.lp - pos); pn.setFilterRp(data.rp - pos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ArrayComprehensionLoop arrayComprehensionLoop() throws IOException { if (nextToken() != Token.FOR) codeBug(); int pos = ts.tokenBeg; int eachPos = -1, lp = -1, rp = -1, inPos = -1; ArrayComprehensionLoop pn = new ArrayComprehensionLoop(pos); pushScope(pn); try { if (matchToken(Token.NAME)) { if (ts.getString().equals("each")) { eachPos = ts.tokenBeg - pos; } else { reportError("msg.no.paren.for"); } } if (mustMatchToken(Token.LP, "msg.no.paren.for")) { lp = ts.tokenBeg - pos; } AstNode iter = null; switch (peekToken()) { case Token.LB: case Token.LC: // handle destructuring assignment iter = destructuringPrimaryExpr(); markDestructuring(iter); break; case Token.NAME: consumeToken(); iter = createNameNode(); break; default: reportError("msg.bad.var"); } // Define as a let since we want the scope of the variable to // be restricted to the array comprehension if (iter.getType() == Token.NAME) { defineSymbol(Token.LET, ts.getString(), true); } if (mustMatchToken(Token.IN, "msg.in.after.for.name")) inPos = ts.tokenBeg - pos; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - pos; pn.setLength(ts.tokenEnd - pos); pn.setIterator(iter); pn.setIteratedObject(obj); pn.setInPosition(inPos); pn.setEachPosition(eachPos); pn.setIsForEach(eachPos != -1); pn.setParens(lp, rp); return pn; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode generatorExpression(AstNode result, int pos) throws IOException { return generatorExpression(result, pos, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode generatorExpression(AstNode result, int pos, boolean inFunctionParams) throws IOException { List<GeneratorExpressionLoop> loops = new ArrayList<GeneratorExpressionLoop>(); while (peekToken() == Token.FOR) { loops.add(generatorExpressionLoop()); } int ifPos = -1; ConditionData data = null; if (peekToken() == Token.IF) { consumeToken(); ifPos = ts.tokenBeg - pos; data = condition(); } if(!inFunctionParams) { mustMatchToken(Token.RP, "msg.no.paren.let"); } GeneratorExpression pn = new GeneratorExpression(pos, ts.tokenEnd - pos); pn.setResult(result); pn.setLoops(loops); if (data != null) { pn.setIfPosition(ifPos); pn.setFilter(data.condition); pn.setFilterLp(data.lp - pos); pn.setFilterRp(data.rp - pos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private GeneratorExpressionLoop generatorExpressionLoop() throws IOException { if (nextToken() != Token.FOR) codeBug(); int pos = ts.tokenBeg; int lp = -1, rp = -1, inPos = -1; GeneratorExpressionLoop pn = new GeneratorExpressionLoop(pos); pushScope(pn); try { if (mustMatchToken(Token.LP, "msg.no.paren.for")) { lp = ts.tokenBeg - pos; } AstNode iter = null; switch (peekToken()) { case Token.LB: case Token.LC: // handle destructuring assignment iter = destructuringPrimaryExpr(); markDestructuring(iter); break; case Token.NAME: consumeToken(); iter = createNameNode(); break; default: reportError("msg.bad.var"); } // Define as a let since we want the scope of the variable to // be restricted to the array comprehension if (iter.getType() == Token.NAME) { defineSymbol(Token.LET, ts.getString(), true); } if (mustMatchToken(Token.IN, "msg.in.after.for.name")) inPos = ts.tokenBeg - pos; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - pos; pn.setLength(ts.tokenEnd - pos); pn.setIterator(iter); pn.setIteratedObject(obj); pn.setInPosition(inPos); pn.setParens(lp, rp); return pn; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectLiteral objectLiteral() throws IOException { int pos = ts.tokenBeg, lineno = ts.lineno; int afterComma = -1; List<ObjectProperty> elems = new ArrayList<ObjectProperty>(); Set<String> propertyNames = new HashSet<String>(); Comment objJsdocNode = getAndResetJsDoc(); commaLoop: for (;;) { String propertyName = null; int tt = peekToken(); Comment jsdocNode = getAndResetJsDoc(); switch(tt) { case Token.NAME: case Token.STRING: saveNameTokenData(ts.tokenBeg, ts.getString(), ts.lineno); consumeToken(); StringLiteral stringProp = null; if (tt == Token.STRING) { stringProp = createStringLiteral(); } Name name = createNameNode(); propertyName = ts.getString(); int ppos = ts.tokenBeg; if ((tt == Token.NAME && (peekToken() == Token.NAME || convertToName(peekToken())) && ("get".equals(propertyName) || "set".equals(propertyName)))) { consumeToken(); name = createNameNode(); name.setJsDocNode(jsdocNode); ObjectProperty objectProp = getterSetterProperty(ppos, name, "get".equals(propertyName)); elems.add(objectProp); propertyName = objectProp.getLeft().getString(); } else { AstNode pname = stringProp != null ? stringProp : name; pname.setJsDocNode(jsdocNode); elems.add(plainProperty(pname, tt)); } break; case Token.NUMBER: consumeToken(); AstNode nl = new NumberLiteral(ts.tokenBeg, ts.getString(), ts.getNumber()); nl.setJsDocNode(jsdocNode); propertyName = ts.getString(); elems.add(plainProperty(nl, tt)); break; case Token.RC: if (afterComma != -1) warnTrailingComma(pos, elems, afterComma); break commaLoop; default: if (convertToName(tt)) { consumeToken(); AstNode pname = createNameNode(); pname.setJsDocNode(jsdocNode); elems.add(plainProperty(pname, tt)); break; } reportError("msg.bad.prop"); break; } if (this.inUseStrictDirective) { if (propertyNames.contains(propertyName)) { addError("msg.dup.obj.lit.prop.strict", propertyName); } propertyNames.add(propertyName); } // Eat any dangling jsdoc in the property. getAndResetJsDoc(); jsdocNode = null; if (matchToken(Token.COMMA)) { afterComma = ts.tokenEnd; } else { break commaLoop; } } mustMatchToken(Token.RC, "msg.no.brace.prop"); ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); } pn.setElements(elems); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectProperty plainProperty(AstNode property, int ptt) throws IOException { // Support, e.g., |var {x, y} = o| as destructuring shorthand // for |var {x: x, y: y} = o|, as implemented in spidermonkey JS 1.8. int tt = peekToken(); if ((tt == Token.COMMA || tt == Token.RC) && ptt == Token.NAME && compilerEnv.getLanguageVersion() >= Context.VERSION_1_8) { if (!inDestructuringAssignment) { reportError("msg.bad.object.init"); } AstNode nn = new Name(property.getPosition(), property.getString()); ObjectProperty pn = new ObjectProperty(); pn.putProp(Node.DESTRUCTURING_SHORTHAND, Boolean.TRUE); pn.setLeftAndRight(property, nn); return pn; } mustMatchToken(Token.COLON, "msg.no.colon.prop"); ObjectProperty pn = new ObjectProperty(); pn.setOperatorPosition(ts.tokenBeg); pn.setLeftAndRight(property, assignExpr()); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectProperty getterSetterProperty(int pos, AstNode propName, boolean isGetter) throws IOException { FunctionNode fn = function(FunctionNode.FUNCTION_EXPRESSION); // We've already parsed the function name, so fn should be anonymous. Name name = fn.getFunctionName(); if (name != null && name.length() != 0) { reportError("msg.bad.prop"); } ObjectProperty pn = new ObjectProperty(pos); if (isGetter) { pn.setIsGetter(); } else { pn.setIsSetter(); } int end = getNodeEnd(fn); pn.setLeft(propName); pn.setRight(fn); pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private String readFully(Reader reader) throws IOException { BufferedReader in = new BufferedReader(reader); try { char[] cbuf = new char[1024]; StringBuilder sb = new StringBuilder(1024); int bytes_read; while ((bytes_read = in.read(cbuf, 0, 1024)) != -1) { sb.append(cbuf, 0, bytes_read); } return sb.toString(); } finally { in.close(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (name != null) { indexOrHash = name.hashCode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(slot); // just serialize the wrapped slot }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private synchronized void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } if (objectsCount == 0) { out.writeInt(0); } else { out.writeInt(slots.length); Slot slot = firstAdded; while (slot != null && slot.wasDeleted) { // as long as we're traversing the order-added linked list, // remove deleted slots slot = slot.orderedNext; } firstAdded = slot; while (slot != null) { out.writeObject(slot); Slot next = slot.orderedNext; while (next != null && next.wasDeleted) { // remove deleted slots next = next.orderedNext; } slot.orderedNext = next; slot = next; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static String readReader(Reader r) throws IOException { char[] buffer = new char[512]; int cursor = 0; for (;;) { int n = r.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { char[] tmp = new char[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } return new String(buffer, 0, cursor); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException { if (initialBufferCapacity <= 0) { throw new IllegalArgumentException( "Bad initialBufferCapacity: "+initialBufferCapacity); } byte[] buffer = new byte[initialBufferCapacity]; int cursor = 0; for (;;) { int n = is.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { byte[] tmp = new byte[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } if (cursor != buffer.length) { byte[] tmp = new byte[cursor]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } return buffer; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.classLoader = Context.getCurrentContext().getApplicationClassLoader(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static void writeAdapterObject(Object javaObject, ObjectOutputStream out) throws IOException { Class<?> cl = javaObject.getClass(); out.writeObject(cl.getSuperclass().getName()); Class<?>[] interfaces = cl.getInterfaces(); String[] interfaceNames = new String[interfaces.length]; for (int i=0; i < interfaces.length; i++) interfaceNames[i] = interfaces[i].getName(); out.writeObject(interfaceNames); try { Object delegee = cl.getField("delegee").get(javaObject); out.writeObject(delegee); return; } catch (IllegalAccessException e) { } catch (NoSuchFieldException e) { } throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (parmsLength > 0) { Class<?>[] types = member.argTypes; typeTags = new byte[parmsLength]; for (int i = 0; i != parmsLength; ++i) { typeTags[i] = (byte)getTypeTag(types[i]); } } if (member.isMethod()) { Method method = member.method(); Class<?> returnType = method.getReturnType(); if (returnType == Void.TYPE) { hasVoidReturn = true; } else { returnTypeTag = getTypeTag(returnType); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void writeObject(ObjectOutputStream os) throws IOException { os.defaultWriteObject(); int N = size; for (int i = 0; i != N; ++i) { Object obj = getImpl(i); os.writeObject(obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); // It reads size int N = size; if (N > FIELDS_STORE_SIZE) { data = new Object[N - FIELDS_STORE_SIZE]; } for (int i = 0; i != N; ++i) { Object obj = is.readObject(); setImpl(i, obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int maxPrototypeId = stream.readInt(); if (maxPrototypeId != 0) { activatePrototypeMap(maxPrototypeId); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); int maxPrototypeId = 0; if (prototypeValues != null) { maxPrototypeId = prototypeValues.getMaxId(); } stream.writeInt(maxPrototypeId); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); if (classLoader != null) { try { return classLoader.loadClass(name); } catch (ClassNotFoundException ex) { // fall through to default loading } } return super.resolveClass(desc); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Object resolveObject(Object obj) throws IOException { if (obj instanceof ScriptableOutputStream.PendingLookup) { String name = ((ScriptableOutputStream.PendingLookup)obj).getName(); obj = ScriptableOutputStream.lookupQualifiedName(scope, name); if (obj == Scriptable.NOT_FOUND) { throw new IOException("Object " + name + " not found upon " + "deserialization."); } }else if (obj instanceof UniqueTag) { obj = ((UniqueTag)obj).readResolve(); }else if (obj instanceof Undefined) { obj = ((Undefined)obj).readResolve(); } return obj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
Override protected Object replaceObject(Object obj) throws IOException { if (false) throw new IOException(); // suppress warning String name = table.get(obj); if (name == null) return obj; return new PendingLookup(name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Object evaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { Script script = compileReader(scope, in, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } else { return null; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Script compileReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { return compileReader(in, sourceName, lineno, securityDomain); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Script compileReader(Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { if (lineno < 0) { // For compatibility IllegalArgumentException can not be thrown here lineno = 0; } return (Script) compileImpl(null, in, null, sourceName, lineno, securityDomain, false, null, null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int count = keyCount; if (count != 0) { boolean hasIntValues = (ivaluesShift != 0); boolean hasObjectValues = (values != null); out.writeBoolean(hasIntValues); out.writeBoolean(hasObjectValues); for (int i = 0; count != 0; ++i) { int key = keys[i]; if (key != EMPTY && key != DELETED) { --count; out.writeInt(key); if (hasIntValues) { out.writeInt(keys[ivaluesShift + i]); } if (hasObjectValues) { out.writeObject(values[i]); } } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; boolean hasIntValues = in.readBoolean(); boolean hasObjectValues = in.readBoolean(); int N = 1 << power; if (hasIntValues) { keys = new int[2 * N]; ivaluesShift = N; }else { keys = new int[N]; } for (int i = 0; i != N; ++i) { keys[i] = EMPTY; } if (hasObjectValues) { values = new Object[N]; } for (int i = 0; i != writtenKeyCount; ++i) { int key = in.readInt(); int index = insertNewKey(key); if (hasIntValues) { int ivalue = in.readInt(); keys[ivaluesShift + index] = ivalue; } if (hasObjectValues) { values[index] = in.readObject(); } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void write(OutputStream oStream) throws IOException { byte[] array = toByteArray(); oStream.write(array); }
(Domain) ClassFileFormatException 7
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void stopMethod(short maxLocals) { if (itsCurrentMethod == null) throw new IllegalStateException("No method to stop"); fixLabelGotos(); itsMaxLocals = maxLocals; StackMapTable stackMap = null; if (GenerateStackMap) { finalizeSuperBlockStarts(); stackMap = new StackMapTable(); stackMap.generate(); } int lineNumberTableLength = 0; if (itsLineNumberTable != null) { // 6 bytes for the attribute header // 2 bytes for the line number count // 4 bytes for each entry lineNumberTableLength = 6 + 2 + (itsLineNumberTableTop * 4); } int variableTableLength = 0; if (itsVarDescriptors != null) { // 6 bytes for the attribute header // 2 bytes for the variable count // 10 bytes for each entry variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10); } int stackMapTableLength = 0; if (stackMap != null) { int stackMapWriteSize = stackMap.computeWriteSize(); if (stackMapWriteSize > 0) { stackMapTableLength = 6 + stackMapWriteSize; } } int attrLength = 2 + // attribute_name_index 4 + // attribute_length 2 + // max_stack 2 + // max_locals 4 + // code_length itsCodeBufferTop + 2 + // exception_table_length (itsExceptionTableTop * 8) + 2 + // attributes_count lineNumberTableLength + variableTableLength + stackMapTableLength; if (attrLength > 65536) { // See http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html, // section 4.10, "The amount of code per non-native, non-abstract // method is limited to 65536 bytes... throw new ClassFileFormatException( "generated bytecode for method exceeds 64K limit."); } byte[] codeAttribute = new byte[attrLength]; int index = 0; int codeAttrIndex = itsConstantPool.addUtf8("Code"); index = putInt16(codeAttrIndex, codeAttribute, index); attrLength -= 6; // discount the attribute header index = putInt32(attrLength, codeAttribute, index); index = putInt16(itsMaxStack, codeAttribute, index); index = putInt16(itsMaxLocals, codeAttribute, index); index = putInt32(itsCodeBufferTop, codeAttribute, index); System.arraycopy(itsCodeBuffer, 0, codeAttribute, index, itsCodeBufferTop); index += itsCodeBufferTop; if (itsExceptionTableTop > 0) { index = putInt16(itsExceptionTableTop, codeAttribute, index); for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short)getLabelPC(ete.itsStartLabel); short endPC = (short)getLabelPC(ete.itsEndLabel); short handlerPC = (short)getLabelPC(ete.itsHandlerLabel); short catchType = ete.itsCatchType; if (startPC == -1) throw new IllegalStateException("start label not defined"); if (endPC == -1) throw new IllegalStateException("end label not defined"); if (handlerPC == -1) throw new IllegalStateException( "handler label not defined"); index = putInt16(startPC, codeAttribute, index); index = putInt16(endPC, codeAttribute, index); index = putInt16(handlerPC, codeAttribute, index); index = putInt16(catchType, codeAttribute, index); } } else { // write 0 as exception table length index = putInt16(0, codeAttribute, index); } int attributeCount = 0; if (itsLineNumberTable != null) attributeCount++; if (itsVarDescriptors != null) attributeCount++; if (stackMapTableLength > 0) { attributeCount++; } index = putInt16(attributeCount, codeAttribute, index); if (itsLineNumberTable != null) { int lineNumberTableAttrIndex = itsConstantPool.addUtf8("LineNumberTable"); index = putInt16(lineNumberTableAttrIndex, codeAttribute, index); int tableAttrLength = 2 + (itsLineNumberTableTop * 4); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(itsLineNumberTableTop, codeAttribute, index); for (int i = 0; i < itsLineNumberTableTop; i++) { index = putInt32(itsLineNumberTable[i], codeAttribute, index); } } if (itsVarDescriptors != null) { int variableTableAttrIndex = itsConstantPool.addUtf8("LocalVariableTable"); index = putInt16(variableTableAttrIndex, codeAttribute, index); int varCount = itsVarDescriptors.size(); int tableAttrLength = 2 + (varCount * 10); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(varCount, codeAttribute, index); for (int i = 0; i < varCount; i++) { int[] chunk = (int[])itsVarDescriptors.get(i); int nameIndex = chunk[0]; int descriptorIndex = chunk[1]; int startPC = chunk[2]; int register = chunk[3]; int length = itsCodeBufferTop - startPC; index = putInt16(startPC, codeAttribute, index); index = putInt16(length, codeAttribute, index); index = putInt16(nameIndex, codeAttribute, index); index = putInt16(descriptorIndex, codeAttribute, index); index = putInt16(register, codeAttribute, index); } } if (stackMapTableLength > 0) { int stackMapTableAttrIndex = itsConstantPool.addUtf8("StackMapTable"); int start = index; index = putInt16(stackMapTableAttrIndex, codeAttribute, index); index = stackMap.write(codeAttribute, index); } itsCurrentMethod.setCodeAttribute(codeAttribute); itsExceptionTable = null; itsExceptionTableTop = 0; itsLineNumberTableTop = 0; itsCodeBufferTop = 0; itsCurrentMethod = null; itsMaxStack = 0; itsStackTop = 0; itsLabelTableTop = 0; itsFixupTableTop = 0; itsVarDescriptors = null; itsSuperBlockStarts = null; itsSuperBlockStartsTop = 0; itsJumpFroms = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.GOTO : // This is necessary because dead code is seemingly being // generated and Sun's verifier is expecting type state to be // placed even at dead blocks of code. addSuperBlockStart(itsCodeBufferTop + 3); // fallthru... case ByteCode.IFEQ : case ByteCode.IFNE : case ByteCode.IFLT : case ByteCode.IFGE : case ByteCode.IFGT : case ByteCode.IFLE : case ByteCode.IF_ICMPEQ : case ByteCode.IF_ICMPNE : case ByteCode.IF_ICMPLT : case ByteCode.IF_ICMPGE : case ByteCode.IF_ICMPGT : case ByteCode.IF_ICMPLE : case ByteCode.IF_ACMPEQ : case ByteCode.IF_ACMPNE : case ByteCode.JSR : case ByteCode.IFNULL : case ByteCode.IFNONNULL : { if ((theOperand & 0x80000000) != 0x80000000) { if ((theOperand < 0) || (theOperand > 65535)) throw new IllegalArgumentException( "Bad label for branch"); } int branchPC = itsCodeBufferTop; addToCodeBuffer(theOpCode); if ((theOperand & 0x80000000) != 0x80000000) { // hard displacement addToCodeInt16(theOperand); int target = theOperand + branchPC; addSuperBlockStart(target); itsJumpFroms.put(target, branchPC); } else { // a label int targetPC = getLabelPC(theOperand); if (DEBUGLABELS) { int theLabel = theOperand & 0x7FFFFFFF; System.out.println("Fixing branch to " + theLabel + " at " + targetPC + " from " + branchPC); } if (targetPC != -1) { int offset = targetPC - branchPC; addToCodeInt16(offset); addSuperBlockStart(targetPC); itsJumpFroms.put(targetPC, branchPC); } else { addLabelFixup(theOperand, branchPC + 1); addToCodeInt16(0); } } } break; case ByteCode.BIPUSH : if ((byte)theOperand != theOperand) throw new IllegalArgumentException("out of range byte"); addToCodeBuffer(theOpCode); addToCodeBuffer((byte)theOperand); break; case ByteCode.SIPUSH : if ((short)theOperand != theOperand) throw new IllegalArgumentException("out of range short"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.NEWARRAY : if (!(0 <= theOperand && theOperand < 256)) throw new IllegalArgumentException("out of range index"); addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); break; case ByteCode.GETFIELD : case ByteCode.PUTFIELD : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range field"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.LDC : case ByteCode.LDC_W : case ByteCode.LDC2_W : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range index"); if (theOperand >= 256 || theOpCode == ByteCode.LDC_W || theOpCode == ByteCode.LDC2_W) { if (theOpCode == ByteCode.LDC) { addToCodeBuffer(ByteCode.LDC_W); } else { addToCodeBuffer(theOpCode); } addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; case ByteCode.RET : case ByteCode.ILOAD : case ByteCode.LLOAD : case ByteCode.FLOAD : case ByteCode.DLOAD : case ByteCode.ALOAD : case ByteCode.ISTORE : case ByteCode.LSTORE : case ByteCode.FSTORE : case ByteCode.DSTORE : case ByteCode.ASTORE : if (!(0 <= theOperand && theOperand < 65536)) throw new ClassFileFormatException("out of range variable"); if (theOperand >= 256) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; default : throw new IllegalArgumentException( "Unexpected opcode for 1 operand"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand1, int theOperand2) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand1) +", "+Integer.toHexString(theOperand2)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (theOpCode == ByteCode.IINC) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new ClassFileFormatException("out of range variable"); if (!(0 <= theOperand2 && theOperand2 < 65536)) throw new ClassFileFormatException("out of range increment"); if (theOperand1 > 255 || theOperand2 < -128 || theOperand2 > 127) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(ByteCode.IINC); addToCodeInt16(theOperand1); addToCodeInt16(theOperand2); } else { addToCodeBuffer(ByteCode.IINC); addToCodeBuffer(theOperand1); addToCodeBuffer(theOperand2); } } else if (theOpCode == ByteCode.MULTIANEWARRAY) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new IllegalArgumentException("out of range index"); if (!(0 <= theOperand2 && theOperand2 < 256)) throw new IllegalArgumentException("out of range dimensions"); addToCodeBuffer(ByteCode.MULTIANEWARRAY); addToCodeInt16(theOperand1); addToCodeBuffer(theOperand2); } else { throw new IllegalArgumentException( "Unexpected opcode for 2 operands"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public int addTableSwitch(int low, int high) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(ByteCode.TABLESWITCH) +" "+low+" "+high); } if (low > high) throw new ClassFileFormatException("Bad bounds: "+low+' '+ high); int newStack = itsStackTop + stackChange(ByteCode.TABLESWITCH); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); int entryCount = high - low + 1; int padSize = 3 & ~itsCodeBufferTop; // == 3 - itsCodeBufferTop % 4 int N = addReservedCodeSpace(1 + padSize + 4 * (1 + 2 + entryCount)); int switchStart = N; itsCodeBuffer[N++] = (byte)ByteCode.TABLESWITCH; while (padSize != 0) { itsCodeBuffer[N++] = 0; --padSize; } N += 4; // skip default offset N = putInt32(low, itsCodeBuffer, N); putInt32(high, itsCodeBuffer, N); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(ByteCode.TABLESWITCH) +" stack = "+itsStackTop); } return switchStart; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget) { if (!(0 <= jumpTarget && jumpTarget <= itsCodeBufferTop)) throw new IllegalArgumentException("Bad jump target: "+jumpTarget); if (!(caseIndex >= -1)) throw new IllegalArgumentException("Bad case index: "+caseIndex); int padSize = 3 & ~switchStart; // == 3 - switchStart % 4 int caseOffset; if (caseIndex < 0) { // default label caseOffset = switchStart + 1 + padSize; } else { caseOffset = switchStart + 1 + padSize + 4 * (3 + caseIndex); } if (!(0 <= switchStart && switchStart <= itsCodeBufferTop - 4 * 4 - padSize - 1)) { throw new IllegalArgumentException( switchStart+" is outside a possible range of tableswitch" +" in already generated code"); } if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) { throw new IllegalArgumentException( switchStart+" is not offset of tableswitch statement"); } if (!(0 <= caseOffset && caseOffset + 4 <= itsCodeBufferTop)) { // caseIndex >= -1 does not guarantee that caseOffset >= 0 due // to a possible overflow. throw new ClassFileFormatException( "Too big case index: "+caseIndex); } // ALERT: perhaps check against case bounds? putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void fixLabelGotos() { byte[] codeBuffer = itsCodeBuffer; for (int i = 0; i < itsFixupTableTop; i++) { long fixup = itsFixupTable[i]; int label = (int)(fixup >> 32); int fixupSite = (int)fixup; int pc = itsLabelTable[label]; if (pc == -1) { // Unlocated label throw new RuntimeException(); } // -1 to get delta from instruction start addSuperBlockStart(pc); itsJumpFroms.put(pc, fixupSite - 1); int offset = pc - (fixupSite - 1); if ((short)offset != offset) { throw new ClassFileFormatException ("Program too complex: too big jump offset"); } codeBuffer[fixupSite] = (byte)(offset >> 8); codeBuffer[fixupSite + 1] = (byte)offset; } itsFixupTableTop = 0; }
0 0
(Domain) JavaScriptException 6
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptRuntime.java
public static void throwStopIteration(Object obj) { throw new JavaScriptException( NativeIterator.getStopIterationObject((Scriptable)obj), "", 0); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
private static Object jsConstructor(Context cx, Scriptable scope, Object[] args) { int arglen = args.length; StringBuffer sourceBuf = new StringBuffer(); sourceBuf.append("function "); /* version != 1.2 Function constructor behavior - * print 'anonymous' as the function name if the * version (under which the function was compiled) is * less than 1.2... or if it's greater than 1.2, because * we need to be closer to ECMA. */ if (cx.getLanguageVersion() != Context.VERSION_1_2) { sourceBuf.append("anonymous"); } sourceBuf.append('('); // Append arguments as coma separated strings for (int i = 0; i < arglen - 1; i++) { if (i > 0) { sourceBuf.append(','); } sourceBuf.append(ScriptRuntime.toString(args[i])); } sourceBuf.append(") {"); if (arglen != 0) { // append function body String funBody = ScriptRuntime.toString(args[arglen - 1]); sourceBuf.append(funBody); } sourceBuf.append("\n}"); String source = sourceBuf.toString(); int[] linep = new int[1]; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<eval'ed string>"; linep[0] = 1; } String sourceURI = ScriptRuntime. makeUrlForGeneratedScript(false, filename, linep[0]); Scriptable global = ScriptableObject.getTopLevelScope(scope); ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, linep[0]); } // Compile with explicit interpreter instance to force interpreter // mode. return cx.compileFunction(global, source, evaluator, reporter, sourceURI, 1, null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
private Object next(Context cx, Scriptable scope) { Boolean b = ScriptRuntime.enumNext(this.objectIterator); if (!b.booleanValue()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return ScriptRuntime.enumId(this.objectIterator, cx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
public Object next() { if (!iterator.hasNext()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return iterator.next(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
private Object resume(Context cx, Scriptable scope, int operation, Object value) { if (savedState == null) { if (operation == GENERATOR_CLOSE) return Undefined.instance; Object thrown; if (operation == GENERATOR_THROW) { thrown = value; } else { thrown = NativeIterator.getStopIterationObject(scope); } throw new JavaScriptException(thrown, lineSource, lineNumber); } try { synchronized (this) { // generator execution is necessarily single-threaded and // non-reentrant. // See https://bugzilla.mozilla.org/show_bug.cgi?id=349263 if (locked) throw ScriptRuntime.typeError0("msg.already.exec.gen"); locked = true; } return function.resumeGenerator(cx, scope, operation, savedState, value); } catch (GeneratorClosedException e) { // On closing a generator in the compile path, the generator // throws a special exception. This ensures execution of all pending // finalizers and will not get caught by user code. return Undefined.instance; } catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; } finally { synchronized (this) { locked = false; } if (operation == GENERATOR_CLOSE) savedState = null; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object evalSpecial(Context cx, Scriptable scope, Object thisArg, Object[] args, String filename, int lineNumber) { if (args.length < 1) return Undefined.instance; Object x = args[0]; if (!(x instanceof CharSequence)) { if (cx.hasFeature(Context.FEATURE_STRICT_MODE) || cx.hasFeature(Context.FEATURE_STRICT_EVAL)) { throw Context.reportRuntimeError0("msg.eval.nonstring.strict"); } String message = ScriptRuntime.getMessage0("msg.eval.nonstring"); Context.reportWarning(message); return x; } if (filename == null) { int[] linep = new int[1]; filename = Context.getSourcePositionFromStack(linep); if (filename != null) { lineNumber = linep[0]; } else { filename = ""; } } String sourceName = ScriptRuntime. makeUrlForGeneratedScript(true, filename, lineNumber); ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, lineNumber); } // Compile with explicit interpreter instance to force interpreter // mode. Script script = cx.compileString(x.toString(), evaluator, reporter, sourceName, 1, null); evaluator.setEvalScriptFlag(script); Callable c = (Callable)script; return c.call(cx, scope, (Scriptable)thisArg, ScriptRuntime.emptyArgs); }
0 0
(Lib) IndexOutOfBoundsException 4
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object get(long index) { if (index < 0 || index >= length) { throw new IndexOutOfBoundsException(); } Object value = getRawElem(this, index); if (value == Scriptable.NOT_FOUND || value == Undefined.instance) { return null; } else if (value instanceof Wrapper) { return ((Wrapper) value).unwrap(); } else { return value; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public ListIterator listIterator(final int start) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; if (start < 0 || start > len) { throw new IndexOutOfBoundsException("Index: " + start); } return new ListIterator() { int cursor = start; public boolean hasNext() { return cursor < len; } public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); } public boolean hasPrevious() { return cursor > 0; } public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); } public int nextIndex() { return cursor; } public int previousIndex() { return cursor - 1; } public void remove() { throw new UnsupportedOperationException(); } public void add(Object o) { throw new UnsupportedOperationException(); } public void set(Object o) { throw new UnsupportedOperationException(); } }; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ArrayLiteral.java
public AstNode getElement(int index) { if (elements == null) throw new IndexOutOfBoundsException("no elements"); return elements.get(index); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onInvalidIndex(int index, int upperBound) { // \u2209 is "NOT ELEMENT OF" String msg = index+" \u2209 [0, "+upperBound+')'; throw new IndexOutOfBoundsException(msg); }
0 0
(Lib) NoSuchElementException 4
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public Node next() { if (cursor == null) { throw new NoSuchElementException(); } removed = false; prev2 = prev; prev = cursor; cursor = cursor.next; return prev; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
0
(Lib) SecurityException 4
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public static void initGlobal(SecurityController controller) { if (controller == null) throw new IllegalArgumentException(); if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setSecurityController(SecurityController controller) { if (sealed) onSealedMutation(); if (controller == null) throw new IllegalArgumentException(); if (securityController != null) { throw new SecurityException("Can not overwrite existing SecurityController object"); } if (SecurityController.hasGlobal()) { throw new SecurityException("Can not overwrite existing global SecurityController object"); } securityController = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public synchronized final void setClassShutter(ClassShutter shutter) { if (sealed) onSealedMutation(); if (shutter == null) throw new IllegalArgumentException(); if (hasClassShutter) { throw new SecurityException("Cannot overwrite existing " + "ClassShutter object"); } classShutter = shutter; hasClassShutter = true; }
0 1
(Domain) EvaluatorException 3
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeFunction.java
public Object resumeGenerator(Context cx, Scriptable scope, int operation, Object state, Object value) { throw new EvaluatorException("resumeGenerator() not implemented"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void reportError(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = getCurrentContext(); if (cx != null) { cx.getErrorReporter().error(message, sourceName, lineno, lineSource, lineOffset); } else { throw new EvaluatorException(message, sourceName, lineno, lineSource, lineOffset); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static EvaluatorException reportRuntimeError(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = getCurrentContext(); if (cx != null) { return cx.getErrorReporter(). runtimeError(message, sourceName, lineno, lineSource, lineOffset); } else { throw new EvaluatorException(message, sourceName, lineno, lineSource, lineOffset); } }
0 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static Object jsToJava(Object value, Class<?> desiredType) throws EvaluatorException { return NativeJavaObject.coerceTypeImpl(desiredType, value); }
(Lib) UndeclaredThrowableException 3
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
Override public Object callWithDomain(final Object securityDomain, final Context cx, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args) { // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return cx.getApplicationClassLoader(); } }); final CodeSource codeSource = (CodeSource)securityDomain; Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized (callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized (classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { Loader loader = new Loader(classLoader, codeSource); Class<?> c = loader.defineClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return thread.getContextClassLoader(); } }); Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized(callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized(classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
private static byte[] loadBytecodePrivileged() { URL url = SecureCaller.class.getResource("SecureCallerImpl.clazz"); try { InputStream in = url.openStream(); try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); for(;;) { int r = in.read(); if(r == -1) { return bout.toByteArray(); } bout.write(r); } } finally { in.close(); } } catch(IOException e) { throw new UndeclaredThrowableException(e); } }
3
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
0
(Lib) ClassNotFoundException 2
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
0 16
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { scriptRefQueue = new ReferenceQueue<Script>(); scripts = new ConcurrentHashMap<String, ScriptReference>(); final Map<String, CachedModuleScript> serScripts = (Map)in.readObject(); for(Map.Entry<String, CachedModuleScript> entry: serScripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue(); putLoadedModule(entry.getKey(), cachedModuleScript.getModule(), cachedModuleScript.getValidator()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefiningClassLoader.java
Override public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Class<?> cl = findLoadedClass(name); if (cl == null) { if (parentLoader != null) { cl = parentLoader.loadClass(name); } else { cl = findSystemClass(name); } } if (resolve) { resolveClass(cl); } return cl; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; int N = 1 << power; keys = new Object[N]; values = new int[2 * N]; for (int i = 0; i != writtenKeyCount; ++i) { Object key = in.readObject(); int hash = key.hashCode(); int index = insertNewKey(key, hash); values[index] = in.readInt(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Member member = readMember(in); if (member instanceof Method) { init((Method)member); } else { init((Constructor<?>)member); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Class<?>[] readParameters(ObjectInputStream in) throws IOException, ClassNotFoundException { Class<?>[] result = new Class[in.readShort()]; for (int i=0; i < result.length; i++) { if (!in.readBoolean()) { result[i] = (Class<?>) in.readObject(); continue; } result[i] = primitives[in.readByte()]; } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (name != null) { indexOrHash = name.hashCode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.classLoader = Context.getCurrentContext().getApplicationClassLoader(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (parmsLength > 0) { Class<?>[] types = member.argTypes; typeTags = new byte[parmsLength]; for (int i = 0; i != parmsLength; ++i) { typeTags[i] = (byte)getTypeTag(types[i]); } } if (member.isMethod()) { Method method = member.method(); Class<?> returnType = method.getReturnType(); if (returnType == Void.TYPE) { hasVoidReturn = true; } else { returnTypeTag = getTypeTag(returnType); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); // It reads size int N = size; if (N > FIELDS_STORE_SIZE) { data = new Object[N - FIELDS_STORE_SIZE]; } for (int i = 0; i != N; ++i) { Object obj = is.readObject(); setImpl(i, obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int maxPrototypeId = stream.readInt(); if (maxPrototypeId != 0) { activatePrototypeMap(maxPrototypeId); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); if (classLoader != null) { try { return classLoader.loadClass(name); } catch (ClassNotFoundException ex) { // fall through to default loading } } return super.resolveClass(desc); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; boolean hasIntValues = in.readBoolean(); boolean hasObjectValues = in.readBoolean(); int N = 1 << power; if (hasIntValues) { keys = new int[2 * N]; ivaluesShift = N; }else { keys = new int[N]; } for (int i = 0; i != N; ++i) { keys[i] = EMPTY; } if (hasObjectValues) { values = new Object[N]; } for (int i = 0; i != writtenKeyCount; ++i) { int key = in.readInt(); int index = insertNewKey(key); if (hasIntValues) { int ivalue = in.readInt(); keys[ivaluesShift + index] = ivalue; } if (hasObjectValues) { values[index] = in.readObject(); } } } }
(Lib) AssertionError 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
private static String toLocale_helper(double t, int methodId) { DateFormat formatter; switch (methodId) { case Id_toLocaleString: if (localeDateTimeFormatter == null) { localeDateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); } formatter = localeDateTimeFormatter; break; case Id_toLocaleTimeString: if (localeTimeFormatter == null) { localeTimeFormatter = DateFormat.getTimeInstance(DateFormat.LONG); } formatter = localeTimeFormatter; break; case Id_toLocaleDateString: if (localeDateFormatter == null) { localeDateFormatter = DateFormat.getDateInstance(DateFormat.LONG); } formatter = localeDateFormatter; break; default: throw new AssertionError(); // unreachable } synchronized (formatter) { return formatter.format(new Date((long) t)); } }
0 0
(Lib) InstantiationException 1 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
5
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, sealed, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static <T extends Scriptable> BaseFunction buildClassCtor( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < methods.length; i++) { Method method = methods[i]; if (!method.getName().equals("init")) continue; Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ContextClass && parmTypes[1] == ScriptRuntime.ScriptableClass && parmTypes[2] == Boolean.TYPE && Modifier.isStatic(method.getModifiers())) { Object args[] = { Context.getContext(), scope, sealed ? Boolean.TRUE : Boolean.FALSE }; method.invoke(null, args); return null; } if (parmTypes.length == 1 && parmTypes[0] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { Object args[] = { scope }; method.invoke(null, args); return null; } } // If we got here, there isn't an "init" method with the right // parameter types. Constructor<?>[] ctors = clazz.getConstructors(); Constructor<?> protoCtor = null; for (int i=0; i < ctors.length; i++) { if (ctors[i].getParameterTypes().length == 0) { protoCtor = ctors[i]; break; } } if (protoCtor == null) { throw Context.reportRuntimeError1( "msg.zero.arg.ctor", clazz.getName()); } Scriptable proto = (Scriptable) protoCtor.newInstance(ScriptRuntime.emptyArgs); String className = proto.getClassName(); // Set the prototype's prototype, trying to map Java inheritance to JS // prototype-based inheritance if requested to do so. Scriptable superProto = null; if (mapInheritance) { Class<? super T> superClass = clazz.getSuperclass(); if (ScriptRuntime.ScriptableClass.isAssignableFrom(superClass) && !Modifier.isAbstract(superClass.getModifiers())) { Class<? extends Scriptable> superScriptable = extendsScriptable(superClass); String name = ScriptableObject.defineClass(scope, superScriptable, sealed, mapInheritance); if (name != null) { superProto = ScriptableObject.getClassPrototype(scope, name); } } } if (superProto == null) { superProto = ScriptableObject.getObjectPrototype(scope); } proto.setPrototype(superProto); // Find out whether there are any methods that begin with // "js". If so, then only methods that begin with special // prefixes will be defined as JavaScript entities. final String functionPrefix = "jsFunction_"; final String staticFunctionPrefix = "jsStaticFunction_"; final String getterPrefix = "jsGet_"; final String setterPrefix = "jsSet_"; final String ctorName = "jsConstructor"; Member ctorMember = findAnnotatedMember(methods, JSConstructor.class); if (ctorMember == null) { ctorMember = findAnnotatedMember(ctors, JSConstructor.class); } if (ctorMember == null) { ctorMember = FunctionObject.findSingleMethod(methods, ctorName); } if (ctorMember == null) { if (ctors.length == 1) { ctorMember = ctors[0]; } else if (ctors.length == 2) { if (ctors[0].getParameterTypes().length == 0) ctorMember = ctors[1]; else if (ctors[1].getParameterTypes().length == 0) ctorMember = ctors[0]; } if (ctorMember == null) { throw Context.reportRuntimeError1( "msg.ctor.multiple.parms", clazz.getName()); } } FunctionObject ctor = new FunctionObject(className, ctorMember, scope); if (ctor.isVarArgsMethod()) { throw Context.reportRuntimeError1 ("msg.varargs.ctor", ctorMember.getName()); } ctor.initAsConstructor(scope, proto); Method finishInit = null; HashSet<String> staticNames = new HashSet<String>(), instanceNames = new HashSet<String>(); for (Method method : methods) { if (method == ctorMember) { continue; } String name = method.getName(); if (name.equals("finishInit")) { Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ScriptableClass && parmTypes[1] == FunctionObject.class && parmTypes[2] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { finishInit = method; continue; } } // ignore any compiler generated methods. if (name.indexOf('$') != -1) continue; if (name.equals(ctorName)) continue; Annotation annotation = null; String prefix = null; if (method.isAnnotationPresent(JSFunction.class)) { annotation = method.getAnnotation(JSFunction.class); } else if (method.isAnnotationPresent(JSStaticFunction.class)) { annotation = method.getAnnotation(JSStaticFunction.class); } else if (method.isAnnotationPresent(JSGetter.class)) { annotation = method.getAnnotation(JSGetter.class); } else if (method.isAnnotationPresent(JSSetter.class)) { continue; } if (annotation == null) { if (name.startsWith(functionPrefix)) { prefix = functionPrefix; } else if (name.startsWith(staticFunctionPrefix)) { prefix = staticFunctionPrefix; } else if (name.startsWith(getterPrefix)) { prefix = getterPrefix; } else if (annotation == null) { // note that setterPrefix is among the unhandled names here - // we deal with that when we see the getter continue; } } boolean isStatic = annotation instanceof JSStaticFunction || prefix == staticFunctionPrefix; HashSet<String> names = isStatic ? staticNames : instanceNames; String propName = getPropertyName(name, prefix, annotation); if (names.contains(propName)) { throw Context.reportRuntimeError2("duplicate.defineClass.name", name, propName); } names.add(propName); name = propName; if (annotation instanceof JSGetter || prefix == getterPrefix) { if (!(proto instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", proto.getClass().toString(), name); } Method setter = findSetterMethod(methods, name, setterPrefix); int attr = ScriptableObject.PERMANENT | ScriptableObject.DONTENUM | (setter != null ? 0 : ScriptableObject.READONLY); ((ScriptableObject) proto).defineProperty(name, null, method, setter, attr); continue; } if (isStatic && !Modifier.isStatic(method.getModifiers())) { throw Context.reportRuntimeError( "jsStaticFunction must be used with static method."); } FunctionObject f = new FunctionObject(name, method, proto); if (f.isVarArgsConstructor()) { throw Context.reportRuntimeError1 ("msg.varargs.fun", ctorMember.getName()); } defineProperty(isStatic ? ctor : proto, name, f, DONTENUM); if (sealed) { f.sealObject(); } } // Call user code to complete initialization if necessary. if (finishInit != null) { Object[] finishArgs = { scope, ctor, proto }; finishInit.invoke(null, finishArgs); } // Seal the object if necessary. if (sealed) { ctor.sealObject(); if (proto instanceof ScriptableObject) { ((ScriptableObject) proto).sealObject(); } } return ctor; }
(Lib) MalformedURLException 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator) throws IOException { final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { final String path = ensureTrailingSlash( ScriptableObject.getTypedProperty(paths, i, String.class)); try { URI uri = new URI(path); if (!uri.isAbsolute()) { uri = new File(path).toURI().resolve(""); } final ModuleSource moduleSource = loadFromUri( uri.resolve(moduleId), uri, validator); if(moduleSource != null) { return moduleSource; } } catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } return null; }
1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
0
(Domain) ParserException 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
void reportError(String messageId, String messageArg, int position, int length) { addError(messageId, position, length); if (!compilerEnv.recoverFromErrors()) { throw new ParserException(); } }
0 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode destructuringPrimaryExpr() throws IOException, ParserException { try { inDestructuringAssignment = true; return primaryExpr(); } finally { inDestructuringAssignment = false; } }
(Domain) WrappedException 1
              
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static RuntimeException throwAsScriptRuntimeEx(Throwable e) { while ((e instanceof InvocationTargetException)) { e = ((InvocationTargetException) e).getTargetException(); } // special handling of Error so scripts would not catch them if (e instanceof Error) { Context cx = getContext(); if (cx == null || !cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS)) { throw (Error)e; } } if (e instanceof RhinoException) { throw (RhinoException)e; } throw new WrappedException(e); }
0 0
Explicit thrown (throw new...): 414/796
Explicit thrown ratio: 52%
Builder thrown ratio: 45.4%
Variable thrown ratio: 2.6%
Checked Runtime Total
Domain 24 18 42
Lib 8 344 352
Total 32 362

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Lib) Exception 20
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (Exception ex) { // Assume any exceptions means the method does not exist. }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (Exception e) { // Ignore any exceptions }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (Exception ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
catch (Exception ex) { // fall through to error String m = ex.getMessage(); if (m != null) msg = m; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (Exception e) { // fall through... }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (Exception e) { // Unable to get class file, use default bytecode version }
14
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
(Lib) SecurityException 15
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (SecurityException e) { meth = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (SecurityException x) { e = x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { Context.reportWarning( "Could not discover accessible methods of class " + clazz.getName() + " due to lack of privileges, " + "attemping superclasses/interfaces."); // Fall through and attempt to discover superclass/interface // methods }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // skip this field Context.reportWarning("Could not access field " + name + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Fall through to !includePrivate case Context.reportWarning("Could not access constructor " + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // fall through to !includePrivate case }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (SecurityException e) { // If we get an exception once, give up on getDeclaredMethods sawSecurityException = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (SecurityException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
(Lib) NoSuchMethodException 11
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (NoSuchMethodException e) { meth = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (NoSuchMethodException e) { adapter_writeAdapterObject = null; adapter_readAdapterObject = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
catch (NoSuchMethodException e) { return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(NoSuchMethodException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (NoSuchMethodException e) { // Not implemented by superclass; fall through }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
(Lib) IllegalAccessException 10
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (IllegalAccessException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalAccessException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (IllegalAccessException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(IllegalAccessException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (IllegalAccessException ex) { }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
(Lib) IOException 9
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { onFailedClosingUrlConnection(urlConnection, e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
catch (IOException ioe) { // ignore it, we're already displaying an error... break; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch(IOException ex) { // #TODO }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (IOException e) { }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
(Lib) NumberFormatException 8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(NumberFormatException e) { return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
catch (NumberFormatException ex) { return ScriptRuntime.NaNobj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
catch (NumberFormatException ex) { parser.addError("msg.caught.nfe"); return Token.ERROR; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (NumberFormatException nfe) { return NaN; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (NumberFormatException ex) { return NaN; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (NumberFormatException e) { // fall through }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
(Lib) RuntimeException 8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (RuntimeException x) { throw x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaScriptException.java
catch (RuntimeException rte) { // ScriptRuntime.toString may throw a RuntimeException if (value instanceof Scriptable) { return ScriptRuntime.defaultObjectToString((Scriptable)value); } else { return value.toString(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException e) { // Only propagate exceptions other than closingException if (e != value) throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (RuntimeException e) { throw e; }
6
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (RuntimeException x) { throw x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException e) { // Only propagate exceptions other than closingException if (e != value) throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (RuntimeException e) { throw e; }
(Lib) InvocationTargetException 5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (InvocationTargetException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(InvocationTargetException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
(Lib) ClassNotFoundException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (ClassNotFoundException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (ClassNotFoundException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
catch (ClassNotFoundException ex) { // fall through to default loading }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
(Lib) IllegalArgumentException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (IllegalArgumentException x) { e = x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
(Lib) InstantiationException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (InstantiationException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(InstantiationException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InstantiationException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
(Domain) EvaluatorException 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (EvaluatorException ee) { reportConversionError(value, type); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ee) { errorseen = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
(Lib) LinkageError 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
0
(Domain) ParserException 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { break; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { // Ignore it }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { // an ErrorNode was added to the ErrorReporter }
0
(Lib) Throwable 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { System.err.println( "RHINO USAGE WARNING: onExit terminated with exception"); ex.printStackTrace(System.err); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
(Domain) ClassFileFormatException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
(Lib) CloneNotSupportedException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
(Domain) ParseException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
catch (java.text.ParseException ex) {}
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
(Lib) PrivilegedActionException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
(Domain) RhinoException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (RhinoException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
(Lib) URISyntaxException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (URISyntaxException usx) { // fall through }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
(Lib) ArrayIndexOutOfBoundsException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
(Lib) Error 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; }
0
(Lib) FileNotFoundException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(FileNotFoundException e) { return null; }
0
(Domain) GeneratorClosedException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (GeneratorClosedException e) { // On closing a generator in the compile path, the generator // throws a special exception. This ensures execution of all pending // finalizers and will not get caught by user code. return Undefined.instance; }
0
(Domain) JavaScriptException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
(Lib) MissingResourceException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
(Lib) NoSuchFieldException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (NoSuchFieldException e) { }
0
(Lib) StackOverflowError 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Lib) RuntimeException
Unknown
6
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (RuntimeException x) { throw x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException e) { // Only propagate exceptions other than closingException if (e != value) throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (RuntimeException e) { throw e; }
(Domain) EvaluatorException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
(Domain) RhinoException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
(Domain) JavaScriptException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
(Domain) ClassFileFormatException
Unknown
2
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
(Lib) IllegalArgumentException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
(Lib) ArrayIndexOutOfBoundsException
(Lib) NoSuchElementException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
(Lib) PrivilegedActionException
(Lib) UndeclaredThrowableException
2
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
(Lib) NoSuchMethodException
(Lib) InstantiationException
(Lib) IOException
(Lib) RuntimeException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
(Lib) SecurityException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
(Lib) IllegalAccessException
Unknown
5
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
(Lib) InvocationTargetException
Unknown
4
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
(Lib) IOException
(Lib) IllegalStateException
(Lib) UndeclaredThrowableException
(Lib) RuntimeException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
2
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
(Lib) Exception
(Lib) IOException
(Lib) RuntimeException
Unknown
2
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
3
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
9
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
(Domain) ParseException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
(Lib) ClassNotFoundException
(Lib) RuntimeException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
(Lib) NumberFormatException
(Domain) ParseException
2
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
(Lib) URISyntaxException
(Lib) MalformedURLException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
(Lib) InstantiationException
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
(Lib) StackOverflowError
Unknown
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
(Lib) CloneNotSupportedException
(Lib) RuntimeException
(Lib) IllegalStateException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
(Lib) Throwable
(Lib) IllegalStateException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
(Lib) MissingResourceException
(Lib) RuntimeException
1
                    
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Lib) RuntimeException
(Domain) ParserException
(Domain) EvaluatorException
(Domain) JavaScriptException
(Domain) ClassFileFormatException
(Lib) IllegalArgumentException
(Lib) SecurityException
(Lib) IOException
(Domain) ParseException
(Lib) ClassNotFoundException
(Lib) InstantiationException
Type Name
(Domain) RhinoException
(Domain) GeneratorClosedException
(Lib) ArrayIndexOutOfBoundsException
(Lib) PrivilegedActionException
(Lib) NoSuchMethodException
(Lib) IllegalAccessException
(Lib) InvocationTargetException
(Lib) Exception
(Lib) FileNotFoundException
(Lib) NumberFormatException
(Lib) URISyntaxException
(Lib) StackOverflowError
(Lib) LinkageError
(Lib) NoSuchFieldException
(Lib) CloneNotSupportedException
(Lib) Throwable
(Lib) Error
(Lib) MissingResourceException
Not caught
Type Name
(Lib) IllegalStateException
(Lib) UnsupportedOperationException
(Lib) NoSuchElementException
(Lib) UndeclaredThrowableException
(Lib) MalformedURLException
(Lib) IndexOutOfBoundsException
(Lib) AssertionError
(Domain) WrappedException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
throwAsScriptRuntimeEx
13
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
13
getMessage 7
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
catch (Exception ex) { // fall through to error String m = ex.getMessage(); if (m != null) msg = m; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
16
getName 6
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { Context.reportWarning( "Could not discover accessible methods of class " + clazz.getName() + " due to lack of privileges, " + "attemping superclasses/interfaces."); // Fall through and attempt to discover superclass/interface // methods }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // skip this field Context.reportWarning("Could not access field " + name + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Fall through to !includePrivate case Context.reportWarning("Could not access constructor " + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
117
initCause 5
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
6
reportConversionError 3
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (EvaluatorException ee) { reportConversionError(value, type); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (IllegalAccessException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (InvocationTargetException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
16
reportWarning 3
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { Context.reportWarning( "Could not discover accessible methods of class " + clazz.getName() + " due to lack of privileges, " + "attemping superclasses/interfaces."); // Fall through and attempt to discover superclass/interface // methods }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // skip this field Context.reportWarning("Could not access field " + name + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Fall through to !includePrivate case Context.reportWarning("Could not access constructor " + " of class " + cl.getName() + " due to lack of privileges."); }
14
toString 3
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaScriptException.java
catch (RuntimeException rte) { // ScriptRuntime.toString may throw a RuntimeException if (value instanceof Scriptable) { return ScriptRuntime.defaultObjectToString((Scriptable)value); } else { return value.toString(); } }
327
close 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
8
getCause
2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
2
getClass 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
45
getTargetException 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
3
isInterface 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
10
printStackTrace 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { System.err.println( "RHINO USAGE WARNING: onExit terminated with exception"); ex.printStackTrace(System.err); }
9
reportClassFileFormatException
2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
2
tryToMakeAccessible
2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
2
MethodSignature 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
3
addError 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
catch (NumberFormatException ex) { parser.addError("msg.caught.nfe"); return Token.ERROR; }
27
constructError 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
19
containsKey 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
8
defaultObjectToString 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaScriptException.java
catch (RuntimeException rte) { // ScriptRuntime.toString may throw a RuntimeException if (value instanceof Scriptable) { return ScriptRuntime.defaultObjectToString((Scriptable)value); } else { return value.toString(); } }
3
getMethods 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
5
getModifiers 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
28
getSuperclass 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
11
getValue 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
28
invoke 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
19
isIdeMode 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
9
lineNumber 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
5
lineSource 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
3
lookupMessage 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
5
onFailedClosingUrlConnection
1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { onFailedClosingUrlConnection(urlConnection, e); }
1
println 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { System.err.println( "RHINO USAGE WARNING: onExit terminated with exception"); ex.printStackTrace(System.err); }
107
put 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
202
remove 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
12
reportRuntimeError 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
20
reportRuntimeError1 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
43
reportRuntimeError3 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
3
searchAccessibleMethod
1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
1
substring 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
48
Method Nbr Nbr total
popScope 14
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { if (currentScope == tempScope) { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { for (int i = 0; i < pushed; i++) { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { if (node instanceof Scope) { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { for (int i = 0; i < pushed; i++) { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { popScope(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { popScope(); }
16
close 4
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java
finally { reader.close(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { in.close(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
finally { in.close(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
finally { MinorVersion = minor; MajorVersion = major; GenerateStackMap = major >= 50; if (is != null) { try { is.close(); } catch (IOException e) { } } }
8
exitLoop
3
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { exitLoop(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { exitLoop(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { exitLoop(); }
3
restore
3
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { savedVars.restore(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { --nestingOfFunction; savedVars.restore(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
finally { --nestingOfFunction; savedVars.restore(); }
3
exit 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
finally { Context.exit(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
finally { exit(); }
3
getValue 2
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
finally { this.value = val = initializer.getValue(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
finally { slot.value = initializer.getValue(); }
28
IllegalStateException 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } }
101
exitSwitch
1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { exitSwitch(); }
1
getLabels 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { currentLabel = null; // remove the labels for this statement from the global set for (Label lb : bundle.getLabels()) { labelSet.remove(lb.getName()); } }
2
getName 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { currentLabel = null; // remove the labels for this statement from the global set for (Label lb : bundle.getLabels()) { labelSet.remove(lb.getName()); } }
117
putAll
1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
finally { if(outermostLocked) { // Make loaded modules visible to other threads only after // the topmost triggering load has completed. This strategy // (compared to the one where we'd make each module // globally available as soon as it loads) prevents other // threads from observing a partially loaded circular // dependency of a module that completed loading. exportedModuleInterfaces.putAll(threadLoadingModules); loadingModuleInterfaces.set(null); } }
1
remove 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
finally { currentLabel = null; // remove the labels for this statement from the global set for (Label lb : bundle.getLabels()) { labelSet.remove(lb.getName()); } }
12
set 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
finally { if(outermostLocked) { // Make loaded modules visible to other threads only after // the topmost triggering load has completed. This strategy // (compared to the one where we'd make each module // globally available as soon as it loads) prevents other // threads from observing a partially loaded circular // dependency of a module that completed loading. exportedModuleInterfaces.putAll(threadLoadingModules); loadingModuleInterfaces.set(null); } }
18
setRegExpProxy 1
                  
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/RegExpImpl.java
finally { ScriptRuntime.setRegExpProxy(cx, reImpl); }
2

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) ArrayIndexOutOfBoundsException 0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
0
unknown (Lib) AssertionError 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
private static String toLocale_helper(double t, int methodId) { DateFormat formatter; switch (methodId) { case Id_toLocaleString: if (localeDateTimeFormatter == null) { localeDateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); } formatter = localeDateTimeFormatter; break; case Id_toLocaleTimeString: if (localeTimeFormatter == null) { localeTimeFormatter = DateFormat.getTimeInstance(DateFormat.LONG); } formatter = localeTimeFormatter; break; case Id_toLocaleDateString: if (localeDateFormatter == null) { localeDateFormatter = DateFormat.getDateInstance(DateFormat.LONG); } formatter = localeDateFormatter; break; default: throw new AssertionError(); // unreachable } synchronized (formatter) { return formatter.format(new Date((long) t)); } }
0 0 0 0 0
runtime (Domain) ClassFileFormatException
public static class ClassFileFormatException extends RuntimeException {

        private static final long serialVersionUID = 1263998431033790599L;

        ClassFileFormatException(String message) {
            super(message);
        }
    }
7
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void stopMethod(short maxLocals) { if (itsCurrentMethod == null) throw new IllegalStateException("No method to stop"); fixLabelGotos(); itsMaxLocals = maxLocals; StackMapTable stackMap = null; if (GenerateStackMap) { finalizeSuperBlockStarts(); stackMap = new StackMapTable(); stackMap.generate(); } int lineNumberTableLength = 0; if (itsLineNumberTable != null) { // 6 bytes for the attribute header // 2 bytes for the line number count // 4 bytes for each entry lineNumberTableLength = 6 + 2 + (itsLineNumberTableTop * 4); } int variableTableLength = 0; if (itsVarDescriptors != null) { // 6 bytes for the attribute header // 2 bytes for the variable count // 10 bytes for each entry variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10); } int stackMapTableLength = 0; if (stackMap != null) { int stackMapWriteSize = stackMap.computeWriteSize(); if (stackMapWriteSize > 0) { stackMapTableLength = 6 + stackMapWriteSize; } } int attrLength = 2 + // attribute_name_index 4 + // attribute_length 2 + // max_stack 2 + // max_locals 4 + // code_length itsCodeBufferTop + 2 + // exception_table_length (itsExceptionTableTop * 8) + 2 + // attributes_count lineNumberTableLength + variableTableLength + stackMapTableLength; if (attrLength > 65536) { // See http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html, // section 4.10, "The amount of code per non-native, non-abstract // method is limited to 65536 bytes... throw new ClassFileFormatException( "generated bytecode for method exceeds 64K limit."); } byte[] codeAttribute = new byte[attrLength]; int index = 0; int codeAttrIndex = itsConstantPool.addUtf8("Code"); index = putInt16(codeAttrIndex, codeAttribute, index); attrLength -= 6; // discount the attribute header index = putInt32(attrLength, codeAttribute, index); index = putInt16(itsMaxStack, codeAttribute, index); index = putInt16(itsMaxLocals, codeAttribute, index); index = putInt32(itsCodeBufferTop, codeAttribute, index); System.arraycopy(itsCodeBuffer, 0, codeAttribute, index, itsCodeBufferTop); index += itsCodeBufferTop; if (itsExceptionTableTop > 0) { index = putInt16(itsExceptionTableTop, codeAttribute, index); for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short)getLabelPC(ete.itsStartLabel); short endPC = (short)getLabelPC(ete.itsEndLabel); short handlerPC = (short)getLabelPC(ete.itsHandlerLabel); short catchType = ete.itsCatchType; if (startPC == -1) throw new IllegalStateException("start label not defined"); if (endPC == -1) throw new IllegalStateException("end label not defined"); if (handlerPC == -1) throw new IllegalStateException( "handler label not defined"); index = putInt16(startPC, codeAttribute, index); index = putInt16(endPC, codeAttribute, index); index = putInt16(handlerPC, codeAttribute, index); index = putInt16(catchType, codeAttribute, index); } } else { // write 0 as exception table length index = putInt16(0, codeAttribute, index); } int attributeCount = 0; if (itsLineNumberTable != null) attributeCount++; if (itsVarDescriptors != null) attributeCount++; if (stackMapTableLength > 0) { attributeCount++; } index = putInt16(attributeCount, codeAttribute, index); if (itsLineNumberTable != null) { int lineNumberTableAttrIndex = itsConstantPool.addUtf8("LineNumberTable"); index = putInt16(lineNumberTableAttrIndex, codeAttribute, index); int tableAttrLength = 2 + (itsLineNumberTableTop * 4); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(itsLineNumberTableTop, codeAttribute, index); for (int i = 0; i < itsLineNumberTableTop; i++) { index = putInt32(itsLineNumberTable[i], codeAttribute, index); } } if (itsVarDescriptors != null) { int variableTableAttrIndex = itsConstantPool.addUtf8("LocalVariableTable"); index = putInt16(variableTableAttrIndex, codeAttribute, index); int varCount = itsVarDescriptors.size(); int tableAttrLength = 2 + (varCount * 10); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(varCount, codeAttribute, index); for (int i = 0; i < varCount; i++) { int[] chunk = (int[])itsVarDescriptors.get(i); int nameIndex = chunk[0]; int descriptorIndex = chunk[1]; int startPC = chunk[2]; int register = chunk[3]; int length = itsCodeBufferTop - startPC; index = putInt16(startPC, codeAttribute, index); index = putInt16(length, codeAttribute, index); index = putInt16(nameIndex, codeAttribute, index); index = putInt16(descriptorIndex, codeAttribute, index); index = putInt16(register, codeAttribute, index); } } if (stackMapTableLength > 0) { int stackMapTableAttrIndex = itsConstantPool.addUtf8("StackMapTable"); int start = index; index = putInt16(stackMapTableAttrIndex, codeAttribute, index); index = stackMap.write(codeAttribute, index); } itsCurrentMethod.setCodeAttribute(codeAttribute); itsExceptionTable = null; itsExceptionTableTop = 0; itsLineNumberTableTop = 0; itsCodeBufferTop = 0; itsCurrentMethod = null; itsMaxStack = 0; itsStackTop = 0; itsLabelTableTop = 0; itsFixupTableTop = 0; itsVarDescriptors = null; itsSuperBlockStarts = null; itsSuperBlockStartsTop = 0; itsJumpFroms = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.GOTO : // This is necessary because dead code is seemingly being // generated and Sun's verifier is expecting type state to be // placed even at dead blocks of code. addSuperBlockStart(itsCodeBufferTop + 3); // fallthru... case ByteCode.IFEQ : case ByteCode.IFNE : case ByteCode.IFLT : case ByteCode.IFGE : case ByteCode.IFGT : case ByteCode.IFLE : case ByteCode.IF_ICMPEQ : case ByteCode.IF_ICMPNE : case ByteCode.IF_ICMPLT : case ByteCode.IF_ICMPGE : case ByteCode.IF_ICMPGT : case ByteCode.IF_ICMPLE : case ByteCode.IF_ACMPEQ : case ByteCode.IF_ACMPNE : case ByteCode.JSR : case ByteCode.IFNULL : case ByteCode.IFNONNULL : { if ((theOperand & 0x80000000) != 0x80000000) { if ((theOperand < 0) || (theOperand > 65535)) throw new IllegalArgumentException( "Bad label for branch"); } int branchPC = itsCodeBufferTop; addToCodeBuffer(theOpCode); if ((theOperand & 0x80000000) != 0x80000000) { // hard displacement addToCodeInt16(theOperand); int target = theOperand + branchPC; addSuperBlockStart(target); itsJumpFroms.put(target, branchPC); } else { // a label int targetPC = getLabelPC(theOperand); if (DEBUGLABELS) { int theLabel = theOperand & 0x7FFFFFFF; System.out.println("Fixing branch to " + theLabel + " at " + targetPC + " from " + branchPC); } if (targetPC != -1) { int offset = targetPC - branchPC; addToCodeInt16(offset); addSuperBlockStart(targetPC); itsJumpFroms.put(targetPC, branchPC); } else { addLabelFixup(theOperand, branchPC + 1); addToCodeInt16(0); } } } break; case ByteCode.BIPUSH : if ((byte)theOperand != theOperand) throw new IllegalArgumentException("out of range byte"); addToCodeBuffer(theOpCode); addToCodeBuffer((byte)theOperand); break; case ByteCode.SIPUSH : if ((short)theOperand != theOperand) throw new IllegalArgumentException("out of range short"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.NEWARRAY : if (!(0 <= theOperand && theOperand < 256)) throw new IllegalArgumentException("out of range index"); addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); break; case ByteCode.GETFIELD : case ByteCode.PUTFIELD : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range field"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.LDC : case ByteCode.LDC_W : case ByteCode.LDC2_W : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range index"); if (theOperand >= 256 || theOpCode == ByteCode.LDC_W || theOpCode == ByteCode.LDC2_W) { if (theOpCode == ByteCode.LDC) { addToCodeBuffer(ByteCode.LDC_W); } else { addToCodeBuffer(theOpCode); } addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; case ByteCode.RET : case ByteCode.ILOAD : case ByteCode.LLOAD : case ByteCode.FLOAD : case ByteCode.DLOAD : case ByteCode.ALOAD : case ByteCode.ISTORE : case ByteCode.LSTORE : case ByteCode.FSTORE : case ByteCode.DSTORE : case ByteCode.ASTORE : if (!(0 <= theOperand && theOperand < 65536)) throw new ClassFileFormatException("out of range variable"); if (theOperand >= 256) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; default : throw new IllegalArgumentException( "Unexpected opcode for 1 operand"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand1, int theOperand2) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand1) +", "+Integer.toHexString(theOperand2)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (theOpCode == ByteCode.IINC) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new ClassFileFormatException("out of range variable"); if (!(0 <= theOperand2 && theOperand2 < 65536)) throw new ClassFileFormatException("out of range increment"); if (theOperand1 > 255 || theOperand2 < -128 || theOperand2 > 127) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(ByteCode.IINC); addToCodeInt16(theOperand1); addToCodeInt16(theOperand2); } else { addToCodeBuffer(ByteCode.IINC); addToCodeBuffer(theOperand1); addToCodeBuffer(theOperand2); } } else if (theOpCode == ByteCode.MULTIANEWARRAY) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new IllegalArgumentException("out of range index"); if (!(0 <= theOperand2 && theOperand2 < 256)) throw new IllegalArgumentException("out of range dimensions"); addToCodeBuffer(ByteCode.MULTIANEWARRAY); addToCodeInt16(theOperand1); addToCodeBuffer(theOperand2); } else { throw new IllegalArgumentException( "Unexpected opcode for 2 operands"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public int addTableSwitch(int low, int high) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(ByteCode.TABLESWITCH) +" "+low+" "+high); } if (low > high) throw new ClassFileFormatException("Bad bounds: "+low+' '+ high); int newStack = itsStackTop + stackChange(ByteCode.TABLESWITCH); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); int entryCount = high - low + 1; int padSize = 3 & ~itsCodeBufferTop; // == 3 - itsCodeBufferTop % 4 int N = addReservedCodeSpace(1 + padSize + 4 * (1 + 2 + entryCount)); int switchStart = N; itsCodeBuffer[N++] = (byte)ByteCode.TABLESWITCH; while (padSize != 0) { itsCodeBuffer[N++] = 0; --padSize; } N += 4; // skip default offset N = putInt32(low, itsCodeBuffer, N); putInt32(high, itsCodeBuffer, N); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(ByteCode.TABLESWITCH) +" stack = "+itsStackTop); } return switchStart; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget) { if (!(0 <= jumpTarget && jumpTarget <= itsCodeBufferTop)) throw new IllegalArgumentException("Bad jump target: "+jumpTarget); if (!(caseIndex >= -1)) throw new IllegalArgumentException("Bad case index: "+caseIndex); int padSize = 3 & ~switchStart; // == 3 - switchStart % 4 int caseOffset; if (caseIndex < 0) { // default label caseOffset = switchStart + 1 + padSize; } else { caseOffset = switchStart + 1 + padSize + 4 * (3 + caseIndex); } if (!(0 <= switchStart && switchStart <= itsCodeBufferTop - 4 * 4 - padSize - 1)) { throw new IllegalArgumentException( switchStart+" is outside a possible range of tableswitch" +" in already generated code"); } if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) { throw new IllegalArgumentException( switchStart+" is not offset of tableswitch statement"); } if (!(0 <= caseOffset && caseOffset + 4 <= itsCodeBufferTop)) { // caseIndex >= -1 does not guarantee that caseOffset >= 0 due // to a possible overflow. throw new ClassFileFormatException( "Too big case index: "+caseIndex); } // ALERT: perhaps check against case bounds? putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void fixLabelGotos() { byte[] codeBuffer = itsCodeBuffer; for (int i = 0; i < itsFixupTableTop; i++) { long fixup = itsFixupTable[i]; int label = (int)(fixup >> 32); int fixupSite = (int)fixup; int pc = itsLabelTable[label]; if (pc == -1) { // Unlocated label throw new RuntimeException(); } // -1 to get delta from instruction start addSuperBlockStart(pc); itsJumpFroms.put(pc, fixupSite - 1); int offset = pc - (fixupSite - 1); if ((short)offset != offset) { throw new ClassFileFormatException ("Program too complex: too big jump offset"); } codeBuffer[fixupSite] = (byte)(offset >> 8); codeBuffer[fixupSite + 1] = (byte)offset; } itsFixupTableTop = 0; }
0 0 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(scriptOrFn, e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (ClassFileWriter.ClassFileFormatException e) { throw reportClassFileFormatException(n, e.getMessage()); }
0
unknown (Lib) ClassNotFoundException 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
0 16
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { scriptRefQueue = new ReferenceQueue<Script>(); scripts = new ConcurrentHashMap<String, ScriptReference>(); final Map<String, CachedModuleScript> serScripts = (Map)in.readObject(); for(Map.Entry<String, CachedModuleScript> entry: serScripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue(); putLoadedModule(entry.getKey(), cachedModuleScript.getModule(), cachedModuleScript.getValidator()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DefiningClassLoader.java
Override public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Class<?> cl = findLoadedClass(name); if (cl == null) { if (parentLoader != null) { cl = parentLoader.loadClass(name); } else { cl = findSystemClass(name); } } if (resolve) { resolveClass(cl); } return cl; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; int N = 1 << power; keys = new Object[N]; values = new int[2 * N]; for (int i = 0; i != writtenKeyCount; ++i) { Object key = in.readObject(); int hash = key.hashCode(); int index = insertNewKey(key, hash); values[index] = in.readInt(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Member member = readMember(in); if (member instanceof Method) { init((Method)member); } else { init((Constructor<?>)member); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Class<?>[] readParameters(ObjectInputStream in) throws IOException, ClassNotFoundException { Class<?>[] result = new Class[in.readShort()]; for (int i=0; i < result.length; i++) { if (!in.readBoolean()) { result[i] = (Class<?>) in.readObject(); continue; } result[i] = primitives[in.readByte()]; } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (name != null) { indexOrHash = name.hashCode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.classLoader = Context.getCurrentContext().getApplicationClassLoader(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (parmsLength > 0) { Class<?>[] types = member.argTypes; typeTags = new byte[parmsLength]; for (int i = 0; i != parmsLength; ++i) { typeTags[i] = (byte)getTypeTag(types[i]); } } if (member.isMethod()) { Method method = member.method(); Class<?> returnType = method.getReturnType(); if (returnType == Void.TYPE) { hasVoidReturn = true; } else { returnTypeTag = getTypeTag(returnType); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); // It reads size int N = size; if (N > FIELDS_STORE_SIZE) { data = new Object[N - FIELDS_STORE_SIZE]; } for (int i = 0; i != N; ++i) { Object obj = is.readObject(); setImpl(i, obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int maxPrototypeId = stream.readInt(); if (maxPrototypeId != 0) { activatePrototypeMap(maxPrototypeId); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); if (classLoader != null) { try { return classLoader.loadClass(name); } catch (ClassNotFoundException ex) { // fall through to default loading } } return super.resolveClass(desc); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; boolean hasIntValues = in.readBoolean(); boolean hasObjectValues = in.readBoolean(); int N = 1 << power; if (hasIntValues) { keys = new int[2 * N]; ivaluesShift = N; }else { keys = new int[N]; } for (int i = 0; i != N; ++i) { keys[i] = EMPTY; } if (hasObjectValues) { values = new Object[N]; } for (int i = 0; i != writtenKeyCount; ++i) { int key = in.readInt(); int index = insertNewKey(key); if (hasIntValues) { int ivalue = in.readInt(); keys[ivaluesShift + index] = ivalue; } if (hasObjectValues) { values[index] = in.readObject(); } } } }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (ClassNotFoundException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (ClassNotFoundException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
catch (ClassNotFoundException ex) { // fall through to default loading }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
1
unknown (Lib) CloneNotSupportedException 0 0 0 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
2
runtime (Domain) ContinuationPending
public class ContinuationPending extends RuntimeException {
    private static final long serialVersionUID = 4956008116771118856L;
    private NativeContinuation continuationState;
    private Object applicationState;

    /**
     * Construct a ContinuationPending exception. Internal call only;
     * users of the API should get continuations created on their behalf by
     * calling {@link org.mozilla.javascript.Context#executeScriptWithContinuations(Script, Scriptable)}
     * and {@link org.mozilla.javascript.Context#callFunctionWithContinuations(Callable, Scriptable, Object[])}
     * @param continuationState Internal Continuation object
     */
    ContinuationPending(NativeContinuation continuationState) {
        this.continuationState = continuationState;
    }

    /**
     * Get continuation object. The only
     * use for this object is to be passed to
     * {@link org.mozilla.javascript.Context#resumeContinuation(Object, Scriptable, Object)}.
     * @return continuation object
     */
    public Object getContinuation() {
        return continuationState;
    }

    /**
     * @return internal continuation state
     */
    NativeContinuation getContinuationState() {
        return continuationState;
    }

    /**
     * Store an arbitrary object that applications can use to associate
     * their state with the continuation.
     * @param applicationState arbitrary application state
     */
    public void setApplicationState(Object applicationState) {
        this.applicationState = applicationState;
    }

    /**
     * @return arbitrary application state
     */
    public Object getApplicationState() {
        return applicationState;
    }
}
0 0 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object executeScriptWithContinuations(Script script, Scriptable scope) throws ContinuationPending { if (!(script instanceof InterpretedFunction) || !((InterpretedFunction)script).isScript()) { // Can only be applied to scripts throw new IllegalArgumentException("Script argument was not" + " a script or was not created by interpreted mode "); } return callFunctionWithContinuations((InterpretedFunction) script, scope, ScriptRuntime.emptyArgs); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object callFunctionWithContinuations(Callable function, Scriptable scope, Object[] args) throws ContinuationPending { if (!(function instanceof InterpretedFunction)) { // Can only be applied to scripts throw new IllegalArgumentException("Function argument was not" + " created by interpreted mode "); } if (ScriptRuntime.hasTopCall(this)) { throw new IllegalStateException("Cannot have any pending top " + "calls when executing a script with continuations"); } // Annotate so we can check later to ensure no java code in // intervening frames isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object resumeContinuation(Object continuation, Scriptable scope, Object functionResult) throws ContinuationPending { Object[] args = { functionResult }; return Interpreter.restartContinuation( (org.mozilla.javascript.NativeContinuation) continuation, this, scope, args); }
0 0 0
runtime (Domain) EcmaError
public class EcmaError extends RhinoException
{
    static final long serialVersionUID = -6261226256957286699L;

    private String errorName;
    private String errorMessage;

    /**
     * Create an exception with the specified detail message.
     *
     * Errors internal to the JavaScript engine will simply throw a
     * RuntimeException.
     *
     * @param sourceName the name of the source responsible for the error
     * @param lineNumber the line number of the source
     * @param columnNumber the columnNumber of the source (may be zero if
     *                     unknown)
     * @param lineSource the source of the line containing the error (may be
     *                   null if unknown)
     */
    EcmaError(String errorName, String errorMessage,
              String sourceName, int lineNumber,
              String lineSource, int columnNumber)
    {
        recordErrorOrigin(sourceName, lineNumber, lineSource, columnNumber);
        this.errorName = errorName;
        this.errorMessage = errorMessage;
    }

    /**
     * @deprecated EcmaError error instances should not be constructed
     *             explicitly since they are generated by the engine.
     */
    public EcmaError(Scriptable nativeError, String sourceName,
                     int lineNumber, int columnNumber, String lineSource)
    {
        this("InternalError", ScriptRuntime.toString(nativeError),
             sourceName, lineNumber, lineSource, columnNumber);
    }

    @Override
    public String details()
    {
        return errorName+": "+errorMessage;
    }

    /**
     * Gets the name of the error.
     *
     * ECMA edition 3 defines the following
     * errors: EvalError, RangeError, ReferenceError,
     * SyntaxError, TypeError, and URIError. Additional error names
     * may be added in the future.
     *
     * See ECMA edition 3, 15.11.7.9.
     *
     * @return the name of the error.
     */
    public String getName()
    {
        return errorName;
    }

    /**
     * Gets the message corresponding to the error.
     *
     * See ECMA edition 3, 15.11.7.10.
     *
     * @return an implementation-defined string describing the error.
     */
    public String getErrorMessage()
    {
        return errorMessage;
    }

    /**
     * @deprecated Use {@link RhinoException#sourceName()} from the super class.
     */
    public String getSourceName()
    {
        return sourceName();
    }

    /**
     * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
     */
    public int getLineNumber()
    {
        return lineNumber();
    }

    /**
     * @deprecated
     * Use {@link RhinoException#columnNumber()} from the super class.
     */
    public int getColumnNumber() {
        return columnNumber();
    }

    /**
     * @deprecated Use {@link RhinoException#lineSource()} from the super class.
     */
    public String getLineSource() {
        return lineSource();
    }

    /**
     * @deprecated
     * Always returns <b>null</b>.
     */
    public Scriptable getErrorObject()
    {
        return null;
    }
}
0 0 0 0 0 0
runtime (Lib) Error 0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; }
0 0
runtime (Domain) EvaluatorException
public class EvaluatorException extends RhinoException
{
    static final long serialVersionUID = -8743165779676009808L;

    public EvaluatorException(String detail)
    {
        super(detail);
    }

    /**
     * Create an exception with the specified detail message.
     *
     * Errors internal to the JavaScript engine will simply throw a
     * RuntimeException.
     *
     * @param detail the error message
     * @param sourceName the name of the source reponsible for the error
     * @param lineNumber the line number of the source
     */
    public EvaluatorException(String detail, String sourceName,
                              int lineNumber)
    {
        this(detail, sourceName, lineNumber, null, 0);
    }

    /**
     * Create an exception with the specified detail message.
     *
     * Errors internal to the JavaScript engine will simply throw a
     * RuntimeException.
     *
     * @param detail the error message
     * @param sourceName the name of the source responsible for the error
     * @param lineNumber the line number of the source
     * @param columnNumber the columnNumber of the source (may be zero if
     *                     unknown)
     * @param lineSource the source of the line containing the error (may be
     *                   null if unknown)
     */
    public EvaluatorException(String detail, String sourceName, int lineNumber,
                              String lineSource, int columnNumber)
    {
        super(detail);
        recordErrorOrigin(sourceName, lineNumber, lineSource, columnNumber);
    }

    /**
     * @deprecated Use {@link RhinoException#sourceName()} from the super class.
     */
    public String getSourceName()
    {
        return sourceName();
    }

    /**
     * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
     */
    public int getLineNumber()
    {
        return lineNumber();
    }

    /**
     * @deprecated Use {@link RhinoException#columnNumber()} from the super class.
     */
    public int getColumnNumber()
    {
        return columnNumber();
    }

    /**
     * @deprecated Use {@link RhinoException#lineSource()} from the super class.
     */
    public String getLineSource()
    {
        return lineSource();
    }

}
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeFunction.java
public Object resumeGenerator(Context cx, Scriptable scope, int operation, Object state, Object value) { throw new EvaluatorException("resumeGenerator() not implemented"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void reportError(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = getCurrentContext(); if (cx != null) { cx.getErrorReporter().error(message, sourceName, lineno, lineSource, lineOffset); } else { throw new EvaluatorException(message, sourceName, lineno, lineSource, lineOffset); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static EvaluatorException reportRuntimeError(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = getCurrentContext(); if (cx != null) { return cx.getErrorReporter(). runtimeError(message, sourceName, lineno, lineSource, lineOffset); } else { throw new EvaluatorException(message, sourceName, lineno, lineSource, lineOffset); } }
0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static Object jsToJava(Object value, Class<?> desiredType) throws EvaluatorException { return NativeJavaObject.coerceTypeImpl(desiredType, value); }
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (EvaluatorException ee) { reportConversionError(value, type); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ee) { errorseen = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; }
0
checked (Lib) Exception 0 0 5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
Override public Object callWithDomain(final Object securityDomain, final Context cx, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args) { // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return cx.getApplicationClassLoader(); } }); final CodeSource codeSource = (CodeSource)securityDomain; Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized (callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized (classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { Loader loader = new Loader(classLoader, codeSource); Class<?> c = loader.defineClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
public Object run() throws Exception { Loader loader = new Loader(classLoader, codeSource); Class<?> c = loader.defineClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode); return c.newInstance(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
Override public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, Scriptable paths) throws Exception { // Overridden to clear the reference queue before retrieving the // script. for(;;) { ScriptReference ref = (ScriptReference)scriptRefQueue.poll(); if(ref == null) { break; } scripts.remove(ref.getModuleId(), ref); } return super.getModuleScript(cx, moduleId, uri, paths); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, Scriptable paths) throws Exception { for (ModuleScriptProvider provider : providers) { final ModuleScript script = provider.getModuleScript(cx, moduleId, uri, paths); if(script != null) { return script; } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java
public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, Scriptable paths) throws Exception { final CachedModuleScript cachedModule1 = getLoadedModule(moduleId); final Object validator1 = getValidator(cachedModule1); final ModuleSource moduleSource = (moduleUri == null) ? moduleSourceProvider.loadSource(moduleId, paths, validator1) : moduleSourceProvider.loadSource(moduleUri, validator1); if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) { return cachedModule1.getModule(); } if(moduleSource == null) { return null; } final Reader reader = moduleSource.getReader(); try { final int idHash = moduleId.hashCode(); synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) { final CachedModuleScript cachedModule2 = getLoadedModule(moduleId); if(cachedModule2 != null) { if(!equal(validator1, getValidator(cachedModule2))) { return cachedModule2.getModule(); } } final URI sourceUri = moduleSource.getUri(); final ModuleScript moduleScript = new ModuleScript( cx.compileReader(reader, sourceUri.toString(), 1, moduleSource.getSecurityDomain()), sourceUri, moduleSource.getBase()); putLoadedModule(moduleId, moduleScript, moduleSource.getValidator()); return moduleScript; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return thread.getContextClassLoader(); } }); Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized(callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized(classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); }
20
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (Exception ex) { // Assume any exceptions means the method does not exist. }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (Exception e) { // Ignore any exceptions }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (Exception ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaClass.java
catch (Exception ex) { // fall through to error String m = ex.getMessage(); if (m != null) msg = m; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (Exception e) { // fall through... }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (Exception e) { // Unable to get class file, use default bytecode version }
14
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(Exception e) { throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Delegator.java
catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (Exception ex) { RuntimeException rex = new RuntimeException(); Kit.initCause(rex, ex); throw rex; }
3
unknown (Lib) FileNotFoundException 0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(FileNotFoundException e) { return null; }
0 0
runtime (Domain) GeneratorClosedException
public static class GeneratorClosedException extends RuntimeException {
        private static final long serialVersionUID = 2561315658662379681L;
    }
0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (GeneratorClosedException e) { // On closing a generator in the compile path, the generator // throws a special exception. This ensures execution of all pending // finalizers and will not get caught by user code. return Undefined.instance; }
0 0
checked (Lib) IOException 8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeBoolean(isAdapter); if (isAdapter) { if (adapter_writeAdapterObject == null) { throw new IOException(); } Object[] args = { javaObject, out }; try { adapter_writeAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { out.writeObject(javaObject); } if (staticType != null) { out.writeObject(staticType.getClass().getName()); } else { out.writeObject(null); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static void writeAdapterObject(Object javaObject, ObjectOutputStream out) throws IOException { Class<?> cl = javaObject.getClass(); out.writeObject(cl.getSuperclass().getName()); Class<?>[] interfaces = cl.getInterfaces(); String[] interfaceNames = new String[interfaces.length]; for (int i=0; i < interfaces.length; i++) interfaceNames[i] = interfaces[i].getName(); out.writeObject(interfaceNames); try { Object delegee = cl.getField("delegee").get(javaObject); out.writeObject(delegee); return; } catch (IllegalAccessException e) { } catch (NoSuchFieldException e) { } throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Object resolveObject(Object obj) throws IOException { if (obj instanceof ScriptableOutputStream.PendingLookup) { String name = ((ScriptableOutputStream.PendingLookup)obj).getName(); obj = ScriptableOutputStream.lookupQualifiedName(scope, name); if (obj == Scriptable.NOT_FOUND) { throw new IOException("Object " + name + " not found upon " + "deserialization."); } }else if (obj instanceof UniqueTag) { obj = ((UniqueTag)obj).readResolve(); }else if (obj instanceof Undefined) { obj = ((Undefined)obj).readResolve(); } return obj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
Override protected Object replaceObject(Object obj) throws IOException { if (false) throw new IOException(); // suppress warning String name = table.get(obj); if (name == null) return obj; return new PendingLookup(name); }
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (Exception ex) { throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
143
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeBoolean(isAdapter); if (isAdapter) { if (adapter_writeAdapterObject == null) { throw new IOException(); } Object[] args = { javaObject, out }; try { adapter_writeAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { out.writeObject(javaObject); } if (staticType != null) { out.writeObject(staticType.getClass().getName()); } else { out.writeObject(null); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); isAdapter = in.readBoolean(); if (isAdapter) { if (adapter_readAdapterObject == null) throw new ClassNotFoundException(); Object[] args = { this, in }; try { javaObject = adapter_readAdapterObject.invoke(null, args); } catch (Exception ex) { throw new IOException(); } } else { javaObject = in.readObject(); } String className = (String)in.readObject(); if (className != null) { staticType = Class.forName(className); } else { staticType = null; } initMembers(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, privilegedUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, fallbackUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private ModuleSource loadFromPathList(String moduleId, Object validator, Iterable<URI> paths) throws IOException, URISyntaxException { if(paths == null) { return null; } for (URI path : paths) { final ModuleSource moduleSource = loadFromUri( path.resolve(moduleId), path, validator); if (moduleSource != null) { return moduleSource; } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromUri(URI uri, URI base, Object validator) throws IOException, URISyntaxException { // We expect modules to have a ".js" file name extension ... URI fullUri = new URI(uri + ".js"); ModuleSource source = loadFromActualUri(fullUri, base, validator); // ... but for compatibility we support modules without extension, // or ids with explicit extension. return source != null ? source : loadFromActualUri(uri, base, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
protected ModuleSource loadFromActualUri(URI uri, URI base, Object validator) throws IOException { final URL url = new URL(base == null ? null : base.toURL(), uri.toString()); final long request_time = System.currentTimeMillis(); final URLConnection urlConnection = openUrlConnection(url); final URLValidator applicableValidator; if(validator instanceof URLValidator) { final URLValidator uriValidator = ((URLValidator)validator); applicableValidator = uriValidator.appliesTo(uri) ? uriValidator : null; } else { applicableValidator = null; } if(applicableValidator != null) { applicableValidator.applyConditionals(urlConnection); } try { urlConnection.connect(); if(applicableValidator != null && applicableValidator.updateValidator(urlConnection, request_time, urlConnectionExpiryCalculator)) { close(urlConnection); return NOT_MODIFIED; } return new ModuleSource(getReader(urlConnection), getSecurityDomain(urlConnection), uri, base, new URLValidator(uri, urlConnection, request_time, urlConnectionExpiryCalculator)); } catch(FileNotFoundException e) { return null; } catch(RuntimeException e) { close(urlConnection); throw e; } catch(IOException e) { close(urlConnection); throw e; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private static Reader getReader(URLConnection urlConnection) throws IOException { return new InputStreamReader(urlConnection.getInputStream(), getCharacterEncoding(urlConnection)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
protected URLConnection openUrlConnection(URL url) throws IOException { return url.openConnection(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
boolean updateValidator(URLConnection urlConnection, long request_time, UrlConnectionExpiryCalculator urlConnectionExpiryCalculator) throws IOException { boolean isResourceChanged = isResourceChanged(urlConnection); if(!isResourceChanged) { expiry = calculateExpiry(urlConnection, request_time, urlConnectionExpiryCalculator); } return isResourceChanged; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private boolean isResourceChanged(URLConnection urlConnection) throws IOException { if(urlConnection instanceof HttpURLConnection) { return ((HttpURLConnection)urlConnection).getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED; } return lastModified == urlConnection.getLastModified(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { scriptRefQueue = new ReferenceQueue<Script>(); scripts = new ConcurrentHashMap<String, ScriptReference>(); final Map<String, CachedModuleScript> serScripts = (Map)in.readObject(); for(Map.Entry<String, CachedModuleScript> entry: serScripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue(); putLoadedModule(entry.getKey(), cachedModuleScript.getModule(), cachedModuleScript.getValidator()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java
private void writeObject(ObjectOutputStream out) throws IOException { final Map<String, CachedModuleScript> serScripts = new HashMap<String, CachedModuleScript>(); for(Map.Entry<String, ScriptReference> entry: scripts.entrySet()) { final CachedModuleScript cachedModuleScript = entry.getValue().getCachedModuleScript(); if(cachedModuleScript != null) { serScripts.put(entry.getKey(), cachedModuleScript); } } out.writeObject(serScripts); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws IOException, URISyntaxException { if(!entityNeedsRevalidation(validator)) { return NOT_MODIFIED; } ModuleSource moduleSource = loadFromPrivilegedLocations( moduleId, validator); if(moduleSource != null) { return moduleSource; } if(paths != null) { moduleSource = loadFromPathArray(moduleId, paths, validator); if(moduleSource != null) { return moduleSource; } } return loadFromFallbackLocations(moduleId, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(URI uri, Object validator) throws IOException, URISyntaxException { return loadFromUri(uri, null, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator) throws IOException { final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { final String path = ensureTrailingSlash( ScriptableObject.getTypedProperty(paths, i, String.class)); try { URI uri = new URI(path); if (!uri.isAbsolute()) { uri = new File(path).toURI().resolve(""); } final ModuleSource moduleSource = loadFromUri( uri.resolve(moduleId), uri, validator); if(moduleSource != null) { return moduleSource; } } catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int count = keyCount; for (int i = 0; count != 0; ++i) { Object key = keys[i]; if (key != null && key != DELETED) { --count; out.writeObject(key); out.writeInt(values[i]); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjToIntMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; int N = 1 << power; keys = new Object[N]; values = new int[2 * N]; for (int i = 0; i != writtenKeyCount; ++i) { Object key = in.readObject(); int hash = key.hashCode(); int index = insertNewKey(key, hash); values[index] = in.readInt(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Member member = readMember(in); if (member instanceof Method) { init((Method)member); } else { init((Constructor<?>)member); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); writeMember(out, memberObject); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeMember(ObjectOutputStream out, Member member) throws IOException { if (member == null) { out.writeBoolean(false); return; } out.writeBoolean(true); if (!(member instanceof Method || member instanceof Constructor)) throw new IllegalArgumentException("not Method or Constructor"); out.writeBoolean(member instanceof Method); out.writeObject(member.getName()); out.writeObject(member.getDeclaringClass()); if (member instanceof Method) { writeParameters(out, ((Method) member).getParameterTypes()); } else { writeParameters(out, ((Constructor<?>) member).getParameterTypes()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Member readMember(ObjectInputStream in) throws IOException, ClassNotFoundException { if (!in.readBoolean()) return null; boolean isMethod = in.readBoolean(); String name = (String) in.readObject(); Class<?> declaring = (Class<?>) in.readObject(); Class<?>[] parms = readParameters(in); try { if (isMethod) { return declaring.getMethod(name, parms); } else { return declaring.getConstructor(parms); } } catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static Class<?>[] readParameters(ObjectInputStream in) throws IOException, ClassNotFoundException { Class<?>[] result = new Class[in.readShort()]; for (int i=0; i < result.length; i++) { if (!in.readBoolean()) { result[i] = (Class<?>) in.readObject(); continue; } result[i] = primitives[in.readByte()]; } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
final int getToken() throws IOException { int c; retry: for (;;) { // Eat whitespace, possibly sensitive to newlines. for (;;) { c = getChar(); if (c == EOF_CHAR) { tokenBeg = cursor - 1; tokenEnd = cursor; return Token.EOF; } else if (c == '\n') { dirtyLine = false; tokenBeg = cursor - 1; tokenEnd = cursor; return Token.EOL; } else if (!isJSSpace(c)) { if (c != '-') { dirtyLine = true; } break; } } // Assume the token will be 1 char - fixed up below. tokenBeg = cursor - 1; tokenEnd = cursor; if (c == '@') return Token.XMLATTR; // identifier/keyword/instanceof? // watch out for starting with a <backslash> boolean identifierStart; boolean isUnicodeEscapeStart = false; if (c == '\\') { c = getChar(); if (c == 'u') { identifierStart = true; isUnicodeEscapeStart = true; stringBufferTop = 0; } else { identifierStart = false; ungetChar(c); c = '\\'; } } else { identifierStart = Character.isJavaIdentifierStart((char)c); if (identifierStart) { stringBufferTop = 0; addToString(c); } } if (identifierStart) { boolean containsEscape = isUnicodeEscapeStart; for (;;) { if (isUnicodeEscapeStart) { // strictly speaking we should probably push-back // all the bad characters if the <backslash>uXXXX // sequence is malformed. But since there isn't a // correct context(is there?) for a bad Unicode // escape sequence in an identifier, we can report // an error here. int escapeVal = 0; for (int i = 0; i != 4; ++i) { c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); // Next check takes care about c < 0 and bad escape if (escapeVal < 0) { break; } } if (escapeVal < 0) { parser.addError("msg.invalid.escape"); return Token.ERROR; } addToString(escapeVal); isUnicodeEscapeStart = false; } else { c = getChar(); if (c == '\\') { c = getChar(); if (c == 'u') { isUnicodeEscapeStart = true; containsEscape = true; } else { parser.addError("msg.illegal.character"); return Token.ERROR; } } else { if (c == EOF_CHAR || c == BYTE_ORDER_MARK || !Character.isJavaIdentifierPart((char)c)) { break; } addToString(c); } } } ungetChar(c); String str = getStringFromBuffer(); if (!containsEscape) { // OPT we shouldn't have to make a string (object!) to // check if it's a keyword. // Return the corresponding token if it's a keyword int result = stringToKeyword(str); if (result != Token.EOF) { if ((result == Token.LET || result == Token.YIELD) && parser.compilerEnv.getLanguageVersion() < Context.VERSION_1_7) { // LET and YIELD are tokens only in 1.7 and later string = result == Token.LET ? "let" : "yield"; result = Token.NAME; } if (result != Token.RESERVED) { return result; } else if (!parser.compilerEnv. isReservedKeywordAsIdentifier()) { return result; } } } this.string = (String)allStrings.intern(str); return Token.NAME; } // is it a number? if (isDigit(c) || (c == '.' && isDigit(peekChar()))) { isOctal = false; stringBufferTop = 0; int base = 10; if (c == '0') { c = getChar(); if (c == 'x' || c == 'X') { base = 16; c = getChar(); } else if (isDigit(c)) { base = 8; isOctal = true; } else { addToString('0'); } } if (base == 16) { while (0 <= Kit.xDigitToInt(c, 0)) { addToString(c); c = getChar(); } } else { while ('0' <= c && c <= '9') { /* * We permit 08 and 09 as decimal numbers, which * makes our behavior a superset of the ECMA * numeric grammar. We might not always be so * permissive, so we warn about it. */ if (base == 8 && c >= '8') { parser.addWarning("msg.bad.octal.literal", c == '8' ? "8" : "9"); base = 10; } addToString(c); c = getChar(); } } boolean isInteger = true; if (base == 10 && (c == '.' || c == 'e' || c == 'E')) { isInteger = false; if (c == '.') { do { addToString(c); c = getChar(); } while (isDigit(c)); } if (c == 'e' || c == 'E') { addToString(c); c = getChar(); if (c == '+' || c == '-') { addToString(c); c = getChar(); } if (!isDigit(c)) { parser.addError("msg.missing.exponent"); return Token.ERROR; } do { addToString(c); c = getChar(); } while (isDigit(c)); } } ungetChar(c); String numString = getStringFromBuffer(); this.string = numString; double dval; if (base == 10 && !isInteger) { try { // Use Java conversion to number from string... dval = Double.parseDouble(numString); } catch (NumberFormatException ex) { parser.addError("msg.caught.nfe"); return Token.ERROR; } } else { dval = ScriptRuntime.stringToNumber(numString, 0, base); } this.number = dval; return Token.NUMBER; } // is it a string? if (c == '"' || c == '\'') { // We attempt to accumulate a string the fast way, by // building it directly out of the reader. But if there // are any escaped characters in the string, we revert to // building it out of a StringBuffer. quoteChar = c; stringBufferTop = 0; c = getChar(false); strLoop: while (c != quoteChar) { if (c == '\n' || c == EOF_CHAR) { ungetChar(c); tokenEnd = cursor; parser.addError("msg.unterminated.string.lit"); return Token.ERROR; } if (c == '\\') { // We've hit an escaped character int escapeVal; c = getChar(); switch (c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; // \v a late addition to the ECMA spec, // it is not in Java, so use 0xb case 'v': c = 0xb; break; case 'u': // Get 4 hex digits; if the u escape is not // followed by 4 hex digits, use 'u' + the // literal character sequence that follows. int escapeStart = stringBufferTop; addToString('u'); escapeVal = 0; for (int i = 0; i != 4; ++i) { c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); if (escapeVal < 0) { continue strLoop; } addToString(c); } // prepare for replace of stored 'u' sequence // by escape value stringBufferTop = escapeStart; c = escapeVal; break; case 'x': // Get 2 hex digits, defaulting to 'x'+literal // sequence, as above. c = getChar(); escapeVal = Kit.xDigitToInt(c, 0); if (escapeVal < 0) { addToString('x'); continue strLoop; } else { int c1 = c; c = getChar(); escapeVal = Kit.xDigitToInt(c, escapeVal); if (escapeVal < 0) { addToString('x'); addToString(c1); continue strLoop; } else { // got 2 hex digits c = escapeVal; } } break; case '\n': // Remove line terminator after escape to follow // SpiderMonkey and C/C++ c = getChar(); continue strLoop; default: if ('0' <= c && c < '8') { int val = c - '0'; c = getChar(); if ('0' <= c && c < '8') { val = 8 * val + c - '0'; c = getChar(); if ('0' <= c && c < '8' && val <= 037) { // c is 3rd char of octal sequence only // if the resulting val <= 0377 val = 8 * val + c - '0'; c = getChar(); } } ungetChar(c); c = val; } } } addToString(c); c = getChar(false); } String str = getStringFromBuffer(); this.string = (String)allStrings.intern(str); return Token.STRING; } switch (c) { case ';': return Token.SEMI; case '[': return Token.LB; case ']': return Token.RB; case '{': return Token.LC; case '}': return Token.RC; case '(': return Token.LP; case ')': return Token.RP; case ',': return Token.COMMA; case '?': return Token.HOOK; case ':': if (matchChar(':')) { return Token.COLONCOLON; } else { return Token.COLON; } case '.': if (matchChar('.')) { return Token.DOTDOT; } else if (matchChar('(')) { return Token.DOTQUERY; } else { return Token.DOT; } case '|': if (matchChar('|')) { return Token.OR; } else if (matchChar('=')) { return Token.ASSIGN_BITOR; } else { return Token.BITOR; } case '^': if (matchChar('=')) { return Token.ASSIGN_BITXOR; } else { return Token.BITXOR; } case '&': if (matchChar('&')) { return Token.AND; } else if (matchChar('=')) { return Token.ASSIGN_BITAND; } else { return Token.BITAND; } case '=': if (matchChar('=')) { if (matchChar('=')) { return Token.SHEQ; } else { return Token.EQ; } } else { return Token.ASSIGN; } case '!': if (matchChar('=')) { if (matchChar('=')) { return Token.SHNE; } else { return Token.NE; } } else { return Token.NOT; } case '<': /* NB:treat HTML begin-comment as comment-till-eol */ if (matchChar('!')) { if (matchChar('-')) { if (matchChar('-')) { tokenBeg = cursor - 4; skipLine(); commentType = Token.CommentType.HTML; return Token.COMMENT; } ungetCharIgnoreLineEnd('-'); } ungetCharIgnoreLineEnd('!'); } if (matchChar('<')) { if (matchChar('=')) { return Token.ASSIGN_LSH; } else { return Token.LSH; } } else { if (matchChar('=')) { return Token.LE; } else { return Token.LT; } } case '>': if (matchChar('>')) { if (matchChar('>')) { if (matchChar('=')) { return Token.ASSIGN_URSH; } else { return Token.URSH; } } else { if (matchChar('=')) { return Token.ASSIGN_RSH; } else { return Token.RSH; } } } else { if (matchChar('=')) { return Token.GE; } else { return Token.GT; } } case '*': if (matchChar('=')) { return Token.ASSIGN_MUL; } else { return Token.MUL; } case '/': markCommentStart(); // is it a // comment? if (matchChar('/')) { tokenBeg = cursor - 2; skipLine(); commentType = Token.CommentType.LINE; return Token.COMMENT; } // is it a /* or /** comment? if (matchChar('*')) { boolean lookForSlash = false; tokenBeg = cursor - 2; if (matchChar('*')) { lookForSlash = true; commentType = Token.CommentType.JSDOC; } else { commentType = Token.CommentType.BLOCK_COMMENT; } for (;;) { c = getChar(); if (c == EOF_CHAR) { tokenEnd = cursor - 1; parser.addError("msg.unterminated.comment"); return Token.COMMENT; } else if (c == '*') { lookForSlash = true; } else if (c == '/') { if (lookForSlash) { tokenEnd = cursor; return Token.COMMENT; } } else { lookForSlash = false; tokenEnd = cursor; } } } if (matchChar('=')) { return Token.ASSIGN_DIV; } else { return Token.DIV; } case '%': if (matchChar('=')) { return Token.ASSIGN_MOD; } else { return Token.MOD; } case '~': return Token.BITNOT; case '+': if (matchChar('=')) { return Token.ASSIGN_ADD; } else if (matchChar('+')) { return Token.INC; } else { return Token.ADD; } case '-': if (matchChar('=')) { c = Token.ASSIGN_SUB; } else if (matchChar('-')) { if (!dirtyLine) { // treat HTML end-comment after possible whitespace // after line start as comment-until-eol if (matchChar('>')) { markCommentStart("--"); skipLine(); commentType = Token.CommentType.HTML; return Token.COMMENT; } } c = Token.DEC; } else { c = Token.SUB; } dirtyLine = true; return c; default: parser.addError("msg.illegal.character"); return Token.ERROR; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
void readRegExp(int startToken) throws IOException { int start = tokenBeg; stringBufferTop = 0; if (startToken == Token.ASSIGN_DIV) { // Miss-scanned /= addToString('='); } else { if (startToken != Token.DIV) Kit.codeBug(); } boolean inCharSet = false; // true if inside a '['..']' pair int c; while ((c = getChar()) != '/' || inCharSet) { if (c == '\n' || c == EOF_CHAR) { ungetChar(c); tokenEnd = cursor - 1; this.string = new String(stringBuffer, 0, stringBufferTop); parser.reportError("msg.unterminated.re.lit"); return; } if (c == '\\') { addToString(c); c = getChar(); } else if (c == '[') { inCharSet = true; } else if (c == ']') { inCharSet = false; } addToString(c); } int reEnd = stringBufferTop; while (true) { if (matchChar('g')) addToString('g'); else if (matchChar('i')) addToString('i'); else if (matchChar('m')) addToString('m'); else if (matchChar('y')) // FireFox 3 addToString('y'); else break; } tokenEnd = start + stringBufferTop + 2; // include slashes if (isAlpha(peekChar())) { parser.reportError("msg.invalid.re.flag"); } this.string = new String(stringBuffer, 0, reEnd); this.regExpFlags = new String(stringBuffer, reEnd, stringBufferTop - reEnd); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
int getFirstXMLToken() throws IOException { xmlOpenTagsCount = 0; xmlIsAttribute = false; xmlIsTagContent = false; if (!canUngetChar()) return Token.ERROR; ungetChar('<'); return getNextXMLToken(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
int getNextXMLToken() throws IOException { tokenBeg = cursor; stringBufferTop = 0; // remember the XML for (int c = getChar(); c != EOF_CHAR; c = getChar()) { if (xmlIsTagContent) { switch (c) { case '>': addToString(c); xmlIsTagContent = false; xmlIsAttribute = false; break; case '/': addToString(c); if (peekChar() == '>') { c = getChar(); addToString(c); xmlIsTagContent = false; xmlOpenTagsCount--; } break; case '{': ungetChar(c); this.string = getStringFromBuffer(); return Token.XML; case '\'': case '"': addToString(c); if (!readQuotedString(c)) return Token.ERROR; break; case '=': addToString(c); xmlIsAttribute = true; break; case ' ': case '\t': case '\r': case '\n': addToString(c); break; default: addToString(c); xmlIsAttribute = false; break; } if (!xmlIsTagContent && xmlOpenTagsCount == 0) { this.string = getStringFromBuffer(); return Token.XMLEND; } } else { switch (c) { case '<': addToString(c); c = peekChar(); switch (c) { case '!': c = getChar(); // Skip ! addToString(c); c = peekChar(); switch (c) { case '-': c = getChar(); // Skip - addToString(c); c = getChar(); if (c == '-') { addToString(c); if(!readXmlComment()) return Token.ERROR; } else { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } break; case '[': c = getChar(); // Skip [ addToString(c); if (getChar() == 'C' && getChar() == 'D' && getChar() == 'A' && getChar() == 'T' && getChar() == 'A' && getChar() == '[') { addToString('C'); addToString('D'); addToString('A'); addToString('T'); addToString('A'); addToString('['); if (!readCDATA()) return Token.ERROR; } else { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } break; default: if(!readEntity()) return Token.ERROR; break; } break; case '?': c = getChar(); // Skip ? addToString(c); if (!readPI()) return Token.ERROR; break; case '/': // End tag c = getChar(); // Skip / addToString(c); if (xmlOpenTagsCount == 0) { // throw away the string in progress stringBufferTop = 0; this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; } xmlIsTagContent = true; xmlOpenTagsCount--; break; default: // Start tag xmlIsTagContent = true; xmlOpenTagsCount++; break; } break; case '{': ungetChar(c); this.string = getStringFromBuffer(); return Token.XML; default: addToString(c); break; } } } tokenEnd = cursor; stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return Token.ERROR; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readQuotedString(int quote) throws IOException { for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); if (c == quote) return true; } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readXmlComment() throws IOException { for (int c = getChar(); c != EOF_CHAR;) { addToString(c); if (c == '-' && peekChar() == '-') { c = getChar(); addToString(c); if (peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } else { continue; } } c = getChar(); } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readCDATA() throws IOException { for (int c = getChar(); c != EOF_CHAR;) { addToString(c); if (c == ']' && peekChar() == ']') { c = getChar(); addToString(c); if (peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } else { continue; } } c = getChar(); } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readEntity() throws IOException { int declTags = 1; for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); switch (c) { case '<': declTags++; break; case '>': declTags--; if (declTags == 0) return true; break; } } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean readPI() throws IOException { for (int c = getChar(); c != EOF_CHAR; c = getChar()) { addToString(c); if (c == '?' && peekChar() == '>') { c = getChar(); // Skip > addToString(c); return true; } } stringBufferTop = 0; // throw away the string in progress this.string = null; parser.addError("msg.XML.bad.form"); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean matchChar(int test) throws IOException { int c = getCharIgnoreLineEnd(); if (c == test) { tokenEnd = cursor; return true; } else { ungetCharIgnoreLineEnd(c); return false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int peekChar() throws IOException { int c = getChar(); ungetChar(c); return c; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getChar() throws IOException { return getChar(true); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getChar(boolean skipFormattingChars) throws IOException { if (ungetCursor != 0) { cursor++; return ungetBuffer[--ungetCursor]; } for(;;) { int c; if (sourceString != null) { if (sourceCursor == sourceEnd) { hitEOF = true; return EOF_CHAR; } cursor++; c = sourceString.charAt(sourceCursor++); } else { if (sourceCursor == sourceEnd) { if (!fillSourceBuffer()) { hitEOF = true; return EOF_CHAR; } } cursor++; c = sourceBuffer[sourceCursor++]; } if (lineEndChar >= 0) { if (lineEndChar == '\r' && c == '\n') { lineEndChar = '\n'; continue; } lineEndChar = -1; lineStart = sourceCursor - 1; lineno++; } if (c <= 127) { if (c == '\n' || c == '\r') { lineEndChar = c; c = '\n'; } } else { if (c == BYTE_ORDER_MARK) return c; // BOM is considered whitespace if (skipFormattingChars && isJSFormatChar(c)) { continue; } if (ScriptRuntime.isJSLineTerminator(c)) { lineEndChar = c; c = '\n'; } } return c; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private int getCharIgnoreLineEnd() throws IOException { if (ungetCursor != 0) { cursor++; return ungetBuffer[--ungetCursor]; } for(;;) { int c; if (sourceString != null) { if (sourceCursor == sourceEnd) { hitEOF = true; return EOF_CHAR; } cursor++; c = sourceString.charAt(sourceCursor++); } else { if (sourceCursor == sourceEnd) { if (!fillSourceBuffer()) { hitEOF = true; return EOF_CHAR; } } cursor++; c = sourceBuffer[sourceCursor++]; } if (c <= 127) { if (c == '\n' || c == '\r') { lineEndChar = c; c = '\n'; } } else { if (c == BYTE_ORDER_MARK) return c; // BOM is considered whitespace if (isJSFormatChar(c)) { continue; } if (ScriptRuntime.isJSLineTerminator(c)) { lineEndChar = c; c = '\n'; } } return c; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private void skipLine() throws IOException { // skip to end of line int c; while ((c = getChar()) != EOF_CHAR && c != '\n') { } ungetChar(c); tokenEnd = cursor; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
private boolean fillSourceBuffer() throws IOException { if (sourceString != null) Kit.codeBug(); if (sourceEnd == sourceBuffer.length) { if (lineStart != 0 && !isMarkingComment()) { System.arraycopy(sourceBuffer, lineStart, sourceBuffer, 0, sourceEnd - lineStart); sourceEnd -= lineStart; sourceCursor -= lineStart; lineStart = 0; } else { char[] tmp = new char[sourceBuffer.length * 2]; System.arraycopy(sourceBuffer, 0, tmp, 0, sourceEnd); sourceBuffer = tmp; } } int n = sourceReader.read(sourceBuffer, sourceEnd, sourceBuffer.length - sourceEnd); if (n < 0) { return false; } sourceEnd += n; return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekToken() throws IOException { // By far the most common case: last token hasn't been consumed, // so return already-peeked token. if (currentFlaggedToken != Token.EOF) { return currentToken; } int lineno = ts.getLineno(); int tt = ts.getToken(); boolean sawEOL = false; // process comments and whitespace while (tt == Token.EOL || tt == Token.COMMENT) { if (tt == Token.EOL) { lineno++; sawEOL = true; } else { if (compilerEnv.isRecordingComments()) { String comment = ts.getAndResetCurrentComment(); recordComment(lineno, comment); // Comments may contain multiple lines, get the number // of EoLs and increase the lineno lineno += getNumberOfEols(comment); } } tt = ts.getToken(); } currentToken = tt; currentFlaggedToken = tt | (sawEOL ? TI_AFTER_EOL : 0); return currentToken; // return unflagged token }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekFlaggedToken() throws IOException { peekToken(); return currentFlaggedToken; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int nextToken() throws IOException { int tt = peekToken(); consumeToken(); return tt; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int nextFlaggedToken() throws IOException { peekToken(); int ttFlagged = currentFlaggedToken; consumeToken(); return ttFlagged; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean matchToken(int toMatch) throws IOException { if (peekToken() != toMatch) { return false; } consumeToken(); return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private int peekTokenOrEOL() throws IOException { int tt = peekToken(); // Check for last peeked token flags if ((currentFlaggedToken & TI_AFTER_EOL) != 0) { tt = Token.EOL; } return tt; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean mustMatchToken(int toMatch, String messageId) throws IOException { return mustMatchToken(toMatch, messageId, ts.tokenBeg, ts.tokenEnd - ts.tokenBeg); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private boolean mustMatchToken(int toMatch, String msgId, int pos, int len) throws IOException { if (matchToken(toMatch)) { return true; } reportError(msgId, pos, len); return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(Reader sourceReader, String sourceURI, int lineno) throws IOException { if (parseFinished) throw new IllegalStateException("parser reused"); if (compilerEnv.isIdeMode()) { return parse(readFully(sourceReader), sourceURI, lineno); } try { this.sourceURI = sourceURI; ts = new TokenStream(this, sourceReader, null, lineno); return parse(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstRoot parse() throws IOException { int pos = 0; AstRoot root = new AstRoot(pos); currentScope = currentScriptOrFn = root; int baseLineno = ts.lineno; // line number where source starts int end = pos; // in case source is empty boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // TODO: eval code should get strict mode from invoking code inUseStrictDirective = false; try { for (;;) { int tt = peekToken(); if (tt <= Token.EOF) { break; } AstNode n; if (tt == Token.FUNCTION) { consumeToken(); try { n = function(calledByCompileFunction ? FunctionNode.FUNCTION_EXPRESSION : FunctionNode.FUNCTION_STATEMENT); } catch (ParserException e) { break; } } else { n = statement(); if (inDirectivePrologue) { String directive = getDirective(n); if (directive == null) { inDirectivePrologue = false; } else if (directive.equals("use strict")) { inUseStrictDirective = true; root.setInStrictMode(true); } } } end = getNodeEnd(n); root.addChildToBack(n); n.setParent(root); } } catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); } finally { inUseStrictDirective = savedStrictMode; } if (this.syntaxErrorCount != 0) { String msg = String.valueOf(this.syntaxErrorCount); msg = lookupMessage("msg.got.syntax.errors", msg); if (!compilerEnv.isIdeMode()) throw errorReporter.runtimeError(msg, sourceURI, baseLineno, null, 0); } // add comments to root in lexical order if (scannedComments != null) { // If we find a comment beyond end of our last statement or // function, extend the root bounds to the end of that comment. int last = scannedComments.size() - 1; end = Math.max(end, getNodeEnd(scannedComments.get(last))); for (Comment c : scannedComments) { root.addComment(c); } } root.setLength(end - pos); root.setSourceName(sourceURI); root.setBaseLineno(baseLineno); root.setEndLineno(ts.lineno); return root; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode parseFunctionBody() throws IOException { boolean isExpressionClosure = false; if (!matchToken(Token.LC)) { if (compilerEnv.getLanguageVersion() < Context.VERSION_1_8) { reportError("msg.no.brace.body"); } else { isExpressionClosure = true; } } ++nestingOfFunction; int pos = ts.tokenBeg; Block pn = new Block(pos); // starts at LC position boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // Don't set 'inUseStrictDirective' to false: inherit strict mode. pn.setLineno(ts.lineno); try { if (isExpressionClosure) { ReturnStatement n = new ReturnStatement(ts.lineno); n.setReturnValue(assignExpr()); // expression closure flag is required on both nodes n.putProp(Node.EXPRESSION_CLOSURE_PROP, Boolean.TRUE); pn.putProp(Node.EXPRESSION_CLOSURE_PROP, Boolean.TRUE); pn.addStatement(n); } else { bodyLoop: for (;;) { AstNode n; int tt = peekToken(); switch (tt) { case Token.ERROR: case Token.EOF: case Token.RC: break bodyLoop; case Token.FUNCTION: consumeToken(); n = function(FunctionNode.FUNCTION_STATEMENT); break; default: n = statement(); if (inDirectivePrologue) { String directive = getDirective(n); if (directive == null) { inDirectivePrologue = false; } else if (directive.equals("use strict")) { inUseStrictDirective = true; } } break; } pn.addStatement(n); } } } catch (ParserException e) { // Ignore it } finally { --nestingOfFunction; inUseStrictDirective = savedStrictMode; } int end = ts.tokenEnd; getAndResetJsDoc(); if (!isExpressionClosure && mustMatchToken(Token.RC, "msg.no.brace.after.body")) end = ts.tokenEnd; pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void parseFunctionParams(FunctionNode fnNode) throws IOException { if (matchToken(Token.RP)) { fnNode.setRp(ts.tokenBeg - fnNode.getPosition()); return; } // Would prefer not to call createDestructuringAssignment until codegen, // but the symbol definitions have to happen now, before body is parsed. Map<String, Node> destructuring = null; Set<String> paramNames = new HashSet<String>(); do { int tt = peekToken(); if (tt == Token.LB || tt == Token.LC) { AstNode expr = destructuringPrimaryExpr(); markDestructuring(expr); fnNode.addParam(expr); // Destructuring assignment for parameters: add a dummy // parameter name, and add a statement to the body to initialize // variables from the destructuring assignment if (destructuring == null) { destructuring = new HashMap<String, Node>(); } String pname = currentScriptOrFn.getNextTempName(); defineSymbol(Token.LP, pname, false); destructuring.put(pname, expr); } else { if (mustMatchToken(Token.NAME, "msg.no.parm")) { fnNode.addParam(createNameNode()); String paramName = ts.getString(); defineSymbol(Token.LP, paramName); if (this.inUseStrictDirective) { if ("eval".equals(paramName) || "arguments".equals(paramName)) { reportError("msg.bad.id.strict", paramName); } if (paramNames.contains(paramName)) addError("msg.dup.param.strict", paramName); paramNames.add(paramName); } } else { fnNode.addParam(makeErrorNode()); } } } while (matchToken(Token.COMMA)); if (destructuring != null) { Node destructuringNode = new Node(Token.COMMA); // Add assignment helper for each destructuring parameter for (Map.Entry<String, Node> param: destructuring.entrySet()) { Node assign = createDestructuringAssignment(Token.VAR, param.getValue(), createName(param.getKey())); destructuringNode.addChildToBack(assign); } fnNode.putProp(Node.DESTRUCTURING_PARAMS, destructuringNode); } if (mustMatchToken(Token.RP, "msg.no.paren.after.parms")) { fnNode.setRp(ts.tokenBeg - fnNode.getPosition()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private FunctionNode function(int type) throws IOException { int syntheticType = type; int baseLineno = ts.lineno; // line number where source starts int functionSourceStart = ts.tokenBeg; // start of "function" kwd Name name = null; AstNode memberExprNode = null; if (matchToken(Token.NAME)) { name = createNameNode(true, Token.NAME); if (inUseStrictDirective) { String id = name.getIdentifier(); if ("eval".equals(id)|| "arguments".equals(id)) { reportError("msg.bad.id.strict", id); } } if (!matchToken(Token.LP)) { if (compilerEnv.isAllowMemberExprAsFunctionName()) { AstNode memberExprHead = name; name = null; memberExprNode = memberExprTail(false, memberExprHead); } mustMatchToken(Token.LP, "msg.no.paren.parms"); } } else if (matchToken(Token.LP)) { // Anonymous function: leave name as null } else { if (compilerEnv.isAllowMemberExprAsFunctionName()) { // Note that memberExpr can not start with '(' like // in function (1+2).toString(), because 'function (' already // processed as anonymous function memberExprNode = memberExpr(false); } mustMatchToken(Token.LP, "msg.no.paren.parms"); } int lpPos = currentToken == Token.LP ? ts.tokenBeg : -1; if (memberExprNode != null) { syntheticType = FunctionNode.FUNCTION_EXPRESSION; } if (syntheticType != FunctionNode.FUNCTION_EXPRESSION && name != null && name.length() > 0) { // Function statements define a symbol in the enclosing scope defineSymbol(Token.FUNCTION, name.getIdentifier()); } FunctionNode fnNode = new FunctionNode(functionSourceStart, name); fnNode.setFunctionType(type); if (lpPos != -1) fnNode.setLp(lpPos - functionSourceStart); fnNode.setJsDocNode(getAndResetJsDoc()); PerFunctionVariables savedVars = new PerFunctionVariables(fnNode); try { parseFunctionParams(fnNode); fnNode.setBody(parseFunctionBody()); fnNode.setEncodedSourceBounds(functionSourceStart, ts.tokenEnd); fnNode.setLength(ts.tokenEnd - functionSourceStart); if (compilerEnv.isStrictMode() && !fnNode.getBody().hasConsistentReturnUsage()) { String msg = (name != null && name.length() > 0) ? "msg.no.return.value" : "msg.anon.no.return.value"; addStrictWarning(msg, name == null ? "" : name.getIdentifier()); } } finally { savedVars.restore(); } if (memberExprNode != null) { // TODO(stevey): fix missing functionality Kit.codeBug(); fnNode.setMemberExprNode(memberExprNode); // rewrite later /* old code: if (memberExprNode != null) { pn = nf.createAssignment(Token.ASSIGN, memberExprNode, pn); if (functionType != FunctionNode.FUNCTION_EXPRESSION) { // XXX check JScript behavior: should it be createExprStatement? pn = nf.createExprStatementNoReturn(pn, baseLineno); } } */ } fnNode.setSourceName(sourceURI); fnNode.setBaseLineno(baseLineno); fnNode.setEndLineno(ts.lineno); // Set the parent scope. Needed for finding undeclared vars. // Have to wait until after parsing the function to set its parent // scope, since defineSymbol needs the defining-scope check to stop // at the function boundary when checking for redeclarations. if (compilerEnv.isIdeMode()) { fnNode.setParentScope(currentScope); } return fnNode; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statements(AstNode parent) throws IOException { if (currentToken != Token.LC // assertion can be invalid in bad code && !compilerEnv.isIdeMode()) codeBug(); int pos = ts.tokenBeg; AstNode block = parent != null ? parent : new Block(pos); block.setLineno(ts.lineno); int tt; while ((tt = peekToken()) > Token.EOF && tt != Token.RC) { block.addChild(statement()); } block.setLength(ts.tokenBeg - pos); return block; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statements() throws IOException { return statements(null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ConditionData condition() throws IOException { ConditionData data = new ConditionData(); if (mustMatchToken(Token.LP, "msg.no.paren.cond")) data.lp = ts.tokenBeg; data.condition = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.after.cond")) data.rp = ts.tokenBeg; // Report strict warning on code like "if (a = 7) ...". Suppress the // warning if the condition is parenthesized, like "if ((a = 7)) ...". if (data.condition instanceof Assignment) { addStrictWarning("msg.equal.as.assign", "", data.condition.getPosition(), data.condition.getLength()); } return data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statement() throws IOException { int pos = ts.tokenBeg; try { AstNode pn = statementHelper(); if (pn != null) { if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) { int beg = pn.getPosition(); beg = Math.max(beg, lineBeginningFor(beg)); addStrictWarning(pn instanceof EmptyStatement ? "msg.extra.trailing.semi" : "msg.no.side.effects", "", beg, nodeEnd(pn) - beg); } return pn; } } catch (ParserException e) { // an ErrorNode was added to the ErrorReporter } // error: skip ahead to a probable statement boundary guessingStatementEnd: for (;;) { int tt = peekTokenOrEOL(); consumeToken(); switch (tt) { case Token.ERROR: case Token.EOF: case Token.EOL: case Token.SEMI: break guessingStatementEnd; } } // We don't make error nodes explicitly part of the tree; // they get added to the ErrorReporter. May need to do // something different here. return new EmptyStatement(pos, ts.tokenBeg - pos); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode statementHelper() throws IOException { // If the statement is set, then it's been told its label by now. if (currentLabel != null && currentLabel.getStatement() != null) currentLabel = null; AstNode pn = null; int tt = peekToken(), pos = ts.tokenBeg; switch (tt) { case Token.IF: return ifStatement(); case Token.SWITCH: return switchStatement(); case Token.WHILE: return whileLoop(); case Token.DO: return doLoop(); case Token.FOR: return forLoop(); case Token.TRY: return tryStatement(); case Token.THROW: pn = throwStatement(); break; case Token.BREAK: pn = breakStatement(); break; case Token.CONTINUE: pn = continueStatement(); break; case Token.WITH: if (this.inUseStrictDirective) { reportError("msg.no.with.strict"); } return withStatement(); case Token.CONST: case Token.VAR: consumeToken(); int lineno = ts.lineno; pn = variables(currentToken, ts.tokenBeg, true); pn.setLineno(lineno); break; case Token.LET: pn = letStatement(); if (pn instanceof VariableDeclaration && peekToken() == Token.SEMI) break; return pn; case Token.RETURN: case Token.YIELD: pn = returnOrYield(tt, false); break; case Token.DEBUGGER: consumeToken(); pn = new KeywordLiteral(ts.tokenBeg, ts.tokenEnd - ts.tokenBeg, tt); pn.setLineno(ts.lineno); break; case Token.LC: return block(); case Token.ERROR: consumeToken(); return makeErrorNode(); case Token.SEMI: consumeToken(); pos = ts.tokenBeg; pn = new EmptyStatement(pos, ts.tokenEnd - pos); pn.setLineno(ts.lineno); return pn; case Token.FUNCTION: consumeToken(); return function(FunctionNode.FUNCTION_EXPRESSION_STATEMENT); case Token.DEFAULT : pn = defaultXmlNamespace(); break; case Token.NAME: pn = nameOrLabel(); if (pn instanceof ExpressionStatement) break; return pn; // LabeledStatement default: lineno = ts.lineno; pn = new ExpressionStatement(expr(), !insideFunction()); pn.setLineno(lineno); break; } autoInsertSemicolon(pn); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void autoInsertSemicolon(AstNode pn) throws IOException { int ttFlagged = peekFlaggedToken(); int pos = pn.getPosition(); switch (ttFlagged & CLEAR_TI_MASK) { case Token.SEMI: // Consume ';' as a part of expression consumeToken(); // extend the node bounds to include the semicolon. pn.setLength(ts.tokenEnd - pos); break; case Token.ERROR: case Token.EOF: case Token.RC: // Autoinsert ; warnMissingSemi(pos, nodeEnd(pn)); break; default: if ((ttFlagged & TI_AFTER_EOL) == 0) { // Report error if no EOL or autoinsert ; otherwise reportError("msg.no.semi.stmt"); } else { warnMissingSemi(pos, nodeEnd(pn)); } break; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private IfStatement ifStatement() throws IOException { if (currentToken != Token.IF) codeBug(); consumeToken(); int pos = ts.tokenBeg, lineno = ts.lineno, elsePos = -1; ConditionData data = condition(); AstNode ifTrue = statement(), ifFalse = null; if (matchToken(Token.ELSE)) { elsePos = ts.tokenBeg - pos; ifFalse = statement(); } int end = getNodeEnd(ifFalse != null ? ifFalse : ifTrue); IfStatement pn = new IfStatement(pos, end - pos); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); pn.setThenPart(ifTrue); pn.setElsePart(ifFalse); pn.setElsePosition(elsePos); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private SwitchStatement switchStatement() throws IOException { if (currentToken != Token.SWITCH) codeBug(); consumeToken(); int pos = ts.tokenBeg; SwitchStatement pn = new SwitchStatement(pos); if (mustMatchToken(Token.LP, "msg.no.paren.switch")) pn.setLp(ts.tokenBeg - pos); pn.setLineno(ts.lineno); AstNode discriminant = expr(); pn.setExpression(discriminant); enterSwitch(pn); try { if (mustMatchToken(Token.RP, "msg.no.paren.after.switch")) pn.setRp(ts.tokenBeg - pos); mustMatchToken(Token.LC, "msg.no.brace.switch"); boolean hasDefault = false; int tt; switchLoop: for (;;) { tt = nextToken(); int casePos = ts.tokenBeg; int caseLineno = ts.lineno; AstNode caseExpression = null; switch (tt) { case Token.RC: pn.setLength(ts.tokenEnd - pos); break switchLoop; case Token.CASE: caseExpression = expr(); mustMatchToken(Token.COLON, "msg.no.colon.case"); break; case Token.DEFAULT: if (hasDefault) { reportError("msg.double.switch.default"); } hasDefault = true; caseExpression = null; mustMatchToken(Token.COLON, "msg.no.colon.case"); break; default: reportError("msg.bad.switch"); break switchLoop; } SwitchCase caseNode = new SwitchCase(casePos); caseNode.setExpression(caseExpression); caseNode.setLength(ts.tokenEnd - pos); // include colon caseNode.setLineno(caseLineno); while ((tt = peekToken()) != Token.RC && tt != Token.CASE && tt != Token.DEFAULT && tt != Token.EOF) { caseNode.addStatement(statement()); // updates length } pn.addCase(caseNode); } } finally { exitSwitch(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private WhileLoop whileLoop() throws IOException { if (currentToken != Token.WHILE) codeBug(); consumeToken(); int pos = ts.tokenBeg; WhileLoop pn = new WhileLoop(pos); pn.setLineno(ts.lineno); enterLoop(pn); try { ConditionData data = condition(); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); AstNode body = statement(); pn.setLength(getNodeEnd(body) - pos); pn.setBody(body); } finally { exitLoop(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private DoLoop doLoop() throws IOException { if (currentToken != Token.DO) codeBug(); consumeToken(); int pos = ts.tokenBeg, end; DoLoop pn = new DoLoop(pos); pn.setLineno(ts.lineno); enterLoop(pn); try { AstNode body = statement(); mustMatchToken(Token.WHILE, "msg.no.while.do"); pn.setWhilePosition(ts.tokenBeg - pos); ConditionData data = condition(); pn.setCondition(data.condition); pn.setParens(data.lp - pos, data.rp - pos); end = getNodeEnd(body); pn.setBody(body); } finally { exitLoop(); } // Always auto-insert semicolon to follow SpiderMonkey: // It is required by ECMAScript but is ignored by the rest of // world, see bug 238945 if (matchToken(Token.SEMI)) { end = ts.tokenEnd; } pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private Loop forLoop() throws IOException { if (currentToken != Token.FOR) codeBug(); consumeToken(); int forPos = ts.tokenBeg, lineno = ts.lineno; boolean isForEach = false, isForIn = false; int eachPos = -1, inPos = -1, lp = -1, rp = -1; AstNode init = null; // init is also foo in 'foo in object' AstNode cond = null; // cond is also object in 'foo in object' AstNode incr = null; Loop pn = null; Scope tempScope = new Scope(); pushScope(tempScope); // decide below what AST class to use try { // See if this is a for each () instead of just a for () if (matchToken(Token.NAME)) { if ("each".equals(ts.getString())) { isForEach = true; eachPos = ts.tokenBeg - forPos; } else { reportError("msg.no.paren.for"); } } if (mustMatchToken(Token.LP, "msg.no.paren.for")) lp = ts.tokenBeg - forPos; int tt = peekToken(); init = forLoopInit(tt); if (matchToken(Token.IN)) { isForIn = true; inPos = ts.tokenBeg - forPos; cond = expr(); // object over which we're iterating } else { // ordinary for-loop mustMatchToken(Token.SEMI, "msg.no.semi.for"); if (peekToken() == Token.SEMI) { // no loop condition cond = new EmptyExpression(ts.tokenBeg, 1); cond.setLineno(ts.lineno); } else { cond = expr(); } mustMatchToken(Token.SEMI, "msg.no.semi.for.cond"); int tmpPos = ts.tokenEnd; if (peekToken() == Token.RP) { incr = new EmptyExpression(tmpPos, 1); incr.setLineno(ts.lineno); } else { incr = expr(); } } if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - forPos; if (isForIn) { ForInLoop fis = new ForInLoop(forPos); if (init instanceof VariableDeclaration) { // check that there was only one variable given if (((VariableDeclaration)init).getVariables().size() > 1) { reportError("msg.mult.index"); } } fis.setIterator(init); fis.setIteratedObject(cond); fis.setInPosition(inPos); fis.setIsForEach(isForEach); fis.setEachPosition(eachPos); pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl; } // replace temp scope with the new loop object currentScope.replaceWith(pn); popScope(); // We have to parse the body -after- creating the loop node, // so that the loop node appears in the loopSet, allowing // break/continue statements to find the enclosing loop. enterLoop(pn); try { AstNode body = statement(); pn.setLength(getNodeEnd(body) - forPos); pn.setBody(body); } finally { exitLoop(); } } finally { if (currentScope == tempScope) { popScope(); } } pn.setParens(lp, rp); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode forLoopInit(int tt) throws IOException { try { inForInit = true; // checked by variables() and relExpr() AstNode init = null; if (tt == Token.SEMI) { init = new EmptyExpression(ts.tokenBeg, 1); init.setLineno(ts.lineno); } else if (tt == Token.VAR || tt == Token.LET) { consumeToken(); init = variables(tt, ts.tokenBeg, false); } else { init = expr(); markDestructuring(init); } return init; } finally { inForInit = false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private TryStatement tryStatement() throws IOException { if (currentToken != Token.TRY) codeBug(); consumeToken(); // Pull out JSDoc info and reset it before recursing. Comment jsdocNode = getAndResetJsDoc(); int tryPos = ts.tokenBeg, lineno = ts.lineno, finallyPos = -1; if (peekToken() != Token.LC) { reportError("msg.no.brace.try"); } AstNode tryBlock = statement(); int tryEnd = getNodeEnd(tryBlock); List<CatchClause> clauses = null; boolean sawDefaultCatch = false; int peek = peekToken(); if (peek == Token.CATCH) { while (matchToken(Token.CATCH)) { int catchLineNum = ts.lineno; if (sawDefaultCatch) { reportError("msg.catch.unreachable"); } int catchPos = ts.tokenBeg, lp = -1, rp = -1, guardPos = -1; if (mustMatchToken(Token.LP, "msg.no.paren.catch")) lp = ts.tokenBeg; mustMatchToken(Token.NAME, "msg.bad.catchcond"); Name varName = createNameNode(); String varNameString = varName.getIdentifier(); if (inUseStrictDirective) { if ("eval".equals(varNameString) || "arguments".equals(varNameString)) { reportError("msg.bad.id.strict", varNameString); } } AstNode catchCond = null; if (matchToken(Token.IF)) { guardPos = ts.tokenBeg; catchCond = expr(); } else { sawDefaultCatch = true; } if (mustMatchToken(Token.RP, "msg.bad.catchcond")) rp = ts.tokenBeg; mustMatchToken(Token.LC, "msg.no.brace.catchblock"); Block catchBlock = (Block)statements(); tryEnd = getNodeEnd(catchBlock); CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); } catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); if (mustMatchToken(Token.RC, "msg.no.brace.after.body")) tryEnd = ts.tokenEnd; catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>(); clauses.add(catchNode); } } else if (peek != Token.FINALLY) { mustMatchToken(Token.FINALLY, "msg.try.no.catchfinally"); } AstNode finallyBlock = null; if (matchToken(Token.FINALLY)) { finallyPos = ts.tokenBeg; finallyBlock = statement(); tryEnd = getNodeEnd(finallyBlock); } TryStatement pn = new TryStatement(tryPos, tryEnd - tryPos); pn.setTryBlock(tryBlock); pn.setCatchClauses(clauses); pn.setFinallyBlock(finallyBlock); if (finallyPos != -1) { pn.setFinallyPosition(finallyPos - tryPos); } pn.setLineno(lineno); if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ThrowStatement throwStatement() throws IOException { if (currentToken != Token.THROW) codeBug(); consumeToken(); int pos = ts.tokenBeg, lineno = ts.lineno; if (peekTokenOrEOL() == Token.EOL) { // ECMAScript does not allow new lines before throw expression, // see bug 256617 reportError("msg.bad.throw.eol"); } AstNode expr = expr(); ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private LabeledStatement matchJumpLabelName() throws IOException { LabeledStatement label = null; if (peekTokenOrEOL() == Token.NAME) { consumeToken(); if (labelSet != null) { label = labelSet.get(ts.getString()); } if (label == null) { reportError("msg.undef.label"); } } return label; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private BreakStatement breakStatement() throws IOException { if (currentToken != Token.BREAK) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; Name breakLabel = null; if (peekTokenOrEOL() == Token.NAME) { breakLabel = createNameNode(); end = getNodeEnd(breakLabel); } // matchJumpLabelName only matches if there is one LabeledStatement labels = matchJumpLabelName(); // always use first label as target Jump breakTarget = labels == null ? null : labels.getFirstLabel(); if (breakTarget == null && breakLabel == null) { if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) { if (breakLabel == null) { reportError("msg.bad.break", pos, end - pos); } } else { breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1); } } BreakStatement pn = new BreakStatement(pos, end - pos); pn.setBreakLabel(breakLabel); // can be null if it's a bad break in error-recovery mode if (breakTarget != null) pn.setBreakTarget(breakTarget); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ContinueStatement continueStatement() throws IOException { if (currentToken != Token.CONTINUE) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; Name label = null; if (peekTokenOrEOL() == Token.NAME) { label = createNameNode(); end = getNodeEnd(label); } // matchJumpLabelName only matches if there is one LabeledStatement labels = matchJumpLabelName(); Loop target = null; if (labels == null && label == null) { if (loopSet == null || loopSet.size() == 0) { reportError("msg.continue.outside"); } else { target = loopSet.get(loopSet.size() - 1); } } else { if (labels == null || !(labels.getStatement() instanceof Loop)) { reportError("msg.continue.nonloop", pos, end - pos); } target = labels == null ? null : (Loop)labels.getStatement(); } ContinueStatement pn = new ContinueStatement(pos, end - pos); if (target != null) // can be null in error-recovery mode pn.setTarget(target); pn.setLabel(label); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private WithStatement withStatement() throws IOException { if (currentToken != Token.WITH) codeBug(); consumeToken(); Comment withComment = getAndResetJsDoc(); int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1; if (mustMatchToken(Token.LP, "msg.no.paren.with")) lp = ts.tokenBeg; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.after.with")) rp = ts.tokenBeg; AstNode body = statement(); WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos); pn.setJsDocNode(withComment); pn.setExpression(obj); pn.setStatement(body); pn.setParens(lp, rp); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode letStatement() throws IOException { if (currentToken != Token.LET) codeBug(); consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg; AstNode pn; if (peekToken() == Token.LP) { pn = let(true, pos); } else { pn = variables(Token.LET, pos, true); // else, e.g.: let x=6, y=7; } pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode returnOrYield(int tt, boolean exprContext) throws IOException { if (!insideFunction()) { reportError(tt == Token.RETURN ? "msg.bad.return" : "msg.bad.yield"); } consumeToken(); int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd; AstNode e = null; // This is ugly, but we don't want to require a semicolon. switch (peekTokenOrEOL()) { case Token.SEMI: case Token.RC: case Token.RB: case Token.RP: case Token.EOF: case Token.EOL: case Token.ERROR: case Token.YIELD: break; default: e = expr(); end = getNodeEnd(e); } int before = endFlags; AstNode ret; if (tt == Token.RETURN) { endFlags |= e == null ? Node.END_RETURNS : Node.END_RETURNS_VALUE; ret = new ReturnStatement(pos, end - pos, e); // see if we need a strict mode warning if (nowAllSet(before, endFlags, Node.END_RETURNS|Node.END_RETURNS_VALUE)) addStrictWarning("msg.return.inconsistent", "", pos, end - pos); } else { if (!insideFunction()) reportError("msg.bad.yield"); endFlags |= Node.END_YIELDS; ret = new Yield(pos, end - pos, e); setRequiresActivation(); setIsGenerator(); if (!exprContext) { ret = new ExpressionStatement(ret); } } // see if we are mixing yields and value returns. if (insideFunction() && nowAllSet(before, endFlags, Node.END_YIELDS|Node.END_RETURNS_VALUE)) { Name name = ((FunctionNode)currentScriptOrFn).getFunctionName(); if (name == null || name.length() == 0) addError("msg.anon.generator.returns", ""); else addError("msg.generator.returns", name.getIdentifier()); } ret.setLineno(lineno); return ret; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode block() throws IOException { if (currentToken != Token.LC) codeBug(); consumeToken(); int pos = ts.tokenBeg; Scope block = new Scope(pos); block.setLineno(ts.lineno); pushScope(block); try { statements(block); mustMatchToken(Token.RC, "msg.no.brace.block"); block.setLength(ts.tokenEnd - pos); return block; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode defaultXmlNamespace() throws IOException { if (currentToken != Token.DEFAULT) codeBug(); consumeToken(); mustHaveXML(); setRequiresActivation(); int lineno = ts.lineno, pos = ts.tokenBeg; if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) { reportError("msg.bad.namespace"); } if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) { reportError("msg.bad.namespace"); } if (!matchToken(Token.ASSIGN)) { reportError("msg.bad.namespace"); } AstNode e = expr(); UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos); dxmln.setOperator(Token.DEFAULTNAMESPACE); dxmln.setOperand(e); dxmln.setLineno(lineno); ExpressionStatement es = new ExpressionStatement(dxmln, true); return es; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private void recordLabel(Label label, LabeledStatement bundle) throws IOException { // current token should be colon that primaryExpr left untouched if (peekToken() != Token.COLON) codeBug(); consumeToken(); String name = label.getName(); if (labelSet == null) { labelSet = new HashMap<String,LabeledStatement>(); } else { LabeledStatement ls = labelSet.get(name); if (ls != null) { if (compilerEnv.isIdeMode()) { Label dup = ls.getLabelByName(name); reportError("msg.dup.label", dup.getAbsolutePosition(), dup.getLength()); } reportError("msg.dup.label", label.getPosition(), label.getLength()); } } bundle.addLabel(label); labelSet.put(name, bundle); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode nameOrLabel() throws IOException { if (currentToken != Token.NAME) throw codeBug(); int pos = ts.tokenBeg; // set check for label and call down to primaryExpr currentFlaggedToken |= TI_CHECK_LABEL; AstNode expr = expr(); if (expr.getType() != Token.LABEL) { AstNode n = new ExpressionStatement(expr, !insideFunction()); n.lineno = expr.lineno; return n; } LabeledStatement bundle = new LabeledStatement(pos); recordLabel((Label)expr, bundle); bundle.setLineno(ts.lineno); // look for more labels AstNode stmt = null; while (peekToken() == Token.NAME) { currentFlaggedToken |= TI_CHECK_LABEL; expr = expr(); if (expr.getType() != Token.LABEL) { stmt = new ExpressionStatement(expr, !insideFunction()); autoInsertSemicolon(stmt); break; } recordLabel((Label)expr, bundle); } // no more labels; now parse the labeled statement try { currentLabel = bundle; if (stmt == null) { stmt = statementHelper(); } } finally { currentLabel = null; // remove the labels for this statement from the global set for (Label lb : bundle.getLabels()) { labelSet.remove(lb.getName()); } } // If stmt has parent assigned its position already is relative // (See bug #710225) bundle.setLength(stmt.getParent() == null ? getNodeEnd(stmt) - pos : getNodeEnd(stmt)); bundle.setStatement(stmt); return bundle; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private VariableDeclaration variables(int declType, int pos, boolean isStatement) throws IOException { int end; VariableDeclaration pn = new VariableDeclaration(pos); pn.setType(declType); pn.setLineno(ts.lineno); Comment varjsdocNode = getAndResetJsDoc(); if (varjsdocNode != null) { pn.setJsDocNode(varjsdocNode); } // Example: // var foo = {a: 1, b: 2}, bar = [3, 4]; // var {b: s2, a: s1} = foo, x = 6, y, [s3, s4] = bar; for (;;) { AstNode destructuring = null; Name name = null; int tt = peekToken(), kidPos = ts.tokenBeg; end = ts.tokenEnd; if (tt == Token.LB || tt == Token.LC) { // Destructuring assignment, e.g., var [a,b] = ... destructuring = destructuringPrimaryExpr(); end = getNodeEnd(destructuring); if (!(destructuring instanceof DestructuringForm)) reportError("msg.bad.assign.left", kidPos, end - kidPos); markDestructuring(destructuring); } else { // Simple variable name mustMatchToken(Token.NAME, "msg.bad.var"); name = createNameNode(); name.setLineno(ts.getLineno()); if (inUseStrictDirective) { String id = ts.getString(); if ("eval".equals(id) || "arguments".equals(ts.getString())) { reportError("msg.bad.id.strict", id); } } defineSymbol(declType, ts.getString(), inForInit); } int lineno = ts.lineno; Comment jsdocNode = getAndResetJsDoc(); AstNode init = null; if (matchToken(Token.ASSIGN)) { init = assignExpr(); end = getNodeEnd(init); } VariableInitializer vi = new VariableInitializer(kidPos, end - kidPos); if (destructuring != null) { if (init == null && !inForInit) { reportError("msg.destruct.assign.no.init"); } vi.setTarget(destructuring); } else { vi.setTarget(name); } vi.setInitializer(init); vi.setType(declType); vi.setJsDocNode(jsdocNode); vi.setLineno(lineno); pn.addVariable(vi); if (!matchToken(Token.COMMA)) break; } pn.setLength(end - pos); pn.setIsStatement(isStatement); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode let(boolean isStatement, int pos) throws IOException { LetNode pn = new LetNode(pos); pn.setLineno(ts.lineno); if (mustMatchToken(Token.LP, "msg.no.paren.after.let")) pn.setLp(ts.tokenBeg - pos); pushScope(pn); try { VariableDeclaration vars = variables(Token.LET, ts.tokenBeg, isStatement); pn.setVariables(vars); if (mustMatchToken(Token.RP, "msg.no.paren.let")) { pn.setRp(ts.tokenBeg - pos); } if (isStatement && peekToken() == Token.LC) { // let statement consumeToken(); int beg = ts.tokenBeg; // position stmt at LC AstNode stmt = statements(); mustMatchToken(Token.RC, "msg.no.curly.let"); stmt.setLength(ts.tokenEnd - beg); pn.setLength(ts.tokenEnd - pos); pn.setBody(stmt); pn.setType(Token.LET); } else { // let expression AstNode expr = expr(); pn.setLength(getNodeEnd(expr) - pos); pn.setBody(expr); if (isStatement) { // let expression in statement context ExpressionStatement es = new ExpressionStatement(pn, !insideFunction()); es.setLineno(pn.getLineno()); return es; } } } finally { popScope(); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode expr() throws IOException { AstNode pn = assignExpr(); int pos = pn.getPosition(); while (matchToken(Token.COMMA)) { int opPos = ts.tokenBeg; if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) addStrictWarning("msg.no.side.effects", "", pos, nodeEnd(pn) - pos); if (peekToken() == Token.YIELD) reportError("msg.yield.parenthesized"); pn = new InfixExpression(Token.COMMA, pn, assignExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode assignExpr() throws IOException { int tt = peekToken(); if (tt == Token.YIELD) { return returnOrYield(tt, true); } AstNode pn = condExpr(); tt = peekToken(); if (Token.FIRST_ASSIGN <= tt && tt <= Token.LAST_ASSIGN) { consumeToken(); // Pull out JSDoc info and reset it before recursing. Comment jsdocNode = getAndResetJsDoc(); markDestructuring(pn); int opPos = ts.tokenBeg; pn = new Assignment(tt, pn, assignExpr(), opPos); if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } } else if (tt == Token.SEMI) { // This may be dead code added intentionally, for JSDoc purposes. // For example: /** @type Number */ C.prototype.x; if (currentJsDocComment != null) { pn.setJsDocNode(getAndResetJsDoc()); } } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode condExpr() throws IOException { AstNode pn = orExpr(); if (matchToken(Token.HOOK)) { int line = ts.lineno; int qmarkPos = ts.tokenBeg, colonPos = -1; AstNode ifTrue = assignExpr(); if (mustMatchToken(Token.COLON, "msg.no.colon.cond")) colonPos = ts.tokenBeg; AstNode ifFalse = assignExpr(); int beg = pn.getPosition(), len = getNodeEnd(ifFalse) - beg; ConditionalExpression ce = new ConditionalExpression(beg, len); ce.setLineno(line); ce.setTestExpression(pn); ce.setTrueExpression(ifTrue); ce.setFalseExpression(ifFalse); ce.setQuestionMarkPosition(qmarkPos - beg); ce.setColonPosition(colonPos - beg); pn = ce; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode orExpr() throws IOException { AstNode pn = andExpr(); if (matchToken(Token.OR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.OR, pn, orExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode andExpr() throws IOException { AstNode pn = bitOrExpr(); if (matchToken(Token.AND)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.AND, pn, andExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitOrExpr() throws IOException { AstNode pn = bitXorExpr(); while (matchToken(Token.BITOR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITOR, pn, bitXorExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitXorExpr() throws IOException { AstNode pn = bitAndExpr(); while (matchToken(Token.BITXOR)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITXOR, pn, bitAndExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode bitAndExpr() throws IOException { AstNode pn = eqExpr(); while (matchToken(Token.BITAND)) { int opPos = ts.tokenBeg; pn = new InfixExpression(Token.BITAND, pn, eqExpr(), opPos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode eqExpr() throws IOException { AstNode pn = relExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.EQ: case Token.NE: case Token.SHEQ: case Token.SHNE: consumeToken(); int parseToken = tt; if (compilerEnv.getLanguageVersion() == Context.VERSION_1_2) { // JavaScript 1.2 uses shallow equality for == and != . if (tt == Token.EQ) parseToken = Token.SHEQ; else if (tt == Token.NE) parseToken = Token.SHNE; } pn = new InfixExpression(parseToken, pn, relExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode relExpr() throws IOException { AstNode pn = shiftExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.IN: if (inForInit) break; // fall through case Token.INSTANCEOF: case Token.LE: case Token.LT: case Token.GE: case Token.GT: consumeToken(); pn = new InfixExpression(tt, pn, shiftExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode shiftExpr() throws IOException { AstNode pn = addExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.LSH: case Token.URSH: case Token.RSH: consumeToken(); pn = new InfixExpression(tt, pn, addExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode addExpr() throws IOException { AstNode pn = mulExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; if (tt == Token.ADD || tt == Token.SUB) { consumeToken(); pn = new InfixExpression(tt, pn, mulExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode mulExpr() throws IOException { AstNode pn = unaryExpr(); for (;;) { int tt = peekToken(), opPos = ts.tokenBeg; switch (tt) { case Token.MUL: case Token.DIV: case Token.MOD: consumeToken(); pn = new InfixExpression(tt, pn, unaryExpr(), opPos); continue; } break; } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode unaryExpr() throws IOException { AstNode node; int tt = peekToken(); int line = ts.lineno; switch(tt) { case Token.VOID: case Token.NOT: case Token.BITNOT: case Token.TYPEOF: consumeToken(); node = new UnaryExpression(tt, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.ADD: consumeToken(); // Convert to special POS token in parse tree node = new UnaryExpression(Token.POS, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.SUB: consumeToken(); // Convert to special NEG token in parse tree node = new UnaryExpression(Token.NEG, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.INC: case Token.DEC: consumeToken(); UnaryExpression expr = new UnaryExpression(tt, ts.tokenBeg, memberExpr(true)); expr.setLineno(line); checkBadIncDec(expr); return expr; case Token.DELPROP: consumeToken(); node = new UnaryExpression(tt, ts.tokenBeg, unaryExpr()); node.setLineno(line); return node; case Token.ERROR: consumeToken(); return makeErrorNode(); case Token.LT: // XML stream encountered in expression. if (compilerEnv.isXmlAvailable()) { consumeToken(); return memberExprTail(true, xmlInitializer()); } // Fall thru to the default handling of RELOP default: AstNode pn = memberExpr(true); // Don't look across a newline boundary for a postfix incop. tt = peekTokenOrEOL(); if (!(tt == Token.INC || tt == Token.DEC)) { return pn; } consumeToken(); UnaryExpression uexpr = new UnaryExpression(tt, ts.tokenBeg, pn, true); uexpr.setLineno(line); checkBadIncDec(uexpr); return uexpr; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode xmlInitializer() throws IOException { if (currentToken != Token.LT) codeBug(); int pos = ts.tokenBeg, tt = ts.getFirstXMLToken(); if (tt != Token.XML && tt != Token.XMLEND) { reportError("msg.syntax"); return makeErrorNode(); } XmlLiteral pn = new XmlLiteral(pos); pn.setLineno(ts.lineno); for (;;tt = ts.getNextXMLToken()) { switch (tt) { case Token.XML: pn.addFragment(new XmlString(ts.tokenBeg, ts.getString())); mustMatchToken(Token.LC, "msg.syntax"); int beg = ts.tokenBeg; AstNode expr = (peekToken() == Token.RC) ? new EmptyExpression(beg, ts.tokenEnd - beg) : expr(); mustMatchToken(Token.RC, "msg.syntax"); XmlExpression xexpr = new XmlExpression(beg, expr); xexpr.setIsXmlAttribute(ts.isXMLAttribute()); xexpr.setLength(ts.tokenEnd - beg); pn.addFragment(xexpr); break; case Token.XMLEND: pn.addFragment(new XmlString(ts.tokenBeg, ts.getString())); return pn; default: reportError("msg.syntax"); return makeErrorNode(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private List<AstNode> argumentList() throws IOException { if (matchToken(Token.RP)) return null; List<AstNode> result = new ArrayList<AstNode>(); boolean wasInForInit = inForInit; inForInit = false; try { do { if (peekToken() == Token.YIELD) { reportError("msg.yield.parenthesized"); } AstNode en = assignExpr(); if (peekToken() == Token.FOR) { try { result.add(generatorExpression(en, 0, true)); } catch(IOException ex) { // #TODO } } else { result.add(en); } } while (matchToken(Token.COMMA)); } finally { inForInit = wasInForInit; } mustMatchToken(Token.RP, "msg.no.paren.arg"); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode memberExpr(boolean allowCallSyntax) throws IOException { int tt = peekToken(), lineno = ts.lineno; AstNode pn; if (tt != Token.NEW) { pn = primaryExpr(); } else { consumeToken(); int pos = ts.tokenBeg; NewExpression nx = new NewExpression(pos); AstNode target = memberExpr(false); int end = getNodeEnd(target); nx.setTarget(target); int lp = -1; if (matchToken(Token.LP)) { lp = ts.tokenBeg; List<AstNode> args = argumentList(); if (args != null && args.size() > ARGC_LIMIT) reportError("msg.too.many.constructor.args"); int rp = ts.tokenBeg; end = ts.tokenEnd; if (args != null) nx.setArguments(args); nx.setParens(lp - pos, rp - pos); } // Experimental syntax: allow an object literal to follow a new // expression, which will mean a kind of anonymous class built with // the JavaAdapter. the object literal will be passed as an // additional argument to the constructor. if (matchToken(Token.LC)) { ObjectLiteral initializer = objectLiteral(); end = getNodeEnd(initializer); nx.setInitializer(initializer); } nx.setLength(end - pos); pn = nx; } pn.setLineno(lineno); AstNode tail = memberExprTail(allowCallSyntax, pn); return tail; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode memberExprTail(boolean allowCallSyntax, AstNode pn) throws IOException { // we no longer return null for errors, so this won't be null if (pn == null) codeBug(); int pos = pn.getPosition(); int lineno; tailLoop: for (;;) { int tt = peekToken(); switch (tt) { case Token.DOT: case Token.DOTDOT: lineno = ts.lineno; pn = propertyAccess(tt, pn); pn.setLineno(lineno); break; case Token.DOTQUERY: consumeToken(); int opPos = ts.tokenBeg, rp = -1; lineno = ts.lineno; mustHaveXML(); setRequiresActivation(); AstNode filter = expr(); int end = getNodeEnd(filter); if (mustMatchToken(Token.RP, "msg.no.paren")) { rp = ts.tokenBeg; end = ts.tokenEnd; } XmlDotQuery q = new XmlDotQuery(pos, end - pos); q.setLeft(pn); q.setRight(filter); q.setOperatorPosition(opPos); q.setRp(rp - pos); q.setLineno(lineno); pn = q; break; case Token.LB: consumeToken(); int lb = ts.tokenBeg, rb = -1; lineno = ts.lineno; AstNode expr = expr(); end = getNodeEnd(expr); if (mustMatchToken(Token.RB, "msg.no.bracket.index")) { rb = ts.tokenBeg; end = ts.tokenEnd; } ElementGet g = new ElementGet(pos, end - pos); g.setTarget(pn); g.setElement(expr); g.setParens(lb, rb); g.setLineno(lineno); pn = g; break; case Token.LP: if (!allowCallSyntax) { break tailLoop; } lineno = ts.lineno; consumeToken(); checkCallRequiresActivation(pn); FunctionCall f = new FunctionCall(pos); f.setTarget(pn); // Assign the line number for the function call to where // the paren appeared, not where the name expression started. f.setLineno(lineno); f.setLp(ts.tokenBeg - pos); List<AstNode> args = argumentList(); if (args != null && args.size() > ARGC_LIMIT) reportError("msg.too.many.function.args"); f.setArguments(args); f.setRp(ts.tokenBeg - pos); f.setLength(ts.tokenEnd - pos); pn = f; break; default: break tailLoop; } } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode propertyAccess(int tt, AstNode pn) throws IOException { if (pn == null) codeBug(); int memberTypeFlags = 0, lineno = ts.lineno, dotPos = ts.tokenBeg; consumeToken(); if (tt == Token.DOTDOT) { mustHaveXML(); memberTypeFlags = Node.DESCENDANTS_FLAG; } if (!compilerEnv.isXmlAvailable()) { mustMatchToken(Token.NAME, "msg.no.name.after.dot"); Name name = createNameNode(true, Token.GETPROP); PropertyGet pg = new PropertyGet(pn, name, dotPos); pg.setLineno(lineno); return pg; } AstNode ref = null; // right side of . or .. operator int token = nextToken(); switch (token) { case Token.THROW: // needed for generator.throw(); saveNameTokenData(ts.tokenBeg, "throw", ts.lineno); ref = propertyName(-1, "throw", memberTypeFlags); break; case Token.NAME: // handles: name, ns::name, ns::*, ns::[expr] ref = propertyName(-1, ts.getString(), memberTypeFlags); break; case Token.MUL: // handles: *, *::name, *::*, *::[expr] saveNameTokenData(ts.tokenBeg, "*", ts.lineno); ref = propertyName(-1, "*", memberTypeFlags); break; case Token.XMLATTR: // handles: '@attr', '@ns::attr', '@ns::*', '@ns::*', // '@::attr', '@::*', '@*', '@*::attr', '@*::*' ref = attributeAccess(); break; default: if (compilerEnv.isReservedKeywordAsIdentifier()) { // allow keywords as property names, e.g. ({if: 1}) String name = Token.keywordToName(token); if (name != null) { saveNameTokenData(ts.tokenBeg, name, ts.lineno); ref = propertyName(-1, name, memberTypeFlags); break; } } reportError("msg.no.name.after.dot"); return makeErrorNode(); } boolean xml = ref instanceof XmlRef; InfixExpression result = xml ? new XmlMemberGet() : new PropertyGet(); if (xml && tt == Token.DOT) result.setType(Token.DOT); int pos = pn.getPosition(); result.setPosition(pos); result.setLength(getNodeEnd(ref) - pos); result.setOperatorPosition(dotPos - pos); result.setLineno(pn.getLineno()); result.setLeft(pn); // do this after setting position result.setRight(ref); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode attributeAccess() throws IOException { int tt = nextToken(), atPos = ts.tokenBeg; switch (tt) { // handles: @name, @ns::name, @ns::*, @ns::[expr] case Token.NAME: return propertyName(atPos, ts.getString(), 0); // handles: @*, @*::name, @*::*, @*::[expr] case Token.MUL: saveNameTokenData(ts.tokenBeg, "*", ts.lineno); return propertyName(atPos, "*", 0); // handles @[expr] case Token.LB: return xmlElemRef(atPos, null, -1); default: reportError("msg.no.name.after.xmlAttr"); return makeErrorNode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode propertyName(int atPos, String s, int memberTypeFlags) throws IOException { int pos = atPos != -1 ? atPos : ts.tokenBeg, lineno = ts.lineno; int colonPos = -1; Name name = createNameNode(true, currentToken); Name ns = null; if (matchToken(Token.COLONCOLON)) { ns = name; colonPos = ts.tokenBeg; switch (nextToken()) { // handles name::name case Token.NAME: name = createNameNode(); break; // handles name::* case Token.MUL: saveNameTokenData(ts.tokenBeg, "*", ts.lineno); name = createNameNode(false, -1); break; // handles name::[expr] or *::[expr] case Token.LB: return xmlElemRef(atPos, ns, colonPos); default: reportError("msg.no.name.after.coloncolon"); return makeErrorNode(); } } if (ns == null && memberTypeFlags == 0 && atPos == -1) { return name; } XmlPropRef ref = new XmlPropRef(pos, getNodeEnd(name) - pos); ref.setAtPos(atPos); ref.setNamespace(ns); ref.setColonPos(colonPos); ref.setPropName(name); ref.setLineno(lineno); return ref; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private XmlElemRef xmlElemRef(int atPos, Name namespace, int colonPos) throws IOException { int lb = ts.tokenBeg, rb = -1, pos = atPos != -1 ? atPos : lb; AstNode expr = expr(); int end = getNodeEnd(expr); if (mustMatchToken(Token.RB, "msg.no.bracket.index")) { rb = ts.tokenBeg; end = ts.tokenEnd; } XmlElemRef ref = new XmlElemRef(pos, end - pos); ref.setNamespace(namespace); ref.setColonPos(colonPos); ref.setAtPos(atPos); ref.setExpression(expr); ref.setBrackets(lb, rb); return ref; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode destructuringPrimaryExpr() throws IOException, ParserException { try { inDestructuringAssignment = true; return primaryExpr(); } finally { inDestructuringAssignment = false; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode primaryExpr() throws IOException { int ttFlagged = nextFlaggedToken(); int tt = ttFlagged & CLEAR_TI_MASK; switch(tt) { case Token.FUNCTION: return function(FunctionNode.FUNCTION_EXPRESSION); case Token.LB: return arrayLiteral(); case Token.LC: return objectLiteral(); case Token.LET: return let(false, ts.tokenBeg); case Token.LP: return parenExpr(); case Token.XMLATTR: mustHaveXML(); return attributeAccess(); case Token.NAME: return name(ttFlagged, tt); case Token.NUMBER: { String s = ts.getString(); if (this.inUseStrictDirective && ts.isNumberOctal()) { reportError("msg.no.octal.strict"); } return new NumberLiteral(ts.tokenBeg, s, ts.getNumber()); } case Token.STRING: return createStringLiteral(); case Token.DIV: case Token.ASSIGN_DIV: // Got / or /= which in this context means a regexp ts.readRegExp(tt); int pos = ts.tokenBeg, end = ts.tokenEnd; RegExpLiteral re = new RegExpLiteral(pos, end - pos); re.setValue(ts.getString()); re.setFlags(ts.readAndClearRegExpFlags()); return re; case Token.NULL: case Token.THIS: case Token.FALSE: case Token.TRUE: pos = ts.tokenBeg; end = ts.tokenEnd; return new KeywordLiteral(pos, end - pos, tt); case Token.RESERVED: reportError("msg.reserved.id"); break; case Token.ERROR: // the scanner or one of its subroutines reported the error. break; case Token.EOF: reportError("msg.unexpected.eof"); break; default: reportError("msg.syntax"); break; } // should only be reachable in IDE/error-recovery mode return makeErrorNode(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode parenExpr() throws IOException { boolean wasInForInit = inForInit; inForInit = false; try { Comment jsdocNode = getAndResetJsDoc(); int lineno = ts.lineno; int begin = ts.tokenBeg; AstNode e = expr(); if (peekToken() == Token.FOR) { return generatorExpression(e, begin); } ParenthesizedExpression pn = new ParenthesizedExpression(e); if (jsdocNode == null) { jsdocNode = getAndResetJsDoc(); } if (jsdocNode != null) { pn.setJsDocNode(jsdocNode); } mustMatchToken(Token.RP, "msg.no.paren"); pn.setLength(ts.tokenEnd - pn.getPosition()); pn.setLineno(lineno); return pn; } finally { inForInit = wasInForInit; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode name(int ttFlagged, int tt) throws IOException { String nameString = ts.getString(); int namePos = ts.tokenBeg, nameLineno = ts.lineno; if (0 != (ttFlagged & TI_CHECK_LABEL) && peekToken() == Token.COLON) { // Do not consume colon. It is used as an unwind indicator // to return to statementHelper. Label label = new Label(namePos, ts.tokenEnd - namePos); label.setName(nameString); label.setLineno(ts.lineno); return label; } // Not a label. Unfortunately peeking the next token to check for // a colon has biffed ts.tokenBeg, ts.tokenEnd. We store the name's // bounds in instance vars and createNameNode uses them. saveNameTokenData(namePos, nameString, nameLineno); if (compilerEnv.isXmlAvailable()) { return propertyName(-1, nameString, 0); } else { return createNameNode(true, Token.NAME); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode arrayLiteral() throws IOException { if (currentToken != Token.LB) codeBug(); int pos = ts.tokenBeg, end = ts.tokenEnd; List<AstNode> elements = new ArrayList<AstNode>(); ArrayLiteral pn = new ArrayLiteral(pos); boolean after_lb_or_comma = true; int afterComma = -1; int skipCount = 0; for (;;) { int tt = peekToken(); if (tt == Token.COMMA) { consumeToken(); afterComma = ts.tokenEnd; if (!after_lb_or_comma) { after_lb_or_comma = true; } else { elements.add(new EmptyExpression(ts.tokenBeg, 1)); skipCount++; } } else if (tt == Token.RB) { consumeToken(); // for ([a,] in obj) is legal, but for ([a] in obj) is // not since we have both key and value supplied. The // trick is that [a,] and [a] are equivalent in other // array literal contexts. So we calculate a special // length value just for destructuring assignment. end = ts.tokenEnd; pn.setDestructuringLength(elements.size() + (after_lb_or_comma ? 1 : 0)); pn.setSkipCount(skipCount); if (afterComma != -1) warnTrailingComma(pos, elements, afterComma); break; } else if (tt == Token.FOR && !after_lb_or_comma && elements.size() == 1) { return arrayComprehension(elements.get(0), pos); } else if (tt == Token.EOF) { reportError("msg.no.bracket.arg"); break; } else { if (!after_lb_or_comma) { reportError("msg.no.bracket.arg"); } elements.add(assignExpr()); after_lb_or_comma = false; afterComma = -1; } } for (AstNode e : elements) { pn.addElement(e); } pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode arrayComprehension(AstNode result, int pos) throws IOException { List<ArrayComprehensionLoop> loops = new ArrayList<ArrayComprehensionLoop>(); while (peekToken() == Token.FOR) { loops.add(arrayComprehensionLoop()); } int ifPos = -1; ConditionData data = null; if (peekToken() == Token.IF) { consumeToken(); ifPos = ts.tokenBeg - pos; data = condition(); } mustMatchToken(Token.RB, "msg.no.bracket.arg"); ArrayComprehension pn = new ArrayComprehension(pos, ts.tokenEnd - pos); pn.setResult(result); pn.setLoops(loops); if (data != null) { pn.setIfPosition(ifPos); pn.setFilter(data.condition); pn.setFilterLp(data.lp - pos); pn.setFilterRp(data.rp - pos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ArrayComprehensionLoop arrayComprehensionLoop() throws IOException { if (nextToken() != Token.FOR) codeBug(); int pos = ts.tokenBeg; int eachPos = -1, lp = -1, rp = -1, inPos = -1; ArrayComprehensionLoop pn = new ArrayComprehensionLoop(pos); pushScope(pn); try { if (matchToken(Token.NAME)) { if (ts.getString().equals("each")) { eachPos = ts.tokenBeg - pos; } else { reportError("msg.no.paren.for"); } } if (mustMatchToken(Token.LP, "msg.no.paren.for")) { lp = ts.tokenBeg - pos; } AstNode iter = null; switch (peekToken()) { case Token.LB: case Token.LC: // handle destructuring assignment iter = destructuringPrimaryExpr(); markDestructuring(iter); break; case Token.NAME: consumeToken(); iter = createNameNode(); break; default: reportError("msg.bad.var"); } // Define as a let since we want the scope of the variable to // be restricted to the array comprehension if (iter.getType() == Token.NAME) { defineSymbol(Token.LET, ts.getString(), true); } if (mustMatchToken(Token.IN, "msg.in.after.for.name")) inPos = ts.tokenBeg - pos; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - pos; pn.setLength(ts.tokenEnd - pos); pn.setIterator(iter); pn.setIteratedObject(obj); pn.setInPosition(inPos); pn.setEachPosition(eachPos); pn.setIsForEach(eachPos != -1); pn.setParens(lp, rp); return pn; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode generatorExpression(AstNode result, int pos) throws IOException { return generatorExpression(result, pos, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode generatorExpression(AstNode result, int pos, boolean inFunctionParams) throws IOException { List<GeneratorExpressionLoop> loops = new ArrayList<GeneratorExpressionLoop>(); while (peekToken() == Token.FOR) { loops.add(generatorExpressionLoop()); } int ifPos = -1; ConditionData data = null; if (peekToken() == Token.IF) { consumeToken(); ifPos = ts.tokenBeg - pos; data = condition(); } if(!inFunctionParams) { mustMatchToken(Token.RP, "msg.no.paren.let"); } GeneratorExpression pn = new GeneratorExpression(pos, ts.tokenEnd - pos); pn.setResult(result); pn.setLoops(loops); if (data != null) { pn.setIfPosition(ifPos); pn.setFilter(data.condition); pn.setFilterLp(data.lp - pos); pn.setFilterRp(data.rp - pos); } return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private GeneratorExpressionLoop generatorExpressionLoop() throws IOException { if (nextToken() != Token.FOR) codeBug(); int pos = ts.tokenBeg; int lp = -1, rp = -1, inPos = -1; GeneratorExpressionLoop pn = new GeneratorExpressionLoop(pos); pushScope(pn); try { if (mustMatchToken(Token.LP, "msg.no.paren.for")) { lp = ts.tokenBeg - pos; } AstNode iter = null; switch (peekToken()) { case Token.LB: case Token.LC: // handle destructuring assignment iter = destructuringPrimaryExpr(); markDestructuring(iter); break; case Token.NAME: consumeToken(); iter = createNameNode(); break; default: reportError("msg.bad.var"); } // Define as a let since we want the scope of the variable to // be restricted to the array comprehension if (iter.getType() == Token.NAME) { defineSymbol(Token.LET, ts.getString(), true); } if (mustMatchToken(Token.IN, "msg.in.after.for.name")) inPos = ts.tokenBeg - pos; AstNode obj = expr(); if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl")) rp = ts.tokenBeg - pos; pn.setLength(ts.tokenEnd - pos); pn.setIterator(iter); pn.setIteratedObject(obj); pn.setInPosition(inPos); pn.setParens(lp, rp); return pn; } finally { popScope(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectLiteral objectLiteral() throws IOException { int pos = ts.tokenBeg, lineno = ts.lineno; int afterComma = -1; List<ObjectProperty> elems = new ArrayList<ObjectProperty>(); Set<String> propertyNames = new HashSet<String>(); Comment objJsdocNode = getAndResetJsDoc(); commaLoop: for (;;) { String propertyName = null; int tt = peekToken(); Comment jsdocNode = getAndResetJsDoc(); switch(tt) { case Token.NAME: case Token.STRING: saveNameTokenData(ts.tokenBeg, ts.getString(), ts.lineno); consumeToken(); StringLiteral stringProp = null; if (tt == Token.STRING) { stringProp = createStringLiteral(); } Name name = createNameNode(); propertyName = ts.getString(); int ppos = ts.tokenBeg; if ((tt == Token.NAME && (peekToken() == Token.NAME || convertToName(peekToken())) && ("get".equals(propertyName) || "set".equals(propertyName)))) { consumeToken(); name = createNameNode(); name.setJsDocNode(jsdocNode); ObjectProperty objectProp = getterSetterProperty(ppos, name, "get".equals(propertyName)); elems.add(objectProp); propertyName = objectProp.getLeft().getString(); } else { AstNode pname = stringProp != null ? stringProp : name; pname.setJsDocNode(jsdocNode); elems.add(plainProperty(pname, tt)); } break; case Token.NUMBER: consumeToken(); AstNode nl = new NumberLiteral(ts.tokenBeg, ts.getString(), ts.getNumber()); nl.setJsDocNode(jsdocNode); propertyName = ts.getString(); elems.add(plainProperty(nl, tt)); break; case Token.RC: if (afterComma != -1) warnTrailingComma(pos, elems, afterComma); break commaLoop; default: if (convertToName(tt)) { consumeToken(); AstNode pname = createNameNode(); pname.setJsDocNode(jsdocNode); elems.add(plainProperty(pname, tt)); break; } reportError("msg.bad.prop"); break; } if (this.inUseStrictDirective) { if (propertyNames.contains(propertyName)) { addError("msg.dup.obj.lit.prop.strict", propertyName); } propertyNames.add(propertyName); } // Eat any dangling jsdoc in the property. getAndResetJsDoc(); jsdocNode = null; if (matchToken(Token.COMMA)) { afterComma = ts.tokenEnd; } else { break commaLoop; } } mustMatchToken(Token.RC, "msg.no.brace.prop"); ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); } pn.setElements(elems); pn.setLineno(lineno); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectProperty plainProperty(AstNode property, int ptt) throws IOException { // Support, e.g., |var {x, y} = o| as destructuring shorthand // for |var {x: x, y: y} = o|, as implemented in spidermonkey JS 1.8. int tt = peekToken(); if ((tt == Token.COMMA || tt == Token.RC) && ptt == Token.NAME && compilerEnv.getLanguageVersion() >= Context.VERSION_1_8) { if (!inDestructuringAssignment) { reportError("msg.bad.object.init"); } AstNode nn = new Name(property.getPosition(), property.getString()); ObjectProperty pn = new ObjectProperty(); pn.putProp(Node.DESTRUCTURING_SHORTHAND, Boolean.TRUE); pn.setLeftAndRight(property, nn); return pn; } mustMatchToken(Token.COLON, "msg.no.colon.prop"); ObjectProperty pn = new ObjectProperty(); pn.setOperatorPosition(ts.tokenBeg); pn.setLeftAndRight(property, assignExpr()); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private ObjectProperty getterSetterProperty(int pos, AstNode propName, boolean isGetter) throws IOException { FunctionNode fn = function(FunctionNode.FUNCTION_EXPRESSION); // We've already parsed the function name, so fn should be anonymous. Name name = fn.getFunctionName(); if (name != null && name.length() != 0) { reportError("msg.bad.prop"); } ObjectProperty pn = new ObjectProperty(pos); if (isGetter) { pn.setIsGetter(); } else { pn.setIsSetter(); } int end = getNodeEnd(fn); pn.setLeft(propName); pn.setRight(fn); pn.setLength(end - pos); return pn; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private String readFully(Reader reader) throws IOException { BufferedReader in = new BufferedReader(reader); try { char[] cbuf = new char[1024]; StringBuilder sb = new StringBuilder(1024); int bytes_read; while ((bytes_read = in.read(cbuf, 0, 1024)) != -1) { sb.append(cbuf, 0, bytes_read); } return sb.toString(); } finally { in.close(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (name != null) { indexOrHash = name.hashCode(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(slot); // just serialize the wrapped slot }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private synchronized void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } if (objectsCount == 0) { out.writeInt(0); } else { out.writeInt(slots.length); Slot slot = firstAdded; while (slot != null && slot.wasDeleted) { // as long as we're traversing the order-added linked list, // remove deleted slots slot = slot.orderedNext; } firstAdded = slot; while (slot != null) { out.writeObject(slot); Slot next = slot.orderedNext; while (next != null && next.wasDeleted) { // remove deleted slots next = next.orderedNext; } slot.orderedNext = next; slot = next; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static String readReader(Reader r) throws IOException { char[] buffer = new char[512]; int cursor = 0; for (;;) { int n = r.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { char[] tmp = new char[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } return new String(buffer, 0, cursor); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException { if (initialBufferCapacity <= 0) { throw new IllegalArgumentException( "Bad initialBufferCapacity: "+initialBufferCapacity); } byte[] buffer = new byte[initialBufferCapacity]; int cursor = 0; for (;;) { int n = is.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { byte[] tmp = new byte[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } if (cursor != buffer.length) { byte[] tmp = new byte[cursor]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } return buffer; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaPackage.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.classLoader = Context.getCurrentContext().getApplicationClassLoader(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static void writeAdapterObject(Object javaObject, ObjectOutputStream out) throws IOException { Class<?> cl = javaObject.getClass(); out.writeObject(cl.getSuperclass().getName()); Class<?>[] interfaces = cl.getInterfaces(); String[] interfaceNames = new String[interfaces.length]; for (int i=0; i < interfaces.length; i++) interfaceNames[i] = interfaces[i].getName(); out.writeObject(interfaceNames); try { Object delegee = cl.getField("delegee").get(javaObject); out.writeObject(delegee); return; } catch (IllegalAccessException e) { } catch (NoSuchFieldException e) { } throw new IOException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object readAdapterObject(Scriptable self, ObjectInputStream in) throws IOException, ClassNotFoundException { ContextFactory factory; Context cx = Context.getCurrentContext(); if (cx != null) { factory = cx.getFactory(); } else { factory = null; } Class<?> superClass = Class.forName((String)in.readObject()); String[] interfaceNames = (String[])in.readObject(); Class<?>[] interfaces = new Class[interfaceNames.length]; for (int i=0; i < interfaceNames.length; i++) interfaces[i] = Class.forName(interfaceNames[i]); Scriptable delegee = (Scriptable)in.readObject(); Class<?> adapterClass = getAdapterClass(self, superClass, interfaces, delegee); Class<?>[] ctorParms = { ScriptRuntime.ContextFactoryClass, ScriptRuntime.ScriptableClass, ScriptRuntime.ScriptableClass }; Object[] ctorArgs = { factory, delegee, self }; try { return adapterClass.getConstructor(ctorParms).newInstance(ctorArgs); } catch(InstantiationException e) { } catch(IllegalAccessException e) { } catch(InvocationTargetException e) { } catch(NoSuchMethodException e) { } throw new ClassNotFoundException("adapter"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (parmsLength > 0) { Class<?>[] types = member.argTypes; typeTags = new byte[parmsLength]; for (int i = 0; i != parmsLength; ++i) { typeTags[i] = (byte)getTypeTag(types[i]); } } if (member.isMethod()) { Method method = member.method(); Class<?> returnType = method.getReturnType(); if (returnType == Void.TYPE) { hasVoidReturn = true; } else { returnTypeTag = getTypeTag(returnType); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void writeObject(ObjectOutputStream os) throws IOException { os.defaultWriteObject(); int N = size; for (int i = 0; i != N; ++i) { Object obj = getImpl(i); os.writeObject(obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); // It reads size int N = size; if (N > FIELDS_STORE_SIZE) { data = new Object[N - FIELDS_STORE_SIZE]; } for (int i = 0; i != N; ++i) { Object obj = is.readObject(); setImpl(i, obj); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int maxPrototypeId = stream.readInt(); if (maxPrototypeId != 0) { activatePrototypeMap(maxPrototypeId); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); int maxPrototypeId = 0; if (prototypeValues != null) { maxPrototypeId = prototypeValues.getMaxId(); } stream.writeInt(maxPrototypeId); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); if (classLoader != null) { try { return classLoader.loadClass(name); } catch (ClassNotFoundException ex) { // fall through to default loading } } return super.resolveClass(desc); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java
Override protected Object resolveObject(Object obj) throws IOException { if (obj instanceof ScriptableOutputStream.PendingLookup) { String name = ((ScriptableOutputStream.PendingLookup)obj).getName(); obj = ScriptableOutputStream.lookupQualifiedName(scope, name); if (obj == Scriptable.NOT_FOUND) { throw new IOException("Object " + name + " not found upon " + "deserialization."); } }else if (obj instanceof UniqueTag) { obj = ((UniqueTag)obj).readResolve(); }else if (obj instanceof Undefined) { obj = ((Undefined)obj).readResolve(); } return obj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
Override protected Object replaceObject(Object obj) throws IOException { if (false) throw new IOException(); // suppress warning String name = table.get(obj); if (name == null) return obj; return new PendingLookup(name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Object evaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { Script script = compileReader(scope, in, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } else { return null; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Script compileReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { return compileReader(in, sourceName, lineno, securityDomain); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final Script compileReader(Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { if (lineno < 0) { // For compatibility IllegalArgumentException can not be thrown here lineno = 0; } return (Script) compileImpl(null, in, null, sourceName, lineno, securityDomain, false, null, null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); int count = keyCount; if (count != 0) { boolean hasIntValues = (ivaluesShift != 0); boolean hasObjectValues = (values != null); out.writeBoolean(hasIntValues); out.writeBoolean(hasObjectValues); for (int i = 0; count != 0; ++i) { int key = keys[i]; if (key != EMPTY && key != DELETED) { --count; out.writeInt(key); if (hasIntValues) { out.writeInt(keys[ivaluesShift + i]); } if (hasObjectValues) { out.writeObject(values[i]); } } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UintMap.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int writtenKeyCount = keyCount; if (writtenKeyCount != 0) { keyCount = 0; boolean hasIntValues = in.readBoolean(); boolean hasObjectValues = in.readBoolean(); int N = 1 << power; if (hasIntValues) { keys = new int[2 * N]; ivaluesShift = N; }else { keys = new int[N]; } for (int i = 0; i != N; ++i) { keys[i] = EMPTY; } if (hasObjectValues) { values = new Object[N]; } for (int i = 0; i != writtenKeyCount; ++i) { int key = in.readInt(); int index = insertNewKey(key); if (hasIntValues) { int ivalue = in.readInt(); keys[ivaluesShift + index] = ivalue; } if (hasObjectValues) { values[index] = in.readObject(); } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void write(OutputStream oStream) throws IOException { byte[] array = toByteArray(); oStream.write(array); }
9
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { onFailedClosingUrlConnection(urlConnection, e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
catch (IOException ioe) { // ignore it, we're already displaying an error... break; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch(IOException ex) { // #TODO }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (IOException e) { }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(IOException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
3
unknown (Lib) IllegalAccessException 0 0 5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, sealed, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static <T extends Scriptable> BaseFunction buildClassCtor( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < methods.length; i++) { Method method = methods[i]; if (!method.getName().equals("init")) continue; Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ContextClass && parmTypes[1] == ScriptRuntime.ScriptableClass && parmTypes[2] == Boolean.TYPE && Modifier.isStatic(method.getModifiers())) { Object args[] = { Context.getContext(), scope, sealed ? Boolean.TRUE : Boolean.FALSE }; method.invoke(null, args); return null; } if (parmTypes.length == 1 && parmTypes[0] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { Object args[] = { scope }; method.invoke(null, args); return null; } } // If we got here, there isn't an "init" method with the right // parameter types. Constructor<?>[] ctors = clazz.getConstructors(); Constructor<?> protoCtor = null; for (int i=0; i < ctors.length; i++) { if (ctors[i].getParameterTypes().length == 0) { protoCtor = ctors[i]; break; } } if (protoCtor == null) { throw Context.reportRuntimeError1( "msg.zero.arg.ctor", clazz.getName()); } Scriptable proto = (Scriptable) protoCtor.newInstance(ScriptRuntime.emptyArgs); String className = proto.getClassName(); // Set the prototype's prototype, trying to map Java inheritance to JS // prototype-based inheritance if requested to do so. Scriptable superProto = null; if (mapInheritance) { Class<? super T> superClass = clazz.getSuperclass(); if (ScriptRuntime.ScriptableClass.isAssignableFrom(superClass) && !Modifier.isAbstract(superClass.getModifiers())) { Class<? extends Scriptable> superScriptable = extendsScriptable(superClass); String name = ScriptableObject.defineClass(scope, superScriptable, sealed, mapInheritance); if (name != null) { superProto = ScriptableObject.getClassPrototype(scope, name); } } } if (superProto == null) { superProto = ScriptableObject.getObjectPrototype(scope); } proto.setPrototype(superProto); // Find out whether there are any methods that begin with // "js". If so, then only methods that begin with special // prefixes will be defined as JavaScript entities. final String functionPrefix = "jsFunction_"; final String staticFunctionPrefix = "jsStaticFunction_"; final String getterPrefix = "jsGet_"; final String setterPrefix = "jsSet_"; final String ctorName = "jsConstructor"; Member ctorMember = findAnnotatedMember(methods, JSConstructor.class); if (ctorMember == null) { ctorMember = findAnnotatedMember(ctors, JSConstructor.class); } if (ctorMember == null) { ctorMember = FunctionObject.findSingleMethod(methods, ctorName); } if (ctorMember == null) { if (ctors.length == 1) { ctorMember = ctors[0]; } else if (ctors.length == 2) { if (ctors[0].getParameterTypes().length == 0) ctorMember = ctors[1]; else if (ctors[1].getParameterTypes().length == 0) ctorMember = ctors[0]; } if (ctorMember == null) { throw Context.reportRuntimeError1( "msg.ctor.multiple.parms", clazz.getName()); } } FunctionObject ctor = new FunctionObject(className, ctorMember, scope); if (ctor.isVarArgsMethod()) { throw Context.reportRuntimeError1 ("msg.varargs.ctor", ctorMember.getName()); } ctor.initAsConstructor(scope, proto); Method finishInit = null; HashSet<String> staticNames = new HashSet<String>(), instanceNames = new HashSet<String>(); for (Method method : methods) { if (method == ctorMember) { continue; } String name = method.getName(); if (name.equals("finishInit")) { Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ScriptableClass && parmTypes[1] == FunctionObject.class && parmTypes[2] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { finishInit = method; continue; } } // ignore any compiler generated methods. if (name.indexOf('$') != -1) continue; if (name.equals(ctorName)) continue; Annotation annotation = null; String prefix = null; if (method.isAnnotationPresent(JSFunction.class)) { annotation = method.getAnnotation(JSFunction.class); } else if (method.isAnnotationPresent(JSStaticFunction.class)) { annotation = method.getAnnotation(JSStaticFunction.class); } else if (method.isAnnotationPresent(JSGetter.class)) { annotation = method.getAnnotation(JSGetter.class); } else if (method.isAnnotationPresent(JSSetter.class)) { continue; } if (annotation == null) { if (name.startsWith(functionPrefix)) { prefix = functionPrefix; } else if (name.startsWith(staticFunctionPrefix)) { prefix = staticFunctionPrefix; } else if (name.startsWith(getterPrefix)) { prefix = getterPrefix; } else if (annotation == null) { // note that setterPrefix is among the unhandled names here - // we deal with that when we see the getter continue; } } boolean isStatic = annotation instanceof JSStaticFunction || prefix == staticFunctionPrefix; HashSet<String> names = isStatic ? staticNames : instanceNames; String propName = getPropertyName(name, prefix, annotation); if (names.contains(propName)) { throw Context.reportRuntimeError2("duplicate.defineClass.name", name, propName); } names.add(propName); name = propName; if (annotation instanceof JSGetter || prefix == getterPrefix) { if (!(proto instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", proto.getClass().toString(), name); } Method setter = findSetterMethod(methods, name, setterPrefix); int attr = ScriptableObject.PERMANENT | ScriptableObject.DONTENUM | (setter != null ? 0 : ScriptableObject.READONLY); ((ScriptableObject) proto).defineProperty(name, null, method, setter, attr); continue; } if (isStatic && !Modifier.isStatic(method.getModifiers())) { throw Context.reportRuntimeError( "jsStaticFunction must be used with static method."); } FunctionObject f = new FunctionObject(name, method, proto); if (f.isVarArgsConstructor()) { throw Context.reportRuntimeError1 ("msg.varargs.fun", ctorMember.getName()); } defineProperty(isStatic ? ctor : proto, name, f, DONTENUM); if (sealed) { f.sealObject(); } } // Call user code to complete initialization if necessary. if (finishInit != null) { Object[] finishArgs = { scope, ctor, proto }; finishInit.invoke(null, finishArgs); } // Seal the object if necessary. if (sealed) { ctor.sealObject(); if (proto instanceof ScriptableObject) { ((ScriptableObject) proto).sealObject(); } } return ctor; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object getAdapterSelf(Class<?> adapterClass, Object adapter) throws NoSuchFieldException, IllegalAccessException { Field self = adapterClass.getDeclaredField("self"); return self.get(adapter); }
10
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (IllegalAccessException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalAccessException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (IllegalAccessException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(IllegalAccessException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (IllegalAccessException ex) { }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accessEx) { if ((field.getModifiers() & Modifier.FINAL) != 0) { // treat Java final the same as JavaScript [[READONLY]] return; } throw Context.throwAsScriptRuntimeEx(accessEx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalAccessException accEx) { throw Context.reportRuntimeError1( "msg.java.internal.private", field.getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { Method accessible = searchAccessibleMethod(method, argTypes); if (accessible != null) { memberObject = accessible; method = accessible; } else { if (!VMBridge.instance.tryToMakeAccessible(method)) { throw Context.throwAsScriptRuntimeEx(ex); } } // Retry after recovery return method.invoke(target, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
0
runtime (Lib) IllegalArgumentException 179
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=0; s="constructor"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(FTAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeContinuation.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(FTAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: throw Context.reportRuntimeError("Direct call is not supported"); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_exec: arity=0; s="exec"; break; case Id_compile: arity=1; s="compile"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(SCRIPT_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeScript.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(SCRIPT_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: { String source = (args.length == 0) ? "" : ScriptRuntime.toString(args[0]); Script script = compile(cx, source); NativeScript nscript = new NativeScript(script); ScriptRuntime.setObjectProtoAndParent(nscript, scope); return nscript; } case Id_toString: { NativeScript real = realThis(thisObj, f); Script realScript = real.script; if (realScript == null) { return ""; } return cx.decompileScript(realScript, 0); } case Id_exec: { throw Context.reportRuntimeError1( "msg.cant.call.indirect", "exec"); } case Id_compile: { NativeScript real = realThis(thisObj, f); String source = ScriptRuntime.toString(args, 0); real.script = compile(cx, source); return real; } } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_hasOwnProperty: arity=1; s="hasOwnProperty"; break; case Id_propertyIsEnumerable: arity=1; s="propertyIsEnumerable"; break; case Id_isPrototypeOf: arity=1; s="isPrototypeOf"; break; case Id_toSource: arity=0; s="toSource"; break; case Id___defineGetter__: arity=2; s="__defineGetter__"; break; case Id___defineSetter__: arity=2; s="__defineSetter__"; break; case Id___lookupGetter__: arity=1; s="__lookupGetter__"; break; case Id___lookupSetter__: arity=1; s="__lookupSetter__"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(OBJECT_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(OBJECT_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: { if (thisObj != null) { // BaseFunction.construct will set up parent, proto return f.construct(cx, scope, args); } if (args.length == 0 || args[0] == null || args[0] == Undefined.instance) { return new NativeObject(); } return ScriptRuntime.toObject(cx, scope, args[0]); } case Id_toLocaleString: // For now just alias toString case Id_toString: { if (cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE)) { String s = ScriptRuntime.defaultObjectToSource(cx, scope, thisObj, args); int L = s.length(); if (L != 0 && s.charAt(0) == '(' && s.charAt(L - 1) == ')') { // Strip () that surrounds toSource s = s.substring(1, L - 1); } return s; } return ScriptRuntime.defaultObjectToString(thisObj); } case Id_valueOf: return thisObj; case Id_hasOwnProperty: { boolean result; if (args.length == 0) { result = false; } else { String s = ScriptRuntime.toStringIdOrIndex(cx, args[0]); if (s == null) { int index = ScriptRuntime.lastIndexResult(cx); result = thisObj.has(index, thisObj); } else { result = thisObj.has(s, thisObj); } } return ScriptRuntime.wrapBoolean(result); } case Id_propertyIsEnumerable: { boolean result; if (args.length == 0) { result = false; } else { String s = ScriptRuntime.toStringIdOrIndex(cx, args[0]); if (s == null) { int index = ScriptRuntime.lastIndexResult(cx); result = thisObj.has(index, thisObj); if (result && thisObj instanceof ScriptableObject) { ScriptableObject so = (ScriptableObject)thisObj; int attrs = so.getAttributes(index); result = ((attrs & ScriptableObject.DONTENUM) == 0); } } else { result = thisObj.has(s, thisObj); if (result && thisObj instanceof ScriptableObject) { ScriptableObject so = (ScriptableObject)thisObj; int attrs = so.getAttributes(s); result = ((attrs & ScriptableObject.DONTENUM) == 0); } } } return ScriptRuntime.wrapBoolean(result); } case Id_isPrototypeOf: { boolean result = false; if (args.length != 0 && args[0] instanceof Scriptable) { Scriptable v = (Scriptable) args[0]; do { v = v.getPrototype(); if (v == thisObj) { result = true; break; } } while (v != null); } return ScriptRuntime.wrapBoolean(result); } case Id_toSource: return ScriptRuntime.defaultObjectToSource(cx, scope, thisObj, args); case Id___defineGetter__: case Id___defineSetter__: { if (args.length < 2 || !(args[1] instanceof Callable)) { Object badArg = (args.length >= 2 ? args[1] : Undefined.instance); throw ScriptRuntime.notFunctionError(badArg); } if (!(thisObj instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", thisObj.getClass().getName(), String.valueOf(args[0])); } ScriptableObject so = (ScriptableObject)thisObj; String name = ScriptRuntime.toStringIdOrIndex(cx, args[0]); int index = (name != null ? 0 : ScriptRuntime.lastIndexResult(cx)); Callable getterOrSetter = (Callable)args[1]; boolean isSetter = (id == Id___defineSetter__); so.setGetterOrSetter(name, index, getterOrSetter, isSetter); if (so instanceof NativeArray) ((NativeArray)so).setDenseOnly(false); } return Undefined.instance; case Id___lookupGetter__: case Id___lookupSetter__: { if (args.length < 1 || !(thisObj instanceof ScriptableObject)) return Undefined.instance; ScriptableObject so = (ScriptableObject)thisObj; String name = ScriptRuntime.toStringIdOrIndex(cx, args[0]); int index = (name != null ? 0 : ScriptRuntime.lastIndexResult(cx)); boolean isSetter = (id == Id___lookupSetter__); Object gs; for (;;) { gs = so.getGetterOrSetter(name, index, isSetter); if (gs != null) break; // If there is no getter or setter for the object itself, // how about the prototype? Scriptable v = so.getPrototype(); if (v == null) break; if (v instanceof ScriptableObject) so = (ScriptableObject)v; else break; } if (gs != null) return gs; } return Undefined.instance; case ConstructorId_getPrototypeOf: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = ensureScriptable(arg); return obj.getPrototype(); } case ConstructorId_keys: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = ensureScriptable(arg); Object[] ids = obj.getIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); } return cx.newArray(scope, ids); } case ConstructorId_getOwnPropertyNames: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); } return cx.newArray(scope, ids); } case ConstructorId_getOwnPropertyDescriptor: { Object arg = args.length < 1 ? Undefined.instance : args[0]; // TODO(norris): There's a deeper issue here if // arg instanceof Scriptable. Should we create a new // interface to admit the new ECMAScript 5 operations? ScriptableObject obj = ensureScriptableObject(arg); Object nameArg = args.length < 2 ? Undefined.instance : args[1]; String name = ScriptRuntime.toString(nameArg); Scriptable desc = obj.getOwnPropertyDescriptor(cx, name); return desc == null ? Undefined.instance : desc; } case ConstructorId_defineProperty: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object name = args.length < 2 ? Undefined.instance : args[1]; Object descArg = args.length < 3 ? Undefined.instance : args[2]; ScriptableObject desc = ensureScriptableObject(descArg); obj.defineOwnProperty(cx, name, desc); return obj; } case ConstructorId_isExtensible: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); return Boolean.valueOf(obj.isExtensible()); } case ConstructorId_preventExtensions: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); obj.preventExtensions(); return obj; } case ConstructorId_defineProperties: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); Object propsObj = args.length < 2 ? Undefined.instance : args[1]; Scriptable props = Context.toObject(propsObj, getParentScope()); obj.defineOwnProperties(cx, ensureScriptableObject(props)); return obj; } case ConstructorId_create: { Object arg = args.length < 1 ? Undefined.instance : args[0]; Scriptable obj = (arg == null) ? null : ensureScriptable(arg); ScriptableObject newObject = new NativeObject(); newObject.setParentScope(this.getParentScope()); newObject.setPrototype(obj); if (args.length > 1 && args[1] != Undefined.instance) { Scriptable props = Context.toObject(args[1], getParentScope()); newObject.defineOwnProperties(cx, ensureScriptableObject(props)); } return newObject; } case ConstructorId_isSealed: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); if (obj.isExtensible()) return Boolean.FALSE; for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) return Boolean.FALSE; } return Boolean.TRUE; } case ConstructorId_isFrozen: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); if (obj.isExtensible()) return Boolean.FALSE; for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) return Boolean.FALSE; if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable"))) return Boolean.FALSE; } return Boolean.TRUE; } case ConstructorId_seal: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { desc.put("configurable", desc, Boolean.FALSE); obj.defineOwnProperty(cx, name, desc, false); } } obj.preventExtensions(); return obj; } case ConstructorId_freeze: { Object arg = args.length < 1 ? Undefined.instance : args[0]; ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable"))) desc.put("writable", desc, Boolean.FALSE); if (Boolean.TRUE.equals(desc.get("configurable"))) desc.put("configurable", desc, Boolean.FALSE); obj.defineOwnProperty(cx, name, desc, false); } obj.preventExtensions(); return obj; } default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_compile: arity=1; s="compile"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_exec: arity=1; s="exec"; break; case Id_test: arity=1; s="test"; break; case Id_prefix: arity=1; s="prefix"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(REGEXP_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(REGEXP_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_compile: return realThis(thisObj, f).compile(cx, scope, args); case Id_toString: case Id_toSource: return realThis(thisObj, f).toString(); case Id_exec: return realThis(thisObj, f).execSub(cx, scope, args, MATCH); case Id_test: { Object x = realThis(thisObj, f).execSub(cx, scope, args, TEST); return Boolean.TRUE.equals(x) ? Boolean.TRUE : Boolean.FALSE; } case Id_prefix: return realThis(thisObj, f).execSub(cx, scope, args, PREFIX); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptRuntime.java
private static int[] decodeIntArray(String str, int arraySize) { // XXX: this extremely inefficient for small integers if (arraySize == 0) { if (str != null) throw new IllegalArgumentException(); return null; } if (str.length() != 1 + arraySize * 2 && str.charAt(0) != 1) { throw new IllegalArgumentException(); } int[] array = new int[arraySize]; for (int i = 0; i != arraySize; ++i) { int shift = 1 + i * 2; array[i] = (str.charAt(shift) << 16) | str.charAt(shift + 1); } return array; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=1; s="toString"; break; case Id_toSource: arity=1; s="toSource"; break; case Id_apply: arity=2; s="apply"; break; case Id_call: arity=1; s="call"; break; case Id_bind: arity=1; s="bind"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(FUNCTION_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(FUNCTION_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return jsConstructor(cx, scope, args); case Id_toString: { BaseFunction realf = realFunction(thisObj, f); int indent = ScriptRuntime.toInt32(args, 0); return realf.decompile(indent, 0); } case Id_toSource: { BaseFunction realf = realFunction(thisObj, f); int indent = 0; int flags = Decompiler.TO_SOURCE_FLAG; if (args.length != 0) { indent = ScriptRuntime.toInt32(args[0]); if (indent >= 0) { flags = 0; } else { indent = 0; } } return realf.decompile(indent, flags); } case Id_apply: case Id_call: return ScriptRuntime.applyOrCall(id == Id_apply, cx, scope, thisObj, args); case Id_bind: if ( !(thisObj instanceof Callable) ) { throw ScriptRuntime.notFunctionError(thisObj); } Callable targetFunction = (Callable) thisObj; int argc = args.length; final Scriptable boundThis; final Object[] boundArgs; if (argc > 0) { boundThis = ScriptRuntime.toObjectOrNull(cx, args[0], scope); boundArgs = new Object[argc-1]; System.arraycopy(args, 1, boundArgs, 0, argc-1); } else { boundThis = null; boundArgs = ScriptRuntime.emptyArgs; } return new BoundFunction(cx, scope, targetFunction, boundThis, boundArgs); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeMember(ObjectOutputStream out, Member member) throws IOException { if (member == null) { out.writeBoolean(false); return; } out.writeBoolean(true); if (!(member instanceof Method || member instanceof Constructor)) throw new IllegalArgumentException("not Method or Constructor"); out.writeBoolean(member instanceof Method); out.writeObject(member.getName()); out.writeObject(member.getDeclaringClass()); if (member instanceof Method) { writeParameters(out, ((Method) member).getParameterTypes()); } else { writeParameters(out, ((Constructor<?>) member).getParameterTypes()); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_charAt: arity=1; s="charAt"; break; case Id_charCodeAt: arity=1; s="charCodeAt"; break; case Id_indexOf: arity=1; s="indexOf"; break; case Id_lastIndexOf: arity=1; s="lastIndexOf"; break; case Id_split: arity=2; s="split"; break; case Id_substring: arity=2; s="substring"; break; case Id_toLowerCase: arity=0; s="toLowerCase"; break; case Id_toUpperCase: arity=0; s="toUpperCase"; break; case Id_substr: arity=2; s="substr"; break; case Id_concat: arity=1; s="concat"; break; case Id_slice: arity=2; s="slice"; break; case Id_bold: arity=0; s="bold"; break; case Id_italics: arity=0; s="italics"; break; case Id_fixed: arity=0; s="fixed"; break; case Id_strike: arity=0; s="strike"; break; case Id_small: arity=0; s="small"; break; case Id_big: arity=0; s="big"; break; case Id_blink: arity=0; s="blink"; break; case Id_sup: arity=0; s="sup"; break; case Id_sub: arity=0; s="sub"; break; case Id_fontsize: arity=0; s="fontsize"; break; case Id_fontcolor: arity=0; s="fontcolor"; break; case Id_link: arity=0; s="link"; break; case Id_anchor: arity=0; s="anchor"; break; case Id_equals: arity=1; s="equals"; break; case Id_equalsIgnoreCase: arity=1; s="equalsIgnoreCase"; break; case Id_match: arity=1; s="match"; break; case Id_search: arity=1; s="search"; break; case Id_replace: arity=1; s="replace"; break; case Id_localeCompare: arity=1; s="localeCompare"; break; case Id_toLocaleLowerCase: arity=0; s="toLocaleLowerCase"; break; case Id_toLocaleUpperCase: arity=0; s="toLocaleUpperCase"; break; case Id_trim: arity=0; s="trim"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(STRING_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeString.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(STRING_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); again: for(;;) { switch (id) { case ConstructorId_charAt: case ConstructorId_charCodeAt: case ConstructorId_indexOf: case ConstructorId_lastIndexOf: case ConstructorId_split: case ConstructorId_substring: case ConstructorId_toLowerCase: case ConstructorId_toUpperCase: case ConstructorId_substr: case ConstructorId_concat: case ConstructorId_slice: case ConstructorId_equalsIgnoreCase: case ConstructorId_match: case ConstructorId_search: case ConstructorId_replace: case ConstructorId_localeCompare: case ConstructorId_toLocaleLowerCase: { if (args.length > 0) { thisObj = ScriptRuntime.toObject(scope, ScriptRuntime.toCharSequence(args[0])); Object[] newArgs = new Object[args.length-1]; for (int i=0; i < newArgs.length; i++) newArgs[i] = args[i+1]; args = newArgs; } else { thisObj = ScriptRuntime.toObject(scope, ScriptRuntime.toCharSequence(thisObj)); } id = -id; continue again; } case ConstructorId_fromCharCode: { int N = args.length; if (N < 1) return ""; StringBuffer sb = new StringBuffer(N); for (int i = 0; i != N; ++i) { sb.append(ScriptRuntime.toUint16(args[i])); } return sb.toString(); } case Id_constructor: { CharSequence s = (args.length >= 1) ? ScriptRuntime.toCharSequence(args[0]) : ""; if (thisObj == null) { // new String(val) creates a new String object. return new NativeString(s); } // String(val) converts val to a string value. return s instanceof String ? s : s.toString(); } case Id_toString: case Id_valueOf: // ECMA 15.5.4.2: 'the toString function is not generic. CharSequence cs = realThis(thisObj, f).string; return cs instanceof String ? cs : cs.toString(); case Id_toSource: { CharSequence s = realThis(thisObj, f).string; return "(new String(\""+ScriptRuntime.escapeString(s.toString())+"\"))"; } case Id_charAt: case Id_charCodeAt: { // See ECMA 15.5.4.[4,5] CharSequence target = ScriptRuntime.toCharSequence(thisObj); double pos = ScriptRuntime.toInteger(args, 0); if (pos < 0 || pos >= target.length()) { if (id == Id_charAt) return ""; else return ScriptRuntime.NaNobj; } char c = target.charAt((int)pos); if (id == Id_charAt) return String.valueOf(c); else return ScriptRuntime.wrapInt(c); } case Id_indexOf: return ScriptRuntime.wrapInt(js_indexOf( ScriptRuntime.toString(thisObj), args)); case Id_lastIndexOf: return ScriptRuntime.wrapInt(js_lastIndexOf( ScriptRuntime.toString(thisObj), args)); case Id_split: return ScriptRuntime.checkRegExpProxy(cx). js_split(cx, scope, ScriptRuntime.toString(thisObj), args); case Id_substring: return js_substring(cx, ScriptRuntime.toCharSequence(thisObj), args); case Id_toLowerCase: // See ECMA 15.5.4.11 return ScriptRuntime.toString(thisObj).toLowerCase( ScriptRuntime.ROOT_LOCALE); case Id_toUpperCase: // See ECMA 15.5.4.12 return ScriptRuntime.toString(thisObj).toUpperCase( ScriptRuntime.ROOT_LOCALE); case Id_substr: return js_substr(ScriptRuntime.toCharSequence(thisObj), args); case Id_concat: return js_concat(ScriptRuntime.toString(thisObj), args); case Id_slice: return js_slice(ScriptRuntime.toCharSequence(thisObj), args); case Id_bold: return tagify(thisObj, "b", null, null); case Id_italics: return tagify(thisObj, "i", null, null); case Id_fixed: return tagify(thisObj, "tt", null, null); case Id_strike: return tagify(thisObj, "strike", null, null); case Id_small: return tagify(thisObj, "small", null, null); case Id_big: return tagify(thisObj, "big", null, null); case Id_blink: return tagify(thisObj, "blink", null, null); case Id_sup: return tagify(thisObj, "sup", null, null); case Id_sub: return tagify(thisObj, "sub", null, null); case Id_fontsize: return tagify(thisObj, "font", "size", args); case Id_fontcolor: return tagify(thisObj, "font", "color", args); case Id_link: return tagify(thisObj, "a", "href", args); case Id_anchor: return tagify(thisObj, "a", "name", args); case Id_equals: case Id_equalsIgnoreCase: { String s1 = ScriptRuntime.toString(thisObj); String s2 = ScriptRuntime.toString(args, 0); return ScriptRuntime.wrapBoolean( (id == Id_equals) ? s1.equals(s2) : s1.equalsIgnoreCase(s2)); } case Id_match: case Id_search: case Id_replace: { int actionType; if (id == Id_match) { actionType = RegExpProxy.RA_MATCH; } else if (id == Id_search) { actionType = RegExpProxy.RA_SEARCH; } else { actionType = RegExpProxy.RA_REPLACE; } return ScriptRuntime.checkRegExpProxy(cx). action(cx, scope, thisObj, args, actionType); } // ECMA-262 1 5.5.4.9 case Id_localeCompare: { // For now, create and configure a collator instance. I can't // actually imagine that this'd be slower than caching them // a la ClassCache, so we aren't trying to outsmart ourselves // with a caching mechanism for now. Collator collator = Collator.getInstance(cx.getLocale()); collator.setStrength(Collator.IDENTICAL); collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); return ScriptRuntime.wrapNumber(collator.compare( ScriptRuntime.toString(thisObj), ScriptRuntime.toString(args, 0))); } case Id_toLocaleLowerCase: { return ScriptRuntime.toString(thisObj) .toLowerCase(cx.getLocale()); } case Id_toLocaleUpperCase: { return ScriptRuntime.toString(thisObj) .toUpperCase(cx.getLocale()); } case Id_trim: { String str = ScriptRuntime.toString(thisObj); char[] chars = str.toCharArray(); int start = 0; while (start < chars.length && ScriptRuntime.isJSWhitespaceOrLineTerminator(chars[start])) { start++; } int end = chars.length; while (end > start && ScriptRuntime.isJSWhitespaceOrLineTerminator(chars[end-1])) { end--; } return str.substring(start, end); } } throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SpecialRef.java
static Ref createSpecial(Context cx, Object object, String name) { Scriptable target = ScriptRuntime.toObjectOrNull(cx, object); if (target == null) { throw ScriptRuntime.undefReadError(object, name); } int type; if (name.equals("__proto__")) { type = SPECIAL_PROTO; } else if (name.equals("__parent__")) { type = SPECIAL_PARENT; } else { throw new IllegalArgumentException(name); } if (!cx.hasFeature(Context.FEATURE_PARENT_PROTO_PROPERTIES)) { // Clear special after checking for valid name! type = SPECIAL_NONE; } return new SpecialRef(target, type, name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static void checkValidAttributes(int attributes) { final int mask = READONLY | DONTENUM | PERMANENT | UNINITIALIZED_CONST; if ((attributes & ~mask) != 0) { throw new IllegalArgumentException(String.valueOf(attributes)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void setGetterOrSetter(String name, int index, Callable getterOrSetter, boolean isSetter, boolean force) { if (name != null && index != 0) throw new IllegalArgumentException(name); if (!force) { checkNotSealed(name, index); } final GetterSlot gslot; if (isExtensible()) { gslot = (GetterSlot)getSlot(name, index, SLOT_MODIFY_GETTER_SETTER); } else { Slot slot = unwrapSlot(getSlot(name, index, SLOT_QUERY)); if (!(slot instanceof GetterSlot)) return; gslot = (GetterSlot) slot; } if (!force) { int attributes = gslot.getAttributes(); if ((attributes & READONLY) != 0) { throw Context.reportRuntimeError1("msg.modify.readonly", name); } } if (isSetter) { gslot.setter = getterOrSetter; } else { gslot.getter = getterOrSetter; } gslot.value = Undefined.instance; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public Object getGetterOrSetter(String name, int index, boolean isSetter) { if (name != null && index != 0) throw new IllegalArgumentException(name); Slot slot = unwrapSlot(getSlot(name, index, SLOT_QUERY)); if (slot == null) return null; if (slot instanceof GetterSlot) { GetterSlot gslot = (GetterSlot)slot; Object result = isSetter ? gslot.setter : gslot.getter; return result != null ? result : Undefined.instance; } else return Undefined.instance; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
void addLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes) { if (name != null && index != 0) throw new IllegalArgumentException(name); checkNotSealed(name, index); GetterSlot gslot = (GetterSlot)getSlot(name, index, SLOT_MODIFY_GETTER_SETTER); gslot.setAttributes(attributes); gslot.getter = null; gslot.setter = null; gslot.value = init; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public void defineProperty(String propertyName, Class<?> clazz, int attributes) { int length = propertyName.length(); if (length == 0) throw new IllegalArgumentException(); char[] buf = new char[3 + length]; propertyName.getChars(0, length, buf, 3); buf[3] = Character.toUpperCase(buf[3]); buf[0] = 'g'; buf[1] = 'e'; buf[2] = 't'; String getterName = new String(buf); buf[0] = 's'; String setterName = new String(buf); Method[] methods = FunctionObject.getMethodList(clazz); Method getter = FunctionObject.findSingleMethod(methods, getterName); Method setter = FunctionObject.findSingleMethod(methods, setterName); if (setter == null) attributes |= ScriptableObject.READONLY; defineProperty(propertyName, null, getter, setter == null ? null : setter, attributes); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public synchronized final Object associateValue(Object key, Object value) { if (value == null) throw new IllegalArgumentException(); Map<Object,Object> h = associatedValues; if (h == null) { h = new HashMap<Object,Object>(); associatedValues = h; } return Kit.initHash(h, key, value); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterfaceAdapter.java
static Object create(Context cx, Class<?> cl, ScriptableObject object) { if (!cl.isInterface()) throw new IllegalArgumentException(); Scriptable topScope = ScriptRuntime.getTopCallScope(cx); ClassCache cache = ClassCache.get(topScope); InterfaceAdapter adapter; adapter = (InterfaceAdapter)cache.getInterfaceAdapter(cl); ContextFactory cf = cx.getFactory(); if (adapter == null) { Method[] methods = cl.getMethods(); if ( object instanceof Callable) { // Check if interface can be implemented by a single function. // We allow this if the interface has only one method or multiple // methods with the same name (in which case they'd result in // the same function to be invoked anyway). int length = methods.length; if (length == 0) { throw Context.reportRuntimeError1( "msg.no.empty.interface.conversion", cl.getName()); } if (length > 1) { String methodName = methods[0].getName(); for (int i = 1; i < length; i++) { if (!methodName.equals(methods[i].getName())) { throw Context.reportRuntimeError1( "msg.no.function.interface.conversion", cl.getName()); } } } } adapter = new InterfaceAdapter(cf, cl); cache.cacheInterfaceAdapter(cl, adapter); } return VMBridge.instance.newInterfaceProxy( adapter.proxyHelper, cf, adapter, object, topScope); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(BOOLEAN_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeBoolean.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(BOOLEAN_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { boolean b; if (args.length == 0) { b = false; } else { b = args[0] instanceof ScriptableObject && ((ScriptableObject) args[0]).avoidObjectDetection() ? true : ScriptRuntime.toBoolean(args[0]); } if (thisObj == null) { // new Boolean(val) creates a new boolean object. return new NativeBoolean(b); } // Boolean(val) converts val to a boolean. return ScriptRuntime.wrapBoolean(b); } // The rest of Boolean.prototype methods require thisObj to be Boolean if (!(thisObj instanceof NativeBoolean)) throw incompatibleCallError(f); boolean value = ((NativeBoolean)thisObj).booleanValue; switch (id) { case Id_toString: return value ? "true" : "false"; case Id_toSource: return value ? "(new Boolean(true))" : "(new Boolean(false))"; case Id_valueOf: return ScriptRuntime.wrapBoolean(value); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
Override protected void initPrototypeId(int id) { String s; int arity; if (id == Id_constructor) { arity=1; s="constructor"; } else { throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(CALL_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeCall.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(CALL_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { if (thisObj != null) { throw Context.reportRuntimeError1("msg.only.from.new", "Call"); } ScriptRuntime.checkDeprecated(cx, "Call"); NativeCall result = new NativeCall(); result.setPrototype(getObjectPrototype(scope)); return result; } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object addListener(Object bag, Object listener) { if (listener == null) throw new IllegalArgumentException(); if (listener instanceof Object[]) throw new IllegalArgumentException(); if (bag == null) { bag = listener; } else if (!(bag instanceof Object[])) { bag = new Object[] { bag, listener }; } else { Object[] array = (Object[])bag; int L = array.length; // bag has at least 2 elements if it is array if (L < 2) throw new IllegalArgumentException(); Object[] tmp = new Object[L + 1]; System.arraycopy(array, 0, tmp, 0, L); tmp[L] = listener; bag = tmp; } return bag; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object removeListener(Object bag, Object listener) { if (listener == null) throw new IllegalArgumentException(); if (listener instanceof Object[]) throw new IllegalArgumentException(); if (bag == listener) { bag = null; } else if (bag instanceof Object[]) { Object[] array = (Object[])bag; int L = array.length; // bag has at least 2 elements if it is array if (L < 2) throw new IllegalArgumentException(); if (L == 2) { if (array[1] == listener) { bag = array[0]; } else if (array[0] == listener) { bag = array[1]; } } else { int i = L; do { --i; if (array[i] == listener) { Object[] tmp = new Object[L - 1]; System.arraycopy(array, 0, tmp, 0, i); System.arraycopy(array, i + 1, tmp, i, L - (i + 1)); bag = tmp; break; } } while (i != 0); } } return bag; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object getListener(Object bag, int index) { if (index == 0) { if (bag == null) return null; if (!(bag instanceof Object[])) return bag; Object[] array = (Object[])bag; // bag has at least 2 elements if it is array if (array.length < 2) throw new IllegalArgumentException(); return array[0]; } else if (index == 1) { if (!(bag instanceof Object[])) { if (bag == null) throw new IllegalArgumentException(); return null; } Object[] array = (Object[])bag; // the array access will check for index on its own return array[1]; } else { // bag has to array Object[] array = (Object[])bag; int L = array.length; if (L < 2) throw new IllegalArgumentException(); if (index == L) return null; return array[index]; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static Object makeHashKeyFromPair(Object key1, Object key2) { if (key1 == null) throw new IllegalArgumentException(); if (key2 == null) throw new IllegalArgumentException(); return new ComplexKey(key1, key2); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException { if (initialBufferCapacity <= 0) { throw new IllegalArgumentException( "Bad initialBufferCapacity: "+initialBufferCapacity); } byte[] buffer = new byte[initialBufferCapacity]; int cursor = 0; for (;;) { int n = is.read(buffer, cursor, buffer.length - cursor); if (n < 0) { break; } cursor += n; if (cursor == buffer.length) { byte[] tmp = new byte[buffer.length * 2]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } } if (cursor != buffer.length) { byte[] tmp = new byte[cursor]; System.arraycopy(buffer, 0, tmp, 0, cursor); buffer = tmp; } return buffer; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=2; s="constructor"; break; case Id_next: arity=0; s="next"; break; case Id___iterator__: arity=1; s=ITERATOR_PROPERTY_NAME; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ITERATOR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ITERATOR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { return jsConstructor(cx, scope, thisObj, args); } if (!(thisObj instanceof NativeIterator)) throw incompatibleCallError(f); NativeIterator iterator = (NativeIterator) thisObj; switch (id) { case Id_next: return iterator.next(cx, scope); case Id___iterator__: /// XXX: what about argument? SpiderMonkey apparently ignores it return thisObj; default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=1; s="toString"; break; case Id_toLocaleString: arity=1; s="toLocaleString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_toFixed: arity=1; s="toFixed"; break; case Id_toExponential: arity=1; s="toExponential"; break; case Id_toPrecision: arity=1; s="toPrecision"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(NUMBER_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeNumber.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(NUMBER_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (id == Id_constructor) { double val = (args.length >= 1) ? ScriptRuntime.toNumber(args[0]) : 0.0; if (thisObj == null) { // new Number(val) creates a new Number object. return new NativeNumber(val); } // Number(val) converts val to a number value. return ScriptRuntime.wrapNumber(val); } // The rest of Number.prototype methods require thisObj to be Number if (!(thisObj instanceof NativeNumber)) throw incompatibleCallError(f); double value = ((NativeNumber)thisObj).doubleValue; switch (id) { case Id_toString: case Id_toLocaleString: { // toLocaleString is just an alias for toString for now int base = (args.length == 0 || args[0] == Undefined.instance) ? 10 : ScriptRuntime.toInt32(args[0]); return ScriptRuntime.numberToString(value, base); } case Id_toSource: return "(new Number("+ScriptRuntime.toString(value)+"))"; case Id_valueOf: return ScriptRuntime.wrapNumber(value); case Id_toFixed: return num_to(value, args, DToA.DTOSTR_FIXED, DToA.DTOSTR_FIXED, -20, 0); case Id_toExponential: { // Handle special values before range check if(Double.isNaN(value)) { return "NaN"; } if(Double.isInfinite(value)) { if(value >= 0) { return "Infinity"; } else { return "-Infinity"; } } // General case return num_to(value, args, DToA.DTOSTR_STANDARD_EXPONENTIAL, DToA.DTOSTR_EXPONENTIAL, 0, 1); } case Id_toPrecision: { // Undefined precision, fall back to ToString() if(args.length == 0 || args[0] == Undefined.instance) { return ScriptRuntime.numberToString(value, 10); } // Handle special values before range check if(Double.isNaN(value)) { return "NaN"; } if(Double.isInfinite(value)) { if(value >= 0) { return "Infinity"; } else { return "-Infinity"; } } return num_to(value, args, DToA.DTOSTR_STANDARD, DToA.DTOSTR_PRECISION, 1, 0); } default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
protected boolean hasFeature(Context cx, int featureIndex) { int version; switch (featureIndex) { case Context.FEATURE_NON_ECMA_GET_YEAR: /* * During the great date rewrite of 1.3, we tried to track the * evolving ECMA standard, which then had a definition of * getYear which always subtracted 1900. Which we * implemented, not realizing that it was incompatible with * the old behavior... now, rather than thrash the behavior * yet again, we've decided to leave it with the - 1900 * behavior and point people to the getFullYear method. But * we try to protect existing scripts that have specified a * version... */ version = cx.getLanguageVersion(); return (version == Context.VERSION_1_0 || version == Context.VERSION_1_1 || version == Context.VERSION_1_2); case Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME: return false; case Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER: return true; case Context.FEATURE_TO_STRING_AS_SOURCE: version = cx.getLanguageVersion(); return version == Context.VERSION_1_2; case Context.FEATURE_PARENT_PROTO_PROPERTIES: return true; case Context.FEATURE_E4X: version = cx.getLanguageVersion(); return (version == Context.VERSION_DEFAULT || version >= Context.VERSION_1_6); case Context.FEATURE_DYNAMIC_SCOPE: return false; case Context.FEATURE_STRICT_VARS: return false; case Context.FEATURE_STRICT_EVAL: return false; case Context.FEATURE_LOCATION_INFORMATION_IN_ERROR: return false; case Context.FEATURE_STRICT_MODE: return false; case Context.FEATURE_WARNING_AS_ERROR: return false; case Context.FEATURE_ENHANCED_JAVA_ACCESS: return false; } // It is a bug to call the method with unknown featureIndex throw new IllegalArgumentException(String.valueOf(featureIndex)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_join: arity=1; s="join"; break; case Id_reverse: arity=0; s="reverse"; break; case Id_sort: arity=1; s="sort"; break; case Id_push: arity=1; s="push"; break; case Id_pop: arity=0; s="pop"; break; case Id_shift: arity=0; s="shift"; break; case Id_unshift: arity=1; s="unshift"; break; case Id_splice: arity=2; s="splice"; break; case Id_concat: arity=1; s="concat"; break; case Id_slice: arity=2; s="slice"; break; case Id_indexOf: arity=1; s="indexOf"; break; case Id_lastIndexOf: arity=1; s="lastIndexOf"; break; case Id_every: arity=1; s="every"; break; case Id_filter: arity=1; s="filter"; break; case Id_forEach: arity=1; s="forEach"; break; case Id_map: arity=1; s="map"; break; case Id_some: arity=1; s="some"; break; case Id_reduce: arity=1; s="reduce"; break; case Id_reduceRight: arity=1; s="reduceRight"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ARRAY_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ARRAY_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); again: for (;;) { switch (id) { case ConstructorId_join: case ConstructorId_reverse: case ConstructorId_sort: case ConstructorId_push: case ConstructorId_pop: case ConstructorId_shift: case ConstructorId_unshift: case ConstructorId_splice: case ConstructorId_concat: case ConstructorId_slice: case ConstructorId_indexOf: case ConstructorId_lastIndexOf: case ConstructorId_every: case ConstructorId_filter: case ConstructorId_forEach: case ConstructorId_map: case ConstructorId_some: case ConstructorId_reduce: case ConstructorId_reduceRight: { if (args.length > 0) { thisObj = ScriptRuntime.toObject(scope, args[0]); Object[] newArgs = new Object[args.length-1]; for (int i=0; i < newArgs.length; i++) newArgs[i] = args[i+1]; args = newArgs; } id = -id; continue again; } case ConstructorId_isArray: return args.length > 0 && (args[0] instanceof NativeArray); case Id_constructor: { boolean inNewExpr = (thisObj == null); if (!inNewExpr) { // IdFunctionObject.construct will set up parent, proto return f.construct(cx, scope, args); } return jsConstructor(cx, scope, args); } case Id_toString: return toStringHelper(cx, scope, thisObj, cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE), false); case Id_toLocaleString: return toStringHelper(cx, scope, thisObj, false, true); case Id_toSource: return toStringHelper(cx, scope, thisObj, true, false); case Id_join: return js_join(cx, thisObj, args); case Id_reverse: return js_reverse(cx, thisObj, args); case Id_sort: return js_sort(cx, scope, thisObj, args); case Id_push: return js_push(cx, thisObj, args); case Id_pop: return js_pop(cx, thisObj, args); case Id_shift: return js_shift(cx, thisObj, args); case Id_unshift: return js_unshift(cx, thisObj, args); case Id_splice: return js_splice(cx, scope, thisObj, args); case Id_concat: return js_concat(cx, scope, thisObj, args); case Id_slice: return js_slice(cx, thisObj, args); case Id_indexOf: return indexOfHelper(cx, thisObj, args, false); case Id_lastIndexOf: return indexOfHelper(cx, thisObj, args, true); case Id_every: case Id_filter: case Id_forEach: case Id_map: case Id_some: return iterativeMethod(cx, id, scope, thisObj, args); case Id_reduce: case Id_reduceRight: return reduceMethod(cx, id, scope, thisObj, args); } throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
void setDenseOnly(boolean denseOnly) { if (denseOnly && !this.denseOnly) throw new IllegalArgumentException(); this.denseOnly = denseOnly; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CompilerEnvirons.java
public void setErrorReporter(ErrorReporter errorReporter) { if (errorReporter == null) throw new IllegalArgumentException(); this.errorReporter = errorReporter; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toSource: arity=0; s="toSource"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(ERROR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(ERROR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return make(cx, scope, f, args); case Id_toString: return js_toString(thisObj); case Id_toSource: return js_toSource(cx, scope, thisObj); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/DToA.java
static String JS_dtobasestr(int base, double d) { if (!(2 <= base && base <= 36)) throw new IllegalArgumentException("Bad base: "+base); /* Check for Infinity and NaN */ if (Double.isNaN(d)) { return "NaN"; } else if (Double.isInfinite(d)) { return (d > 0.0) ? "Infinity" : "-Infinity"; } else if (d == 0) { // ALERT: should it distinguish -0.0 from +0.0 ? return "0"; } boolean negative; if (d >= 0.0) { negative = false; } else { negative = true; d = -d; } /* Get the integer part of d including '-' sign. */ String intDigits; double dfloor = Math.floor(d); long lfloor = (long)dfloor; if (lfloor == dfloor) { // int part fits long intDigits = Long.toString((negative) ? -lfloor : lfloor, base); } else { // BigInteger should be used long floorBits = Double.doubleToLongBits(dfloor); int exp = (int)(floorBits >> Exp_shiftL) & Exp_mask_shifted; long mantissa; if (exp == 0) { mantissa = (floorBits & Frac_maskL) << 1; } else { mantissa = (floorBits & Frac_maskL) | Exp_msk1L; } if (negative) { mantissa = -mantissa; } exp -= 1075; BigInteger x = BigInteger.valueOf(mantissa); if (exp > 0) { x = x.shiftLeft(exp); } else if (exp < 0) { x = x.shiftRight(-exp); } intDigits = x.toString(base); } if (d == dfloor) { // No fraction part return intDigits; } else { /* We have a fraction. */ StringBuilder buffer; /* The output string */ int digit; double df; /* The fractional part of d */ BigInteger b; buffer = new StringBuilder(); buffer.append(intDigits).append('.'); df = d - dfloor; long dBits = Double.doubleToLongBits(d); int word0 = (int)(dBits >> 32); int word1 = (int)(dBits); int[] e = new int[1]; int[] bbits = new int[1]; b = d2b(df, e, bbits); // JS_ASSERT(e < 0); /* At this point df = b * 2^e. e must be less than zero because 0 < df < 1. */ int s2 = -(word0 >>> Exp_shift1 & Exp_mask >> Exp_shift1); if (s2 == 0) s2 = -1; s2 += Bias + P; /* 1/2^s2 = (nextDouble(d) - d)/2 */ // JS_ASSERT(-s2 < e); BigInteger mlo = BigInteger.valueOf(1); BigInteger mhi = mlo; if ((word1 == 0) && ((word0 & Bndry_mask) == 0) && ((word0 & (Exp_mask & Exp_mask << 1)) != 0)) { /* The special case. Here we want to be within a quarter of the last input significant digit instead of one half of it when the output string's value is less than d. */ s2 += Log2P; mhi = BigInteger.valueOf(1<<Log2P); } b = b.shiftLeft(e[0] + s2); BigInteger s = BigInteger.valueOf(1); s = s.shiftLeft(s2); /* At this point we have the following: * s = 2^s2; * 1 > df = b/2^s2 > 0; * (d - prevDouble(d))/2 = mlo/2^s2; * (nextDouble(d) - d)/2 = mhi/2^s2. */ BigInteger bigBase = BigInteger.valueOf(base); boolean done = false; do { b = b.multiply(bigBase); BigInteger[] divResult = b.divideAndRemainder(s); b = divResult[1]; digit = (char)(divResult[0].intValue()); if (mlo == mhi) mlo = mhi = mlo.multiply(bigBase); else { mlo = mlo.multiply(bigBase); mhi = mhi.multiply(bigBase); } /* Do we yet have the shortest string that will round to d? */ int j = b.compareTo(mlo); /* j is b/2^s2 compared with mlo/2^s2. */ BigInteger delta = s.subtract(mhi); int j1 = (delta.signum() <= 0) ? 1 : b.compareTo(delta); /* j1 is b/2^s2 compared with 1 - mhi/2^s2. */ if (j1 == 0 && ((word1 & 1) == 0)) { if (j > 0) digit++; done = true; } else if (j < 0 || (j == 0 && ((word1 & 1) == 0))) { if (j1 > 0) { /* Either dig or dig+1 would work here as the least significant digit. Use whichever would produce an output value closer to d. */ b = b.shiftLeft(1); j1 = b.compareTo(s); if (j1 > 0) /* The even test (|| (j1 == 0 && (digit & 1))) is not here because it messes up odd base output * such as 3.5 in base 3. */ digit++; } done = true; } else if (j1 > 0) { digit++; done = true; } // JS_ASSERT(digit < (uint32)base); buffer.append(BASEDIGIT(digit)); } while (!done); return buffer.toString(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Icode.java
static String bytecodeName(int bytecode) { if (!validBytecode(bytecode)) { throw new IllegalArgumentException(String.valueOf(bytecode)); } if (!Token.printICode) { return String.valueOf(bytecode); } if (validTokenCode(bytecode)) { return Token.name(bytecode); } switch (bytecode) { case Icode_DUP: return "DUP"; case Icode_DUP2: return "DUP2"; case Icode_SWAP: return "SWAP"; case Icode_POP: return "POP"; case Icode_POP_RESULT: return "POP_RESULT"; case Icode_IFEQ_POP: return "IFEQ_POP"; case Icode_VAR_INC_DEC: return "VAR_INC_DEC"; case Icode_NAME_INC_DEC: return "NAME_INC_DEC"; case Icode_PROP_INC_DEC: return "PROP_INC_DEC"; case Icode_ELEM_INC_DEC: return "ELEM_INC_DEC"; case Icode_REF_INC_DEC: return "REF_INC_DEC"; case Icode_SCOPE_LOAD: return "SCOPE_LOAD"; case Icode_SCOPE_SAVE: return "SCOPE_SAVE"; case Icode_TYPEOFNAME: return "TYPEOFNAME"; case Icode_NAME_AND_THIS: return "NAME_AND_THIS"; case Icode_PROP_AND_THIS: return "PROP_AND_THIS"; case Icode_ELEM_AND_THIS: return "ELEM_AND_THIS"; case Icode_VALUE_AND_THIS: return "VALUE_AND_THIS"; case Icode_CLOSURE_EXPR: return "CLOSURE_EXPR"; case Icode_CLOSURE_STMT: return "CLOSURE_STMT"; case Icode_CALLSPECIAL: return "CALLSPECIAL"; case Icode_RETUNDEF: return "RETUNDEF"; case Icode_GOSUB: return "GOSUB"; case Icode_STARTSUB: return "STARTSUB"; case Icode_RETSUB: return "RETSUB"; case Icode_LINE: return "LINE"; case Icode_SHORTNUMBER: return "SHORTNUMBER"; case Icode_INTNUMBER: return "INTNUMBER"; case Icode_LITERAL_NEW: return "LITERAL_NEW"; case Icode_LITERAL_SET: return "LITERAL_SET"; case Icode_SPARE_ARRAYLIT: return "SPARE_ARRAYLIT"; case Icode_REG_IND_C0: return "REG_IND_C0"; case Icode_REG_IND_C1: return "REG_IND_C1"; case Icode_REG_IND_C2: return "REG_IND_C2"; case Icode_REG_IND_C3: return "REG_IND_C3"; case Icode_REG_IND_C4: return "REG_IND_C4"; case Icode_REG_IND_C5: return "REG_IND_C5"; case Icode_REG_IND1: return "LOAD_IND1"; case Icode_REG_IND2: return "LOAD_IND2"; case Icode_REG_IND4: return "LOAD_IND4"; case Icode_REG_STR_C0: return "REG_STR_C0"; case Icode_REG_STR_C1: return "REG_STR_C1"; case Icode_REG_STR_C2: return "REG_STR_C2"; case Icode_REG_STR_C3: return "REG_STR_C3"; case Icode_REG_STR1: return "LOAD_STR1"; case Icode_REG_STR2: return "LOAD_STR2"; case Icode_REG_STR4: return "LOAD_STR4"; case Icode_GETVAR1: return "GETVAR1"; case Icode_SETVAR1: return "SETVAR1"; case Icode_UNDEF: return "UNDEF"; case Icode_ZERO: return "ZERO"; case Icode_ONE: return "ONE"; case Icode_ENTERDQ: return "ENTERDQ"; case Icode_LEAVEDQ: return "LEAVEDQ"; case Icode_TAIL_CALL: return "TAIL_CALL"; case Icode_LOCAL_CLEAR: return "LOCAL_CLEAR"; case Icode_LITERAL_GETTER: return "LITERAL_GETTER"; case Icode_LITERAL_SETTER: return "LITERAL_SETTER"; case Icode_SETCONST: return "SETCONST"; case Icode_SETCONSTVAR: return "SETCONSTVAR"; case Icode_SETCONSTVAR1: return "SETCONSTVAR1"; case Icode_GENERATOR: return "GENERATOR"; case Icode_GENERATOR_END: return "GENERATOR_END"; case Icode_DEBUGGER: return "DEBUGGER"; } // icode without name throw new IllegalStateException(String.valueOf(bytecode)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IRFactory.java
public Node transform(AstNode node) { switch (node.getType()) { case Token.ARRAYCOMP: return transformArrayComp((ArrayComprehension)node); case Token.ARRAYLIT: return transformArrayLiteral((ArrayLiteral)node); case Token.BLOCK: return transformBlock(node); case Token.BREAK: return transformBreak((BreakStatement)node); case Token.CALL: return transformFunctionCall((FunctionCall)node); case Token.CONTINUE: return transformContinue((ContinueStatement)node); case Token.DO: return transformDoLoop((DoLoop)node); case Token.EMPTY: return node; case Token.FOR: if (node instanceof ForInLoop) { return transformForInLoop((ForInLoop)node); } else { return transformForLoop((ForLoop)node); } case Token.FUNCTION: return transformFunction((FunctionNode)node); case Token.GENEXPR: return transformGenExpr((GeneratorExpression)node); case Token.GETELEM: return transformElementGet((ElementGet)node); case Token.GETPROP: return transformPropertyGet((PropertyGet)node); case Token.HOOK: return transformCondExpr((ConditionalExpression)node); case Token.IF: return transformIf((IfStatement)node); case Token.TRUE: case Token.FALSE: case Token.THIS: case Token.NULL: case Token.DEBUGGER: return transformLiteral(node); case Token.NAME: return transformName((Name)node); case Token.NUMBER: return transformNumber((NumberLiteral)node); case Token.NEW: return transformNewExpr((NewExpression)node); case Token.OBJECTLIT: return transformObjectLiteral((ObjectLiteral)node); case Token.REGEXP: return transformRegExp((RegExpLiteral)node); case Token.RETURN: return transformReturn((ReturnStatement)node); case Token.SCRIPT: return transformScript((ScriptNode)node); case Token.STRING: return transformString((StringLiteral)node); case Token.SWITCH: return transformSwitch((SwitchStatement)node); case Token.THROW: return transformThrow((ThrowStatement)node); case Token.TRY: return transformTry((TryStatement)node); case Token.WHILE: return transformWhileLoop((WhileLoop)node); case Token.WITH: return transformWith((WithStatement)node); case Token.YIELD: return transformYield((Yield)node); default: if (node instanceof ExpressionStatement) { return transformExprStmt((ExpressionStatement)node); } if (node instanceof Assignment) { return transformAssignment((Assignment)node); } if (node instanceof UnaryExpression) { return transformUnary((UnaryExpression)node); } if (node instanceof XmlMemberGet) { return transformXmlMemberGet((XmlMemberGet)node); } if (node instanceof InfixExpression) { return transformInfix((InfixExpression)node); } if (node instanceof VariableDeclaration) { return transformVariables((VariableDeclaration)node); } if (node instanceof ParenthesizedExpression) { return transformParenExpr((ParenthesizedExpression)node); } if (node instanceof LabeledStatement) { return transformLabeledStatement((LabeledStatement)node); } if (node instanceof LetNode) { return transformLetNode((LetNode)node); } if (node instanceof XmlRef) { return transformXmlRef((XmlRef)node); } if (node instanceof XmlLiteral) { return transformXmlLiteral((XmlLiteral)node); } throw new IllegalArgumentException("Can't transform: " + node); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Label.java
public void setName(String name) { name = name == null ? null : name.trim(); if (name == null || "".equals(name)) throw new IllegalArgumentException("invalid label name"); this.name = name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/KeywordLiteral.java
Override public KeywordLiteral setType(int nodeType) { if (!(nodeType == Token.THIS || nodeType == Token.NULL || nodeType == Token.TRUE || nodeType == Token.FALSE || nodeType == Token.DEBUGGER)) throw new IllegalArgumentException("Invalid node type: " + nodeType); type = nodeType; return this; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Symbol.java
public void setDeclType(int declType) { if (!(declType == Token.FUNCTION || declType == Token.LP || declType == Token.VAR || declType == Token.LET || declType == Token.CONST)) throw new IllegalArgumentException("Invalid declType: " + declType); this.declType = declType; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ObjectProperty.java
public void setNodeType(int nodeType) { if (nodeType != Token.COLON && nodeType != Token.GET && nodeType != Token.SET) throw new IllegalArgumentException("invalid node type: " + nodeType); setType(nodeType); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/InfixExpression.java
public void setOperator(int operator) { if (!Token.isValidToken(operator)) throw new IllegalArgumentException("Invalid token: " + operator); setType(operator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/UnaryExpression.java
public void setOperator(int operator) { if (!Token.isValidToken(operator)) throw new IllegalArgumentException("Invalid token: " + operator); setType(operator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Scope.java
public void putSymbol(Symbol symbol) { if (symbol.getName() == null) throw new IllegalArgumentException("null symbol name"); ensureSymbolTable(); symbolTable.put(symbol.getName(), symbol); symbol.setContainingTable(this); top.addSymbol(symbol); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableDeclaration.java
Override public org.mozilla.javascript.Node setType(int type) { if (type != Token.VAR && type != Token.CONST && type != Token.LET) throw new IllegalArgumentException("invalid decl type: " + type); return super.setType(type); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableInitializer.java
public void setNodeType(int nodeType) { if (nodeType != Token.VAR && nodeType != Token.CONST && nodeType != Token.LET) throw new IllegalArgumentException("invalid node type"); setType(nodeType); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/VariableInitializer.java
public void setTarget(AstNode target) { // Don't throw exception if target is an "invalid" node type. // See mozilla/js/tests/js1_7/block/regress-350279.js if (target == null) throw new IllegalArgumentException("invalid target arg"); this.target = target; target.setParent(this); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
public static String operatorToString(int op) { String result = operatorNames.get(op); if (result == null) throw new IllegalArgumentException("Invalid operator: " + op); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
protected void assertNotNull(Object arg) { if (arg == null) throw new IllegalArgumentException("arg cannot be null"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
public static Object convertArg(Context cx, Scriptable scope, Object arg, int typeTag) { switch (typeTag) { case JAVA_STRING_TYPE: if (arg instanceof String) return arg; return ScriptRuntime.toString(arg); case JAVA_INT_TYPE: if (arg instanceof Integer) return arg; return Integer.valueOf(ScriptRuntime.toInt32(arg)); case JAVA_BOOLEAN_TYPE: if (arg instanceof Boolean) return arg; return ScriptRuntime.toBoolean(arg) ? Boolean.TRUE : Boolean.FALSE; case JAVA_DOUBLE_TYPE: if (arg instanceof Double) return arg; return new Double(ScriptRuntime.toNumber(arg)); case JAVA_SCRIPTABLE_TYPE: return ScriptRuntime.toObjectOrNull(cx, arg, scope); case JAVA_OBJECT_TYPE: return arg; default: throw new IllegalArgumentException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initSourceName(String sourceName) { if (sourceName == null) throw new IllegalArgumentException(); if (this.sourceName != null) throw new IllegalStateException(); this.sourceName = sourceName; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineNumber(int lineNumber) { if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber)); if (this.lineNumber > 0) throw new IllegalStateException(); this.lineNumber = lineNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initColumnNumber(int columnNumber) { if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber)); if (this.columnNumber > 0) throw new IllegalStateException(); this.columnNumber = columnNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineSource(String lineSource) { if (lineSource == null) throw new IllegalArgumentException(); if (this.lineSource != null) throw new IllegalStateException(); this.lineSource = lineSource; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public static void initGlobal(SecurityController controller) { if (controller == null) throw new IllegalArgumentException(); if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=0; s="constructor"; break; case Id_importClass: arity=1; s="importClass"; break; case Id_importPackage: arity=1; s="importPackage"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(IMPORTER_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ImporterTopLevel.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(IMPORTER_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: return js_construct(scope, args); case Id_importClass: return realThis(thisObj, f).js_importClass(args); case Id_importPackage: return realThis(thisObj, f).js_importPackage(args); } throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: arity=1; s="constructor"; break; case Id_toString: arity=0; s="toString"; break; case Id_toTimeString: arity=0; s="toTimeString"; break; case Id_toDateString: arity=0; s="toDateString"; break; case Id_toLocaleString: arity=0; s="toLocaleString"; break; case Id_toLocaleTimeString: arity=0; s="toLocaleTimeString"; break; case Id_toLocaleDateString: arity=0; s="toLocaleDateString"; break; case Id_toUTCString: arity=0; s="toUTCString"; break; case Id_toSource: arity=0; s="toSource"; break; case Id_valueOf: arity=0; s="valueOf"; break; case Id_getTime: arity=0; s="getTime"; break; case Id_getYear: arity=0; s="getYear"; break; case Id_getFullYear: arity=0; s="getFullYear"; break; case Id_getUTCFullYear: arity=0; s="getUTCFullYear"; break; case Id_getMonth: arity=0; s="getMonth"; break; case Id_getUTCMonth: arity=0; s="getUTCMonth"; break; case Id_getDate: arity=0; s="getDate"; break; case Id_getUTCDate: arity=0; s="getUTCDate"; break; case Id_getDay: arity=0; s="getDay"; break; case Id_getUTCDay: arity=0; s="getUTCDay"; break; case Id_getHours: arity=0; s="getHours"; break; case Id_getUTCHours: arity=0; s="getUTCHours"; break; case Id_getMinutes: arity=0; s="getMinutes"; break; case Id_getUTCMinutes: arity=0; s="getUTCMinutes"; break; case Id_getSeconds: arity=0; s="getSeconds"; break; case Id_getUTCSeconds: arity=0; s="getUTCSeconds"; break; case Id_getMilliseconds: arity=0; s="getMilliseconds"; break; case Id_getUTCMilliseconds: arity=0; s="getUTCMilliseconds"; break; case Id_getTimezoneOffset: arity=0; s="getTimezoneOffset"; break; case Id_setTime: arity=1; s="setTime"; break; case Id_setMilliseconds: arity=1; s="setMilliseconds"; break; case Id_setUTCMilliseconds: arity=1; s="setUTCMilliseconds"; break; case Id_setSeconds: arity=2; s="setSeconds"; break; case Id_setUTCSeconds: arity=2; s="setUTCSeconds"; break; case Id_setMinutes: arity=3; s="setMinutes"; break; case Id_setUTCMinutes: arity=3; s="setUTCMinutes"; break; case Id_setHours: arity=4; s="setHours"; break; case Id_setUTCHours: arity=4; s="setUTCHours"; break; case Id_setDate: arity=1; s="setDate"; break; case Id_setUTCDate: arity=1; s="setUTCDate"; break; case Id_setMonth: arity=2; s="setMonth"; break; case Id_setUTCMonth: arity=2; s="setUTCMonth"; break; case Id_setFullYear: arity=3; s="setFullYear"; break; case Id_setUTCFullYear: arity=3; s="setUTCFullYear"; break; case Id_setYear: arity=1; s="setYear"; break; case Id_toISOString: arity=0; s="toISOString"; break; case Id_toJSON: arity=1; s="toJSON"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(DATE_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(DATE_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case ConstructorId_now: return ScriptRuntime.wrapNumber(now()); case ConstructorId_parse: { String dataStr = ScriptRuntime.toString(args, 0); return ScriptRuntime.wrapNumber(date_parseString(dataStr)); } case ConstructorId_UTC: return ScriptRuntime.wrapNumber(jsStaticFunction_UTC(args)); case Id_constructor: { // if called as a function, just return a string // representing the current time. if (thisObj != null) return date_format(now(), Id_toString); return jsConstructor(args); } case Id_toJSON: { if (thisObj instanceof NativeDate) { return ((NativeDate) thisObj).toISOString(); } final String toISOString = "toISOString"; Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj); Object tv = ScriptRuntime.toPrimitive(o, ScriptRuntime.NumberClass); if (tv instanceof Number) { double d = ((Number) tv).doubleValue(); if (d != d || Double.isInfinite(d)) { return null; } } Object toISO = o.get(toISOString, o); if (toISO == NOT_FOUND) { throw ScriptRuntime.typeError2("msg.function.not.found.in", toISOString, ScriptRuntime.toString(o)); } if ( !(toISO instanceof Callable) ) { throw ScriptRuntime.typeError3("msg.isnt.function.in", toISOString, ScriptRuntime.toString(o), ScriptRuntime.toString(toISO)); } Object result = ((Callable) toISO).call(cx, scope, o, ScriptRuntime.emptyArgs); if ( !ScriptRuntime.isPrimitive(result) ) { throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive", ScriptRuntime.toString(result)); } return result; } } // The rest of Date.prototype methods require thisObj to be Date if (!(thisObj instanceof NativeDate)) throw incompatibleCallError(f); NativeDate realThis = (NativeDate)thisObj; double t = realThis.date; switch (id) { case Id_toString: case Id_toTimeString: case Id_toDateString: if (t == t) { return date_format(t, id); } return js_NaN_date_str; case Id_toLocaleString: case Id_toLocaleTimeString: case Id_toLocaleDateString: if (t == t) { return toLocale_helper(t, id); } return js_NaN_date_str; case Id_toUTCString: if (t == t) { return js_toUTCString(t); } return js_NaN_date_str; case Id_toSource: return "(new Date("+ScriptRuntime.toString(t)+"))"; case Id_valueOf: case Id_getTime: return ScriptRuntime.wrapNumber(t); case Id_getYear: case Id_getFullYear: case Id_getUTCFullYear: if (t == t) { if (id != Id_getUTCFullYear) t = LocalTime(t); t = YearFromTime(t); if (id == Id_getYear) { if (cx.hasFeature(Context.FEATURE_NON_ECMA_GET_YEAR)) { if (1900 <= t && t < 2000) { t -= 1900; } } else { t -= 1900; } } } return ScriptRuntime.wrapNumber(t); case Id_getMonth: case Id_getUTCMonth: if (t == t) { if (id == Id_getMonth) t = LocalTime(t); t = MonthFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getDate: case Id_getUTCDate: if (t == t) { if (id == Id_getDate) t = LocalTime(t); t = DateFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getDay: case Id_getUTCDay: if (t == t) { if (id == Id_getDay) t = LocalTime(t); t = WeekDay(t); } return ScriptRuntime.wrapNumber(t); case Id_getHours: case Id_getUTCHours: if (t == t) { if (id == Id_getHours) t = LocalTime(t); t = HourFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getMinutes: case Id_getUTCMinutes: if (t == t) { if (id == Id_getMinutes) t = LocalTime(t); t = MinFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getSeconds: case Id_getUTCSeconds: if (t == t) { if (id == Id_getSeconds) t = LocalTime(t); t = SecFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getMilliseconds: case Id_getUTCMilliseconds: if (t == t) { if (id == Id_getMilliseconds) t = LocalTime(t); t = msFromTime(t); } return ScriptRuntime.wrapNumber(t); case Id_getTimezoneOffset: if (t == t) { t = (t - LocalTime(t)) / msPerMinute; } return ScriptRuntime.wrapNumber(t); case Id_setTime: t = TimeClip(ScriptRuntime.toNumber(args, 0)); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setMilliseconds: case Id_setUTCMilliseconds: case Id_setSeconds: case Id_setUTCSeconds: case Id_setMinutes: case Id_setUTCMinutes: case Id_setHours: case Id_setUTCHours: t = makeTime(t, args, id); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setDate: case Id_setUTCDate: case Id_setMonth: case Id_setUTCMonth: case Id_setFullYear: case Id_setUTCFullYear: t = makeDate(t, args, id); realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_setYear: { double year = ScriptRuntime.toNumber(args, 0); if (year != year || Double.isInfinite(year)) { t = ScriptRuntime.NaN; } else { if (t != t) { t = 0; } else { t = LocalTime(t); } if (year >= 0 && year <= 99) year += 1900; double day = MakeDay(year, MonthFromTime(t), DateFromTime(t)); t = MakeDate(day, TimeWithinDay(t)); t = internalUTC(t); t = TimeClip(t); } } realThis.date = t; return ScriptRuntime.wrapNumber(t); case Id_toISOString: return realThis.toISOString(); default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
Override protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_close: arity=1; s="close"; break; case Id_next: arity=1; s="next"; break; case Id_send: arity=0; s="send"; break; case Id_throw: arity=0; s="throw"; break; case Id___iterator__: arity=1; s="__iterator__"; break; default: throw new IllegalArgumentException(String.valueOf(id)); } initPrototypeMethod(GENERATOR_TAG, id, s, arity); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(GENERATOR_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); if (!(thisObj instanceof NativeGenerator)) throw incompatibleCallError(f); NativeGenerator generator = (NativeGenerator) thisObj; switch (id) { case Id_close: // need to run any pending finally clauses return generator.resume(cx, scope, GENERATOR_CLOSE, new GeneratorClosedException()); case Id_next: // arguments to next() are ignored generator.firstTime = false; return generator.resume(cx, scope, GENERATOR_SEND, Undefined.instance); case Id_send: { Object arg = args.length > 0 ? args[0] : Undefined.instance; if (generator.firstTime && !arg.equals(Undefined.instance)) { throw ScriptRuntime.typeError0("msg.send.newborn"); } return generator.resume(cx, scope, GENERATOR_SEND, arg); } case Id_throw: return generator.resume(cx, scope, GENERATOR_THROW, args.length > 0 ? args[0] : Undefined.instance); case Id___iterator__: return thisObj; default: throw new IllegalArgumentException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
public final void setSize(int newSize) { if (newSize < 0) throw new IllegalArgumentException(); if (sealed) throw onSeledMutation(); int N = size; if (newSize < N) { for (int i = newSize; i != N; ++i) { setImpl(i, null); } } else if (newSize > N) { if (newSize > FIELDS_STORE_SIZE) { ensureCapacity(newSize); } } size = newSize; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private void ensureCapacity(int minimalCapacity) { int required = minimalCapacity - FIELDS_STORE_SIZE; if (required <= 0) throw new IllegalArgumentException(); if (data == null) { int alloc = FIELDS_STORE_SIZE * 2; if (alloc < required) { alloc = required; } data = new Object[alloc]; } else { int alloc = data.length; if (alloc < required) { if (alloc <= FIELDS_STORE_SIZE) { alloc = FIELDS_STORE_SIZE * 2; } else { alloc *= 2; } if (alloc < required) { alloc = required; } Object[] tmp = new Object[alloc]; if (size > FIELDS_STORE_SIZE) { System.arraycopy(data, 0, tmp, 0, size - FIELDS_STORE_SIZE); } data = tmp; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final void initValue(int id, String name, Object value, int attributes) { if (!(1 <= id && id <= maxId)) throw new IllegalArgumentException(); if (name == null) throw new IllegalArgumentException(); if (value == NOT_FOUND) throw new IllegalArgumentException(); ScriptableObject.checkValidAttributes(attributes); if (obj.findPrototypeId(name) != id) throw new IllegalArgumentException(name); if (id == constructorId) { if (!(value instanceof IdFunctionObject)) { throw new IllegalArgumentException("consructor should be initialized with IdFunctionObject"); } constructor = (IdFunctionObject)value; constructorAttrs = (short)attributes; return; } initSlot(id, name, value, attributes); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final void set(int id, Scriptable start, Object value) { if (value == NOT_FOUND) throw new IllegalArgumentException(); ensureId(id); int attr = attributeArray[id - 1]; if ((attr & READONLY) == 0) { if (start == obj) { if (value == null) { value = UniqueTag.NULL_VALUE; } int valueSlot = (id - 1) * SLOT_SPAN; synchronized (this) { valueArray[valueSlot] = value; } } else { int nameSlot = (id - 1) * SLOT_SPAN + NAME_SLOT; String name = (String)valueArray[nameSlot]; start.put(name, start, value); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected String getInstanceIdName(int id) { throw new IllegalArgumentException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void initPrototypeConstructor(IdFunctionObject f) { int id = prototypeValues.constructorId; if (id == 0) throw new IllegalStateException(); if (f.methodId() != id) throw new IllegalArgumentException(); if (isSealed()) { f.sealObject(); } prototypeValues.initValue(id, "constructor", f, DONTENUM); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ClassCache.java
public boolean associate(ScriptableObject topScope) { if (topScope.getParentScope() != null) { // Can only associate cache with top level scope throw new IllegalArgumentException(); } if (this == topScope.associateValue(AKEY, this)) { associatedScope = topScope; return true; } return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
public void addOptionalExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if(obj != null && obj != UniqueTag.NOT_FOUND) { if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException( "Object for excluded name " + name + " is not a Scriptable, it is " + obj.getClass().getName()); } table.put(obj, name); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
void addToken(int token) { if (!(0 <= token && token <= Token.LAST_TOKEN)) throw new IllegalArgumentException(); append((char)token); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
void addEOL(int token) { if (!(0 <= token && token <= Token.LAST_TOKEN)) throw new IllegalArgumentException(); append((char)token); append((char)Token.EOL); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
public static String decompile(String source, int flags, UintMap properties) { int length = source.length(); if (length == 0) { return ""; } int indent = properties.getInt(INITIAL_INDENT_PROP, 0); if (indent < 0) throw new IllegalArgumentException(); int indentGap = properties.getInt(INDENT_GAP_PROP, 4); if (indentGap < 0) throw new IllegalArgumentException(); int caseGap = properties.getInt(CASE_GAP_PROP, 2); if (caseGap < 0) throw new IllegalArgumentException(); StringBuffer result = new StringBuffer(); boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG)); boolean toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG)); // Spew tokens in source, for debugging. // as TYPE number char if (printSource) { System.err.println("length:" + length); for (int i = 0; i < length; ++i) { // Note that tokenToName will fail unless Context.printTrees // is true. String tokenname = null; if (Token.printNames) { tokenname = Token.name(source.charAt(i)); } if (tokenname == null) { tokenname = "---"; } String pad = tokenname.length() > 7 ? "\t" : "\t\t"; System.err.println (tokenname + pad + (int)source.charAt(i) + "\t'" + ScriptRuntime.escapeString (source.substring(i, i+1)) + "'"); } System.err.println(); } int braceNesting = 0; boolean afterFirstEOL = false; int i = 0; int topFunctionType; if (source.charAt(i) == Token.SCRIPT) { ++i; topFunctionType = -1; } else { topFunctionType = source.charAt(i + 1); } if (!toSource) { // add an initial newline to exactly match js. result.append('\n'); for (int j = 0; j < indent; j++) result.append(' '); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append('('); } } while (i < length) { switch(source.charAt(i)) { case Token.GET: case Token.SET: result.append(source.charAt(i) == Token.GET ? "get " : "set "); ++i; i = printSourceString(source, i + 1, false, result); // Now increment one more to get past the FUNCTION token ++i; break; case Token.NAME: case Token.REGEXP: // re-wrapped in '/'s in parser... i = printSourceString(source, i + 1, false, result); continue; case Token.STRING: i = printSourceString(source, i + 1, true, result); continue; case Token.NUMBER: i = printSourceNumber(source, i + 1, result); continue; case Token.TRUE: result.append("true"); break; case Token.FALSE: result.append("false"); break; case Token.NULL: result.append("null"); break; case Token.THIS: result.append("this"); break; case Token.FUNCTION: ++i; // skip function type result.append("function "); break; case FUNCTION_END: // Do nothing break; case Token.COMMA: result.append(", "); break; case Token.LC: ++braceNesting; if (Token.EOL == getNext(source, length, i)) indent += indentGap; result.append('{'); break; case Token.RC: { --braceNesting; /* don't print the closing RC if it closes the * toplevel function and we're called from * decompileFunctionBody. */ if (justFunctionBody && braceNesting == 0) break; result.append('}'); switch (getNext(source, length, i)) { case Token.EOL: case FUNCTION_END: indent -= indentGap; break; case Token.WHILE: case Token.ELSE: indent -= indentGap; result.append(' '); break; } break; } case Token.LP: result.append('('); break; case Token.RP: result.append(')'); if (Token.LC == getNext(source, length, i)) result.append(' '); break; case Token.LB: result.append('['); break; case Token.RB: result.append(']'); break; case Token.EOL: { if (toSource) break; boolean newLine = true; if (!afterFirstEOL) { afterFirstEOL = true; if (justFunctionBody) { /* throw away just added 'function name(...) {' * and restore the original indent */ result.setLength(0); indent -= indentGap; newLine = false; } } if (newLine) { result.append('\n'); } /* add indent if any tokens remain, * less setback if next token is * a label, case or default. */ if (i + 1 < length) { int less = 0; int nextToken = source.charAt(i + 1); if (nextToken == Token.CASE || nextToken == Token.DEFAULT) { less = indentGap - caseGap; } else if (nextToken == Token.RC) { less = indentGap; } /* elaborate check against label... skip past a * following inlined NAME and look for a COLON. */ else if (nextToken == Token.NAME) { int afterName = getSourceStringEnd(source, i + 2); if (source.charAt(afterName) == Token.COLON) less = indentGap; } for (; less < indent; less++) result.append(' '); } break; } case Token.DOT: result.append('.'); break; case Token.NEW: result.append("new "); break; case Token.DELPROP: result.append("delete "); break; case Token.IF: result.append("if "); break; case Token.ELSE: result.append("else "); break; case Token.FOR: result.append("for "); break; case Token.IN: result.append(" in "); break; case Token.WITH: result.append("with "); break; case Token.WHILE: result.append("while "); break; case Token.DO: result.append("do "); break; case Token.TRY: result.append("try "); break; case Token.CATCH: result.append("catch "); break; case Token.FINALLY: result.append("finally "); break; case Token.THROW: result.append("throw "); break; case Token.SWITCH: result.append("switch "); break; case Token.BREAK: result.append("break"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CONTINUE: result.append("continue"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CASE: result.append("case "); break; case Token.DEFAULT: result.append("default"); break; case Token.RETURN: result.append("return"); if (Token.SEMI != getNext(source, length, i)) result.append(' '); break; case Token.VAR: result.append("var "); break; case Token.LET: result.append("let "); break; case Token.SEMI: result.append(';'); if (Token.EOL != getNext(source, length, i)) { // separators in FOR result.append(' '); } break; case Token.ASSIGN: result.append(" = "); break; case Token.ASSIGN_ADD: result.append(" += "); break; case Token.ASSIGN_SUB: result.append(" -= "); break; case Token.ASSIGN_MUL: result.append(" *= "); break; case Token.ASSIGN_DIV: result.append(" /= "); break; case Token.ASSIGN_MOD: result.append(" %= "); break; case Token.ASSIGN_BITOR: result.append(" |= "); break; case Token.ASSIGN_BITXOR: result.append(" ^= "); break; case Token.ASSIGN_BITAND: result.append(" &= "); break; case Token.ASSIGN_LSH: result.append(" <<= "); break; case Token.ASSIGN_RSH: result.append(" >>= "); break; case Token.ASSIGN_URSH: result.append(" >>>= "); break; case Token.HOOK: result.append(" ? "); break; case Token.OBJECTLIT: // pun OBJECTLIT to mean colon in objlit property // initialization. // This needs to be distinct from COLON in the general case // to distinguish from the colon in a ternary... which needs // different spacing. result.append(':'); break; case Token.COLON: if (Token.EOL == getNext(source, length, i)) // it's the end of a label result.append(':'); else // it's the middle part of a ternary result.append(" : "); break; case Token.OR: result.append(" || "); break; case Token.AND: result.append(" && "); break; case Token.BITOR: result.append(" | "); break; case Token.BITXOR: result.append(" ^ "); break; case Token.BITAND: result.append(" & "); break; case Token.SHEQ: result.append(" === "); break; case Token.SHNE: result.append(" !== "); break; case Token.EQ: result.append(" == "); break; case Token.NE: result.append(" != "); break; case Token.LE: result.append(" <= "); break; case Token.LT: result.append(" < "); break; case Token.GE: result.append(" >= "); break; case Token.GT: result.append(" > "); break; case Token.INSTANCEOF: result.append(" instanceof "); break; case Token.LSH: result.append(" << "); break; case Token.RSH: result.append(" >> "); break; case Token.URSH: result.append(" >>> "); break; case Token.TYPEOF: result.append("typeof "); break; case Token.VOID: result.append("void "); break; case Token.CONST: result.append("const "); break; case Token.YIELD: result.append("yield "); break; case Token.NOT: result.append('!'); break; case Token.BITNOT: result.append('~'); break; case Token.POS: result.append('+'); break; case Token.NEG: result.append('-'); break; case Token.INC: result.append("++"); break; case Token.DEC: result.append("--"); break; case Token.ADD: result.append(" + "); break; case Token.SUB: result.append(" - "); break; case Token.MUL: result.append(" * "); break; case Token.DIV: result.append(" / "); break; case Token.MOD: result.append(" % "); break; case Token.COLONCOLON: result.append("::"); break; case Token.DOTDOT: result.append(".."); break; case Token.DOTQUERY: result.append(".("); break; case Token.XMLATTR: result.append('@'); break; case Token.DEBUGGER: result.append("debugger;\n"); break; default: // If we don't know how to decompile it, raise an exception. throw new RuntimeException("Token: " + Token.name(source.charAt(i))); } ++i; } if (!toSource) { // add that trailing newline if it's an outermost function. if (!justFunctionBody) result.append('\n'); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append(')'); } } return result.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (scope == null) throw new IllegalArgumentException(); if (cx.topCallScope != null) throw new IllegalStateException(); Object result; cx.topCallScope = ScriptableObject.getTopLevelScope(scope); cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE); ContextFactory f = cx.getFactory(); try { result = f.doTopCall(callable, cx, scope, thisObj, args); } finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object[] getArrayElements(Scriptable object) { Context cx = Context.getContext(); long longLen = NativeArray.getLengthProperty(cx, object); if (longLen > Integer.MAX_VALUE) { // arrays beyond MAX_INT is not in Java in any case throw new IllegalArgumentException(); } int len = (int) longLen; if (len == 0) { return ScriptRuntime.emptyArgs; } else { Object[] result = new Object[len]; for (int i=0; i < len; i++) { Object elem = ScriptableObject.getProperty(object, i); result[i] = (elem == Scriptable.NOT_FOUND) ? Undefined.instance : elem; } return result; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void setRegExpProxy(Context cx, RegExpProxy proxy) { if (proxy == null) throw new IllegalArgumentException(); cx.regExpProxy = proxy; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void storeUint32Result(Context cx, long value) { if ((value >>> 32) != 0) throw new IllegalArgumentException(); cx.scratchUint32 = value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void unseal(Object sealKey) { if (sealKey == null) throw new IllegalArgumentException(); if (this.sealKey != sealKey) throw new IllegalArgumentException(); if (!sealed) throw new IllegalStateException(); sealed = false; this.sealKey = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void checkLanguageVersion(int version) { if (isValidLanguageVersion(version)) { return; } throw new IllegalArgumentException("Bad language version: "+version); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object executeScriptWithContinuations(Script script, Scriptable scope) throws ContinuationPending { if (!(script instanceof InterpretedFunction) || !((InterpretedFunction)script).isScript()) { // Can only be applied to scripts throw new IllegalArgumentException("Script argument was not" + " a script or was not created by interpreted mode "); } return callFunctionWithContinuations((InterpretedFunction) script, scope, ScriptRuntime.emptyArgs); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object callFunctionWithContinuations(Callable function, Scriptable scope, Object[] args) throws ContinuationPending { if (!(function instanceof InterpretedFunction)) { // Can only be applied to scripts throw new IllegalArgumentException("Function argument was not" + " created by interpreted mode "); } if (ScriptRuntime.hasTopCall(this)) { throw new IllegalStateException("Cannot have any pending top " + "calls when executing a script with continuations"); } // Annotate so we can check later to ensure no java code in // intervening frames isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Scriptable newArray(Scriptable scope, Object[] elements) { if (elements.getClass().getComponentType() != ScriptRuntime.ObjectClass) throw new IllegalArgumentException(); NativeArray result = new NativeArray(elements); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Array); return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void checkOptimizationLevel(int optimizationLevel) { if (isValidOptimizationLevel(optimizationLevel)) { return; } throw new IllegalArgumentException( "Optimization level outside [-1..9]: "+optimizationLevel); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setMaximumInterpreterStackDepth(int max) { if(sealed) onSealedMutation(); if(optimizationLevel != -1) { throw new IllegalStateException("Cannot set maximumInterpreterStackDepth when optimizationLevel != -1"); } if(max < 1) { throw new IllegalArgumentException("Cannot set maximumInterpreterStackDepth to less than 1"); } maximumInterpreterStackDepth = max; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setSecurityController(SecurityController controller) { if (sealed) onSealedMutation(); if (controller == null) throw new IllegalArgumentException(); if (securityController != null) { throw new SecurityException("Can not overwrite existing SecurityController object"); } if (SecurityController.hasGlobal()) { throw new SecurityException("Can not overwrite existing global SecurityController object"); } securityController = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public synchronized final void setClassShutter(ClassShutter shutter) { if (sealed) onSealedMutation(); if (shutter == null) throw new IllegalArgumentException(); if (hasClassShutter) { throw new SecurityException("Cannot overwrite existing " + "ClassShutter object"); } classShutter = shutter; hasClassShutter = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setWrapFactory(WrapFactory wrapFactory) { if (sealed) onSealedMutation(); if (wrapFactory == null) throw new IllegalArgumentException(); this.wrapFactory = wrapFactory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setInstructionObserverThreshold(int threshold) { if (sealed) onSealedMutation(); if (threshold < 0) throw new IllegalArgumentException(); instructionThreshold = threshold; setGenerateObserverCount(threshold > 0); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setApplicationClassLoader(ClassLoader loader) { if (sealed) onSealedMutation(); if (loader == null) { // restore default behaviour applicationClassLoader = null; return; } if (!Kit.testIfCanLoadRhinoClasses(loader)) { throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); } applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdFunctionObject.java
public void initFunction(String name, Scriptable scope) { if (name == null) throw new IllegalArgumentException(); if (scope == null) throw new IllegalArgumentException(); this.functionName = name; setParentScope(scope); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode) { if (opcodeCount(theOpCode) != 0) throw new IllegalArgumentException("Unexpected operands"); int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (DEBUGCODE) System.out.println("Add " + bytecodeStr(theOpCode)); addToCodeBuffer(theOpCode); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } if (theOpCode == ByteCode.ATHROW) { addSuperBlockStart(itsCodeBufferTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.GOTO : // This is necessary because dead code is seemingly being // generated and Sun's verifier is expecting type state to be // placed even at dead blocks of code. addSuperBlockStart(itsCodeBufferTop + 3); // fallthru... case ByteCode.IFEQ : case ByteCode.IFNE : case ByteCode.IFLT : case ByteCode.IFGE : case ByteCode.IFGT : case ByteCode.IFLE : case ByteCode.IF_ICMPEQ : case ByteCode.IF_ICMPNE : case ByteCode.IF_ICMPLT : case ByteCode.IF_ICMPGE : case ByteCode.IF_ICMPGT : case ByteCode.IF_ICMPLE : case ByteCode.IF_ACMPEQ : case ByteCode.IF_ACMPNE : case ByteCode.JSR : case ByteCode.IFNULL : case ByteCode.IFNONNULL : { if ((theOperand & 0x80000000) != 0x80000000) { if ((theOperand < 0) || (theOperand > 65535)) throw new IllegalArgumentException( "Bad label for branch"); } int branchPC = itsCodeBufferTop; addToCodeBuffer(theOpCode); if ((theOperand & 0x80000000) != 0x80000000) { // hard displacement addToCodeInt16(theOperand); int target = theOperand + branchPC; addSuperBlockStart(target); itsJumpFroms.put(target, branchPC); } else { // a label int targetPC = getLabelPC(theOperand); if (DEBUGLABELS) { int theLabel = theOperand & 0x7FFFFFFF; System.out.println("Fixing branch to " + theLabel + " at " + targetPC + " from " + branchPC); } if (targetPC != -1) { int offset = targetPC - branchPC; addToCodeInt16(offset); addSuperBlockStart(targetPC); itsJumpFroms.put(targetPC, branchPC); } else { addLabelFixup(theOperand, branchPC + 1); addToCodeInt16(0); } } } break; case ByteCode.BIPUSH : if ((byte)theOperand != theOperand) throw new IllegalArgumentException("out of range byte"); addToCodeBuffer(theOpCode); addToCodeBuffer((byte)theOperand); break; case ByteCode.SIPUSH : if ((short)theOperand != theOperand) throw new IllegalArgumentException("out of range short"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.NEWARRAY : if (!(0 <= theOperand && theOperand < 256)) throw new IllegalArgumentException("out of range index"); addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); break; case ByteCode.GETFIELD : case ByteCode.PUTFIELD : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range field"); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); break; case ByteCode.LDC : case ByteCode.LDC_W : case ByteCode.LDC2_W : if (!(0 <= theOperand && theOperand < 65536)) throw new IllegalArgumentException("out of range index"); if (theOperand >= 256 || theOpCode == ByteCode.LDC_W || theOpCode == ByteCode.LDC2_W) { if (theOpCode == ByteCode.LDC) { addToCodeBuffer(ByteCode.LDC_W); } else { addToCodeBuffer(theOpCode); } addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; case ByteCode.RET : case ByteCode.ILOAD : case ByteCode.LLOAD : case ByteCode.FLOAD : case ByteCode.DLOAD : case ByteCode.ALOAD : case ByteCode.ISTORE : case ByteCode.LSTORE : case ByteCode.FSTORE : case ByteCode.DSTORE : case ByteCode.ASTORE : if (!(0 <= theOperand && theOperand < 65536)) throw new ClassFileFormatException("out of range variable"); if (theOperand >= 256) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(theOpCode); addToCodeInt16(theOperand); } else { addToCodeBuffer(theOpCode); addToCodeBuffer(theOperand); } break; default : throw new IllegalArgumentException( "Unexpected opcode for 1 operand"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, int theOperand1, int theOperand2) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+Integer.toHexString(theOperand1) +", "+Integer.toHexString(theOperand2)); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); if (theOpCode == ByteCode.IINC) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new ClassFileFormatException("out of range variable"); if (!(0 <= theOperand2 && theOperand2 < 65536)) throw new ClassFileFormatException("out of range increment"); if (theOperand1 > 255 || theOperand2 < -128 || theOperand2 > 127) { addToCodeBuffer(ByteCode.WIDE); addToCodeBuffer(ByteCode.IINC); addToCodeInt16(theOperand1); addToCodeInt16(theOperand2); } else { addToCodeBuffer(ByteCode.IINC); addToCodeBuffer(theOperand1); addToCodeBuffer(theOperand2); } } else if (theOpCode == ByteCode.MULTIANEWARRAY) { if (!(0 <= theOperand1 && theOperand1 < 65536)) throw new IllegalArgumentException("out of range index"); if (!(0 <= theOperand2 && theOperand2 < 256)) throw new IllegalArgumentException("out of range dimensions"); addToCodeBuffer(ByteCode.MULTIANEWARRAY); addToCodeInt16(theOperand1); addToCodeBuffer(theOperand2); } else { throw new IllegalArgumentException( "Unexpected opcode for 2 operands"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, String className) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className); } int newStack = itsStackTop + stackChange(theOpCode); if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.NEW : case ByteCode.ANEWARRAY : case ByteCode.CHECKCAST : case ByteCode.INSTANCEOF : { short classIndex = itsConstantPool.addClass(className); addToCodeBuffer(theOpCode); addToCodeInt16(classIndex); } break; default : throw new IllegalArgumentException( "bad opcode for class reference"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void add(int theOpCode, String className, String fieldName, String fieldType) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className+", "+fieldName+", "+fieldType); } int newStack = itsStackTop + stackChange(theOpCode); char fieldTypeChar = fieldType.charAt(0); int fieldSize = (fieldTypeChar == 'J' || fieldTypeChar == 'D') ? 2 : 1; switch (theOpCode) { case ByteCode.GETFIELD : case ByteCode.GETSTATIC : newStack += fieldSize; break; case ByteCode.PUTSTATIC : case ByteCode.PUTFIELD : newStack -= fieldSize; break; default : throw new IllegalArgumentException( "bad opcode for field reference"); } if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); short fieldRefIndex = itsConstantPool.addFieldRef(className, fieldName, fieldType); addToCodeBuffer(theOpCode); addToCodeInt16(fieldRefIndex); itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addInvoke(int theOpCode, String className, String methodName, String methodType) { if (DEBUGCODE) { System.out.println("Add "+bytecodeStr(theOpCode) +", "+className+", "+methodName+", " +methodType); } int parameterInfo = sizeOfParameters(methodType); int parameterCount = parameterInfo >>> 16; int stackDiff = (short)parameterInfo; int newStack = itsStackTop + stackDiff; newStack += stackChange(theOpCode); // adjusts for 'this' if (newStack < 0 || Short.MAX_VALUE < newStack) badStack(newStack); switch (theOpCode) { case ByteCode.INVOKEVIRTUAL : case ByteCode.INVOKESPECIAL : case ByteCode.INVOKESTATIC : case ByteCode.INVOKEINTERFACE : { addToCodeBuffer(theOpCode); if (theOpCode == ByteCode.INVOKEINTERFACE) { short ifMethodRefIndex = itsConstantPool.addInterfaceMethodRef( className, methodName, methodType); addToCodeInt16(ifMethodRefIndex); addToCodeBuffer(parameterCount + 1); addToCodeBuffer(0); } else { short methodRefIndex = itsConstantPool.addMethodRef( className, methodName, methodType); addToCodeInt16(methodRefIndex); } } break; default : throw new IllegalArgumentException( "bad opcode for method reference"); } itsStackTop = (short)newStack; if (newStack > itsMaxStack) itsMaxStack = (short)newStack; if (DEBUGSTACK) { System.out.println("After "+bytecodeStr(theOpCode) +" stack = "+itsStackTop); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public final void markTableSwitchCase(int switchStart, int caseIndex, int stackTop) { if (!(0 <= stackTop && stackTop <= itsMaxStack)) throw new IllegalArgumentException("Bad stack index: "+stackTop); itsStackTop = (short)stackTop; addSuperBlockStart(itsCodeBufferTop); itsJumpFroms.put(itsCodeBufferTop, switchStart); setTableSwitchJump(switchStart, caseIndex, itsCodeBufferTop); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget) { if (!(0 <= jumpTarget && jumpTarget <= itsCodeBufferTop)) throw new IllegalArgumentException("Bad jump target: "+jumpTarget); if (!(caseIndex >= -1)) throw new IllegalArgumentException("Bad case index: "+caseIndex); int padSize = 3 & ~switchStart; // == 3 - switchStart % 4 int caseOffset; if (caseIndex < 0) { // default label caseOffset = switchStart + 1 + padSize; } else { caseOffset = switchStart + 1 + padSize + 4 * (3 + caseIndex); } if (!(0 <= switchStart && switchStart <= itsCodeBufferTop - 4 * 4 - padSize - 1)) { throw new IllegalArgumentException( switchStart+" is outside a possible range of tableswitch" +" in already generated code"); } if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) { throw new IllegalArgumentException( switchStart+" is not offset of tableswitch statement"); } if (!(0 <= caseOffset && caseOffset + 4 <= itsCodeBufferTop)) { // caseIndex >= -1 does not guarantee that caseOffset >= 0 due // to a possible overflow. throw new ClassFileFormatException( "Too big case index: "+caseIndex); } // ALERT: perhaps check against case bounds? putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void markLabel(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (label > itsLabelTableTop) throw new IllegalArgumentException("Bad label"); if (itsLabelTable[label] != -1) { throw new IllegalStateException("Can only mark label once"); } itsLabelTable[label] = itsCodeBufferTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public int getLabelPC(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (!(label < itsLabelTableTop)) throw new IllegalArgumentException("Bad label"); return itsLabelTable[label]; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void addLabelFixup(int label, int fixupSite) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (!(label < itsLabelTableTop)) throw new IllegalArgumentException("Bad label"); int top = itsFixupTableTop; if (itsFixupTable == null || top == itsFixupTable.length) { if (itsFixupTable == null) { itsFixupTable = new long[MIN_FIXUP_TABLE_SIZE]; }else { long[] tmp = new long[itsFixupTable.length * 2]; System.arraycopy(itsFixupTable, 0, tmp, 0, top); itsFixupTable = tmp; } } itsFixupTableTop = top + 1; itsFixupTable[top] = ((long)label << 32) | fixupSite; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int addReservedCodeSpace(int size) { if (itsCurrentMethod == null) throw new IllegalArgumentException("No method to add to"); int oldTop = itsCodeBufferTop; int newTop = oldTop + size; if (newTop > itsCodeBuffer.length) { int newSize = itsCodeBuffer.length * 2; if (newTop > newSize) { newSize = newTop; } byte[] tmp = new byte[newSize]; System.arraycopy(itsCodeBuffer, 0, tmp, 0, oldTop); itsCodeBuffer = tmp; } itsCodeBufferTop = newTop; return oldTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addExceptionHandler(int startLabel, int endLabel, int handlerLabel, String catchClassName) { if ((startLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad startLabel"); if ((endLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad endLabel"); if ((handlerLabel & 0x80000000) != 0x80000000) throw new IllegalArgumentException("Bad handlerLabel"); /* * If catchClassName is null, use 0 for the catch_type_index; which * means catch everything. (Even when the verifier has let you throw * something other than a Throwable.) */ short catch_type_index = (catchClassName == null) ? 0 : itsConstantPool.addClass(catchClassName); ExceptionTableEntry newEntry = new ExceptionTableEntry( startLabel, endLabel, handlerLabel, catch_type_index); int N = itsExceptionTableTop; if (N == 0) { itsExceptionTable = new ExceptionTableEntry[ExceptionTableSize]; } else if (N == itsExceptionTable.length) { ExceptionTableEntry[] tmp = new ExceptionTableEntry[N * 2]; System.arraycopy(itsExceptionTable, 0, tmp, 0, N); itsExceptionTable = tmp; } itsExceptionTable[N] = newEntry; itsExceptionTableTop = N + 1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void addLineNumberEntry(short lineNumber) { if (itsCurrentMethod == null) throw new IllegalArgumentException("No method to stop"); int N = itsLineNumberTableTop; if (N == 0) { itsLineNumberTable = new int[LineNumberTableSize]; } else if (N == itsLineNumberTable.length) { int[] tmp = new int[N * 2]; System.arraycopy(itsLineNumberTable, 0, tmp, 0, N); itsLineNumberTable = tmp; } itsLineNumberTable[N] = (itsCodeBufferTop << 16) + lineNumber; itsLineNumberTableTop = N + 1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private SuperBlock getSuperBlockFromOffset(int offset) { for (int i = 0; i < superBlocks.length; i++) { SuperBlock sb = superBlocks[i]; if (sb == null) { break; } else if (offset >= sb.getStart() && offset < sb.getEnd()) { return sb; } } throw new IllegalArgumentException("bad offset: " + offset); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int getOperand(int start, int size) { int result = 0; if (size > 4) { throw new IllegalArgumentException("bad operand size"); } for (int i = 0; i < size; i++) { result = (result << 8) | (itsCodeBuffer[start + i] & 0xFF); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int execute(int bci) { int bc = itsCodeBuffer[bci] & 0xFF; int type, type2, index; int length = 0; long lType, lType2; String className; switch (bc) { case ByteCode.NOP: case ByteCode.IINC: case ByteCode.GOTO: case ByteCode.GOTO_W: // No change break; case ByteCode.CHECKCAST: pop(); push(TypeInfo.OBJECT(getOperand(bci + 1, 2))); break; case ByteCode.IASTORE: // pop; pop; pop case ByteCode.LASTORE: case ByteCode.FASTORE: case ByteCode.DASTORE: case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: pop(); case ByteCode.PUTFIELD: // pop; pop case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPNE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: pop(); case ByteCode.IFEQ: // pop case ByteCode.IFNE: case ByteCode.IFLT: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFNULL: case ByteCode.IFNONNULL: case ByteCode.POP: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.PUTSTATIC: pop(); break; case ByteCode.POP2: pop2(); break; case ByteCode.ACONST_NULL: push(TypeInfo.NULL); break; case ByteCode.IALOAD: // pop; pop; push(INTEGER) case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: case ByteCode.IADD: case ByteCode.ISUB: case ByteCode.IMUL: case ByteCode.IDIV: case ByteCode.IREM: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.IUSHR: case ByteCode.IAND: case ByteCode.IOR: case ByteCode.IXOR: case ByteCode.LCMP: case ByteCode.FCMPL: case ByteCode.FCMPG: case ByteCode.DCMPL: case ByteCode.DCMPG: pop(); case ByteCode.INEG: // pop; push(INTEGER) case ByteCode.L2I: case ByteCode.F2I: case ByteCode.D2I: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2S: case ByteCode.ARRAYLENGTH: case ByteCode.INSTANCEOF: pop(); case ByteCode.ICONST_M1: // push(INTEGER) case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.BIPUSH: case ByteCode.SIPUSH: push(TypeInfo.INTEGER); break; case ByteCode.LALOAD: // pop; pop; push(LONG) case ByteCode.LADD: case ByteCode.LSUB: case ByteCode.LMUL: case ByteCode.LDIV: case ByteCode.LREM: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.LAND: case ByteCode.LOR: case ByteCode.LXOR: pop(); case ByteCode.LNEG: // pop; push(LONG) case ByteCode.I2L: case ByteCode.F2L: case ByteCode.D2L: pop(); case ByteCode.LCONST_0: // push(LONG) case ByteCode.LCONST_1: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: push(TypeInfo.LONG); break; case ByteCode.FALOAD: // pop; pop; push(FLOAT) case ByteCode.FADD: case ByteCode.FSUB: case ByteCode.FMUL: case ByteCode.FDIV: case ByteCode.FREM: pop(); case ByteCode.FNEG: // pop; push(FLOAT) case ByteCode.I2F: case ByteCode.L2F: case ByteCode.D2F: pop(); case ByteCode.FCONST_0: // push(FLOAT) case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: push(TypeInfo.FLOAT); break; case ByteCode.DALOAD: // pop; pop; push(DOUBLE) case ByteCode.DADD: case ByteCode.DSUB: case ByteCode.DMUL: case ByteCode.DDIV: case ByteCode.DREM: pop(); case ByteCode.DNEG: // pop; push(DOUBLE) case ByteCode.I2D: case ByteCode.L2D: case ByteCode.F2D: pop(); case ByteCode.DCONST_0: // push(DOUBLE) case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: push(TypeInfo.DOUBLE); break; case ByteCode.ISTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.INTEGER); break; case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: executeStore(bc - ByteCode.ISTORE_0, TypeInfo.INTEGER); break; case ByteCode.LSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.LONG); break; case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: executeStore(bc - ByteCode.LSTORE_0, TypeInfo.LONG); break; case ByteCode.FSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.FLOAT); break; case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: executeStore(bc - ByteCode.FSTORE_0, TypeInfo.FLOAT); break; case ByteCode.DSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.DOUBLE); break; case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: executeStore(bc - ByteCode.DSTORE_0, TypeInfo.DOUBLE); break; case ByteCode.ALOAD: executeALoad(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: executeALoad(bc - ByteCode.ALOAD_0); break; case ByteCode.ASTORE: executeAStore(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: executeAStore(bc - ByteCode.ASTORE_0); break; case ByteCode.IRETURN: case ByteCode.LRETURN: case ByteCode.FRETURN: case ByteCode.DRETURN: case ByteCode.ARETURN: case ByteCode.RETURN: clearStack(); break; case ByteCode.ATHROW: type = pop(); clearStack(); push(type); break; case ByteCode.SWAP: type = pop(); type2 = pop(); push(type); push(type2); break; case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.LDC2_W: if (bc == ByteCode.LDC) { index = getOperand(bci + 1); } else { index = getOperand(bci + 1, 2); } byte constType = itsConstantPool.getConstantType(index); switch (constType) { case ConstantPool.CONSTANT_Double: push(TypeInfo.DOUBLE); break; case ConstantPool.CONSTANT_Float: push(TypeInfo.FLOAT); break; case ConstantPool.CONSTANT_Long: push(TypeInfo.LONG); break; case ConstantPool.CONSTANT_Integer: push(TypeInfo.INTEGER); break; case ConstantPool.CONSTANT_String: push(TypeInfo.OBJECT("java/lang/String", itsConstantPool)); break; default: throw new IllegalArgumentException( "bad const type " + constType); } break; case ByteCode.NEW: push(TypeInfo.UNINITIALIZED_VARIABLE(bci)); break; case ByteCode.NEWARRAY: pop(); char componentType = arrayTypeToName(itsCodeBuffer[bci + 1]); index = itsConstantPool.addClass("[" + componentType); push(TypeInfo.OBJECT((short) index)); break; case ByteCode.ANEWARRAY: index = getOperand(bci + 1, 2); className = (String) itsConstantPool.getConstantData(index); pop(); push(TypeInfo.OBJECT("[L" + className + ';', itsConstantPool)); break; case ByteCode.INVOKEVIRTUAL: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEINTERFACE: index = getOperand(bci + 1, 2); FieldOrMethodRef m = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String methodType = m.getType(); String methodName = m.getName(); int parameterCount = sizeOfParameters(methodType) >>> 16; for (int i = 0; i < parameterCount; i++) { pop(); } if (bc != ByteCode.INVOKESTATIC) { int instType = pop(); int tag = TypeInfo.getTag(instType); if (tag == TypeInfo.UNINITIALIZED_VARIABLE(0) || tag == TypeInfo.UNINITIALIZED_THIS) { if ("<init>".equals(methodName)) { int newType = TypeInfo.OBJECT(itsThisClassIndex); initializeTypeInfo(instType, newType); } else { throw new IllegalStateException("bad instance"); } } } int rParen = methodType.indexOf(')'); String returnType = methodType.substring(rParen + 1); returnType = descriptorToInternalName(returnType); if (!returnType.equals("V")) { push(TypeInfo.fromType(returnType, itsConstantPool)); } break; case ByteCode.GETFIELD: pop(); case ByteCode.GETSTATIC: index = getOperand(bci + 1, 2); FieldOrMethodRef f = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String fieldType = descriptorToInternalName(f.getType()); push(TypeInfo.fromType(fieldType, itsConstantPool)); break; case ByteCode.DUP: type = pop(); push(type); push(type); break; case ByteCode.DUP_X1: type = pop(); type2 = pop(); push(type); push(type2); push(type); break; case ByteCode.DUP_X2: type = pop(); lType = pop2(); push(type); push2(lType); push(type); break; case ByteCode.DUP2: lType = pop2(); push2(lType); push2(lType); break; case ByteCode.DUP2_X1: lType = pop2(); type = pop(); push2(lType); push(type); push2(lType); break; case ByteCode.DUP2_X2: lType = pop2(); lType2 = pop2(); push2(lType); push2(lType2); push2(lType); break; case ByteCode.TABLESWITCH: int switchStart = bci + 1 + (3 & ~bci); int low = getOperand(switchStart + 4, 4); int high = getOperand(switchStart + 8, 4); length = 4 * (high - low + 4) + switchStart - bci; pop(); break; case ByteCode.AALOAD: pop(); int typeIndex = pop() >>> 8; className = (String) itsConstantPool.getConstantData(typeIndex); String arrayType = className; if (arrayType.charAt(0) != '[') { throw new IllegalStateException("bad array type"); } String elementDesc = arrayType.substring(1); String elementType = descriptorToInternalName(elementDesc); typeIndex = itsConstantPool.addClass(elementType); push(TypeInfo.OBJECT(typeIndex)); break; case ByteCode.WIDE: // Alters behaviour of next instruction wide = true; break; case ByteCode.MULTIANEWARRAY: case ByteCode.LOOKUPSWITCH: // Currently not used in any part of Rhino, so ignore it case ByteCode.JSR: // TODO: JSR is deprecated case ByteCode.RET: case ByteCode.JSR_W: default: throw new IllegalArgumentException("bad opcode: " + bc); } if (length == 0) { length = opcodeLength(bc, wide); } if (wide && bc != ByteCode.WIDE) { wide = false; } return length; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static char arrayTypeToName(int type) { switch (type) { case ByteCode.T_BOOLEAN: return 'Z'; case ByteCode.T_CHAR: return 'C'; case ByteCode.T_FLOAT: return 'F'; case ByteCode.T_DOUBLE: return 'D'; case ByteCode.T_BYTE: return 'B'; case ByteCode.T_SHORT: return 'S'; case ByteCode.T_INT: return 'I'; case ByteCode.T_LONG: return 'J'; default: throw new IllegalArgumentException("bad operand"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static String descriptorToInternalName(String descriptor) { switch (descriptor.charAt(0)) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 'V': case '[': return descriptor; case 'L': return classDescriptorToInternalName(descriptor); default: throw new IllegalArgumentException("bad descriptor:" + descriptor); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int[] createInitialLocals() { int[] initialLocals = new int[itsMaxLocals]; int localsTop = 0; // Instance methods require the first local variable in the array // to be "this". However, if the method being created is a // constructor, aka the method is <init>, then the type of "this" // should be StackMapTable.UNINITIALIZED_THIS if ((itsCurrentMethod.getFlags() & ACC_STATIC) == 0) { if ("<init>".equals(itsCurrentMethod.getName())) { initialLocals[localsTop++] = TypeInfo.UNINITIALIZED_THIS; } else { initialLocals[localsTop++] = TypeInfo.OBJECT(itsThisClassIndex); } } // No error checking should be necessary, sizeOfParameters does this String type = itsCurrentMethod.getType(); int lParenIndex = type.indexOf('('); int rParenIndex = type.indexOf(')'); if (lParenIndex != 0 || rParenIndex < 0) { throw new IllegalArgumentException("bad method type"); } int start = lParenIndex + 1; StringBuilder paramType = new StringBuilder(); while (start < rParenIndex) { switch (type.charAt(start)) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': paramType.append(type.charAt(start)); ++start; break; case 'L': int end = type.indexOf(';', start) + 1; String name = type.substring(start, end); paramType.append(name); start = end; break; case '[': paramType.append('['); ++start; continue; } String internalType = descriptorToInternalName(paramType.toString()); int typeInfo = TypeInfo.fromType(internalType, itsConstantPool); initialLocals[localsTop++] = typeInfo; if (TypeInfo.isTwoWords(typeInfo)) { localsTop++; } paramType.setLength(0); } return initialLocals; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static int sizeOfParameters(String pString) { int length = pString.length(); int rightParenthesis = pString.lastIndexOf(')'); if (3 <= length /* minimal signature takes at least 3 chars: ()V */ && pString.charAt(0) == '(' && 1 <= rightParenthesis && rightParenthesis + 1 < length) { boolean ok = true; int index = 1; int stackDiff = 0; int count = 0; stringLoop: while (index != rightParenthesis) { switch (pString.charAt(index)) { default: ok = false; break stringLoop; case 'J' : case 'D' : --stackDiff; // fall thru case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : --stackDiff; ++count; ++index; continue; case '[' : ++index; int c = pString.charAt(index); while (c == '[') { ++index; c = pString.charAt(index); } switch (c) { default: ok = false; break stringLoop; case 'J' : case 'D' : case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : --stackDiff; ++count; ++index; continue; case 'L': // fall thru } // fall thru case 'L' : { --stackDiff; ++count; ++index; int semicolon = pString.indexOf(';', index); if (!(index + 1 <= semicolon && semicolon < rightParenthesis)) { ok = false; break stringLoop; } index = semicolon + 1; continue; } } } if (ok) { switch (pString.charAt(rightParenthesis + 1)) { default: ok = false; break; case 'J' : case 'D' : ++stackDiff; // fall thru case 'B' : case 'S' : case 'C' : case 'I' : case 'Z' : case 'F' : case 'L' : case '[' : ++stackDiff; // fall thru case 'V' : break; } if (ok) { return ((count << 16) | (0xFFFF & stackDiff)); } } } throw new IllegalArgumentException( "Bad parameter signature: "+pString); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int opcodeLength(int opcode, boolean wide) { switch (opcode) { case ByteCode.AALOAD: case ByteCode.AASTORE: case ByteCode.ACONST_NULL: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.ARETURN: case ByteCode.ARRAYLENGTH: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.BASTORE: case ByteCode.BREAKPOINT: case ByteCode.CALOAD: case ByteCode.CASTORE: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.D2L: case ByteCode.DADD: case ByteCode.DALOAD: case ByteCode.DASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DDIV: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DMUL: case ByteCode.DNEG: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.DUP: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2I: case ByteCode.F2L: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FASTORE: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FDIV: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.FMUL: case ByteCode.FNEG: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2D: case ByteCode.I2F: case ByteCode.I2L: case ByteCode.I2S: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IASTORE: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.IDIV: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.IMUL: case ByteCode.INEG: case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2D: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LADD: case ByteCode.LALOAD: case ByteCode.LAND: case ByteCode.LASTORE: case ByteCode.LCMP: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDIV: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: case ByteCode.LMUL: case ByteCode.LNEG: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LUSHR: case ByteCode.LXOR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.NOP: case ByteCode.POP: case ByteCode.POP2: case ByteCode.RETURN: case ByteCode.SALOAD: case ByteCode.SASTORE: case ByteCode.SWAP: case ByteCode.WIDE: return 1; case ByteCode.BIPUSH: case ByteCode.LDC: case ByteCode.NEWARRAY: return 2; case ByteCode.ALOAD: case ByteCode.ASTORE: case ByteCode.DLOAD: case ByteCode.DSTORE: case ByteCode.FLOAD: case ByteCode.FSTORE: case ByteCode.ILOAD: case ByteCode.ISTORE: case ByteCode.LLOAD: case ByteCode.LSTORE: case ByteCode.RET: return wide ? 3 : 2; case ByteCode.ANEWARRAY: case ByteCode.CHECKCAST: case ByteCode.GETFIELD: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.INSTANCEOF: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEVIRTUAL: case ByteCode.JSR: case ByteCode.LDC_W: case ByteCode.LDC2_W: case ByteCode.NEW: case ByteCode.PUTFIELD: case ByteCode.PUTSTATIC: case ByteCode.SIPUSH: return 3; case ByteCode.IINC: return wide ? 5 : 3; case ByteCode.MULTIANEWARRAY: return 4; case ByteCode.GOTO_W: case ByteCode.INVOKEINTERFACE: case ByteCode.JSR_W: return 5; /* case ByteCode.LOOKUPSWITCH: case ByteCode.TABLESWITCH: return -1; */ } throw new IllegalArgumentException("Bad opcode: " + opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int opcodeCount(int opcode) { switch (opcode) { case ByteCode.AALOAD: case ByteCode.AASTORE: case ByteCode.ACONST_NULL: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.ARETURN: case ByteCode.ARRAYLENGTH: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.BASTORE: case ByteCode.BREAKPOINT: case ByteCode.CALOAD: case ByteCode.CASTORE: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.D2L: case ByteCode.DADD: case ByteCode.DALOAD: case ByteCode.DASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DDIV: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DMUL: case ByteCode.DNEG: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.DUP: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2I: case ByteCode.F2L: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FASTORE: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FDIV: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.FMUL: case ByteCode.FNEG: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2D: case ByteCode.I2F: case ByteCode.I2L: case ByteCode.I2S: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IASTORE: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.IDIV: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.IMUL: case ByteCode.INEG: case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2D: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LADD: case ByteCode.LALOAD: case ByteCode.LAND: case ByteCode.LASTORE: case ByteCode.LCMP: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDIV: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: case ByteCode.LMUL: case ByteCode.LNEG: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LUSHR: case ByteCode.LXOR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.NOP: case ByteCode.POP: case ByteCode.POP2: case ByteCode.RETURN: case ByteCode.SALOAD: case ByteCode.SASTORE: case ByteCode.SWAP: case ByteCode.WIDE: return 0; case ByteCode.ALOAD: case ByteCode.ANEWARRAY: case ByteCode.ASTORE: case ByteCode.BIPUSH: case ByteCode.CHECKCAST: case ByteCode.DLOAD: case ByteCode.DSTORE: case ByteCode.FLOAD: case ByteCode.FSTORE: case ByteCode.GETFIELD: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.GOTO_W: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.ILOAD: case ByteCode.INSTANCEOF: case ByteCode.INVOKEINTERFACE: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEVIRTUAL: case ByteCode.ISTORE: case ByteCode.JSR: case ByteCode.JSR_W: case ByteCode.LDC: case ByteCode.LDC2_W: case ByteCode.LDC_W: case ByteCode.LLOAD: case ByteCode.LSTORE: case ByteCode.NEW: case ByteCode.NEWARRAY: case ByteCode.PUTFIELD: case ByteCode.PUTSTATIC: case ByteCode.RET: case ByteCode.SIPUSH: return 1; case ByteCode.IINC: case ByteCode.MULTIANEWARRAY: return 2; case ByteCode.LOOKUPSWITCH: case ByteCode.TABLESWITCH: return -1; } throw new IllegalArgumentException("Bad opcode: "+opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int stackChange(int opcode) { // For INVOKE... accounts only for popping this (unless static), // ignoring parameters and return type switch (opcode) { case ByteCode.DASTORE: case ByteCode.LASTORE: return -4; case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.DCMPG: case ByteCode.DCMPL: case ByteCode.FASTORE: case ByteCode.IASTORE: case ByteCode.LCMP: case ByteCode.SASTORE: return -3; case ByteCode.DADD: case ByteCode.DDIV: case ByteCode.DMUL: case ByteCode.DREM: case ByteCode.DRETURN: case ByteCode.DSTORE: case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: case ByteCode.DSUB: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPNE: case ByteCode.LADD: case ByteCode.LAND: case ByteCode.LDIV: case ByteCode.LMUL: case ByteCode.LOR: case ByteCode.LREM: case ByteCode.LRETURN: case ByteCode.LSTORE: case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: case ByteCode.LSUB: case ByteCode.LXOR: case ByteCode.POP2: return -2; case ByteCode.AALOAD: case ByteCode.ARETURN: case ByteCode.ASTORE: case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: case ByteCode.ATHROW: case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.D2F: case ByteCode.D2I: case ByteCode.FADD: case ByteCode.FALOAD: case ByteCode.FCMPG: case ByteCode.FCMPL: case ByteCode.FDIV: case ByteCode.FMUL: case ByteCode.FREM: case ByteCode.FRETURN: case ByteCode.FSTORE: case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: case ByteCode.FSUB: case ByteCode.GETFIELD: case ByteCode.IADD: case ByteCode.IALOAD: case ByteCode.IAND: case ByteCode.IDIV: case ByteCode.IFEQ: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFLT: case ByteCode.IFNE: case ByteCode.IFNONNULL: case ByteCode.IFNULL: case ByteCode.IMUL: case ByteCode.INVOKEINTERFACE: // case ByteCode.INVOKESPECIAL: // but needs to account for case ByteCode.INVOKEVIRTUAL: // pops 'this' (unless static) case ByteCode.IOR: case ByteCode.IREM: case ByteCode.IRETURN: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.ISTORE: case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: case ByteCode.ISUB: case ByteCode.IUSHR: case ByteCode.IXOR: case ByteCode.L2F: case ByteCode.L2I: case ByteCode.LOOKUPSWITCH: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.POP: case ByteCode.PUTFIELD: case ByteCode.SALOAD: case ByteCode.TABLESWITCH: return -1; case ByteCode.ANEWARRAY: case ByteCode.ARRAYLENGTH: case ByteCode.BREAKPOINT: case ByteCode.CHECKCAST: case ByteCode.D2L: case ByteCode.DALOAD: case ByteCode.DNEG: case ByteCode.F2I: case ByteCode.FNEG: case ByteCode.GETSTATIC: case ByteCode.GOTO: case ByteCode.GOTO_W: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2F: case ByteCode.I2S: case ByteCode.IINC: case ByteCode.IMPDEP1: case ByteCode.IMPDEP2: case ByteCode.INEG: case ByteCode.INSTANCEOF: case ByteCode.INVOKESTATIC: case ByteCode.L2D: case ByteCode.LALOAD: case ByteCode.LNEG: case ByteCode.NEWARRAY: case ByteCode.NOP: case ByteCode.PUTSTATIC: case ByteCode.RET: case ByteCode.RETURN: case ByteCode.SWAP: case ByteCode.WIDE: return 0; case ByteCode.ACONST_NULL: case ByteCode.ALOAD: case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: case ByteCode.BIPUSH: case ByteCode.DUP: case ByteCode.DUP_X1: case ByteCode.DUP_X2: case ByteCode.F2D: case ByteCode.F2L: case ByteCode.FCONST_0: case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: case ByteCode.I2D: case ByteCode.I2L: case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ICONST_M1: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.JSR: case ByteCode.JSR_W: case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.MULTIANEWARRAY: case ByteCode.NEW: case ByteCode.SIPUSH: return 1; case ByteCode.DCONST_0: case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: case ByteCode.DUP2: case ByteCode.DUP2_X1: case ByteCode.DUP2_X2: case ByteCode.LCONST_0: case ByteCode.LCONST_1: case ByteCode.LDC2_W: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: return 2; } throw new IllegalArgumentException("Bad opcode: "+opcode); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
short addUtf8(String k) { int theIndex = itsUtf8Hash.get(k, -1); if (theIndex == -1) { int strLen = k.length(); boolean tooBigString; if (strLen > MAX_UTF_ENCODING_SIZE) { tooBigString = true; } else { tooBigString = false; // Ask for worst case scenario buffer when each char takes 3 // bytes ensure(1 + 2 + strLen * 3); int top = itsTop; itsPool[top++] = CONSTANT_Utf8; top += 2; // skip length char[] chars = cfw.getCharBuffer(strLen); k.getChars(0, strLen, chars, 0); for (int i = 0; i != strLen; i++) { int c = chars[i]; if (c != 0 && c <= 0x7F) { itsPool[top++] = (byte)c; } else if (c > 0x7FF) { itsPool[top++] = (byte)(0xE0 | (c >> 12)); itsPool[top++] = (byte)(0x80 | ((c >> 6) & 0x3F)); itsPool[top++] = (byte)(0x80 | (c & 0x3F)); } else { itsPool[top++] = (byte)(0xC0 | (c >> 6)); itsPool[top++] = (byte)(0x80 | (c & 0x3F)); } } int utfLen = top - (itsTop + 1 + 2); if (utfLen > MAX_UTF_ENCODING_SIZE) { tooBigString = true; } else { // Write back length itsPool[itsTop + 1] = (byte)(utfLen >>> 8); itsPool[itsTop + 2] = (byte)utfLen; itsTop = top; theIndex = itsTopIndex++; itsUtf8Hash.put(k, theIndex); } } if (tooBigString) { throw new IllegalArgumentException("Too big string"); } } setConstantData(theIndex, k); itsPoolTypes.put(theIndex, CONSTANT_Utf8); return (short)theIndex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
boolean merge(int[] locals, int localsTop, int[] stack, int stackTop, ConstantPool pool) { if (!isInitialized) { System.arraycopy(locals, 0, this.locals, 0, localsTop); this.stack = new int[stackTop]; System.arraycopy(stack, 0, this.stack, 0, stackTop); isInitialized = true; return true; } else if (this.locals.length == localsTop && this.stack.length == stackTop) { boolean localsChanged = mergeState(this.locals, locals, localsTop, pool); boolean stackChanged = mergeState(this.stack, stack, stackTop, pool); return localsChanged || stackChanged; } else { if (ClassFileWriter.StackMapTable.DEBUGSTACKMAP) { System.out.println("bad merge"); System.out.println("current type state:"); TypeInfo.print(this.locals, this.stack, pool); System.out.println("incoming type state:"); TypeInfo.print(locals, localsTop, stack, stackTop, pool); } throw new IllegalArgumentException("bad merge attempt"); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static final String getPayloadAsType(int typeInfo, ConstantPool pool) { if (getTag(typeInfo) == OBJECT_TAG) { return (String) pool.getConstantData(getPayload(typeInfo)); } throw new IllegalArgumentException("expecting object type"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static final int fromType(String type, ConstantPool pool) { if (type.length() == 1) { switch (type.charAt(0)) { case 'B': // sbyte case 'C': // unicode char case 'S': // short case 'Z': // boolean case 'I': // all of the above are verified as integers return INTEGER; case 'D': return DOUBLE; case 'F': return FLOAT; case 'J': return LONG; default: throw new IllegalArgumentException("bad type"); } } return TypeInfo.OBJECT(type, pool); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static int merge(int current, int incoming, ConstantPool pool) { int currentTag = getTag(current); int incomingTag = getTag(incoming); boolean currentIsObject = currentTag == TypeInfo.OBJECT_TAG; boolean incomingIsObject = incomingTag == TypeInfo.OBJECT_TAG; if (current == incoming || (currentIsObject && incoming == NULL)) { return current; } else if (currentTag == TypeInfo.TOP || incomingTag == TypeInfo.TOP) { return TypeInfo.TOP; } else if (current == NULL && incomingIsObject) { return incoming; } else if (currentIsObject && incomingIsObject) { String currentName = getPayloadAsType(current, pool); String incomingName = getPayloadAsType(incoming, pool); // The class file always has the class and super names in the same // spot. The constant order is: class_data, class_name, super_data, // super_name. String currentlyGeneratedName = (String) pool.getConstantData(2); String currentlyGeneratedSuperName = (String) pool.getConstantData(4); // If any of the merged types are the class that's currently being // generated, automatically start at the super class instead. At // this point, we already know the classes are different, so we // don't need to handle that case. if (currentName.equals(currentlyGeneratedName)) { currentName = currentlyGeneratedSuperName; } if (incomingName.equals(currentlyGeneratedName)) { incomingName = currentlyGeneratedSuperName; } Class<?> currentClass = getClassFromInternalName(currentName); Class<?> incomingClass = getClassFromInternalName(incomingName); if (currentClass.isAssignableFrom(incomingClass)) { return current; } else if (incomingClass.isAssignableFrom(currentClass)) { return incoming; } else if (incomingClass.isInterface() || currentClass.isInterface()) { // For verification purposes, Sun specifies that interfaces are // subtypes of Object. Therefore, we know that the merge result // involving interfaces where one is not assignable to the // other results in Object. return OBJECT("java/lang/Object", pool); } else { Class<?> commonClass = incomingClass.getSuperclass(); while (commonClass != null) { if (commonClass.isAssignableFrom(currentClass)) { String name = commonClass.getName(); name = ClassFileWriter.getSlashedForm(name); return OBJECT(name, pool); } commonClass = commonClass.getSuperclass(); } } } throw new IllegalArgumentException("bad merge attempt between " + toString(current, pool) + " and " + toString(incoming, pool)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static String toString(int type, ConstantPool pool) { int tag = getTag(type); switch (tag) { case TypeInfo.TOP: return "top"; case TypeInfo.INTEGER: return "int"; case TypeInfo.FLOAT: return "float"; case TypeInfo.DOUBLE: return "double"; case TypeInfo.LONG: return "long"; case TypeInfo.NULL: return "null"; case TypeInfo.UNINITIALIZED_THIS: return "uninitialized_this"; default: if (tag == TypeInfo.OBJECT_TAG) { return getPayloadAsType(type, pool); } else if (tag == TypeInfo.UNINITIALIZED_VAR_TAG) { return "uninitialized"; } else { throw new IllegalArgumentException("bad type"); } } }
0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static Object toType(Object value, Class<?> desiredType) throws IllegalArgumentException { try { return jsToJava(value, desiredType); } catch (EvaluatorException ex) { IllegalArgumentException ex2 = new IllegalArgumentException(ex.getMessage()); Kit.initCause(ex2, ex); throw ex2; } }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (IllegalArgumentException x) { e = x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (IllegalArgumentException argEx) { throw Context.reportRuntimeError3( "msg.java.internal.field.type", value.getClass().getName(), field, javaObject.getClass().getName()); }
0
runtime (Lib) IllegalStateException 96
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/UniqueTag.java
public Object readResolve() { switch (tagId) { case ID_NOT_FOUND: return NOT_FOUND; case ID_NULL_VALUE: return NULL_VALUE; case ID_DOUBLE_MARK: return DOUBLE_MARK; } throw new IllegalStateException(String.valueOf(tagId)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Token.java
public static String typeToName(int token) { switch (token) { case ERROR: return "ERROR"; case EOF: return "EOF"; case EOL: return "EOL"; case ENTERWITH: return "ENTERWITH"; case LEAVEWITH: return "LEAVEWITH"; case RETURN: return "RETURN"; case GOTO: return "GOTO"; case IFEQ: return "IFEQ"; case IFNE: return "IFNE"; case SETNAME: return "SETNAME"; case BITOR: return "BITOR"; case BITXOR: return "BITXOR"; case BITAND: return "BITAND"; case EQ: return "EQ"; case NE: return "NE"; case LT: return "LT"; case LE: return "LE"; case GT: return "GT"; case GE: return "GE"; case LSH: return "LSH"; case RSH: return "RSH"; case URSH: return "URSH"; case ADD: return "ADD"; case SUB: return "SUB"; case MUL: return "MUL"; case DIV: return "DIV"; case MOD: return "MOD"; case NOT: return "NOT"; case BITNOT: return "BITNOT"; case POS: return "POS"; case NEG: return "NEG"; case NEW: return "NEW"; case DELPROP: return "DELPROP"; case TYPEOF: return "TYPEOF"; case GETPROP: return "GETPROP"; case GETPROPNOWARN: return "GETPROPNOWARN"; case SETPROP: return "SETPROP"; case GETELEM: return "GETELEM"; case SETELEM: return "SETELEM"; case CALL: return "CALL"; case NAME: return "NAME"; case NUMBER: return "NUMBER"; case STRING: return "STRING"; case NULL: return "NULL"; case THIS: return "THIS"; case FALSE: return "FALSE"; case TRUE: return "TRUE"; case SHEQ: return "SHEQ"; case SHNE: return "SHNE"; case REGEXP: return "REGEXP"; case BINDNAME: return "BINDNAME"; case THROW: return "THROW"; case RETHROW: return "RETHROW"; case IN: return "IN"; case INSTANCEOF: return "INSTANCEOF"; case LOCAL_LOAD: return "LOCAL_LOAD"; case GETVAR: return "GETVAR"; case SETVAR: return "SETVAR"; case CATCH_SCOPE: return "CATCH_SCOPE"; case ENUM_INIT_KEYS: return "ENUM_INIT_KEYS"; case ENUM_INIT_VALUES:return "ENUM_INIT_VALUES"; case ENUM_INIT_ARRAY: return "ENUM_INIT_ARRAY"; case ENUM_NEXT: return "ENUM_NEXT"; case ENUM_ID: return "ENUM_ID"; case THISFN: return "THISFN"; case RETURN_RESULT: return "RETURN_RESULT"; case ARRAYLIT: return "ARRAYLIT"; case OBJECTLIT: return "OBJECTLIT"; case GET_REF: return "GET_REF"; case SET_REF: return "SET_REF"; case DEL_REF: return "DEL_REF"; case REF_CALL: return "REF_CALL"; case REF_SPECIAL: return "REF_SPECIAL"; case DEFAULTNAMESPACE:return "DEFAULTNAMESPACE"; case ESCXMLTEXT: return "ESCXMLTEXT"; case ESCXMLATTR: return "ESCXMLATTR"; case REF_MEMBER: return "REF_MEMBER"; case REF_NS_MEMBER: return "REF_NS_MEMBER"; case REF_NAME: return "REF_NAME"; case REF_NS_NAME: return "REF_NS_NAME"; case TRY: return "TRY"; case SEMI: return "SEMI"; case LB: return "LB"; case RB: return "RB"; case LC: return "LC"; case RC: return "RC"; case LP: return "LP"; case RP: return "RP"; case COMMA: return "COMMA"; case ASSIGN: return "ASSIGN"; case ASSIGN_BITOR: return "ASSIGN_BITOR"; case ASSIGN_BITXOR: return "ASSIGN_BITXOR"; case ASSIGN_BITAND: return "ASSIGN_BITAND"; case ASSIGN_LSH: return "ASSIGN_LSH"; case ASSIGN_RSH: return "ASSIGN_RSH"; case ASSIGN_URSH: return "ASSIGN_URSH"; case ASSIGN_ADD: return "ASSIGN_ADD"; case ASSIGN_SUB: return "ASSIGN_SUB"; case ASSIGN_MUL: return "ASSIGN_MUL"; case ASSIGN_DIV: return "ASSIGN_DIV"; case ASSIGN_MOD: return "ASSIGN_MOD"; case HOOK: return "HOOK"; case COLON: return "COLON"; case OR: return "OR"; case AND: return "AND"; case INC: return "INC"; case DEC: return "DEC"; case DOT: return "DOT"; case FUNCTION: return "FUNCTION"; case EXPORT: return "EXPORT"; case IMPORT: return "IMPORT"; case IF: return "IF"; case ELSE: return "ELSE"; case SWITCH: return "SWITCH"; case CASE: return "CASE"; case DEFAULT: return "DEFAULT"; case WHILE: return "WHILE"; case DO: return "DO"; case FOR: return "FOR"; case BREAK: return "BREAK"; case CONTINUE: return "CONTINUE"; case VAR: return "VAR"; case WITH: return "WITH"; case CATCH: return "CATCH"; case FINALLY: return "FINALLY"; case VOID: return "VOID"; case RESERVED: return "RESERVED"; case EMPTY: return "EMPTY"; case BLOCK: return "BLOCK"; case LABEL: return "LABEL"; case TARGET: return "TARGET"; case LOOP: return "LOOP"; case EXPR_VOID: return "EXPR_VOID"; case EXPR_RESULT: return "EXPR_RESULT"; case JSR: return "JSR"; case SCRIPT: return "SCRIPT"; case TYPEOFNAME: return "TYPEOFNAME"; case USE_STACK: return "USE_STACK"; case SETPROP_OP: return "SETPROP_OP"; case SETELEM_OP: return "SETELEM_OP"; case LOCAL_BLOCK: return "LOCAL_BLOCK"; case SET_REF_OP: return "SET_REF_OP"; case DOTDOT: return "DOTDOT"; case COLONCOLON: return "COLONCOLON"; case XML: return "XML"; case DOTQUERY: return "DOTQUERY"; case XMLATTR: return "XMLATTR"; case XMLEND: return "XMLEND"; case TO_OBJECT: return "TO_OBJECT"; case TO_DOUBLE: return "TO_DOUBLE"; case GET: return "GET"; case SET: return "SET"; case LET: return "LET"; case YIELD: return "YIELD"; case CONST: return "CONST"; case SETCONST: return "SETCONST"; case ARRAYCOMP: return "ARRAYCOMP"; case WITHEXPR: return "WITHEXPR"; case LETEXPR: return "LETEXPR"; case DEBUGGER: return "DEBUGGER"; case COMMENT: return "COMMENT"; case GENEXPR: return "GENEXPR"; } // Token without name throw new IllegalStateException(String.valueOf(token)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeWith.java
protected Object updateDotQuery(boolean value) { // NativeWith itself does not support it throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2007-05-09 08:16:24 EDT L0: { id = 0; String X = null; int c; int s_length = s.length(); if (s_length==6) { c=s.charAt(0); if (c=='g') { X="global";id=Id_global; } else if (c=='s') { X="source";id=Id_source; } } else if (s_length==9) { c=s.charAt(0); if (c=='l') { X="lastIndex";id=Id_lastIndex; } else if (c=='m') { X="multiline";id=Id_multiline; } } else if (s_length==10) { X="ignoreCase";id=Id_ignoreCase; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# // #/string_id_map# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_lastIndex: attr = PERMANENT | DONTENUM; break; case Id_source: case Id_global: case Id_ignoreCase: case Id_multiline: attr = PERMANENT | READONLY | DONTENUM; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private void endCatch(ExceptionInfo ei, int exceptionType, int catchEnd) { if (ei.exceptionStarts[exceptionType] == 0) { throw new IllegalStateException("bad exception start"); } int currentStart = ei.exceptionStarts[exceptionType]; int currentStartPC = cfw.getLabelPC(currentStart); int catchEndPC = cfw.getLabelPC(catchEnd); if (currentStartPC != catchEndPC) { cfw.addExceptionHandler(ei.exceptionStarts[exceptionType], catchEnd, ei.handlerLabels[exceptionType], exceptionTypeToName(exceptionType)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2007-05-09 08:15:15 EDT L0: { id = 0; String X = null; int c; L: switch (s.length()) { case 4: X="name";id=Id_name; break L; case 5: X="arity";id=Id_arity; break L; case 6: X="length";id=Id_length; break L; case 9: c=s.charAt(0); if (c=='a') { X="arguments";id=Id_arguments; } else if (c=='p') { X="prototype";id=Id_prototype; } break L; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# // #/string_id_map# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_length: case Id_arity: case Id_name: attr = DONTENUM | READONLY | PERMANENT; break; case Id_prototype: // some functions such as built-ins don't have a prototype property if (!hasPrototypeProperty()) { return 0; } attr = prototypePropertyAttributes; break; case Id_arguments: attr = DONTENUM | PERMANENT; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
public void setImmunePrototypeProperty(Object value) { if ((prototypePropertyAttributes & READONLY) != 0) { throw new IllegalStateException(); } prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE; prototypePropertyAttributes = DONTENUM | PERMANENT | READONLY; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
public Scriptable construct(Context cx, Scriptable scope, Object[] args) { Scriptable result = createObject(cx, scope); if (result != null) { Object val = call(cx, scope, result, args); if (val instanceof Scriptable) { result = (Scriptable)val; } } else { Object val = call(cx, scope, null, args); if (!(val instanceof Scriptable)) { // It is program error not to return Scriptable from // the call method if createObject returns null. throw new IllegalStateException( "Bad implementaion of call as constructor, name=" +getFunctionName()+" in "+getClass().getName()); } result = (Scriptable)val; if (result.getPrototype() == null) { result.setPrototype(getClassPrototype()); } if (result.getParentScope() == null) { Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
public Scriptable requireMain(Context cx, String mainModuleId) { if(this.mainModuleId != null) { if (!this.mainModuleId.equals(mainModuleId)) { throw new IllegalStateException("Main module already set to " + this.mainModuleId); } return mainExports; } ModuleScript moduleScript; try { // try to get the module script to see if it is on the module path moduleScript = moduleScriptProvider.getModuleScript( cx, mainModuleId, null, paths); } catch (RuntimeException x) { throw x; } catch (Exception x) { throw new RuntimeException(x); } if (moduleScript != null) { mainExports = getExportedModuleInterface(cx, mainModuleId, null, true); } else if (!sandboxed) { URI mainUri = null; // try to resolve to an absolute URI or file path try { mainUri = new URI(mainModuleId); } catch (URISyntaxException usx) { // fall through } // if not an absolute uri resolve to a file path if (mainUri == null || !mainUri.isAbsolute()) { File file = new File(mainModuleId); if (!file.isFile()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + mainModuleId + "\" not found."); } mainUri = file.toURI(); } mainExports = getExportedModuleInterface(cx, mainUri.toString(), mainUri, true); } this.mainModuleId = mainModuleId; return mainExports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
private Scriptable getExportedModuleInterface(Context cx, String id, URI uri, boolean isMain) { // Check if the requested module is already completely loaded Scriptable exports = exportedModuleInterfaces.get(id); if(exports != null) { if(isMain) { throw new IllegalStateException( "Attempt to set main module after it was loaded"); } return exports; } // Check if it is currently being loaded on the current thread // (supporting circular dependencies). Map<String, Scriptable> threadLoadingModules = loadingModuleInterfaces.get(); if(threadLoadingModules != null) { exports = threadLoadingModules.get(id); if(exports != null) { return exports; } } // The requested module is neither already loaded, nor is it being // loaded on the current thread. End of fast path. We must synchronize // now, as we have to guarantee that at most one thread can load // modules at any one time. Otherwise, two threads could end up // attempting to load two circularly dependent modules in opposite // order, which would lead to either unacceptable non-determinism or // deadlock, depending on whether we underprotected or overprotected it // with locks. synchronized(loadLock) { // Recheck if it is already loaded - other thread might've // completed loading it just as we entered the synchronized block. exports = exportedModuleInterfaces.get(id); if(exports != null) { return exports; } // Nope, still not loaded; we're loading it then. final ModuleScript moduleScript = getModule(cx, id, uri); if (sandboxed && !moduleScript.isSandboxed()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + id + "\" is not contained in sandbox."); } exports = cx.newObject(nativeScope); // Are we the outermost locked invocation on this thread? final boolean outermostLocked = threadLoadingModules == null; if(outermostLocked) { threadLoadingModules = new HashMap<String, Scriptable>(); loadingModuleInterfaces.set(threadLoadingModules); } // Must make the module exports available immediately on the // current thread, to satisfy the CommonJS Modules/1.1 requirement // that "If there is a dependency cycle, the foreign module may not // have finished executing at the time it is required by one of its // transitive dependencies; in this case, the object returned by // "require" must contain at least the exports that the foreign // module has prepared before the call to require that led to the // current module's execution." threadLoadingModules.put(id, exports); try { // Support non-standard Node.js feature to allow modules to // replace the exports object by setting module.exports. Scriptable newExports = executeModuleScript(cx, id, exports, moduleScript, isMain); if (exports != newExports) { threadLoadingModules.put(id, newExports); exports = newExports; } } catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; } finally { if(outermostLocked) { // Make loaded modules visible to other threads only after // the topmost triggering load has completed. This strategy // (compared to the one where we'd make each module // globally available as soon as it loads) prevents other // threads from observing a partially loaded circular // dependency of a module that completed loading. exportedModuleInterfaces.putAll(threadLoadingModules); loadingModuleInterfaces.set(null); } } } return exports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeMath.java
Override protected void initPrototypeId(int id) { if (id <= LAST_METHOD_ID) { String name; int arity; switch (id) { case Id_toSource: arity = 0; name = "toSource"; break; case Id_abs: arity = 1; name = "abs"; break; case Id_acos: arity = 1; name = "acos"; break; case Id_asin: arity = 1; name = "asin"; break; case Id_atan: arity = 1; name = "atan"; break; case Id_atan2: arity = 2; name = "atan2"; break; case Id_ceil: arity = 1; name = "ceil"; break; case Id_cos: arity = 1; name = "cos"; break; case Id_exp: arity = 1; name = "exp"; break; case Id_floor: arity = 1; name = "floor"; break; case Id_log: arity = 1; name = "log"; break; case Id_max: arity = 2; name = "max"; break; case Id_min: arity = 2; name = "min"; break; case Id_pow: arity = 2; name = "pow"; break; case Id_random: arity = 0; name = "random"; break; case Id_round: arity = 1; name = "round"; break; case Id_sin: arity = 1; name = "sin"; break; case Id_sqrt: arity = 1; name = "sqrt"; break; case Id_tan: arity = 1; name = "tan"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeMethod(MATH_TAG, id, name, arity); } else { String name; double x; switch (id) { case Id_E: x = Math.E; name = "E"; break; case Id_PI: x = Math.PI; name = "PI"; break; case Id_LN10: x = 2.302585092994046; name = "LN10"; break; case Id_LN2: x = 0.6931471805599453; name = "LN2"; break; case Id_LOG2E: x = 1.4426950408889634; name = "LOG2E"; break; case Id_LOG10E: x = 0.4342944819032518; name = "LOG10E"; break; case Id_SQRT1_2: x = 0.7071067811865476; name = "SQRT1_2"; break; case Id_SQRT2: x = 1.4142135623730951; name = "SQRT2"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeValue(id, name, ScriptRuntime.wrapNumber(x), DONTENUM | READONLY | PERMANENT); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeMath.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(MATH_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } double x; int methodId = f.methodId(); switch (methodId) { case Id_toSource: return "Math"; case Id_abs: x = ScriptRuntime.toNumber(args, 0); // abs(-0.0) should be 0.0, but -0.0 < 0.0 == false x = (x == 0.0) ? 0.0 : (x < 0.0) ? -x : x; break; case Id_acos: case Id_asin: x = ScriptRuntime.toNumber(args, 0); if (x == x && -1.0 <= x && x <= 1.0) { x = (methodId == Id_acos) ? Math.acos(x) : Math.asin(x); } else { x = Double.NaN; } break; case Id_atan: x = ScriptRuntime.toNumber(args, 0); x = Math.atan(x); break; case Id_atan2: x = ScriptRuntime.toNumber(args, 0); x = Math.atan2(x, ScriptRuntime.toNumber(args, 1)); break; case Id_ceil: x = ScriptRuntime.toNumber(args, 0); x = Math.ceil(x); break; case Id_cos: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) ? Double.NaN : Math.cos(x); break; case Id_exp: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY) ? x : (x == Double.NEGATIVE_INFINITY) ? 0.0 : Math.exp(x); break; case Id_floor: x = ScriptRuntime.toNumber(args, 0); x = Math.floor(x); break; case Id_log: x = ScriptRuntime.toNumber(args, 0); // Java's log(<0) = -Infinity; we need NaN x = (x < 0) ? Double.NaN : Math.log(x); break; case Id_max: case Id_min: x = (methodId == Id_max) ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; for (int i = 0; i != args.length; ++i) { double d = ScriptRuntime.toNumber(args[i]); if (d != d) { x = d; // NaN break; } if (methodId == Id_max) { // if (x < d) x = d; does not work due to -0.0 >= +0.0 x = Math.max(x, d); } else { x = Math.min(x, d); } } break; case Id_pow: x = ScriptRuntime.toNumber(args, 0); x = js_pow(x, ScriptRuntime.toNumber(args, 1)); break; case Id_random: x = Math.random(); break; case Id_round: x = ScriptRuntime.toNumber(args, 0); if (x == x && x != Double.POSITIVE_INFINITY && x != Double.NEGATIVE_INFINITY) { // Round only finite x long l = Math.round(x); if (l != 0) { x = l; } else { // We must propagate the sign of d into the result if (x < 0.0) { x = ScriptRuntime.negativeZero; } else if (x != 0.0) { x = 0.0; } } } break; case Id_sin: x = ScriptRuntime.toNumber(args, 0); x = (x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) ? Double.NaN : Math.sin(x); break; case Id_sqrt: x = ScriptRuntime.toNumber(args, 0); x = Math.sqrt(x); break; case Id_tan: x = ScriptRuntime.toNumber(args, 0); x = Math.tan(x); break; default: throw new IllegalStateException(String.valueOf(methodId)); } return ScriptRuntime.wrapNumber(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void remove() { if (prev == NOT_SET) { throw new IllegalStateException("next() has not been called"); } if (removed) { throw new IllegalStateException( "remove() already called for current element"); } if (prev == first) { first = prev.next; } else if (prev == last) { prev2.next = null; last = prev2; } else { prev2.next = cursor; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/VMBridge.java
private static VMBridge makeInstance() { String[] classNames = { "org.mozilla.javascript.VMBridge_custom", "org.mozilla.javascript.jdk15.VMBridge_jdk15", "org.mozilla.javascript.jdk13.VMBridge_jdk13", "org.mozilla.javascript.jdk11.VMBridge_jdk11", }; for (int i = 0; i != classNames.length; ++i) { String className = classNames[i]; Class<?> cl = Kit.classOrNull(className); if (cl != null) { VMBridge bridge = (VMBridge)Kit.newInstanceOrNull(cl); if (bridge != null) { return bridge; } } } throw new IllegalStateException("Failed to create VMBridge instance"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Arguments.java
Override protected int findInstanceIdInfo(String s) { int id; // #generated# Last update: 2010-01-06 05:48:21 ARST L0: { id = 0; String X = null; int c; int s_length = s.length(); if (s_length==6) { c=s.charAt(5); if (c=='e') { X="callee";id=Id_callee; } else if (c=='h') { X="length";id=Id_length; } else if (c=='r') { X="caller";id=Id_caller; } } else if (s_length==11) { X="constructor";id=Id_constructor; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; } // #/generated# if (id == 0) return super.findInstanceIdInfo(s); int attr; switch (id) { case Id_callee: case Id_caller: case Id_length: case Id_constructor: attr = DONTENUM; break; default: throw new IllegalStateException(); } return instanceIdInfo(attr, id); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(String sourceString, String sourceURI, int lineno) { if (parseFinished) throw new IllegalStateException("parser reused"); this.sourceURI = sourceURI; if (compilerEnv.isIdeMode()) { this.sourceChars = sourceString.toCharArray(); } this.ts = new TokenStream(this, null, sourceString, lineno); try { return parse(); } catch (IOException iox) { // Should never happen throw new IllegalStateException(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
public AstRoot parse(Reader sourceReader, String sourceURI, int lineno) throws IOException { if (parseFinished) throw new IllegalStateException("parser reused"); if (compilerEnv.isIdeMode()) { return parse(readFully(sourceReader), sourceURI, lineno); } try { this.sourceURI = sourceURI; ts = new TokenStream(this, sourceReader, null, lineno); return parse(); } finally { parseFinished = true; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public synchronized static GlobalSetter getGlobalSetter() { if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; class GlobalSetterImpl implements GlobalSetter { public void setContextFactoryGlobal(ContextFactory factory) { global = factory == null ? new ContextFactory() : factory; } public ContextFactory getContextFactoryGlobal() { return global; } } return new GlobalSetterImpl(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void addListener(Listener listener) { checkNotSealed(); synchronized (listenersLock) { if (disabledListening) { throw new IllegalStateException(); } listeners = Kit.addListener(listeners, listener); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
public final void removeListener(Listener listener) { checkNotSealed(); synchronized (listenersLock) { if (disabledListening) { throw new IllegalStateException(); } listeners = Kit.removeListener(listeners, listener); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
protected final void checkNotSealed() { if (sealed) throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object[] toArray(Object[] a) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; Object[] array = a.length >= len ? a : (Object[]) java.lang.reflect.Array .newInstance(a.getClass().getComponentType(), len); for (int i = 0; i < len; i++) { array[i] = get(i); } return array; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int size() { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } return (int) longLen; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int indexOf(Object o) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; if (o == null) { for (int i = 0; i < len; i++) { if (get(i) == null) { return i; } } } else { for (int i = 0; i < len; i++) { if (o.equals(get(i))) { return i; } } } return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public int lastIndexOf(Object o) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; if (o == null) { for (int i = len - 1; i >= 0; i--) { if (get(i) == null) { return i; } } } else { for (int i = len - 1; i >= 0; i--) { if (o.equals(get(i))) { return i; } } } return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public ListIterator listIterator(final int start) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; if (start < 0 || start > len) { throw new IndexOutOfBoundsException("Index: " + start); } return new ListIterator() { int cursor = start; public boolean hasNext() { return cursor < len; } public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); } public boolean hasPrevious() { return cursor > 0; } public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); } public int nextIndex() { return cursor; } public int previousIndex() { return cursor - 1; } public void remove() { throw new UnsupportedOperationException(); } public void add(Object o) { throw new UnsupportedOperationException(); } public void set(Object o) { throw new UnsupportedOperationException(); } }; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/InterpretedFunction.java
public Object exec(Context cx, Scriptable scope) { if (!isScript()) { // Can only be applied to scripts throw new IllegalStateException(); } if (!ScriptRuntime.hasTopCall(cx)) { // It will go through "call" path. but they are equivalent return ScriptRuntime.doTopCall( this, cx, scope, scope, ScriptRuntime.emptyArgs); } return Interpreter.interpret( this, cx, scope, scope, ScriptRuntime.emptyArgs); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Icode.java
static String bytecodeName(int bytecode) { if (!validBytecode(bytecode)) { throw new IllegalArgumentException(String.valueOf(bytecode)); } if (!Token.printICode) { return String.valueOf(bytecode); } if (validTokenCode(bytecode)) { return Token.name(bytecode); } switch (bytecode) { case Icode_DUP: return "DUP"; case Icode_DUP2: return "DUP2"; case Icode_SWAP: return "SWAP"; case Icode_POP: return "POP"; case Icode_POP_RESULT: return "POP_RESULT"; case Icode_IFEQ_POP: return "IFEQ_POP"; case Icode_VAR_INC_DEC: return "VAR_INC_DEC"; case Icode_NAME_INC_DEC: return "NAME_INC_DEC"; case Icode_PROP_INC_DEC: return "PROP_INC_DEC"; case Icode_ELEM_INC_DEC: return "ELEM_INC_DEC"; case Icode_REF_INC_DEC: return "REF_INC_DEC"; case Icode_SCOPE_LOAD: return "SCOPE_LOAD"; case Icode_SCOPE_SAVE: return "SCOPE_SAVE"; case Icode_TYPEOFNAME: return "TYPEOFNAME"; case Icode_NAME_AND_THIS: return "NAME_AND_THIS"; case Icode_PROP_AND_THIS: return "PROP_AND_THIS"; case Icode_ELEM_AND_THIS: return "ELEM_AND_THIS"; case Icode_VALUE_AND_THIS: return "VALUE_AND_THIS"; case Icode_CLOSURE_EXPR: return "CLOSURE_EXPR"; case Icode_CLOSURE_STMT: return "CLOSURE_STMT"; case Icode_CALLSPECIAL: return "CALLSPECIAL"; case Icode_RETUNDEF: return "RETUNDEF"; case Icode_GOSUB: return "GOSUB"; case Icode_STARTSUB: return "STARTSUB"; case Icode_RETSUB: return "RETSUB"; case Icode_LINE: return "LINE"; case Icode_SHORTNUMBER: return "SHORTNUMBER"; case Icode_INTNUMBER: return "INTNUMBER"; case Icode_LITERAL_NEW: return "LITERAL_NEW"; case Icode_LITERAL_SET: return "LITERAL_SET"; case Icode_SPARE_ARRAYLIT: return "SPARE_ARRAYLIT"; case Icode_REG_IND_C0: return "REG_IND_C0"; case Icode_REG_IND_C1: return "REG_IND_C1"; case Icode_REG_IND_C2: return "REG_IND_C2"; case Icode_REG_IND_C3: return "REG_IND_C3"; case Icode_REG_IND_C4: return "REG_IND_C4"; case Icode_REG_IND_C5: return "REG_IND_C5"; case Icode_REG_IND1: return "LOAD_IND1"; case Icode_REG_IND2: return "LOAD_IND2"; case Icode_REG_IND4: return "LOAD_IND4"; case Icode_REG_STR_C0: return "REG_STR_C0"; case Icode_REG_STR_C1: return "REG_STR_C1"; case Icode_REG_STR_C2: return "REG_STR_C2"; case Icode_REG_STR_C3: return "REG_STR_C3"; case Icode_REG_STR1: return "LOAD_STR1"; case Icode_REG_STR2: return "LOAD_STR2"; case Icode_REG_STR4: return "LOAD_STR4"; case Icode_GETVAR1: return "GETVAR1"; case Icode_SETVAR1: return "SETVAR1"; case Icode_UNDEF: return "UNDEF"; case Icode_ZERO: return "ZERO"; case Icode_ONE: return "ONE"; case Icode_ENTERDQ: return "ENTERDQ"; case Icode_LEAVEDQ: return "LEAVEDQ"; case Icode_TAIL_CALL: return "TAIL_CALL"; case Icode_LOCAL_CLEAR: return "LOCAL_CLEAR"; case Icode_LITERAL_GETTER: return "LITERAL_GETTER"; case Icode_LITERAL_SETTER: return "LITERAL_SETTER"; case Icode_SETCONST: return "SETCONST"; case Icode_SETCONSTVAR: return "SETCONSTVAR"; case Icode_SETCONSTVAR1: return "SETCONSTVAR1"; case Icode_GENERATOR: return "GENERATOR"; case Icode_GENERATOR_END: return "GENERATOR_END"; case Icode_DEBUGGER: return "DEBUGGER"; } // icode without name throw new IllegalStateException(String.valueOf(bytecode)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/KeywordLiteral.java
Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); switch (getType()) { case Token.THIS: sb.append("this"); break; case Token.NULL: sb.append("null"); break; case Token.TRUE: sb.append("true"); break; case Token.FALSE: sb.append("false"); break; case Token.DEBUGGER: sb.append("debugger;\n"); break; default: throw new IllegalStateException("Invalid keyword literal type: " + getType()); } return sb.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ScriptNode.java
public void setCompilerData(Object data) { assertNotNull(data); // Can only call once if (compilerData != null) throw new IllegalStateException(); compilerData = data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstRoot.java
public boolean visit(AstNode node) { int type = node.getType(); if (type == Token.SCRIPT) return true; if (node.getParent() == null) throw new IllegalStateException ("No parent for node: " + node + "\n" + node.toSource(0)); return true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
Override protected void initPrototypeId(int id) { if (id <= LAST_METHOD_ID) { String name; int arity; switch (id) { case Id_toSource: arity = 0; name = "toSource"; break; case Id_parse: arity = 2; name = "parse"; break; case Id_stringify: arity = 3; name = "stringify"; break; default: throw new IllegalStateException(String.valueOf(id)); } initPrototypeMethod(JSON_TAG, id, name, arity); } else { throw new IllegalStateException(String.valueOf(id)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(JSON_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int methodId = f.methodId(); switch (methodId) { case Id_toSource: return "JSON"; case Id_parse: { String jtext = ScriptRuntime.toString(args, 0); Object reviver = null; if (args.length > 1) { reviver = args[1]; } if (reviver instanceof Callable) { return parse(cx, scope, jtext, (Callable) reviver); } else { return parse(cx, scope, jtext); } } case Id_stringify: { Object value = null, replacer = null, space = null; switch (args.length) { default: case 3: space = args[2]; case 2: replacer = args[1]; case 1: value = args[0]; case 0: } return stringify(cx, scope, value, replacer, space); } default: throw new IllegalStateException(String.valueOf(methodId)); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initSourceName(String sourceName) { if (sourceName == null) throw new IllegalArgumentException(); if (this.sourceName != null) throw new IllegalStateException(); this.sourceName = sourceName; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineNumber(int lineNumber) { if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber)); if (this.lineNumber > 0) throw new IllegalStateException(); this.lineNumber = lineNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initColumnNumber(int columnNumber) { if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber)); if (this.columnNumber > 0) throw new IllegalStateException(); this.columnNumber = columnNumber; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/RhinoException.java
public final void initLineSource(String lineSource) { if (lineSource == null) throw new IllegalArgumentException(); if (this.lineSource != null) throw new IllegalStateException(); this.lineSource = lineSource; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public Object execWithDomain(Context cx, Scriptable scope, Script script, Object securityDomain) { throw new IllegalStateException("callWithDomain should be overridden"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onSeledMutation() { throw new IllegalStateException("Attempt to modify sealed array"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private void initSlot(int id, String name, Object value, int attributes) { Object[] array = valueArray; if (array == null) throw new IllegalStateException(); if (value == null) { value = UniqueTag.NULL_VALUE; } int index = (id - 1) * SLOT_SPAN; synchronized (this) { Object value2 = array[index]; if (value2 == null) { array[index] = value; array[index + NAME_SLOT] = name; attributeArray[id - 1] = (short)attributes; } else { if (!name.equals(array[index + NAME_SLOT])) throw new IllegalStateException(); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
final IdFunctionObject createPrecachedConstructor() { if (constructorId != 0) throw new IllegalStateException(); constructorId = obj.findPrototypeId("constructor"); if (constructorId == 0) { throw new IllegalStateException( "No id for constructor property"); } obj.initPrototypeId(constructorId); if (constructor == null) { throw new IllegalStateException( obj.getClass().getName()+".initPrototypeId() did not " +"initialize id="+constructorId); } constructor.initFunction(obj.getClassName(), ScriptableObject.getTopLevelScope(obj)); constructor.markAsConstructor(obj); return constructor; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
private Object ensureId(int id) { Object[] array = valueArray; if (array == null) { synchronized (this) { array = valueArray; if (array == null) { array = new Object[maxId * SLOT_SPAN]; valueArray = array; attributeArray = new short[maxId]; } } } int valueSlot = (id - 1) * SLOT_SPAN; Object value = array[valueSlot]; if (value == null) { if (id == constructorId) { initSlot(constructorId, "constructor", constructor, constructorAttrs); constructor = null; // no need to refer it any longer } else { obj.initPrototypeId(id); } value = array[valueSlot]; if (value == null) { throw new IllegalStateException( obj.getClass().getName()+".initPrototypeId(int id) " +"did not initialize id="+id); } } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected Object getInstanceIdValue(int id) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected void setInstanceIdValue(int id, Object value) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void activatePrototypeMap(int maxPrototypeId) { PrototypeValues values = new PrototypeValues(this, maxPrototypeId); synchronized (this) { if (prototypeValues != null) throw new IllegalStateException(); prototypeValues = values; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
public final void initPrototypeConstructor(IdFunctionObject f) { int id = prototypeValues.constructorId; if (id == 0) throw new IllegalStateException(); if (f.methodId() != id) throw new IllegalArgumentException(); if (isSealed()) { f.sealObject(); } prototypeValues.initValue(id, "constructor", f, DONTENUM); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected void initPrototypeId(int id) { throw new IllegalStateException(String.valueOf(id)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/IdScriptableObject.java
protected int findPrototypeId(String name) { throw new IllegalStateException(name); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
CallFrame cloneFrozen() { if (!frozen) Kit.codeBug(); CallFrame copy; try { copy = (CallFrame)clone(); } catch (CloneNotSupportedException ex) { throw new IllegalStateException(); } // clone stack but keep varSource to point to values // from this frame to share variables. copy.stack = stack.clone(); copy.stackAttributes = stackAttributes.clone(); copy.sDbl = sDbl.clone(); copy.frozen = false; return copy; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static Object interpretLoop(Context cx, CallFrame frame, Object throwable) { // throwable holds exception object to rethrow or catch // It is also used for continuation restart in which case // it holds ContinuationJump final Object DBL_MRK = DOUBLE_MARK; final Object undefined = Undefined.instance; final boolean instructionCounting = (cx.instructionThreshold != 0); // arbitrary number to add to instructionCount when calling // other functions final int INVOCATION_COST = 100; // arbitrary exception cost for instruction counting final int EXCEPTION_COST = 100; String stringReg = null; int indexReg = -1; if (cx.lastInterpreterFrame != null) { // save the top frame from the previous interpretLoop // invocation on the stack if (cx.previousInterpreterInvocations == null) { cx.previousInterpreterInvocations = new ObjArray(); } cx.previousInterpreterInvocations.push(cx.lastInterpreterFrame); } // When restarting continuation throwable is not null and to jump // to the code that rewind continuation state indexReg should be set // to -1. // With the normal call throwable == null and indexReg == -1 allows to // catch bugs with using indeReg to access array elements before // initializing indexReg. GeneratorState generatorState = null; if (throwable != null) { if (throwable instanceof GeneratorState) { generatorState = (GeneratorState) throwable; // reestablish this call frame enterFrame(cx, frame, ScriptRuntime.emptyArgs, true); throwable = null; } else if (!(throwable instanceof ContinuationJump)) { // It should be continuation Kit.codeBug(); } } Object interpreterResult = null; double interpreterResultDbl = 0.0; StateLoop: for (;;) { withoutExceptions: try { if (throwable != null) { // Need to return both 'frame' and 'throwable' from // 'processThrowable', so just added a 'throwable' // member in 'frame'. frame = processThrowable(cx, throwable, frame, indexReg, instructionCounting); throwable = frame.throwable; frame.throwable = null; } else { if (generatorState == null && frame.frozen) Kit.codeBug(); } // Use local variables for constant values in frame // for faster access Object[] stack = frame.stack; double[] sDbl = frame.sDbl; Object[] vars = frame.varSource.stack; double[] varDbls = frame.varSource.sDbl; int[] varAttributes = frame.varSource.stackAttributes; byte[] iCode = frame.idata.itsICode; String[] strings = frame.idata.itsStringTable; // Use local for stackTop as well. Since execption handlers // can only exist at statement level where stack is empty, // it is necessary to save/restore stackTop only across // function calls and normal returns. int stackTop = frame.savedStackTop; // Store new frame in cx which is used for error reporting etc. cx.lastInterpreterFrame = frame; Loop: for (;;) { // Exception handler assumes that PC is already incremented // pass the instruction start when it searches the // exception handler int op = iCode[frame.pc++]; jumplessRun: { // Back indent to ease implementation reading switch (op) { case Icode_GENERATOR: { if (!frame.frozen) { // First time encountering this opcode: create new generator // object and return frame.pc--; // we want to come back here when we resume CallFrame generatorFrame = captureFrameForGenerator(frame); generatorFrame.frozen = true; NativeGenerator generator = new NativeGenerator(frame.scope, generatorFrame.fnOrScript, generatorFrame); frame.result = generator; break Loop; } else { // We are now resuming execution. Fall through to YIELD case. } } // fall through... case Token.YIELD: { if (!frame.frozen) { return freezeGenerator(cx, frame, stackTop, generatorState); } else { Object obj = thawGenerator(frame, stackTop, generatorState, op); if (obj != Scriptable.NOT_FOUND) { throwable = obj; break withoutExceptions; } continue Loop; } } case Icode_GENERATOR_END: { // throw StopIteration frame.frozen = true; int sourceLine = getIndex(iCode, frame.pc); generatorState.returnedException = new JavaScriptException( NativeIterator.getStopIterationObject(frame.scope), frame.idata.itsSourceFile, sourceLine); break Loop; } case Token.THROW: { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int sourceLine = getIndex(iCode, frame.pc); throwable = new JavaScriptException(value, frame.idata.itsSourceFile, sourceLine); break withoutExceptions; } case Token.RETHROW: { indexReg += frame.localShift; throwable = stack[indexReg]; break withoutExceptions; } case Token.GE : case Token.LE : case Token.GT : case Token.LT : { stackTop = doCompare(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.IN : case Token.INSTANCEOF : { stackTop = doInOrInstanceof(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.EQ : case Token.NE : { --stackTop; boolean valBln = doEquals(stack, sDbl, stackTop); valBln ^= (op == Token.NE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.SHEQ : case Token.SHNE : { --stackTop; boolean valBln = doShallowEquals(stack, sDbl, stackTop); valBln ^= (op == Token.SHNE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.IFNE : if (stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Token.IFEQ : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Icode_IFEQ_POP : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } stack[stackTop--] = null; break jumplessRun; case Token.GOTO : break jumplessRun; case Icode_GOSUB : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.pc + 2; break jumplessRun; case Icode_STARTSUB : if (stackTop == frame.emptyStackTop + 1) { // Call from Icode_GOSUB: store return PC address in the local indexReg += frame.localShift; stack[indexReg] = stack[stackTop]; sDbl[indexReg] = sDbl[stackTop]; --stackTop; } else { // Call from exception handler: exception object is already stored // in the local if (stackTop != frame.emptyStackTop) Kit.codeBug(); } continue Loop; case Icode_RETSUB : { // indexReg: local to store return address if (instructionCounting) { addInstructionCount(cx, frame, 0); } indexReg += frame.localShift; Object value = stack[indexReg]; if (value != DBL_MRK) { // Invocation from exception handler, restore object to rethrow throwable = value; break withoutExceptions; } // Normal return from GOSUB frame.pc = (int)sDbl[indexReg]; if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } case Icode_POP : stack[stackTop] = null; stackTop--; continue Loop; case Icode_POP_RESULT : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; stack[stackTop] = null; --stackTop; continue Loop; case Icode_DUP : stack[stackTop + 1] = stack[stackTop]; sDbl[stackTop + 1] = sDbl[stackTop]; stackTop++; continue Loop; case Icode_DUP2 : stack[stackTop + 1] = stack[stackTop - 1]; sDbl[stackTop + 1] = sDbl[stackTop - 1]; stack[stackTop + 2] = stack[stackTop]; sDbl[stackTop + 2] = sDbl[stackTop]; stackTop += 2; continue Loop; case Icode_SWAP : { Object o = stack[stackTop]; stack[stackTop] = stack[stackTop - 1]; stack[stackTop - 1] = o; double d = sDbl[stackTop]; sDbl[stackTop] = sDbl[stackTop - 1]; sDbl[stackTop - 1] = d; continue Loop; } case Token.RETURN : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; --stackTop; break Loop; case Token.RETURN_RESULT : break Loop; case Icode_RETUNDEF : frame.result = undefined; break Loop; case Token.BITNOT : { int rIntValue = stack_int32(frame, stackTop); stack[stackTop] = DBL_MRK; sDbl[stackTop] = ~rIntValue; continue Loop; } case Token.BITAND : case Token.BITOR : case Token.BITXOR : case Token.LSH : case Token.RSH : { stackTop = doBitOp(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.URSH : { double lDbl = stack_double(frame, stackTop - 1); int rIntValue = stack_int32(frame, stackTop) & 0x1F; stack[--stackTop] = DBL_MRK; sDbl[stackTop] = ScriptRuntime.toUint32(lDbl) >>> rIntValue; continue Loop; } case Token.NEG : case Token.POS : { double rDbl = stack_double(frame, stackTop); stack[stackTop] = DBL_MRK; if (op == Token.NEG) { rDbl = -rDbl; } sDbl[stackTop] = rDbl; continue Loop; } case Token.ADD : --stackTop; doAdd(stack, sDbl, stackTop, cx); continue Loop; case Token.SUB : case Token.MUL : case Token.DIV : case Token.MOD : { stackTop = doArithmetic(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.NOT : stack[stackTop] = ScriptRuntime.wrapBoolean( !stack_boolean(frame, stackTop)); continue Loop; case Token.BINDNAME : stack[++stackTop] = ScriptRuntime.bind(cx, frame.scope, stringReg); continue Loop; case Token.STRICT_SETNAME: case Token.SETNAME : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = op == Token.SETNAME ? ScriptRuntime.setName(lhs, rhs, cx, frame.scope, stringReg) : ScriptRuntime.strictSetName(lhs, rhs, cx, frame.scope, stringReg); continue Loop; } case Icode_SETCONST: { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = ScriptRuntime.setConst(lhs, rhs, cx, stringReg); continue Loop; } case Token.DELPROP : case Icode_DELNAME : { stackTop = doDelName(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.GETPROPNOWARN : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectPropNoWarn(lhs, stringReg, cx); continue Loop; } case Token.GETPROP : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx, frame.scope); continue Loop; } case Token.SETPROP : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setObjectProp(lhs, stringReg, rhs, cx); continue Loop; } case Icode_PROP_INC_DEC : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.propIncrDecr(lhs, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.GETELEM : { stackTop = doGetElem(cx, frame, stack, sDbl, stackTop); continue Loop; } case Token.SETELEM : { stackTop = doSetElem(cx, stack, sDbl, stackTop); continue Loop; } case Icode_ELEM_INC_DEC: { stackTop = doElemIncDec(cx, frame, iCode, stack, sDbl, stackTop); continue Loop; } case Token.GET_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refGet(ref, cx); continue Loop; } case Token.SET_REF : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refSet(ref, value, cx); continue Loop; } case Token.DEL_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refDel(ref, cx); continue Loop; } case Icode_REF_INC_DEC : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refIncrDecr(ref, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.LOCAL_LOAD : ++stackTop; indexReg += frame.localShift; stack[stackTop] = stack[indexReg]; sDbl[stackTop] = sDbl[indexReg]; continue Loop; case Icode_LOCAL_CLEAR : indexReg += frame.localShift; stack[indexReg] = null; continue Loop; case Icode_NAME_AND_THIS : // stringReg: name ++stackTop; stack[stackTop] = ScriptRuntime.getNameFunctionAndThis(stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; case Icode_PROP_AND_THIS: { Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); // stringReg: property stack[stackTop] = ScriptRuntime.getPropFunctionAndThis(obj, stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_ELEM_AND_THIS: { Object obj = stack[stackTop - 1]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop - 1]); Object id = stack[stackTop]; if (id == DBL_MRK) id = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id, cx); stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_VALUE_AND_THIS : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getValueFunctionAndThis(value, cx); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_CALLSPECIAL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } stackTop = doCallSpecial(cx, frame, stack, sDbl, stackTop, iCode, indexReg); continue Loop; } case Token.CALL : case Icode_TAIL_CALL : case Token.REF_CALL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function thisObj arg0 .. argN -> result // indexReg: number of arguments stackTop -= 1 + indexReg; // CALL generation ensures that fun and funThisObj // are already Scriptable and Callable objects respectively Callable fun = (Callable)stack[stackTop]; Scriptable funThisObj = (Scriptable)stack[stackTop + 1]; if (op == Token.REF_CALL) { Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 2, indexReg); stack[stackTop] = ScriptRuntime.callRef(fun, funThisObj, outArgs, cx); continue Loop; } Scriptable calleeScope = frame.scope; if (frame.useActivation) { calleeScope = ScriptableObject.getTopLevelScope(frame.scope); } if (fun instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction)fun; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { CallFrame callParentFrame = frame; CallFrame calleeFrame = new CallFrame(); if (op == Icode_TAIL_CALL) { // In principle tail call can re-use the current // frame and its stack arrays but it is hard to // do properly. Any exceptions that can legally // happen during frame re-initialization including // StackOverflowException during innocent looking // System.arraycopy may leave the current frame // data corrupted leading to undefined behaviour // in the catch code bellow that unwinds JS stack // on exceptions. Then there is issue about frame release // end exceptions there. // To avoid frame allocation a released frame // can be cached for re-use which would also benefit // non-tail calls but it is not clear that this caching // would gain in performance due to potentially // bad interaction with GC. callParentFrame = frame.parentFrame; // Release the current frame. See Bug #344501 to see why // it is being done here. exitFrame(cx, frame, null); } initFrame(cx, calleeScope, funThisObj, stack, sDbl, stackTop + 2, indexReg, ifun, callParentFrame, calleeFrame); if (op != Icode_TAIL_CALL) { frame.savedStackTop = stackTop; frame.savedCallOp = op; } frame = calleeFrame; continue StateLoop; } } if (fun instanceof NativeContinuation) { // Jump to the captured continuation ContinuationJump cjump; cjump = new ContinuationJump((NativeContinuation)fun, frame); // continuation result is the first argument if any // of continuation call if (indexReg == 0) { cjump.result = undefined; } else { cjump.result = stack[stackTop + 2]; cjump.resultDbl = sDbl[stackTop + 2]; } // Start the real unwind job throwable = cjump; break withoutExceptions; } if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } // Bug 405654 -- make best effort to keep Function.apply and // Function.call within this interpreter loop invocation if (BaseFunction.isApplyOrCall(ifun)) { Callable applyCallable = ScriptRuntime.getCallable(funThisObj); if (applyCallable instanceof InterpretedFunction) { InterpretedFunction iApplyCallable = (InterpretedFunction)applyCallable; if (frame.fnOrScript.securityDomain == iApplyCallable.securityDomain) { frame = initFrameForApplyOrCall(cx, frame, indexReg, stack, sDbl, stackTop, op, calleeScope, ifun, iApplyCallable); continue StateLoop; } } } } // Bug 447697 -- make best effort to keep __noSuchMethod__ within this // interpreter loop invocation if (fun instanceof NoSuchMethodShim) { // get the shim and the actual method NoSuchMethodShim noSuchMethodShim = (NoSuchMethodShim) fun; Callable noSuchMethodMethod = noSuchMethodShim.noSuchMethodMethod; // if the method is in fact an InterpretedFunction if (noSuchMethodMethod instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction) noSuchMethodMethod; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { frame = initFrameForNoSuchMethod(cx, frame, indexReg, stack, sDbl, stackTop, op, funThisObj, calleeScope, noSuchMethodShim, ifun); continue StateLoop; } } } cx.lastInterpreterFrame = frame; frame.savedCallOp = op; frame.savedStackTop = stackTop; stack[stackTop] = fun.call(cx, calleeScope, funThisObj, getArgsArray(stack, sDbl, stackTop + 2, indexReg)); continue Loop; } case Token.NEW : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function arg0 .. argN -> newResult // indexReg: number of arguments stackTop -= indexReg; Object lhs = stack[stackTop]; if (lhs instanceof InterpretedFunction) { InterpretedFunction f = (InterpretedFunction)lhs; if (frame.fnOrScript.securityDomain == f.securityDomain) { Scriptable newInstance = f.createObject(cx, frame.scope); CallFrame calleeFrame = new CallFrame(); initFrame(cx, frame.scope, newInstance, stack, sDbl, stackTop + 1, indexReg, f, frame, calleeFrame); stack[stackTop] = newInstance; frame.savedStackTop = stackTop; frame.savedCallOp = op; frame = calleeFrame; continue StateLoop; } } if (!(lhs instanceof Function)) { if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); throw ScriptRuntime.notFunctionError(lhs); } Function fun = (Function)lhs; if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } } Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 1, indexReg); stack[stackTop] = fun.construct(cx, frame.scope, outArgs); continue Loop; } case Token.TYPEOF : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.typeof(lhs); continue Loop; } case Icode_TYPEOFNAME : stack[++stackTop] = ScriptRuntime.typeofName(frame.scope, stringReg); continue Loop; case Token.STRING : stack[++stackTop] = stringReg; continue Loop; case Icode_SHORTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getShort(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_INTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Token.NUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.idata.itsDoubleTable[indexReg]; continue Loop; case Token.NAME : stack[++stackTop] = ScriptRuntime.name(cx, frame.scope, stringReg); continue Loop; case Icode_NAME_INC_DEC : stack[++stackTop] = ScriptRuntime.nameIncrDecr(frame.scope, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; case Icode_SETCONSTVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETCONSTVAR : stackTop = doSetConstVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_SETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETVAR : stackTop = doSetVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_GETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.GETVAR : stackTop = doGetVar(frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; case Icode_VAR_INC_DEC : { stackTop = doVarIncDec(cx, frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; } case Icode_ZERO : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 0; continue Loop; case Icode_ONE : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 1; continue Loop; case Token.NULL : stack[++stackTop] = null; continue Loop; case Token.THIS : stack[++stackTop] = frame.thisObj; continue Loop; case Token.THISFN : stack[++stackTop] = frame.fnOrScript; continue Loop; case Token.FALSE : stack[++stackTop] = Boolean.FALSE; continue Loop; case Token.TRUE : stack[++stackTop] = Boolean.TRUE; continue Loop; case Icode_UNDEF : stack[++stackTop] = undefined; continue Loop; case Token.ENTERWITH : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterWith(lhs, cx, frame.scope); continue Loop; } case Token.LEAVEWITH : frame.scope = ScriptRuntime.leaveWith(frame.scope); continue Loop; case Token.CATCH_SCOPE : { // stack top: exception object // stringReg: name of exception variable // indexReg: local for exception scope --stackTop; indexReg += frame.localShift; boolean afterFirstScope = (frame.idata.itsICode[frame.pc] != 0); Throwable caughtException = (Throwable)stack[stackTop + 1]; Scriptable lastCatchScope; if (!afterFirstScope) { lastCatchScope = null; } else { lastCatchScope = (Scriptable)stack[indexReg]; } stack[indexReg] = ScriptRuntime.newCatchScope(caughtException, lastCatchScope, stringReg, cx, frame.scope); ++frame.pc; continue Loop; } case Token.ENUM_INIT_KEYS : case Token.ENUM_INIT_VALUES : case Token.ENUM_INIT_ARRAY : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; indexReg += frame.localShift; int enumType = op == Token.ENUM_INIT_KEYS ? ScriptRuntime.ENUMERATE_KEYS : op == Token.ENUM_INIT_VALUES ? ScriptRuntime.ENUMERATE_VALUES : ScriptRuntime.ENUMERATE_ARRAY; stack[indexReg] = ScriptRuntime.enumInit(lhs, cx, enumType); continue Loop; } case Token.ENUM_NEXT : case Token.ENUM_ID : { indexReg += frame.localShift; Object val = stack[indexReg]; ++stackTop; stack[stackTop] = (op == Token.ENUM_NEXT) ? (Object)ScriptRuntime.enumNext(val) : (Object)ScriptRuntime.enumId(val, cx); continue Loop; } case Token.REF_SPECIAL : { //stringReg: name of special property Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg, cx); continue Loop; } case Token.REF_MEMBER: { //indexReg: flags stackTop = doRefMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NS_MEMBER: { //indexReg: flags stackTop = doRefNsMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NAME: { //indexReg: flags Object name = stack[stackTop]; if (name == DBL_MRK) name = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.nameRef(name, cx, frame.scope, indexReg); continue Loop; } case Token.REF_NS_NAME: { //indexReg: flags stackTop = doRefNsName(cx, frame, stack, sDbl, stackTop, indexReg); continue Loop; } case Icode_SCOPE_LOAD : indexReg += frame.localShift; frame.scope = (Scriptable)stack[indexReg]; continue Loop; case Icode_SCOPE_SAVE : indexReg += frame.localShift; stack[indexReg] = frame.scope; continue Loop; case Icode_CLOSURE_EXPR : stack[++stackTop] = InterpretedFunction.createFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Icode_CLOSURE_STMT : initFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Token.REGEXP : Object re = frame.idata.itsRegExpLiterals[indexReg]; stack[++stackTop] = ScriptRuntime.wrapRegExp(cx, frame.scope, re); continue Loop; case Icode_LITERAL_NEW : // indexReg: number of values in the literal ++stackTop; stack[stackTop] = new int[indexReg]; ++stackTop; stack[stackTop] = new Object[indexReg]; sDbl[stackTop] = 0; continue Loop; case Icode_LITERAL_SET : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_GETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = -1; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_SETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = +1; sDbl[stackTop] = i + 1; continue Loop; } case Token.ARRAYLIT : case Icode_SPARE_ARRAYLIT : case Token.OBJECTLIT : { Object[] data = (Object[])stack[stackTop]; --stackTop; int[] getterSetters = (int[])stack[stackTop]; Object val; if (op == Token.OBJECTLIT) { Object[] ids = (Object[])frame.idata.literalIds[indexReg]; val = ScriptRuntime.newObjectLiteral(ids, data, getterSetters, cx, frame.scope); } else { int[] skipIndexces = null; if (op == Icode_SPARE_ARRAYLIT) { skipIndexces = (int[])frame.idata.literalIds[indexReg]; } val = ScriptRuntime.newArrayLiteral(data, skipIndexces, cx, frame.scope); } stack[stackTop] = val; continue Loop; } case Icode_ENTERDQ : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterDotQuery(lhs, frame.scope); continue Loop; } case Icode_LEAVEDQ : { boolean valBln = stack_boolean(frame, stackTop); Object x = ScriptRuntime.updateDotQuery(valBln, frame.scope); if (x != null) { stack[stackTop] = x; frame.scope = ScriptRuntime.leaveDotQuery(frame.scope); frame.pc += 2; continue Loop; } // reset stack and PC to code after ENTERDQ --stackTop; break jumplessRun; } case Token.DEFAULTNAMESPACE : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setDefaultNamespace(value, cx); continue Loop; } case Token.ESCXMLATTR : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeAttributeValue(value, cx); } continue Loop; } case Token.ESCXMLTEXT : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeTextValue(value, cx); } continue Loop; } case Icode_DEBUGGER: if (frame.debuggerFrame != null) { frame.debuggerFrame.onDebuggerStatement(cx); } continue Loop; case Icode_LINE : frame.pcSourceLineStart = frame.pc; if (frame.debuggerFrame != null) { int line = getIndex(iCode, frame.pc); frame.debuggerFrame.onLineChange(cx, line); } frame.pc += 2; continue Loop; case Icode_REG_IND_C0: indexReg = 0; continue Loop; case Icode_REG_IND_C1: indexReg = 1; continue Loop; case Icode_REG_IND_C2: indexReg = 2; continue Loop; case Icode_REG_IND_C3: indexReg = 3; continue Loop; case Icode_REG_IND_C4: indexReg = 4; continue Loop; case Icode_REG_IND_C5: indexReg = 5; continue Loop; case Icode_REG_IND1: indexReg = 0xFF & iCode[frame.pc]; ++frame.pc; continue Loop; case Icode_REG_IND2: indexReg = getIndex(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_REG_IND4: indexReg = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Icode_REG_STR_C0: stringReg = strings[0]; continue Loop; case Icode_REG_STR_C1: stringReg = strings[1]; continue Loop; case Icode_REG_STR_C2: stringReg = strings[2]; continue Loop; case Icode_REG_STR_C3: stringReg = strings[3]; continue Loop; case Icode_REG_STR1: stringReg = strings[0xFF & iCode[frame.pc]]; ++frame.pc; continue Loop; case Icode_REG_STR2: stringReg = strings[getIndex(iCode, frame.pc)]; frame.pc += 2; continue Loop; case Icode_REG_STR4: stringReg = strings[getInt(iCode, frame.pc)]; frame.pc += 4; continue Loop; default : dumpICode(frame.idata); throw new RuntimeException("Unknown icode : " + op + " @ pc : " + (frame.pc-1)); } // end of interpreter switch } // end of jumplessRun label block // This should be reachable only for jump implementation // when pc points to encoded target offset if (instructionCounting) { addInstructionCount(cx, frame, 2); } int offset = getShort(iCode, frame.pc); if (offset != 0) { // -1 accounts for pc pointing to jump opcode + 1 frame.pc += offset - 1; } else { frame.pc = frame.idata.longJumps. getExistingInt(frame.pc); } if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } // end of Loop: for exitFrame(cx, frame, null); interpreterResult = frame.result; interpreterResultDbl = frame.resultDbl; if (frame.parentFrame != null) { frame = frame.parentFrame; if (frame.frozen) { frame = frame.cloneFrozen(); } setCallResult( frame, interpreterResult, interpreterResultDbl); interpreterResult = null; // Help GC continue StateLoop; } break StateLoop; } // end of interpreter withoutExceptions: try catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; } // This should be reachable only after above catch or from // finally when it needs to propagate exception or from // explicit throw if (throwable == null) Kit.codeBug(); // Exception type final int EX_CATCH_STATE = 2; // Can execute JS catch final int EX_FINALLY_STATE = 1; // Can execute JS finally final int EX_NO_JS_STATE = 0; // Terminate JS execution int exState; ContinuationJump cjump = null; if (generatorState != null && generatorState.operation == NativeGenerator.GENERATOR_CLOSE && throwable == generatorState.value) { exState = EX_FINALLY_STATE; } else if (throwable instanceof JavaScriptException) { exState = EX_CATCH_STATE; } else if (throwable instanceof EcmaError) { // an offical ECMA error object, exState = EX_CATCH_STATE; } else if (throwable instanceof EvaluatorException) { exState = EX_CATCH_STATE; } else if (throwable instanceof RuntimeException) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } else if (throwable instanceof Error) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_NO_JS_STATE; } else if (throwable instanceof ContinuationJump) { // It must be ContinuationJump exState = EX_FINALLY_STATE; cjump = (ContinuationJump)throwable; } else { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } if (instructionCounting) { try { addInstructionCount(cx, frame, EXCEPTION_COST); } catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; } catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } if (frame.debuggerFrame != null && throwable instanceof RuntimeException) { // Call debugger only for RuntimeException RuntimeException rex = (RuntimeException)throwable; try { frame.debuggerFrame.onExceptionThrown(cx, rex); } catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } for (;;) { if (exState != EX_NO_JS_STATE) { boolean onlyFinally = (exState != EX_CATCH_STATE); indexReg = getExceptionHandler(frame, onlyFinally); if (indexReg >= 0) { // We caught an exception, restart the loop // with exception pending the processing at the loop // start continue StateLoop; } } // No allowed exception handlers in this frame, unwind // to parent and try to look there exitFrame(cx, frame, throwable); frame = frame.parentFrame; if (frame == null) { break; } if (cjump != null && cjump.branchFrame == frame) { // Continuation branch point was hit, // restart the state loop to reenter continuation indexReg = -1; continue StateLoop; } } // No more frames, rethrow the exception or deal with continuation if (cjump != null) { if (cjump.branchFrame != null) { // The above loop should locate the top frame Kit.codeBug(); } if (cjump.capturedFrame != null) { // Restarting detached continuation indexReg = -1; continue StateLoop; } // Return continuation result to the caller interpreterResult = cjump.result; interpreterResultDbl = cjump.resultDbl; throwable = null; } break StateLoop; } // end of StateLoop: for(;;) // Do cleanups/restorations before the final return or throw if (cx.previousInterpreterInvocations != null && cx.previousInterpreterInvocations.size() != 0) { cx.lastInterpreterFrame = cx.previousInterpreterInvocations.pop(); } else { // It was the last interpreter frame on the stack cx.lastInterpreterFrame = null; // Force GC of the value cx.previousInterpreterInvocations cx.previousInterpreterInvocations = null; } if (throwable != null) { if (throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else { // Must be instance of Error or code bug throw (Error)throwable; } } return (interpreterResult != DBL_MRK) ? interpreterResult : ScriptRuntime.wrapNumber(interpreterResultDbl); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
public static NativeContinuation captureContinuation(Context cx) { if (cx.lastInterpreterFrame == null || !(cx.lastInterpreterFrame instanceof CallFrame)) { throw new IllegalStateException("Interpreter frames not found"); } return captureContinuation(cx, (CallFrame)cx.lastInterpreterFrame, true); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static NativeContinuation captureContinuation(Context cx, CallFrame frame, boolean requireContinuationsTopFrame) { NativeContinuation c = new NativeContinuation(); ScriptRuntime.setObjectProtoAndParent( c, ScriptRuntime.getTopCallScope(cx)); // Make sure that all frames are frozen CallFrame x = frame; CallFrame outermost = frame; while (x != null && !x.frozen) { x.frozen = true; // Allow to GC unused stack space for (int i = x.savedStackTop + 1; i != x.stack.length; ++i) { // Allow to GC unused stack space x.stack[i] = null; x.stackAttributes[i] = ScriptableObject.EMPTY; } if (x.savedCallOp == Token.CALL) { // the call will always overwrite the stack top with the result x.stack[x.savedStackTop] = null; } else { if (x.savedCallOp != Token.NEW) Kit.codeBug(); // the new operator uses stack top to store the constructed // object so it shall not be cleared: see comments in // setCallResult } outermost = x; x = x.parentFrame; } if (requireContinuationsTopFrame) { while (outermost.parentFrame != null) outermost = outermost.parentFrame; if (!outermost.isContinuationsTopFrame) { throw new IllegalStateException("Cannot capture continuation " + "from JavaScript code not called directly by " + "executeScriptWithContinuations or " + "callFunctionWithContinuations"); } } c.initImplementation(frame); return c; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Callable getValueFunctionAndThis(Object value, Context cx) { if (!(value instanceof Callable)) { throw notFunctionError(value); } Callable f = (Callable)value; Scriptable thisObj = null; if (f instanceof Scriptable) { thisObj = ((Scriptable)f).getParentScope(); } if (thisObj == null) { if (cx.topCallScope == null) throw new IllegalStateException(); thisObj = cx.topCallScope; } if (thisObj.getParentScope() != null) { if (thisObj instanceof NativeWith) { // functions defined inside with should have with target // as their thisObj } else if (thisObj instanceof NativeCall) { // nested functions should have top scope as their thisObj thisObj = ScriptableObject.getTopLevelScope(thisObj); } } storeScriptable(cx, thisObj); return f; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Ref callRef(Callable function, Scriptable thisObj, Object[] args, Context cx) { if (function instanceof RefCallable) { RefCallable rfunction = (RefCallable)function; Ref ref = rfunction.refCall(cx, thisObj, args); if (ref == null) { throw new IllegalStateException(rfunction.getClass().getName()+".refCall() returned null"); } return ref; } // No runtime support for now String msg = getMessage1("msg.no.ref.from.function", toString(function)); throw constructError("ReferenceError", msg); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Scriptable getTopCallScope(Context cx) { Scriptable scope = cx.topCallScope; if (scope == null) { throw new IllegalStateException(); } return scope; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (scope == null) throw new IllegalArgumentException(); if (cx.topCallScope != null) throw new IllegalStateException(); Object result; cx.topCallScope = ScriptableObject.getTopLevelScope(scope); cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE); ContextFactory f = cx.getFactory(); try { result = f.doTopCall(callable, cx, scope, thisObj, args); } finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void initScript(NativeFunction funObj, Scriptable thisObj, Context cx, Scriptable scope, boolean evalScript) { if (cx.topCallScope == null) throw new IllegalStateException(); int varCount = funObj.getParamAndVarCount(); if (varCount != 0) { Scriptable varScope = scope; // Never define any variables from var statements inside with // object. See bug 38590. while (varScope instanceof NativeWith) { varScope = varScope.getParentScope(); } for (int i = varCount; i-- != 0;) { String name = funObj.getParamOrVarName(i); boolean isConst = funObj.getParamOrVarConst(i); // Don't overwrite existing def if already defined in object // or prototypes of object. if (!ScriptableObject.hasProperty(scope, name)) { if (!evalScript) { // Global var definitions are supposed to be DONTDELETE if (isConst) ScriptableObject.defineConstProperty(varScope, name); else ScriptableObject.defineProperty( varScope, name, Undefined.instance, ScriptableObject.PERMANENT); } else { varScope.put(name, varScope, Undefined.instance); } } else { ScriptableObject.redefineProperty(scope, name, isConst); } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static void enterActivationFunction(Context cx, Scriptable scope) { if (cx.topCallScope == null) throw new IllegalStateException(); NativeCall call = (NativeCall)scope; call.parentActivationCall = cx.currentActivationCall; cx.currentActivationCall = call; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
private static XMLLib currentXMLLib(Context cx) { // Scripts should be running to access this if (cx.topCallScope == null) throw new IllegalStateException(); XMLLib xmlLib = cx.cachedXMLLib; if (xmlLib == null) { xmlLib = XMLLib.extractFromScope(cx.topCallScope); if (xmlLib == null) throw new IllegalStateException(); cx.cachedXMLLib = xmlLib; } return xmlLib; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static long lastUint32Result(Context cx) { long value = cx.scratchUint32; if ((value >>> 32) != 0) throw new IllegalStateException(); return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
private static void storeScriptable(Context cx, Scriptable value) { // The previously stored scratchScriptable should be consumed if (cx.scratchScriptable != null) throw new IllegalStateException(); cx.scratchScriptable = value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
void init() { synchronized (this) { if (state == STATE_INITIALIZING) throw new IllegalStateException( "Recursive initialization for "+propertyName); if (state == STATE_BEFORE_INIT) { state = STATE_INITIALIZING; // Set value now to have something to set in finally block if // buildValue throws. Object value = Scriptable.NOT_FOUND; try { value = buildValue(); } finally { initializedValue = value; state = STATE_WITH_VALUE; } } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
Object getValue() { if (state != STATE_WITH_VALUE) throw new IllegalStateException(propertyName); return initializedValue; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static final Context enter(Context cx, ContextFactory factory) { Object helper = VMBridge.instance.getThreadContextHelper(); Context old = VMBridge.instance.getContext(helper); if (old != null) { cx = old; } else { if (cx == null) { cx = factory.makeContext(); if (cx.enterCount != 0) { throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread"); } factory.onContextCreated(cx); if (factory.isSealed() && !cx.isSealed()) { cx.seal(null); } } else { if (cx.enterCount != 0) { throw new IllegalStateException("can not use Context instance already associated with some thread"); } } VMBridge.instance.setContext(helper, cx); } ++cx.enterCount; return cx; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void unseal(Object sealKey) { if (sealKey == null) throw new IllegalArgumentException(); if (this.sealKey != sealKey) throw new IllegalArgumentException(); if (!sealed) throw new IllegalStateException(); sealed = false; this.sealKey = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static void onSealedMutation() { throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public Object callFunctionWithContinuations(Callable function, Scriptable scope, Object[] args) throws ContinuationPending { if (!(function instanceof InterpretedFunction)) { // Can only be applied to scripts throw new IllegalArgumentException("Function argument was not" + " created by interpreted mode "); } if (ScriptRuntime.hasTopCall(this)) { throw new IllegalStateException("Cannot have any pending top " + "calls when executing a script with continuations"); } // Annotate so we can check later to ensure no java code in // intervening frames isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setMaximumInterpreterStackDepth(int max) { if(sealed) onSealedMutation(); if(optimizationLevel != -1) { throw new IllegalStateException("Cannot set maximumInterpreterStackDepth when optimizationLevel != -1"); } if(max < 1) { throw new IllegalArgumentException("Cannot set maximumInterpreterStackDepth to less than 1"); } maximumInterpreterStackDepth = max; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void stopMethod(short maxLocals) { if (itsCurrentMethod == null) throw new IllegalStateException("No method to stop"); fixLabelGotos(); itsMaxLocals = maxLocals; StackMapTable stackMap = null; if (GenerateStackMap) { finalizeSuperBlockStarts(); stackMap = new StackMapTable(); stackMap.generate(); } int lineNumberTableLength = 0; if (itsLineNumberTable != null) { // 6 bytes for the attribute header // 2 bytes for the line number count // 4 bytes for each entry lineNumberTableLength = 6 + 2 + (itsLineNumberTableTop * 4); } int variableTableLength = 0; if (itsVarDescriptors != null) { // 6 bytes for the attribute header // 2 bytes for the variable count // 10 bytes for each entry variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10); } int stackMapTableLength = 0; if (stackMap != null) { int stackMapWriteSize = stackMap.computeWriteSize(); if (stackMapWriteSize > 0) { stackMapTableLength = 6 + stackMapWriteSize; } } int attrLength = 2 + // attribute_name_index 4 + // attribute_length 2 + // max_stack 2 + // max_locals 4 + // code_length itsCodeBufferTop + 2 + // exception_table_length (itsExceptionTableTop * 8) + 2 + // attributes_count lineNumberTableLength + variableTableLength + stackMapTableLength; if (attrLength > 65536) { // See http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html, // section 4.10, "The amount of code per non-native, non-abstract // method is limited to 65536 bytes... throw new ClassFileFormatException( "generated bytecode for method exceeds 64K limit."); } byte[] codeAttribute = new byte[attrLength]; int index = 0; int codeAttrIndex = itsConstantPool.addUtf8("Code"); index = putInt16(codeAttrIndex, codeAttribute, index); attrLength -= 6; // discount the attribute header index = putInt32(attrLength, codeAttribute, index); index = putInt16(itsMaxStack, codeAttribute, index); index = putInt16(itsMaxLocals, codeAttribute, index); index = putInt32(itsCodeBufferTop, codeAttribute, index); System.arraycopy(itsCodeBuffer, 0, codeAttribute, index, itsCodeBufferTop); index += itsCodeBufferTop; if (itsExceptionTableTop > 0) { index = putInt16(itsExceptionTableTop, codeAttribute, index); for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short)getLabelPC(ete.itsStartLabel); short endPC = (short)getLabelPC(ete.itsEndLabel); short handlerPC = (short)getLabelPC(ete.itsHandlerLabel); short catchType = ete.itsCatchType; if (startPC == -1) throw new IllegalStateException("start label not defined"); if (endPC == -1) throw new IllegalStateException("end label not defined"); if (handlerPC == -1) throw new IllegalStateException( "handler label not defined"); index = putInt16(startPC, codeAttribute, index); index = putInt16(endPC, codeAttribute, index); index = putInt16(handlerPC, codeAttribute, index); index = putInt16(catchType, codeAttribute, index); } } else { // write 0 as exception table length index = putInt16(0, codeAttribute, index); } int attributeCount = 0; if (itsLineNumberTable != null) attributeCount++; if (itsVarDescriptors != null) attributeCount++; if (stackMapTableLength > 0) { attributeCount++; } index = putInt16(attributeCount, codeAttribute, index); if (itsLineNumberTable != null) { int lineNumberTableAttrIndex = itsConstantPool.addUtf8("LineNumberTable"); index = putInt16(lineNumberTableAttrIndex, codeAttribute, index); int tableAttrLength = 2 + (itsLineNumberTableTop * 4); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(itsLineNumberTableTop, codeAttribute, index); for (int i = 0; i < itsLineNumberTableTop; i++) { index = putInt32(itsLineNumberTable[i], codeAttribute, index); } } if (itsVarDescriptors != null) { int variableTableAttrIndex = itsConstantPool.addUtf8("LocalVariableTable"); index = putInt16(variableTableAttrIndex, codeAttribute, index); int varCount = itsVarDescriptors.size(); int tableAttrLength = 2 + (varCount * 10); index = putInt32(tableAttrLength, codeAttribute, index); index = putInt16(varCount, codeAttribute, index); for (int i = 0; i < varCount; i++) { int[] chunk = (int[])itsVarDescriptors.get(i); int nameIndex = chunk[0]; int descriptorIndex = chunk[1]; int startPC = chunk[2]; int register = chunk[3]; int length = itsCodeBufferTop - startPC; index = putInt16(startPC, codeAttribute, index); index = putInt16(length, codeAttribute, index); index = putInt16(nameIndex, codeAttribute, index); index = putInt16(descriptorIndex, codeAttribute, index); index = putInt16(register, codeAttribute, index); } } if (stackMapTableLength > 0) { int stackMapTableAttrIndex = itsConstantPool.addUtf8("StackMapTable"); int start = index; index = putInt16(stackMapTableAttrIndex, codeAttribute, index); index = stackMap.write(codeAttribute, index); } itsCurrentMethod.setCodeAttribute(codeAttribute); itsExceptionTable = null; itsExceptionTableTop = 0; itsLineNumberTableTop = 0; itsCodeBufferTop = 0; itsCurrentMethod = null; itsMaxStack = 0; itsStackTop = 0; itsLabelTableTop = 0; itsFixupTableTop = 0; itsVarDescriptors = null; itsSuperBlockStarts = null; itsSuperBlockStartsTop = 0; itsJumpFroms = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public void markLabel(int label) { if (!(label < 0)) throw new IllegalArgumentException("Bad label, no biscuit"); label &= 0x7FFFFFFF; if (label > itsLabelTableTop) throw new IllegalArgumentException("Bad label"); if (itsLabelTable[label] != -1) { throw new IllegalStateException("Can only mark label once"); } itsLabelTable[label] = itsCodeBufferTop; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private int execute(int bci) { int bc = itsCodeBuffer[bci] & 0xFF; int type, type2, index; int length = 0; long lType, lType2; String className; switch (bc) { case ByteCode.NOP: case ByteCode.IINC: case ByteCode.GOTO: case ByteCode.GOTO_W: // No change break; case ByteCode.CHECKCAST: pop(); push(TypeInfo.OBJECT(getOperand(bci + 1, 2))); break; case ByteCode.IASTORE: // pop; pop; pop case ByteCode.LASTORE: case ByteCode.FASTORE: case ByteCode.DASTORE: case ByteCode.AASTORE: case ByteCode.BASTORE: case ByteCode.CASTORE: case ByteCode.SASTORE: pop(); case ByteCode.PUTFIELD: // pop; pop case ByteCode.IF_ICMPEQ: case ByteCode.IF_ICMPNE: case ByteCode.IF_ICMPLT: case ByteCode.IF_ICMPGE: case ByteCode.IF_ICMPGT: case ByteCode.IF_ICMPLE: case ByteCode.IF_ACMPEQ: case ByteCode.IF_ACMPNE: pop(); case ByteCode.IFEQ: // pop case ByteCode.IFNE: case ByteCode.IFLT: case ByteCode.IFGE: case ByteCode.IFGT: case ByteCode.IFLE: case ByteCode.IFNULL: case ByteCode.IFNONNULL: case ByteCode.POP: case ByteCode.MONITORENTER: case ByteCode.MONITOREXIT: case ByteCode.PUTSTATIC: pop(); break; case ByteCode.POP2: pop2(); break; case ByteCode.ACONST_NULL: push(TypeInfo.NULL); break; case ByteCode.IALOAD: // pop; pop; push(INTEGER) case ByteCode.BALOAD: case ByteCode.CALOAD: case ByteCode.SALOAD: case ByteCode.IADD: case ByteCode.ISUB: case ByteCode.IMUL: case ByteCode.IDIV: case ByteCode.IREM: case ByteCode.ISHL: case ByteCode.ISHR: case ByteCode.IUSHR: case ByteCode.IAND: case ByteCode.IOR: case ByteCode.IXOR: case ByteCode.LCMP: case ByteCode.FCMPL: case ByteCode.FCMPG: case ByteCode.DCMPL: case ByteCode.DCMPG: pop(); case ByteCode.INEG: // pop; push(INTEGER) case ByteCode.L2I: case ByteCode.F2I: case ByteCode.D2I: case ByteCode.I2B: case ByteCode.I2C: case ByteCode.I2S: case ByteCode.ARRAYLENGTH: case ByteCode.INSTANCEOF: pop(); case ByteCode.ICONST_M1: // push(INTEGER) case ByteCode.ICONST_0: case ByteCode.ICONST_1: case ByteCode.ICONST_2: case ByteCode.ICONST_3: case ByteCode.ICONST_4: case ByteCode.ICONST_5: case ByteCode.ILOAD: case ByteCode.ILOAD_0: case ByteCode.ILOAD_1: case ByteCode.ILOAD_2: case ByteCode.ILOAD_3: case ByteCode.BIPUSH: case ByteCode.SIPUSH: push(TypeInfo.INTEGER); break; case ByteCode.LALOAD: // pop; pop; push(LONG) case ByteCode.LADD: case ByteCode.LSUB: case ByteCode.LMUL: case ByteCode.LDIV: case ByteCode.LREM: case ByteCode.LSHL: case ByteCode.LSHR: case ByteCode.LUSHR: case ByteCode.LAND: case ByteCode.LOR: case ByteCode.LXOR: pop(); case ByteCode.LNEG: // pop; push(LONG) case ByteCode.I2L: case ByteCode.F2L: case ByteCode.D2L: pop(); case ByteCode.LCONST_0: // push(LONG) case ByteCode.LCONST_1: case ByteCode.LLOAD: case ByteCode.LLOAD_0: case ByteCode.LLOAD_1: case ByteCode.LLOAD_2: case ByteCode.LLOAD_3: push(TypeInfo.LONG); break; case ByteCode.FALOAD: // pop; pop; push(FLOAT) case ByteCode.FADD: case ByteCode.FSUB: case ByteCode.FMUL: case ByteCode.FDIV: case ByteCode.FREM: pop(); case ByteCode.FNEG: // pop; push(FLOAT) case ByteCode.I2F: case ByteCode.L2F: case ByteCode.D2F: pop(); case ByteCode.FCONST_0: // push(FLOAT) case ByteCode.FCONST_1: case ByteCode.FCONST_2: case ByteCode.FLOAD: case ByteCode.FLOAD_0: case ByteCode.FLOAD_1: case ByteCode.FLOAD_2: case ByteCode.FLOAD_3: push(TypeInfo.FLOAT); break; case ByteCode.DALOAD: // pop; pop; push(DOUBLE) case ByteCode.DADD: case ByteCode.DSUB: case ByteCode.DMUL: case ByteCode.DDIV: case ByteCode.DREM: pop(); case ByteCode.DNEG: // pop; push(DOUBLE) case ByteCode.I2D: case ByteCode.L2D: case ByteCode.F2D: pop(); case ByteCode.DCONST_0: // push(DOUBLE) case ByteCode.DCONST_1: case ByteCode.DLOAD: case ByteCode.DLOAD_0: case ByteCode.DLOAD_1: case ByteCode.DLOAD_2: case ByteCode.DLOAD_3: push(TypeInfo.DOUBLE); break; case ByteCode.ISTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.INTEGER); break; case ByteCode.ISTORE_0: case ByteCode.ISTORE_1: case ByteCode.ISTORE_2: case ByteCode.ISTORE_3: executeStore(bc - ByteCode.ISTORE_0, TypeInfo.INTEGER); break; case ByteCode.LSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.LONG); break; case ByteCode.LSTORE_0: case ByteCode.LSTORE_1: case ByteCode.LSTORE_2: case ByteCode.LSTORE_3: executeStore(bc - ByteCode.LSTORE_0, TypeInfo.LONG); break; case ByteCode.FSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.FLOAT); break; case ByteCode.FSTORE_0: case ByteCode.FSTORE_1: case ByteCode.FSTORE_2: case ByteCode.FSTORE_3: executeStore(bc - ByteCode.FSTORE_0, TypeInfo.FLOAT); break; case ByteCode.DSTORE: executeStore(getOperand(bci + 1, wide ? 2 : 1), TypeInfo.DOUBLE); break; case ByteCode.DSTORE_0: case ByteCode.DSTORE_1: case ByteCode.DSTORE_2: case ByteCode.DSTORE_3: executeStore(bc - ByteCode.DSTORE_0, TypeInfo.DOUBLE); break; case ByteCode.ALOAD: executeALoad(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ALOAD_0: case ByteCode.ALOAD_1: case ByteCode.ALOAD_2: case ByteCode.ALOAD_3: executeALoad(bc - ByteCode.ALOAD_0); break; case ByteCode.ASTORE: executeAStore(getOperand(bci + 1, wide ? 2 : 1)); break; case ByteCode.ASTORE_0: case ByteCode.ASTORE_1: case ByteCode.ASTORE_2: case ByteCode.ASTORE_3: executeAStore(bc - ByteCode.ASTORE_0); break; case ByteCode.IRETURN: case ByteCode.LRETURN: case ByteCode.FRETURN: case ByteCode.DRETURN: case ByteCode.ARETURN: case ByteCode.RETURN: clearStack(); break; case ByteCode.ATHROW: type = pop(); clearStack(); push(type); break; case ByteCode.SWAP: type = pop(); type2 = pop(); push(type); push(type2); break; case ByteCode.LDC: case ByteCode.LDC_W: case ByteCode.LDC2_W: if (bc == ByteCode.LDC) { index = getOperand(bci + 1); } else { index = getOperand(bci + 1, 2); } byte constType = itsConstantPool.getConstantType(index); switch (constType) { case ConstantPool.CONSTANT_Double: push(TypeInfo.DOUBLE); break; case ConstantPool.CONSTANT_Float: push(TypeInfo.FLOAT); break; case ConstantPool.CONSTANT_Long: push(TypeInfo.LONG); break; case ConstantPool.CONSTANT_Integer: push(TypeInfo.INTEGER); break; case ConstantPool.CONSTANT_String: push(TypeInfo.OBJECT("java/lang/String", itsConstantPool)); break; default: throw new IllegalArgumentException( "bad const type " + constType); } break; case ByteCode.NEW: push(TypeInfo.UNINITIALIZED_VARIABLE(bci)); break; case ByteCode.NEWARRAY: pop(); char componentType = arrayTypeToName(itsCodeBuffer[bci + 1]); index = itsConstantPool.addClass("[" + componentType); push(TypeInfo.OBJECT((short) index)); break; case ByteCode.ANEWARRAY: index = getOperand(bci + 1, 2); className = (String) itsConstantPool.getConstantData(index); pop(); push(TypeInfo.OBJECT("[L" + className + ';', itsConstantPool)); break; case ByteCode.INVOKEVIRTUAL: case ByteCode.INVOKESPECIAL: case ByteCode.INVOKESTATIC: case ByteCode.INVOKEINTERFACE: index = getOperand(bci + 1, 2); FieldOrMethodRef m = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String methodType = m.getType(); String methodName = m.getName(); int parameterCount = sizeOfParameters(methodType) >>> 16; for (int i = 0; i < parameterCount; i++) { pop(); } if (bc != ByteCode.INVOKESTATIC) { int instType = pop(); int tag = TypeInfo.getTag(instType); if (tag == TypeInfo.UNINITIALIZED_VARIABLE(0) || tag == TypeInfo.UNINITIALIZED_THIS) { if ("<init>".equals(methodName)) { int newType = TypeInfo.OBJECT(itsThisClassIndex); initializeTypeInfo(instType, newType); } else { throw new IllegalStateException("bad instance"); } } } int rParen = methodType.indexOf(')'); String returnType = methodType.substring(rParen + 1); returnType = descriptorToInternalName(returnType); if (!returnType.equals("V")) { push(TypeInfo.fromType(returnType, itsConstantPool)); } break; case ByteCode.GETFIELD: pop(); case ByteCode.GETSTATIC: index = getOperand(bci + 1, 2); FieldOrMethodRef f = (FieldOrMethodRef) itsConstantPool.getConstantData(index); String fieldType = descriptorToInternalName(f.getType()); push(TypeInfo.fromType(fieldType, itsConstantPool)); break; case ByteCode.DUP: type = pop(); push(type); push(type); break; case ByteCode.DUP_X1: type = pop(); type2 = pop(); push(type); push(type2); push(type); break; case ByteCode.DUP_X2: type = pop(); lType = pop2(); push(type); push2(lType); push(type); break; case ByteCode.DUP2: lType = pop2(); push2(lType); push2(lType); break; case ByteCode.DUP2_X1: lType = pop2(); type = pop(); push2(lType); push(type); push2(lType); break; case ByteCode.DUP2_X2: lType = pop2(); lType2 = pop2(); push2(lType); push2(lType2); push2(lType); break; case ByteCode.TABLESWITCH: int switchStart = bci + 1 + (3 & ~bci); int low = getOperand(switchStart + 4, 4); int high = getOperand(switchStart + 8, 4); length = 4 * (high - low + 4) + switchStart - bci; pop(); break; case ByteCode.AALOAD: pop(); int typeIndex = pop() >>> 8; className = (String) itsConstantPool.getConstantData(typeIndex); String arrayType = className; if (arrayType.charAt(0) != '[') { throw new IllegalStateException("bad array type"); } String elementDesc = arrayType.substring(1); String elementType = descriptorToInternalName(elementDesc); typeIndex = itsConstantPool.addClass(elementType); push(TypeInfo.OBJECT(typeIndex)); break; case ByteCode.WIDE: // Alters behaviour of next instruction wide = true; break; case ByteCode.MULTIANEWARRAY: case ByteCode.LOOKUPSWITCH: // Currently not used in any part of Rhino, so ignore it case ByteCode.JSR: // TODO: JSR is deprecated case ByteCode.RET: case ByteCode.JSR_W: default: throw new IllegalArgumentException("bad opcode: " + bc); } if (length == 0) { length = opcodeLength(bc, wide); } if (wide && bc != ByteCode.WIDE) { wide = false; } return length; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void executeALoad(int localIndex) { int type = getLocal(localIndex); int tag = TypeInfo.getTag(type); if (tag == TypeInfo.OBJECT_TAG || tag == TypeInfo.UNINITIALIZED_THIS || tag == TypeInfo.UNINITIALIZED_VAR_TAG || tag == TypeInfo.NULL) { push(type); } else { throw new IllegalStateException("bad local variable type: " + type + " at index: " + localIndex); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private static void badStack(int value) { String s; if (value < 0) { s = "Stack underflow: "+value; } else { s = "Too big stack: "+value; } throw new IllegalStateException(s); }
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (IOException iox) { // Should never happen throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (IllegalAccessException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (CloneNotSupportedException ex) { throw new IllegalStateException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
0 0 0 0
unknown (Lib) IndexOutOfBoundsException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object get(long index) { if (index < 0 || index >= length) { throw new IndexOutOfBoundsException(); } Object value = getRawElem(this, index); if (value == Scriptable.NOT_FOUND || value == Undefined.instance) { return null; } else if (value instanceof Wrapper) { return ((Wrapper) value).unwrap(); } else { return value; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public ListIterator listIterator(final int start) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; if (start < 0 || start > len) { throw new IndexOutOfBoundsException("Index: " + start); } return new ListIterator() { int cursor = start; public boolean hasNext() { return cursor < len; } public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); } public boolean hasPrevious() { return cursor > 0; } public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); } public int nextIndex() { return cursor; } public int previousIndex() { return cursor - 1; } public void remove() { throw new UnsupportedOperationException(); } public void add(Object o) { throw new UnsupportedOperationException(); } public void set(Object o) { throw new UnsupportedOperationException(); } }; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ArrayLiteral.java
public AstNode getElement(int index) { if (elements == null) throw new IndexOutOfBoundsException("no elements"); return elements.get(index); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onInvalidIndex(int index, int upperBound) { // \u2209 is "NOT ELEMENT OF" String msg = index+" \u2209 [0, "+upperBound+')'; throw new IndexOutOfBoundsException(msg); }
0 0 0 0 0
unknown (Lib) InstantiationException 1 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, sealed, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static <T extends Scriptable> BaseFunction buildClassCtor( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < methods.length; i++) { Method method = methods[i]; if (!method.getName().equals("init")) continue; Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ContextClass && parmTypes[1] == ScriptRuntime.ScriptableClass && parmTypes[2] == Boolean.TYPE && Modifier.isStatic(method.getModifiers())) { Object args[] = { Context.getContext(), scope, sealed ? Boolean.TRUE : Boolean.FALSE }; method.invoke(null, args); return null; } if (parmTypes.length == 1 && parmTypes[0] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { Object args[] = { scope }; method.invoke(null, args); return null; } } // If we got here, there isn't an "init" method with the right // parameter types. Constructor<?>[] ctors = clazz.getConstructors(); Constructor<?> protoCtor = null; for (int i=0; i < ctors.length; i++) { if (ctors[i].getParameterTypes().length == 0) { protoCtor = ctors[i]; break; } } if (protoCtor == null) { throw Context.reportRuntimeError1( "msg.zero.arg.ctor", clazz.getName()); } Scriptable proto = (Scriptable) protoCtor.newInstance(ScriptRuntime.emptyArgs); String className = proto.getClassName(); // Set the prototype's prototype, trying to map Java inheritance to JS // prototype-based inheritance if requested to do so. Scriptable superProto = null; if (mapInheritance) { Class<? super T> superClass = clazz.getSuperclass(); if (ScriptRuntime.ScriptableClass.isAssignableFrom(superClass) && !Modifier.isAbstract(superClass.getModifiers())) { Class<? extends Scriptable> superScriptable = extendsScriptable(superClass); String name = ScriptableObject.defineClass(scope, superScriptable, sealed, mapInheritance); if (name != null) { superProto = ScriptableObject.getClassPrototype(scope, name); } } } if (superProto == null) { superProto = ScriptableObject.getObjectPrototype(scope); } proto.setPrototype(superProto); // Find out whether there are any methods that begin with // "js". If so, then only methods that begin with special // prefixes will be defined as JavaScript entities. final String functionPrefix = "jsFunction_"; final String staticFunctionPrefix = "jsStaticFunction_"; final String getterPrefix = "jsGet_"; final String setterPrefix = "jsSet_"; final String ctorName = "jsConstructor"; Member ctorMember = findAnnotatedMember(methods, JSConstructor.class); if (ctorMember == null) { ctorMember = findAnnotatedMember(ctors, JSConstructor.class); } if (ctorMember == null) { ctorMember = FunctionObject.findSingleMethod(methods, ctorName); } if (ctorMember == null) { if (ctors.length == 1) { ctorMember = ctors[0]; } else if (ctors.length == 2) { if (ctors[0].getParameterTypes().length == 0) ctorMember = ctors[1]; else if (ctors[1].getParameterTypes().length == 0) ctorMember = ctors[0]; } if (ctorMember == null) { throw Context.reportRuntimeError1( "msg.ctor.multiple.parms", clazz.getName()); } } FunctionObject ctor = new FunctionObject(className, ctorMember, scope); if (ctor.isVarArgsMethod()) { throw Context.reportRuntimeError1 ("msg.varargs.ctor", ctorMember.getName()); } ctor.initAsConstructor(scope, proto); Method finishInit = null; HashSet<String> staticNames = new HashSet<String>(), instanceNames = new HashSet<String>(); for (Method method : methods) { if (method == ctorMember) { continue; } String name = method.getName(); if (name.equals("finishInit")) { Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ScriptableClass && parmTypes[1] == FunctionObject.class && parmTypes[2] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { finishInit = method; continue; } } // ignore any compiler generated methods. if (name.indexOf('$') != -1) continue; if (name.equals(ctorName)) continue; Annotation annotation = null; String prefix = null; if (method.isAnnotationPresent(JSFunction.class)) { annotation = method.getAnnotation(JSFunction.class); } else if (method.isAnnotationPresent(JSStaticFunction.class)) { annotation = method.getAnnotation(JSStaticFunction.class); } else if (method.isAnnotationPresent(JSGetter.class)) { annotation = method.getAnnotation(JSGetter.class); } else if (method.isAnnotationPresent(JSSetter.class)) { continue; } if (annotation == null) { if (name.startsWith(functionPrefix)) { prefix = functionPrefix; } else if (name.startsWith(staticFunctionPrefix)) { prefix = staticFunctionPrefix; } else if (name.startsWith(getterPrefix)) { prefix = getterPrefix; } else if (annotation == null) { // note that setterPrefix is among the unhandled names here - // we deal with that when we see the getter continue; } } boolean isStatic = annotation instanceof JSStaticFunction || prefix == staticFunctionPrefix; HashSet<String> names = isStatic ? staticNames : instanceNames; String propName = getPropertyName(name, prefix, annotation); if (names.contains(propName)) { throw Context.reportRuntimeError2("duplicate.defineClass.name", name, propName); } names.add(propName); name = propName; if (annotation instanceof JSGetter || prefix == getterPrefix) { if (!(proto instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", proto.getClass().toString(), name); } Method setter = findSetterMethod(methods, name, setterPrefix); int attr = ScriptableObject.PERMANENT | ScriptableObject.DONTENUM | (setter != null ? 0 : ScriptableObject.READONLY); ((ScriptableObject) proto).defineProperty(name, null, method, setter, attr); continue; } if (isStatic && !Modifier.isStatic(method.getModifiers())) { throw Context.reportRuntimeError( "jsStaticFunction must be used with static method."); } FunctionObject f = new FunctionObject(name, method, proto); if (f.isVarArgsConstructor()) { throw Context.reportRuntimeError1 ("msg.varargs.fun", ctorMember.getName()); } defineProperty(isStatic ? ctor : proto, name, f, DONTENUM); if (sealed) { f.sealObject(); } } // Call user code to complete initialization if necessary. if (finishInit != null) { Object[] finishArgs = { scope, ctor, proto }; finishInit.invoke(null, finishArgs); } // Seal the object if necessary. if (sealed) { ctor.sealObject(); if (proto instanceof ScriptableObject) { ((ScriptableObject) proto).sealObject(); } } return ctor; }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (InstantiationException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(InstantiationException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InstantiationException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InstantiationException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
0
unknown (Lib) InvocationTargetException 0 0 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, sealed, false); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
static <T extends Scriptable> BaseFunction buildClassCtor( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < methods.length; i++) { Method method = methods[i]; if (!method.getName().equals("init")) continue; Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ContextClass && parmTypes[1] == ScriptRuntime.ScriptableClass && parmTypes[2] == Boolean.TYPE && Modifier.isStatic(method.getModifiers())) { Object args[] = { Context.getContext(), scope, sealed ? Boolean.TRUE : Boolean.FALSE }; method.invoke(null, args); return null; } if (parmTypes.length == 1 && parmTypes[0] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { Object args[] = { scope }; method.invoke(null, args); return null; } } // If we got here, there isn't an "init" method with the right // parameter types. Constructor<?>[] ctors = clazz.getConstructors(); Constructor<?> protoCtor = null; for (int i=0; i < ctors.length; i++) { if (ctors[i].getParameterTypes().length == 0) { protoCtor = ctors[i]; break; } } if (protoCtor == null) { throw Context.reportRuntimeError1( "msg.zero.arg.ctor", clazz.getName()); } Scriptable proto = (Scriptable) protoCtor.newInstance(ScriptRuntime.emptyArgs); String className = proto.getClassName(); // Set the prototype's prototype, trying to map Java inheritance to JS // prototype-based inheritance if requested to do so. Scriptable superProto = null; if (mapInheritance) { Class<? super T> superClass = clazz.getSuperclass(); if (ScriptRuntime.ScriptableClass.isAssignableFrom(superClass) && !Modifier.isAbstract(superClass.getModifiers())) { Class<? extends Scriptable> superScriptable = extendsScriptable(superClass); String name = ScriptableObject.defineClass(scope, superScriptable, sealed, mapInheritance); if (name != null) { superProto = ScriptableObject.getClassPrototype(scope, name); } } } if (superProto == null) { superProto = ScriptableObject.getObjectPrototype(scope); } proto.setPrototype(superProto); // Find out whether there are any methods that begin with // "js". If so, then only methods that begin with special // prefixes will be defined as JavaScript entities. final String functionPrefix = "jsFunction_"; final String staticFunctionPrefix = "jsStaticFunction_"; final String getterPrefix = "jsGet_"; final String setterPrefix = "jsSet_"; final String ctorName = "jsConstructor"; Member ctorMember = findAnnotatedMember(methods, JSConstructor.class); if (ctorMember == null) { ctorMember = findAnnotatedMember(ctors, JSConstructor.class); } if (ctorMember == null) { ctorMember = FunctionObject.findSingleMethod(methods, ctorName); } if (ctorMember == null) { if (ctors.length == 1) { ctorMember = ctors[0]; } else if (ctors.length == 2) { if (ctors[0].getParameterTypes().length == 0) ctorMember = ctors[1]; else if (ctors[1].getParameterTypes().length == 0) ctorMember = ctors[0]; } if (ctorMember == null) { throw Context.reportRuntimeError1( "msg.ctor.multiple.parms", clazz.getName()); } } FunctionObject ctor = new FunctionObject(className, ctorMember, scope); if (ctor.isVarArgsMethod()) { throw Context.reportRuntimeError1 ("msg.varargs.ctor", ctorMember.getName()); } ctor.initAsConstructor(scope, proto); Method finishInit = null; HashSet<String> staticNames = new HashSet<String>(), instanceNames = new HashSet<String>(); for (Method method : methods) { if (method == ctorMember) { continue; } String name = method.getName(); if (name.equals("finishInit")) { Class<?>[] parmTypes = method.getParameterTypes(); if (parmTypes.length == 3 && parmTypes[0] == ScriptRuntime.ScriptableClass && parmTypes[1] == FunctionObject.class && parmTypes[2] == ScriptRuntime.ScriptableClass && Modifier.isStatic(method.getModifiers())) { finishInit = method; continue; } } // ignore any compiler generated methods. if (name.indexOf('$') != -1) continue; if (name.equals(ctorName)) continue; Annotation annotation = null; String prefix = null; if (method.isAnnotationPresent(JSFunction.class)) { annotation = method.getAnnotation(JSFunction.class); } else if (method.isAnnotationPresent(JSStaticFunction.class)) { annotation = method.getAnnotation(JSStaticFunction.class); } else if (method.isAnnotationPresent(JSGetter.class)) { annotation = method.getAnnotation(JSGetter.class); } else if (method.isAnnotationPresent(JSSetter.class)) { continue; } if (annotation == null) { if (name.startsWith(functionPrefix)) { prefix = functionPrefix; } else if (name.startsWith(staticFunctionPrefix)) { prefix = staticFunctionPrefix; } else if (name.startsWith(getterPrefix)) { prefix = getterPrefix; } else if (annotation == null) { // note that setterPrefix is among the unhandled names here - // we deal with that when we see the getter continue; } } boolean isStatic = annotation instanceof JSStaticFunction || prefix == staticFunctionPrefix; HashSet<String> names = isStatic ? staticNames : instanceNames; String propName = getPropertyName(name, prefix, annotation); if (names.contains(propName)) { throw Context.reportRuntimeError2("duplicate.defineClass.name", name, propName); } names.add(propName); name = propName; if (annotation instanceof JSGetter || prefix == getterPrefix) { if (!(proto instanceof ScriptableObject)) { throw Context.reportRuntimeError2( "msg.extend.scriptable", proto.getClass().toString(), name); } Method setter = findSetterMethod(methods, name, setterPrefix); int attr = ScriptableObject.PERMANENT | ScriptableObject.DONTENUM | (setter != null ? 0 : ScriptableObject.READONLY); ((ScriptableObject) proto).defineProperty(name, null, method, setter, attr); continue; } if (isStatic && !Modifier.isStatic(method.getModifiers())) { throw Context.reportRuntimeError( "jsStaticFunction must be used with static method."); } FunctionObject f = new FunctionObject(name, method, proto); if (f.isVarArgsConstructor()) { throw Context.reportRuntimeError1 ("msg.varargs.fun", ctorMember.getName()); } defineProperty(isStatic ? ctor : proto, name, f, DONTENUM); if (sealed) { f.sealObject(); } } // Call user code to complete initialization if necessary. if (finishInit != null) { Object[] finishArgs = { scope, ctor, proto }; finishInit.invoke(null, finishArgs); } // Seal the object if necessary. if (sealed) { ctor.sealObject(); if (proto instanceof ScriptableObject) { ((ScriptableObject) proto).sealObject(); } } return ctor; }
5
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (InvocationTargetException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(InvocationTargetException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (InvocationTargetException ite) { // Must allow ContinuationPending exceptions to propagate unhindered Throwable e = ite; do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); if (e instanceof ContinuationPending) throw (ContinuationPending) e; throw Context.throwAsScriptRuntimeEx(e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (InvocationTargetException ex) { throw Context.throwAsScriptRuntimeEx(ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (InvocationTargetException ex) { Throwable target = ex.getTargetException(); if (target instanceof RuntimeException) { throw (RuntimeException)target; } }
0
runtime (Domain) JavaScriptException
public class JavaScriptException extends RhinoException
{
    static final long serialVersionUID = -7666130513694669293L;

    /**
     * @deprecated
     * Use {@link WrappedException#WrappedException(Throwable)} to report
     * exceptions in Java code.
     */
    public JavaScriptException(Object value)
    {
        this(value, "", 0);
    }

    /**
     * Create a JavaScript exception wrapping the given JavaScript value
     *
     * @param value the JavaScript value thrown.
     */
    public JavaScriptException(Object value, String sourceName, int lineNumber)
    {
        recordErrorOrigin(sourceName, lineNumber, null, 0);
        this.value = value;
        // Fill in fileName and lineNumber automatically when not specified
        // explicitly, see Bugzilla issue #342807
        if (value instanceof NativeError && Context.getContext()
                .hasFeature(Context.FEATURE_LOCATION_INFORMATION_IN_ERROR)) {
            NativeError error = (NativeError) value;
            if (!error.has("fileName", error)) {
                error.put("fileName", error, sourceName);
            }
            if (!error.has("lineNumber", error)) {
                error.put("lineNumber", error, Integer.valueOf(lineNumber));
            }
            // set stack property, see bug #549604
            error.setStackProvider(this);
        }
    }

    @Override
    public String details()
    {
        if (value == null) {
            return "null";
        } else if (value instanceof NativeError) {
            return value.toString();
        }
        try {
            return ScriptRuntime.toString(value);
        } catch (RuntimeException rte) {
            // ScriptRuntime.toString may throw a RuntimeException
            if (value instanceof Scriptable) {
                return ScriptRuntime.defaultObjectToString((Scriptable)value);
            } else {
                return value.toString();
            }
        }
    }

    /**
     * @return the value wrapped by this exception
     */
    public Object getValue()
    {
        return value;
    }

    /**
     * @deprecated Use {@link RhinoException#sourceName()} from the super class.
     */
    public String getSourceName()
    {
        return sourceName();
    }

    /**
     * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
     */
    public int getLineNumber()
    {
        return lineNumber();
    }

    private Object value;
}
6
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/OptRuntime.java
public static void throwStopIteration(Object obj) { throw new JavaScriptException( NativeIterator.getStopIterationObject((Scriptable)obj), "", 0); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/BaseFunction.java
private static Object jsConstructor(Context cx, Scriptable scope, Object[] args) { int arglen = args.length; StringBuffer sourceBuf = new StringBuffer(); sourceBuf.append("function "); /* version != 1.2 Function constructor behavior - * print 'anonymous' as the function name if the * version (under which the function was compiled) is * less than 1.2... or if it's greater than 1.2, because * we need to be closer to ECMA. */ if (cx.getLanguageVersion() != Context.VERSION_1_2) { sourceBuf.append("anonymous"); } sourceBuf.append('('); // Append arguments as coma separated strings for (int i = 0; i < arglen - 1; i++) { if (i > 0) { sourceBuf.append(','); } sourceBuf.append(ScriptRuntime.toString(args[i])); } sourceBuf.append(") {"); if (arglen != 0) { // append function body String funBody = ScriptRuntime.toString(args[arglen - 1]); sourceBuf.append(funBody); } sourceBuf.append("\n}"); String source = sourceBuf.toString(); int[] linep = new int[1]; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<eval'ed string>"; linep[0] = 1; } String sourceURI = ScriptRuntime. makeUrlForGeneratedScript(false, filename, linep[0]); Scriptable global = ScriptableObject.getTopLevelScope(scope); ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, linep[0]); } // Compile with explicit interpreter instance to force interpreter // mode. return cx.compileFunction(global, source, evaluator, reporter, sourceURI, 1, null); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
private Object next(Context cx, Scriptable scope) { Boolean b = ScriptRuntime.enumNext(this.objectIterator); if (!b.booleanValue()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return ScriptRuntime.enumId(this.objectIterator, cx); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeIterator.java
public Object next() { if (!iterator.hasNext()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return iterator.next(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
private Object resume(Context cx, Scriptable scope, int operation, Object value) { if (savedState == null) { if (operation == GENERATOR_CLOSE) return Undefined.instance; Object thrown; if (operation == GENERATOR_THROW) { thrown = value; } else { thrown = NativeIterator.getStopIterationObject(scope); } throw new JavaScriptException(thrown, lineSource, lineNumber); } try { synchronized (this) { // generator execution is necessarily single-threaded and // non-reentrant. // See https://bugzilla.mozilla.org/show_bug.cgi?id=349263 if (locked) throw ScriptRuntime.typeError0("msg.already.exec.gen"); locked = true; } return function.resumeGenerator(cx, scope, operation, savedState, value); } catch (GeneratorClosedException e) { // On closing a generator in the compile path, the generator // throws a special exception. This ensures execution of all pending // finalizers and will not get caught by user code. return Undefined.instance; } catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; } finally { synchronized (this) { locked = false; } if (operation == GENERATOR_CLOSE) savedState = null; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public static Object evalSpecial(Context cx, Scriptable scope, Object thisArg, Object[] args, String filename, int lineNumber) { if (args.length < 1) return Undefined.instance; Object x = args[0]; if (!(x instanceof CharSequence)) { if (cx.hasFeature(Context.FEATURE_STRICT_MODE) || cx.hasFeature(Context.FEATURE_STRICT_EVAL)) { throw Context.reportRuntimeError0("msg.eval.nonstring.strict"); } String message = ScriptRuntime.getMessage0("msg.eval.nonstring"); Context.reportWarning(message); return x; } if (filename == null) { int[] linep = new int[1]; filename = Context.getSourcePositionFromStack(linep); if (filename != null) { lineNumber = linep[0]; } else { filename = ""; } } String sourceName = ScriptRuntime. makeUrlForGeneratedScript(true, filename, lineNumber); ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, lineNumber); } // Compile with explicit interpreter instance to force interpreter // mode. Script script = cx.compileString(x.toString(), evaluator, reporter, sourceName, 1, null); evaluator.setEvalScriptFlag(script); Callable c = (Callable)script; return c.call(cx, scope, (Scriptable)thisArg, ScriptRuntime.emptyArgs); }
0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; } throw e; }
0
unknown (Lib) LinkageError 0 0 0 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (LinkageError ex) { }
0 0
unknown (Lib) MalformedURLException 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator) throws IOException { final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { final String path = ensureTrailingSlash( ScriptableObject.getTypedProperty(paths, i, String.class)); try { URI uri = new URI(path); if (!uri.isAbsolute()) { uri = new File(path).toURI().resolve(""); } final ModuleSource moduleSource = loadFromUri( uri.resolve(moduleId), uri, validator); if(moduleSource != null) { return moduleSource; } } catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } return null; }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
0 0 0 0
unknown (Lib) MissingResourceException 0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
1
unknown (Lib) NoSuchElementException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public Node next() { if (cursor == null) { throw new NoSuchElementException(); } removed = false; prev2 = prev; prev = cursor; cursor = cursor.next; return prev; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); }
0 0 0 0
unknown (Lib) NoSuchFieldException 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
public static Object getAdapterSelf(Class<?> adapterClass, Object adapter) throws NoSuchFieldException, IllegalAccessException { Field self = adapterClass.getDeclaredField("self"); return self.get(adapter); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (NoSuchFieldException e) { }
0 0
unknown (Lib) NoSuchMethodException 0 0 0 11
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (NoSuchMethodException e) { meth = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (NoSuchMethodException e) { adapter_writeAdapterObject = null; adapter_readAdapterObject = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ContextFactory.java
catch (NoSuchMethodException e) { return false; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch(NoSuchMethodException e) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
catch (NoSuchMethodException e) { // Not implemented by superclass; fall through }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java
catch (NoSuchMethodException e) { // Throw a fitting exception that is handled by // org.mozilla.javascript.Kit.newInstanceOrNull: throw new InstantiationException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (NoSuchMethodException e) { throw new IOException("Cannot find member: " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/jdk13/VMBridge_jdk13.java
catch (NoSuchMethodException ex) { // Should not happen throw Kit.initCause(new IllegalStateException(), ex); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
1
unknown (Lib) NumberFormatException 0 0 0 8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(NumberFormatException e) { return -1; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGlobal.java
catch (NumberFormatException ex) { return ScriptRuntime.NaNobj; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/TokenStream.java
catch (NumberFormatException ex) { parser.addError("msg.caught.nfe"); return Token.ERROR; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (NumberFormatException nfe) { return NaN; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (NumberFormatException ex) { return NaN; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (NumberFormatException e) { // fall through }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
0
checked (Domain) ParseException
public static class ParseException extends Exception {
        
        static final long serialVersionUID = 4804542791749920772L;
        
        ParseException(String message) {
            super(message);
        }

        ParseException(Exception cause) {
            super(cause);
        }
    }
24
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readValue() throws ParseException { consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch (c) { case '{': return readObject(); case '[': return readArray(); case 't': return readTrue(); case 'f': return readFalse(); case '"': return readString(); case 'n': return readNull(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': case '-': return readNumber(c); default: throw new ParseException("Unexpected token: " + c); } } throw new ParseException("Empty JSON string"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readObject() throws ParseException { Scriptable object = cx.newObject(scope); String id; Object value; boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch(c) { case '}': return object; case ',': if (!needsComma) { throw new ParseException("Unexpected comma in object literal"); } needsComma = false; break; case '"': if (needsComma) { throw new ParseException("Missing comma in object literal"); } id = readString(); consume(':'); value = readValue(); long index = ScriptRuntime.indexFromString(id); if (index < 0) { object.put(id, object, value); } else { object.put((int)index, object, value); } needsComma = true; break; default: throw new ParseException("Unexpected token in object literal"); } consumeWhitespace(); } throw new ParseException("Unterminated object literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readArray() throws ParseException { List<Object> list = new ArrayList<Object>(); boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos); switch(c) { case ']': pos += 1; return cx.newArray(scope, list.toArray()); case ',': if (!needsComma) { throw new ParseException("Unexpected comma in array literal"); } needsComma = false; pos += 1; break; default: if (needsComma) { throw new ParseException("Missing comma in array literal"); } list.add(readValue()); needsComma = true; } consumeWhitespace(); } throw new ParseException("Unterminated array literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private String readString() throws ParseException { StringBuilder b = new StringBuilder(); while (pos < length) { char c = src.charAt(pos++); if (c <= '\u001F') { throw new ParseException("String contains control character"); } switch(c) { case '\\': if (pos >= length) { throw new ParseException("Unterminated string"); } c = src.charAt(pos++); switch (c) { case '"': b.append('"'); break; case '\\': b.append('\\'); break; case '/': b.append('/'); break; case 'b': b.append('\b'); break; case 'f': b.append('\f'); break; case 'n': b.append('\n'); break; case 'r': b.append('\r'); break; case 't': b.append('\t'); break; case 'u': if (length - pos < 5) { throw new ParseException("Invalid character code: \\u" + src.substring(pos)); } try { b.append((char) Integer.parseInt(src.substring(pos, pos + 4), 16)); pos += 4; } catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); } break; default: throw new ParseException("Unexcpected character in string: '\\" + c + "'"); } break; case '"': return b.toString(); default: b.append(c); break; } } throw new ParseException("Unterminated string literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Number readNumber(char first) throws ParseException { StringBuilder b = new StringBuilder(); b.append(first); while (pos < length) { char c = src.charAt(pos); if (!Character.isDigit(c) && c != '-' && c != '+' && c != '.' && c != 'e' && c != 'E') { break; } pos += 1; b.append(c); } String num = b.toString(); int numLength = num.length(); try { // check for leading zeroes for (int i = 0; i < numLength; i++) { char c = num.charAt(i); if (Character.isDigit(c)) { if (c == '0' && numLength > i + 1 && Character.isDigit(num.charAt(i + 1))) { throw new ParseException("Unsupported number format: " + num); } break; } } final double dval = Double.parseDouble(num); final int ival = (int)dval; if (ival == dval) { return Integer.valueOf(ival); } else { return Double.valueOf(dval); } } catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readFalse() throws ParseException { if (length - pos < 4 || src.charAt(pos) != 'a' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 's' || src.charAt(pos + 3) != 'e') { throw new ParseException("Unexpected token: f"); } pos += 4; return Boolean.FALSE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readNull() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'u' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 'l') { throw new ParseException("Unexpected token: n"); } pos += 3; return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); }
10
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readValue() throws ParseException { consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch (c) { case '{': return readObject(); case '[': return readArray(); case 't': return readTrue(); case 'f': return readFalse(); case '"': return readString(); case 'n': return readNull(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': case '-': return readNumber(c); default: throw new ParseException("Unexpected token: " + c); } } throw new ParseException("Empty JSON string"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readObject() throws ParseException { Scriptable object = cx.newObject(scope); String id; Object value; boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos++); switch(c) { case '}': return object; case ',': if (!needsComma) { throw new ParseException("Unexpected comma in object literal"); } needsComma = false; break; case '"': if (needsComma) { throw new ParseException("Missing comma in object literal"); } id = readString(); consume(':'); value = readValue(); long index = ScriptRuntime.indexFromString(id); if (index < 0) { object.put(id, object, value); } else { object.put((int)index, object, value); } needsComma = true; break; default: throw new ParseException("Unexpected token in object literal"); } consumeWhitespace(); } throw new ParseException("Unterminated object literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readArray() throws ParseException { List<Object> list = new ArrayList<Object>(); boolean needsComma = false; consumeWhitespace(); while (pos < length) { char c = src.charAt(pos); switch(c) { case ']': pos += 1; return cx.newArray(scope, list.toArray()); case ',': if (!needsComma) { throw new ParseException("Unexpected comma in array literal"); } needsComma = false; pos += 1; break; default: if (needsComma) { throw new ParseException("Missing comma in array literal"); } list.add(readValue()); needsComma = true; } consumeWhitespace(); } throw new ParseException("Unterminated array literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private String readString() throws ParseException { StringBuilder b = new StringBuilder(); while (pos < length) { char c = src.charAt(pos++); if (c <= '\u001F') { throw new ParseException("String contains control character"); } switch(c) { case '\\': if (pos >= length) { throw new ParseException("Unterminated string"); } c = src.charAt(pos++); switch (c) { case '"': b.append('"'); break; case '\\': b.append('\\'); break; case '/': b.append('/'); break; case 'b': b.append('\b'); break; case 'f': b.append('\f'); break; case 'n': b.append('\n'); break; case 'r': b.append('\r'); break; case 't': b.append('\t'); break; case 'u': if (length - pos < 5) { throw new ParseException("Invalid character code: \\u" + src.substring(pos)); } try { b.append((char) Integer.parseInt(src.substring(pos, pos + 4), 16)); pos += 4; } catch (NumberFormatException nfx) { throw new ParseException("Invalid character code: " + src.substring(pos, pos + 4)); } break; default: throw new ParseException("Unexcpected character in string: '\\" + c + "'"); } break; case '"': return b.toString(); default: b.append(c); break; } } throw new ParseException("Unterminated string literal"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Number readNumber(char first) throws ParseException { StringBuilder b = new StringBuilder(); b.append(first); while (pos < length) { char c = src.charAt(pos); if (!Character.isDigit(c) && c != '-' && c != '+' && c != '.' && c != 'e' && c != 'E') { break; } pos += 1; b.append(c); } String num = b.toString(); int numLength = num.length(); try { // check for leading zeroes for (int i = 0; i < numLength; i++) { char c = num.charAt(i); if (Character.isDigit(c)) { if (c == '0' && numLength > i + 1 && Character.isDigit(num.charAt(i + 1))) { throw new ParseException("Unsupported number format: " + num); } break; } } final double dval = Double.parseDouble(num); final int ival = (int)dval; if (ival == dval) { return Integer.valueOf(ival); } else { return Double.valueOf(dval); } } catch (NumberFormatException nfe) { throw new ParseException("Unsupported number format: " + num); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Boolean readFalse() throws ParseException { if (length - pos < 4 || src.charAt(pos) != 'a' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 's' || src.charAt(pos + 3) != 'e') { throw new ParseException("Unexpected token: f"); } pos += 4; return Boolean.FALSE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private Object readNull() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'u' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 'l') { throw new ParseException("Unexpected token: n"); } pos += 3; return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/json/JsonParser.java
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeDate.java
catch (java.text.ParseException ex) {}
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJSON.java
catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); }
0
runtime (Domain) ParserException
private static class ParserException extends RuntimeException
    {
        static final long serialVersionUID = 5882582646773765630L;
    }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
void reportError(String messageId, String messageArg, int position, int length) { addError(messageId, position, length); if (!compilerEnv.recoverFromErrors()) { throw new ParserException(); } }
0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private AstNode destructuringPrimaryExpr() throws IOException, ParserException { try { inDestructuringAssignment = true; return primaryExpr(); } finally { inDestructuringAssignment = false; } }
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { break; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { // Ignore it }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (ParserException e) { // an ErrorNode was added to the ErrorReporter }
0 0
unknown (Lib) PrivilegedActionException 0 0 0 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
0
runtime (Domain) RhinoException
public abstract class RhinoException extends RuntimeException
{

    RhinoException()
    {
        Evaluator e = Context.createInterpreter();
        if (e != null)
            e.captureStackInfo(this);
    }

    RhinoException(String details)
    {
        super(details);
        Evaluator e = Context.createInterpreter();
        if (e != null)
            e.captureStackInfo(this);
    }

    @Override
    public final String getMessage()
    {
        String details = details();
        if (sourceName == null || lineNumber <= 0) {
            return details;
        }
        StringBuffer buf = new StringBuffer(details);
        buf.append(" (");
        if (sourceName != null) {
            buf.append(sourceName);
        }
        if (lineNumber > 0) {
            buf.append('#');
            buf.append(lineNumber);
        }
        buf.append(')');
        return buf.toString();
    }

    public String details()
    {
        return super.getMessage();
    }

    /**
     * Get the uri of the script source containing the error, or null
     * if that information is not available.
     */
    public final String sourceName()
    {
        return sourceName;
    }

    /**
     * Initialize the uri of the script source containing the error.
     *
     * @param sourceName the uri of the script source responsible for the error.
     *                   It should not be <tt>null</tt>.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initSourceName(String sourceName)
    {
        if (sourceName == null) throw new IllegalArgumentException();
        if (this.sourceName != null) throw new IllegalStateException();
        this.sourceName = sourceName;
    }

    /**
     * Returns the line number of the statement causing the error,
     * or zero if not available.
     */
    public final int lineNumber()
    {
        return lineNumber;
    }

    /**
     * Initialize the line number of the script statement causing the error.
     *
     * @param lineNumber the line number in the script source.
     *                   It should be positive number.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initLineNumber(int lineNumber)
    {
        if (lineNumber <= 0) throw new IllegalArgumentException(String.valueOf(lineNumber));
        if (this.lineNumber > 0) throw new IllegalStateException();
        this.lineNumber = lineNumber;
    }

    /**
     * The column number of the location of the error, or zero if unknown.
     */
    public final int columnNumber()
    {
        return columnNumber;
    }

    /**
     * Initialize the column number of the script statement causing the error.
     *
     * @param columnNumber the column number in the script source.
     *                     It should be positive number.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initColumnNumber(int columnNumber)
    {
        if (columnNumber <= 0) throw new IllegalArgumentException(String.valueOf(columnNumber));
        if (this.columnNumber > 0) throw new IllegalStateException();
        this.columnNumber = columnNumber;
    }

    /**
     * The source text of the line causing the error, or null if unknown.
     */
    public final String lineSource()
    {
        return lineSource;
    }

    /**
     * Initialize the text of the source line containing the error.
     *
     * @param lineSource the text of the source line responsible for the error.
     *                   It should not be <tt>null</tt>.
     *
     * @throws IllegalStateException if the method is called more then once.
     */
    public final void initLineSource(String lineSource)
    {
        if (lineSource == null) throw new IllegalArgumentException();
        if (this.lineSource != null) throw new IllegalStateException();
        this.lineSource = lineSource;
    }

    final void recordErrorOrigin(String sourceName, int lineNumber,
                                 String lineSource, int columnNumber)
    {
        // XXX: for compatibility allow for now -1 to mean 0
        if (lineNumber == -1) {
            lineNumber = 0;
        }

        if (sourceName != null) {
            initSourceName(sourceName);
        }
        if (lineNumber != 0) {
            initLineNumber(lineNumber);
        }
        if (lineSource != null) {
            initLineSource(lineSource);
        }
        if (columnNumber != 0) {
            initColumnNumber(columnNumber);
        }
    }

    private String generateStackTrace()
    {
        // Get stable reference to work properly with concurrent access
        CharArrayWriter writer = new CharArrayWriter();
        super.printStackTrace(new PrintWriter(writer));
        String origStackTrace = writer.toString();
        Evaluator e = Context.createInterpreter();
        if (e != null)
            return e.getPatchedStack(this, origStackTrace);
        return null;
    }

    /**
     * Get a string representing the script stack of this exception.
     * If optimization is enabled, this includes java stack elements
     * whose source and method names suggest they have been generated
     * by the Rhino script compiler.
     * @return a script stack dump
     * @since 1.6R6
     */
    public String getScriptStackTrace()
    {
        StringBuilder buffer = new StringBuilder();
        String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
        ScriptStackElement[] stack = getScriptStack();
        for (ScriptStackElement elem : stack) {
            if (useMozillaStackStyle) {
                elem.renderMozillaStyle(buffer);
            } else {
                elem.renderJavaStyle(buffer);
            }
            buffer.append(lineSeparator);
        }
        return buffer.toString();
    }

    /**
     * Get a string representing the script stack of this exception.
     * @deprecated the filter argument is ignored as we are able to
     * recognize script stack elements by our own. Use
     * #getScriptStackTrace() instead.
     * @param filter ignored
     * @return a script stack dump
     * @since 1.6R6
     */
    public String getScriptStackTrace(FilenameFilter filter)
    {
        return getScriptStackTrace();
    }

    /**
     * Get the script stack of this exception as an array of
     * {@link ScriptStackElement}s.
     * If optimization is enabled, this includes java stack elements
     * whose source and method names suggest they have been generated
     * by the Rhino script compiler.
     * @return the script stack for this exception
     * @since 1.7R3
     */
    public ScriptStackElement[] getScriptStack() {
        List<ScriptStackElement> list = new ArrayList<ScriptStackElement>();
        ScriptStackElement[][] interpreterStack = null;
        if (interpreterStackInfo != null) {
            Evaluator interpreter = Context.createInterpreter();
            if (interpreter instanceof Interpreter)
                interpreterStack = ((Interpreter) interpreter).getScriptStackElements(this);
        }
        int interpreterStackIndex = 0;
        StackTraceElement[] stack = getStackTrace();
        // Pattern to recover function name from java method name -
        // see Codegen.getBodyMethodName()
        // kudos to Marc Guillemot for coming up with this
        Pattern pattern = Pattern.compile("_c_(.*)_\\d+");
        for (StackTraceElement e : stack) {
            String fileName = e.getFileName();
            if (e.getMethodName().startsWith("_c_")
                    && e.getLineNumber() > -1
                    && fileName != null
                    && !fileName.endsWith(".java")) {
                String methodName = e.getMethodName();
                Matcher match = pattern.matcher(methodName);
                // the method representing the main script is always "_c_script_0" -
                // at least we hope so
                methodName = !"_c_script_0".equals(methodName) && match.find() ?
                        match.group(1) : null;
                list.add(new ScriptStackElement(fileName, methodName, e.getLineNumber()));
            } else if ("org.mozilla.javascript.Interpreter".equals(e.getClassName())
                    && "interpretLoop".equals(e.getMethodName())
                    && interpreterStack != null
                    && interpreterStack.length > interpreterStackIndex) {
                for (ScriptStackElement elem : interpreterStack[interpreterStackIndex++]) {
                    list.add(elem);
                }
            }
        }
        return list.toArray(new ScriptStackElement[list.size()]);
    }


    @Override
    public void printStackTrace(PrintWriter s)
    {
        if (interpreterStackInfo == null) {
            super.printStackTrace(s);
        } else {
            s.print(generateStackTrace());
        }
    }

    @Override
    public void printStackTrace(PrintStream s)
    {
        if (interpreterStackInfo == null) {
            super.printStackTrace(s);
        } else {
            s.print(generateStackTrace());
        }
    }

    /**
     * Returns true if subclasses of <code>RhinoException</code>
     * use the Mozilla/Firefox style of rendering script stacks
     * (<code>functionName()@fileName:lineNumber</code>)
     * instead of Rhino's own Java-inspired format
     * (<code>    at fileName:lineNumber (functionName)</code>).
     * @return true if stack is rendered in Mozilla/Firefox style
     * @see ScriptStackElement
     * @since 1.7R3
     */
    public static boolean usesMozillaStackStyle() {
        return useMozillaStackStyle;
    }

    /**
     * Tell subclasses of <code>RhinoException</code> whether to
     * use the Mozilla/Firefox style of rendering script stacks
     * (<code>functionName()@fileName:lineNumber</code>)
     * instead of Rhino's own Java-inspired format
     * (<code>    at fileName:lineNumber (functionName)</code>)
     * @param flag whether to render stacks in Mozilla/Firefox style
     * @see ScriptStackElement
     * @since 1.7R3
     */
    public static void useMozillaStackStyle(boolean flag) {
        useMozillaStackStyle = flag;
    }

    static final long serialVersionUID = 1883500631321581169L;
    
    private static boolean useMozillaStackStyle = false;

    private String sourceName;
    private int lineNumber;
    private String lineSource;
    private int columnNumber;

    Object interpreterStackInfo;
    int[] interpreterLineData;
}
0 0 0 2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (RhinoException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeGenerator.java
catch (RhinoException e) { lineNumber = e.lineNumber(); lineSource = e.lineSource(); savedState = null; throw e; }
0
runtime (Lib) RuntimeException 29
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/CodeGenerator.java
private RuntimeException badTree(Node node) { throw new RuntimeException(node.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public Script createScriptObject(Object bytecode, Object staticSecurityDomain) { Class<?> cl = defineClass(bytecode, staticSecurityDomain); Script script; try { script = (Script)cl.newInstance(); } catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); } return script; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public Function createFunctionObject(Context cx, Scriptable scope, Object bytecode, Object staticSecurityDomain) { Class<?> cl = defineClass(bytecode, staticSecurityDomain); NativeFunction f; try { Constructor<?>ctor = cl.getConstructors()[0]; Object[] initArgs = { scope, cx, Integer.valueOf(0) }; f = (NativeFunction)ctor.newInstance(initArgs); } catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); } return f; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private Class<?> defineClass(Object bytecode, Object staticSecurityDomain) { Object[] nameBytesPair = (Object[])bytecode; String className = (String)nameBytesPair[0]; byte[] classBytes = (byte[])nameBytesPair[1]; // The generated classes in this case refer only to Rhino classes // which must be accessible through this class loader ClassLoader rhinoLoader = getClass().getClassLoader(); GeneratedClassLoader loader; loader = SecurityController.createLoader(rhinoLoader, staticSecurityDomain); Exception e; try { Class<?> cl = loader.defineClass(className, classBytes); loader.linkClass(cl); return cl; } catch (SecurityException x) { e = x; } catch (IllegalArgumentException x) { e = x; } throw new RuntimeException("Malformed optimizer package " + e); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
static RuntimeException badTree() { throw new RuntimeException("Bad tree in codegen"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
private void generateExpression(Node node, Node parent) { int type = node.getType(); Node child = node.getFirstChild(); switch (type) { case Token.USE_STACK: break; case Token.FUNCTION: if (fnCurrent != null || parent.getType() != Token.SCRIPT) { int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP); OptFunctionNode ofn = OptFunctionNode.get(scriptOrFn, fnIndex); int t = ofn.fnode.getFunctionType(); if (t != FunctionNode.FUNCTION_EXPRESSION) { throw Codegen.badTree(); } visitFunction(ofn, t); } break; case Token.NAME: { cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); cfw.addPush(node.getString()); addScriptRuntimeInvoke( "name", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/String;" +")Ljava/lang/Object;"); } break; case Token.CALL: case Token.NEW: { int specialType = node.getIntProp(Node.SPECIALCALL_PROP, Node.NON_SPECIALCALL); if (specialType == Node.NON_SPECIALCALL) { OptFunctionNode target; target = (OptFunctionNode)node.getProp( Node.DIRECTCALL_PROP); if (target != null) { visitOptimizedCall(node, target, type, child); } else if (type == Token.CALL) { visitStandardCall(node, child); } else { visitStandardNew(node, child); } } else { visitSpecialCall(node, type, specialType, child); } } break; case Token.REF_CALL: generateFunctionAndThisObj(child, node); // stack: ... functionObj thisObj child = child.getNext(); generateCallArgArray(node, child, false); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "callRef", "(Lorg/mozilla/javascript/Callable;" +"Lorg/mozilla/javascript/Scriptable;" +"[Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Lorg/mozilla/javascript/Ref;"); break; case Token.NUMBER: { double num = node.getDouble(); if (node.getIntProp(Node.ISNUMBER_PROP, -1) != -1) { cfw.addPush(num); } else { codegen.pushNumberAsObject(cfw, num); } } break; case Token.STRING: cfw.addPush(node.getString()); break; case Token.THIS: cfw.addALoad(thisObjLocal); break; case Token.THISFN: cfw.add(ByteCode.ALOAD_0); break; case Token.NULL: cfw.add(ByteCode.ACONST_NULL); break; case Token.TRUE: cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "TRUE", "Ljava/lang/Boolean;"); break; case Token.FALSE: cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "FALSE", "Ljava/lang/Boolean;"); break; case Token.REGEXP: { // Create a new wrapper around precompiled regexp cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); int i = node.getExistingIntProp(Node.REGEXP_PROP); cfw.add(ByteCode.GETSTATIC, codegen.mainClassName, codegen.getCompiledRegexpName(scriptOrFn, i), "Ljava/lang/Object;"); cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/ScriptRuntime", "wrapRegExp", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/Object;" +")Lorg/mozilla/javascript/Scriptable;"); } break; case Token.COMMA: { Node next = child.getNext(); while (next != null) { generateExpression(child, node); cfw.add(ByteCode.POP); child = next; next = next.getNext(); } generateExpression(child, node); break; } case Token.ENUM_NEXT: case Token.ENUM_ID: { int local = getLocalBlockRegister(node); cfw.addALoad(local); if (type == Token.ENUM_NEXT) { addScriptRuntimeInvoke( "enumNext", "(Ljava/lang/Object;)Ljava/lang/Boolean;"); } else { cfw.addALoad(contextLocal); addScriptRuntimeInvoke("enumId", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } break; } case Token.ARRAYLIT: visitArrayLiteral(node, child, false); break; case Token.OBJECTLIT: visitObjectLiteral(node, child, false); break; case Token.NOT: { int trueTarget = cfw.acquireLabel(); int falseTarget = cfw.acquireLabel(); int beyond = cfw.acquireLabel(); generateIfJump(child, node, trueTarget, falseTarget); cfw.markLabel(trueTarget); cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "FALSE", "Ljava/lang/Boolean;"); cfw.add(ByteCode.GOTO, beyond); cfw.markLabel(falseTarget); cfw.add(ByteCode.GETSTATIC, "java/lang/Boolean", "TRUE", "Ljava/lang/Boolean;"); cfw.markLabel(beyond); cfw.adjustStackTop(-1); break; } case Token.BITNOT: generateExpression(child, node); addScriptRuntimeInvoke("toInt32", "(Ljava/lang/Object;)I"); cfw.addPush(-1); // implement ~a as (a ^ -1) cfw.add(ByteCode.IXOR); cfw.add(ByteCode.I2D); addDoubleWrap(); break; case Token.VOID: generateExpression(child, node); cfw.add(ByteCode.POP); Codegen.pushUndefined(cfw); break; case Token.TYPEOF: generateExpression(child, node); addScriptRuntimeInvoke("typeof", "(Ljava/lang/Object;" +")Ljava/lang/String;"); break; case Token.TYPEOFNAME: visitTypeofname(node); break; case Token.INC: case Token.DEC: visitIncDec(node); break; case Token.OR: case Token.AND: { generateExpression(child, node); cfw.add(ByteCode.DUP); addScriptRuntimeInvoke("toBoolean", "(Ljava/lang/Object;)Z"); int falseTarget = cfw.acquireLabel(); if (type == Token.AND) cfw.add(ByteCode.IFEQ, falseTarget); else cfw.add(ByteCode.IFNE, falseTarget); cfw.add(ByteCode.POP); generateExpression(child.getNext(), node); cfw.markLabel(falseTarget); } break; case Token.HOOK : { Node ifThen = child.getNext(); Node ifElse = ifThen.getNext(); generateExpression(child, node); addScriptRuntimeInvoke("toBoolean", "(Ljava/lang/Object;)Z"); int elseTarget = cfw.acquireLabel(); cfw.add(ByteCode.IFEQ, elseTarget); short stack = cfw.getStackTop(); generateExpression(ifThen, node); int afterHook = cfw.acquireLabel(); cfw.add(ByteCode.GOTO, afterHook); cfw.markLabel(elseTarget, stack); generateExpression(ifElse, node); cfw.markLabel(afterHook); } break; case Token.ADD: { generateExpression(child, node); generateExpression(child.getNext(), node); switch (node.getIntProp(Node.ISNUMBER_PROP, -1)) { case Node.BOTH: cfw.add(ByteCode.DADD); break; case Node.LEFT: addOptRuntimeInvoke("add", "(DLjava/lang/Object;)Ljava/lang/Object;"); break; case Node.RIGHT: addOptRuntimeInvoke("add", "(Ljava/lang/Object;D)Ljava/lang/Object;"); break; default: if (child.getType() == Token.STRING) { addScriptRuntimeInvoke("add", "(Ljava/lang/CharSequence;" +"Ljava/lang/Object;" +")Ljava/lang/CharSequence;"); } else if (child.getNext().getType() == Token.STRING) { addScriptRuntimeInvoke("add", "(Ljava/lang/Object;" +"Ljava/lang/CharSequence;" +")Ljava/lang/CharSequence;"); } else { cfw.addALoad(contextLocal); addScriptRuntimeInvoke("add", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } } } break; case Token.MUL: visitArithmetic(node, ByteCode.DMUL, child, parent); break; case Token.SUB: visitArithmetic(node, ByteCode.DSUB, child, parent); break; case Token.DIV: case Token.MOD: visitArithmetic(node, type == Token.DIV ? ByteCode.DDIV : ByteCode.DREM, child, parent); break; case Token.BITOR: case Token.BITXOR: case Token.BITAND: case Token.LSH: case Token.RSH: case Token.URSH: visitBitOp(node, type, child); break; case Token.POS: case Token.NEG: generateExpression(child, node); addObjectToDouble(); if (type == Token.NEG) { cfw.add(ByteCode.DNEG); } addDoubleWrap(); break; case Token.TO_DOUBLE: // cnvt to double (not Double) generateExpression(child, node); addObjectToDouble(); break; case Token.TO_OBJECT: { // convert from double int prop = -1; if (child.getType() == Token.NUMBER) { prop = child.getIntProp(Node.ISNUMBER_PROP, -1); } if (prop != -1) { child.removeProp(Node.ISNUMBER_PROP); generateExpression(child, node); child.putIntProp(Node.ISNUMBER_PROP, prop); } else { generateExpression(child, node); addDoubleWrap(); } break; } case Token.IN: case Token.INSTANCEOF: case Token.LE: case Token.LT: case Token.GE: case Token.GT: { int trueGOTO = cfw.acquireLabel(); int falseGOTO = cfw.acquireLabel(); visitIfJumpRelOp(node, child, trueGOTO, falseGOTO); addJumpedBooleanWrap(trueGOTO, falseGOTO); break; } case Token.EQ: case Token.NE: case Token.SHEQ: case Token.SHNE: { int trueGOTO = cfw.acquireLabel(); int falseGOTO = cfw.acquireLabel(); visitIfJumpEqOp(node, child, trueGOTO, falseGOTO); addJumpedBooleanWrap(trueGOTO, falseGOTO); break; } case Token.GETPROP: case Token.GETPROPNOWARN: visitGetProp(node, child); break; case Token.GETELEM: generateExpression(child, node); // object generateExpression(child.getNext(), node); // id cfw.addALoad(contextLocal); if (node.getIntProp(Node.ISNUMBER_PROP, -1) != -1) { addScriptRuntimeInvoke( "getObjectIndex", "(Ljava/lang/Object;D" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } else { cfw.addALoad(variableObjectLocal); addScriptRuntimeInvoke( "getObjectElem", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +")Ljava/lang/Object;"); } break; case Token.GET_REF: generateExpression(child, node); // reference cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refGet", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.GETVAR: visitGetVar(node); break; case Token.SETVAR: visitSetVar(node, child, true); break; case Token.SETNAME: visitSetName(node, child); break; case Token.STRICT_SETNAME: visitStrictSetName(node, child); break; case Token.SETCONST: visitSetConst(node, child); break; case Token.SETCONSTVAR: visitSetConstVar(node, child, true); break; case Token.SETPROP: case Token.SETPROP_OP: visitSetProp(type, node, child); break; case Token.SETELEM: case Token.SETELEM_OP: visitSetElem(type, node, child); break; case Token.SET_REF: case Token.SET_REF_OP: { generateExpression(child, node); child = child.getNext(); if (type == Token.SET_REF_OP) { cfw.add(ByteCode.DUP); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refGet", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "refSet", "(Lorg/mozilla/javascript/Ref;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); } break; case Token.DEL_REF: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("refDel", "(Lorg/mozilla/javascript/Ref;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.DELPROP: boolean isName = child.getType() == Token.BINDNAME; generateExpression(child, node); child = child.getNext(); generateExpression(child, node); cfw.addALoad(contextLocal); cfw.addPush(isName); addScriptRuntimeInvoke("delete", "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Z)Ljava/lang/Object;"); break; case Token.BINDNAME: { while (child != null) { generateExpression(child, node); child = child.getNext(); } // Generate code for "ScriptRuntime.bind(varObj, "s")" cfw.addALoad(contextLocal); cfw.addALoad(variableObjectLocal); cfw.addPush(node.getString()); addScriptRuntimeInvoke( "bind", "(Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"Ljava/lang/String;" +")Lorg/mozilla/javascript/Scriptable;"); } break; case Token.LOCAL_LOAD: cfw.addALoad(getLocalBlockRegister(node)); break; case Token.REF_SPECIAL: { String special = (String)node.getProp(Node.NAME_PROP); generateExpression(child, node); cfw.addPush(special); cfw.addALoad(contextLocal); addScriptRuntimeInvoke( "specialRef", "(Ljava/lang/Object;" +"Ljava/lang/String;" +"Lorg/mozilla/javascript/Context;" +")Lorg/mozilla/javascript/Ref;"); } break; case Token.REF_MEMBER: case Token.REF_NS_MEMBER: case Token.REF_NAME: case Token.REF_NS_NAME: { int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0); // generate possible target, possible namespace and member do { generateExpression(child, node); child = child.getNext(); } while (child != null); cfw.addALoad(contextLocal); String methodName, signature; switch (type) { case Token.REF_MEMBER: methodName = "memberRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"I" +")Lorg/mozilla/javascript/Ref;"; break; case Token.REF_NS_MEMBER: methodName = "memberRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"I" +")Lorg/mozilla/javascript/Ref;"; break; case Token.REF_NAME: methodName = "nameRef"; signature = "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"I" +")Lorg/mozilla/javascript/Ref;"; cfw.addALoad(variableObjectLocal); break; case Token.REF_NS_NAME: methodName = "nameRef"; signature = "(Ljava/lang/Object;" +"Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +"Lorg/mozilla/javascript/Scriptable;" +"I" +")Lorg/mozilla/javascript/Ref;"; cfw.addALoad(variableObjectLocal); break; default: throw Kit.codeBug(); } cfw.addPush(memberTypeFlags); addScriptRuntimeInvoke(methodName, signature); } break; case Token.DOTQUERY: visitDotQuery(node, child); break; case Token.ESCXMLATTR: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("escapeAttributeValue", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/String;"); break; case Token.ESCXMLTEXT: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("escapeTextValue", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/String;"); break; case Token.DEFAULTNAMESPACE: generateExpression(child, node); cfw.addALoad(contextLocal); addScriptRuntimeInvoke("setDefaultNamespace", "(Ljava/lang/Object;" +"Lorg/mozilla/javascript/Context;" +")Ljava/lang/Object;"); break; case Token.YIELD: generateYieldPoint(node, true); break; case Token.WITHEXPR: { Node enterWith = child; Node with = enterWith.getNext(); Node leaveWith = with.getNext(); generateStatement(enterWith); generateExpression(with.getFirstChild(), with); generateStatement(leaveWith); break; } case Token.ARRAYCOMP: { Node initStmt = child; Node expr = child.getNext(); generateStatement(initStmt); generateExpression(expr, node); break; } default: throw new RuntimeException("Unexpected node type "+type); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
public Scriptable requireMain(Context cx, String mainModuleId) { if(this.mainModuleId != null) { if (!this.mainModuleId.equals(mainModuleId)) { throw new IllegalStateException("Main module already set to " + this.mainModuleId); } return mainExports; } ModuleScript moduleScript; try { // try to get the module script to see if it is on the module path moduleScript = moduleScriptProvider.getModuleScript( cx, mainModuleId, null, paths); } catch (RuntimeException x) { throw x; } catch (Exception x) { throw new RuntimeException(x); } if (moduleScript != null) { mainExports = getExportedModuleInterface(cx, mainModuleId, null, true); } else if (!sandboxed) { URI mainUri = null; // try to resolve to an absolute URI or file path try { mainUri = new URI(mainModuleId); } catch (URISyntaxException usx) { // fall through } // if not an absolute uri resolve to a file path if (mainUri == null || !mainUri.isAbsolute()) { File file = new File(mainModuleId); if (!file.isFile()) { throw ScriptRuntime.throwError(cx, nativeScope, "Module \"" + mainModuleId + "\" not found."); } mainUri = file.toURI(); } mainExports = getExportedModuleInterface(cx, mainUri.toString(), mainUri, true); } this.mainModuleId = mainModuleId; return mainExports; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public Node getChildBefore(Node child) { if (child == first) return null; Node n = first; while (n.next != child) { n = n.next; if (n == null) throw new RuntimeException("node is not a child"); } return n; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void addChildBefore(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildBefore"); if (first == node) { newChild.next = first; first = newChild; return; } Node prev = getChildBefore(node); addChildAfter(newChild, prev); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Node.java
public void addChildAfter(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildAfter"); newChild.next = node.next; node.next = newChild; if (last == node) last = newChild; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptableObject.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int tableSize = in.readInt(); if (tableSize != 0) { // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) throw new RuntimeException("Property table overflow"); int newSize = INITIAL_SLOT_SIZE; while (newSize < tableSize) newSize <<= 1; tableSize = newSize; } slots = new Slot[tableSize]; int objectsCount = count; if (objectsCount < 0) { // "this" was sealed objectsCount = ~objectsCount; } Slot prev = null; for (int i=0; i != objectsCount; ++i) { lastAdded = (Slot)in.readObject(); if (i==0) { firstAdded = lastAdded; } else { prev.orderedNext = lastAdded; } int slotIndex = getSlotIndex(tableSize, lastAdded.indexOrHash); addKnownAbsentSlot(slots, lastAdded, slotIndex); prev = lastAdded; } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
public void setStackProvider(RhinoException re) { // We go some extra miles to make sure the stack property is only // generated on demand, is cached after the first access, and is // overwritable like an ordinary property. Hence this setup with // the getter and setter below. if (stackProvider == null) { stackProvider = re; try { defineProperty("stack", null, NativeError.class.getMethod("getStack"), NativeError.class.getMethod("setStack", Object.class), 0); } catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaAdapter.java
static void generateReturnResult(ClassFileWriter cfw, Class<?> retType, boolean callConvertResult) { // wrap boolean values with java.lang.Boolean, convert all other // primitive values to java.lang.Double. if (retType == Void.TYPE) { cfw.add(ByteCode.POP); cfw.add(ByteCode.RETURN); } else if (retType == Boolean.TYPE) { cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toBoolean", "(Ljava/lang/Object;)Z"); cfw.add(ByteCode.IRETURN); } else if (retType == Character.TYPE) { // characters are represented as strings in JavaScript. // return the first character. // first convert the value to a string if possible. cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toString", "(Ljava/lang/Object;)Ljava/lang/String;"); cfw.add(ByteCode.ICONST_0); cfw.addInvoke(ByteCode.INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); cfw.add(ByteCode.IRETURN); } else if (retType.isPrimitive()) { cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/Context", "toNumber", "(Ljava/lang/Object;)D"); String typeName = retType.getName(); switch (typeName.charAt(0)) { case 'b': case 's': case 'i': cfw.add(ByteCode.D2I); cfw.add(ByteCode.IRETURN); break; case 'l': cfw.add(ByteCode.D2L); cfw.add(ByteCode.LRETURN); break; case 'f': cfw.add(ByteCode.D2F); cfw.add(ByteCode.FRETURN); break; case 'd': cfw.add(ByteCode.DRETURN); break; default: throw new RuntimeException("Unexpected return type " + retType.toString()); } } else { String retTypeStr = retType.getName(); if (callConvertResult) { cfw.addLoadConstant(retTypeStr); cfw.addInvoke(ByteCode.INVOKESTATIC, "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;"); cfw.addInvoke(ByteCode.INVOKESTATIC, "org/mozilla/javascript/JavaAdapter", "convertResult", "(Ljava/lang/Object;" +"Ljava/lang/Class;" +")Ljava/lang/Object;"); } // Now cast to return type cfw.add(ByteCode.CHECKCAST, retTypeStr); cfw.add(ByteCode.ARETURN); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
public DiyFp clone() { try { return (DiyFp) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ObjArray.java
private static RuntimeException onEmptyStackTopRead() { throw new RuntimeException("Empty stack"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ClassCache.java
public static ClassCache get(Scriptable scope) { ClassCache cache = (ClassCache) ScriptableObject.getTopScopeValue(scope, AKEY); if (cache == null) { throw new RuntimeException("Can't find top level scope for " + "ClassCache.get"); } return cache; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
public static String decompile(String source, int flags, UintMap properties) { int length = source.length(); if (length == 0) { return ""; } int indent = properties.getInt(INITIAL_INDENT_PROP, 0); if (indent < 0) throw new IllegalArgumentException(); int indentGap = properties.getInt(INDENT_GAP_PROP, 4); if (indentGap < 0) throw new IllegalArgumentException(); int caseGap = properties.getInt(CASE_GAP_PROP, 2); if (caseGap < 0) throw new IllegalArgumentException(); StringBuffer result = new StringBuffer(); boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG)); boolean toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG)); // Spew tokens in source, for debugging. // as TYPE number char if (printSource) { System.err.println("length:" + length); for (int i = 0; i < length; ++i) { // Note that tokenToName will fail unless Context.printTrees // is true. String tokenname = null; if (Token.printNames) { tokenname = Token.name(source.charAt(i)); } if (tokenname == null) { tokenname = "---"; } String pad = tokenname.length() > 7 ? "\t" : "\t\t"; System.err.println (tokenname + pad + (int)source.charAt(i) + "\t'" + ScriptRuntime.escapeString (source.substring(i, i+1)) + "'"); } System.err.println(); } int braceNesting = 0; boolean afterFirstEOL = false; int i = 0; int topFunctionType; if (source.charAt(i) == Token.SCRIPT) { ++i; topFunctionType = -1; } else { topFunctionType = source.charAt(i + 1); } if (!toSource) { // add an initial newline to exactly match js. result.append('\n'); for (int j = 0; j < indent; j++) result.append(' '); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append('('); } } while (i < length) { switch(source.charAt(i)) { case Token.GET: case Token.SET: result.append(source.charAt(i) == Token.GET ? "get " : "set "); ++i; i = printSourceString(source, i + 1, false, result); // Now increment one more to get past the FUNCTION token ++i; break; case Token.NAME: case Token.REGEXP: // re-wrapped in '/'s in parser... i = printSourceString(source, i + 1, false, result); continue; case Token.STRING: i = printSourceString(source, i + 1, true, result); continue; case Token.NUMBER: i = printSourceNumber(source, i + 1, result); continue; case Token.TRUE: result.append("true"); break; case Token.FALSE: result.append("false"); break; case Token.NULL: result.append("null"); break; case Token.THIS: result.append("this"); break; case Token.FUNCTION: ++i; // skip function type result.append("function "); break; case FUNCTION_END: // Do nothing break; case Token.COMMA: result.append(", "); break; case Token.LC: ++braceNesting; if (Token.EOL == getNext(source, length, i)) indent += indentGap; result.append('{'); break; case Token.RC: { --braceNesting; /* don't print the closing RC if it closes the * toplevel function and we're called from * decompileFunctionBody. */ if (justFunctionBody && braceNesting == 0) break; result.append('}'); switch (getNext(source, length, i)) { case Token.EOL: case FUNCTION_END: indent -= indentGap; break; case Token.WHILE: case Token.ELSE: indent -= indentGap; result.append(' '); break; } break; } case Token.LP: result.append('('); break; case Token.RP: result.append(')'); if (Token.LC == getNext(source, length, i)) result.append(' '); break; case Token.LB: result.append('['); break; case Token.RB: result.append(']'); break; case Token.EOL: { if (toSource) break; boolean newLine = true; if (!afterFirstEOL) { afterFirstEOL = true; if (justFunctionBody) { /* throw away just added 'function name(...) {' * and restore the original indent */ result.setLength(0); indent -= indentGap; newLine = false; } } if (newLine) { result.append('\n'); } /* add indent if any tokens remain, * less setback if next token is * a label, case or default. */ if (i + 1 < length) { int less = 0; int nextToken = source.charAt(i + 1); if (nextToken == Token.CASE || nextToken == Token.DEFAULT) { less = indentGap - caseGap; } else if (nextToken == Token.RC) { less = indentGap; } /* elaborate check against label... skip past a * following inlined NAME and look for a COLON. */ else if (nextToken == Token.NAME) { int afterName = getSourceStringEnd(source, i + 2); if (source.charAt(afterName) == Token.COLON) less = indentGap; } for (; less < indent; less++) result.append(' '); } break; } case Token.DOT: result.append('.'); break; case Token.NEW: result.append("new "); break; case Token.DELPROP: result.append("delete "); break; case Token.IF: result.append("if "); break; case Token.ELSE: result.append("else "); break; case Token.FOR: result.append("for "); break; case Token.IN: result.append(" in "); break; case Token.WITH: result.append("with "); break; case Token.WHILE: result.append("while "); break; case Token.DO: result.append("do "); break; case Token.TRY: result.append("try "); break; case Token.CATCH: result.append("catch "); break; case Token.FINALLY: result.append("finally "); break; case Token.THROW: result.append("throw "); break; case Token.SWITCH: result.append("switch "); break; case Token.BREAK: result.append("break"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CONTINUE: result.append("continue"); if (Token.NAME == getNext(source, length, i)) result.append(' '); break; case Token.CASE: result.append("case "); break; case Token.DEFAULT: result.append("default"); break; case Token.RETURN: result.append("return"); if (Token.SEMI != getNext(source, length, i)) result.append(' '); break; case Token.VAR: result.append("var "); break; case Token.LET: result.append("let "); break; case Token.SEMI: result.append(';'); if (Token.EOL != getNext(source, length, i)) { // separators in FOR result.append(' '); } break; case Token.ASSIGN: result.append(" = "); break; case Token.ASSIGN_ADD: result.append(" += "); break; case Token.ASSIGN_SUB: result.append(" -= "); break; case Token.ASSIGN_MUL: result.append(" *= "); break; case Token.ASSIGN_DIV: result.append(" /= "); break; case Token.ASSIGN_MOD: result.append(" %= "); break; case Token.ASSIGN_BITOR: result.append(" |= "); break; case Token.ASSIGN_BITXOR: result.append(" ^= "); break; case Token.ASSIGN_BITAND: result.append(" &= "); break; case Token.ASSIGN_LSH: result.append(" <<= "); break; case Token.ASSIGN_RSH: result.append(" >>= "); break; case Token.ASSIGN_URSH: result.append(" >>>= "); break; case Token.HOOK: result.append(" ? "); break; case Token.OBJECTLIT: // pun OBJECTLIT to mean colon in objlit property // initialization. // This needs to be distinct from COLON in the general case // to distinguish from the colon in a ternary... which needs // different spacing. result.append(':'); break; case Token.COLON: if (Token.EOL == getNext(source, length, i)) // it's the end of a label result.append(':'); else // it's the middle part of a ternary result.append(" : "); break; case Token.OR: result.append(" || "); break; case Token.AND: result.append(" && "); break; case Token.BITOR: result.append(" | "); break; case Token.BITXOR: result.append(" ^ "); break; case Token.BITAND: result.append(" & "); break; case Token.SHEQ: result.append(" === "); break; case Token.SHNE: result.append(" !== "); break; case Token.EQ: result.append(" == "); break; case Token.NE: result.append(" != "); break; case Token.LE: result.append(" <= "); break; case Token.LT: result.append(" < "); break; case Token.GE: result.append(" >= "); break; case Token.GT: result.append(" > "); break; case Token.INSTANCEOF: result.append(" instanceof "); break; case Token.LSH: result.append(" << "); break; case Token.RSH: result.append(" >> "); break; case Token.URSH: result.append(" >>> "); break; case Token.TYPEOF: result.append("typeof "); break; case Token.VOID: result.append("void "); break; case Token.CONST: result.append("const "); break; case Token.YIELD: result.append("yield "); break; case Token.NOT: result.append('!'); break; case Token.BITNOT: result.append('~'); break; case Token.POS: result.append('+'); break; case Token.NEG: result.append('-'); break; case Token.INC: result.append("++"); break; case Token.DEC: result.append("--"); break; case Token.ADD: result.append(" + "); break; case Token.SUB: result.append(" - "); break; case Token.MUL: result.append(" * "); break; case Token.DIV: result.append(" / "); break; case Token.MOD: result.append(" % "); break; case Token.COLONCOLON: result.append("::"); break; case Token.DOTDOT: result.append(".."); break; case Token.DOTQUERY: result.append(".("); break; case Token.XMLATTR: result.append('@'); break; case Token.DEBUGGER: result.append("debugger;\n"); break; default: // If we don't know how to decompile it, raise an exception. throw new RuntimeException("Token: " + Token.name(source.charAt(i))); } ++i; } if (!toSource) { // add that trailing newline if it's an outermost function. if (!justFunctionBody) result.append('\n'); } else { if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) { result.append(')'); } } return result.toString(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Decompiler.java
private static int printSourceNumber(String source, int offset, StringBuffer sb) { double number = 0.0; char type = source.charAt(offset); ++offset; if (type == 'S') { if (sb != null) { int ival = source.charAt(offset); number = ival; } ++offset; } else if (type == 'J' || type == 'D') { if (sb != null) { long lbits; lbits = (long)source.charAt(offset) << 48; lbits |= (long)source.charAt(offset + 1) << 32; lbits |= (long)source.charAt(offset + 2) << 16; lbits |= source.charAt(offset + 3); if (type == 'J') { number = lbits; } else { number = Double.longBitsToDouble(lbits); } } offset += 4; } else { // Bad source throw new RuntimeException(); } if (sb != null) { sb.append(ScriptRuntime.numberToString(number, 10)); } return offset; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
private static Object interpretLoop(Context cx, CallFrame frame, Object throwable) { // throwable holds exception object to rethrow or catch // It is also used for continuation restart in which case // it holds ContinuationJump final Object DBL_MRK = DOUBLE_MARK; final Object undefined = Undefined.instance; final boolean instructionCounting = (cx.instructionThreshold != 0); // arbitrary number to add to instructionCount when calling // other functions final int INVOCATION_COST = 100; // arbitrary exception cost for instruction counting final int EXCEPTION_COST = 100; String stringReg = null; int indexReg = -1; if (cx.lastInterpreterFrame != null) { // save the top frame from the previous interpretLoop // invocation on the stack if (cx.previousInterpreterInvocations == null) { cx.previousInterpreterInvocations = new ObjArray(); } cx.previousInterpreterInvocations.push(cx.lastInterpreterFrame); } // When restarting continuation throwable is not null and to jump // to the code that rewind continuation state indexReg should be set // to -1. // With the normal call throwable == null and indexReg == -1 allows to // catch bugs with using indeReg to access array elements before // initializing indexReg. GeneratorState generatorState = null; if (throwable != null) { if (throwable instanceof GeneratorState) { generatorState = (GeneratorState) throwable; // reestablish this call frame enterFrame(cx, frame, ScriptRuntime.emptyArgs, true); throwable = null; } else if (!(throwable instanceof ContinuationJump)) { // It should be continuation Kit.codeBug(); } } Object interpreterResult = null; double interpreterResultDbl = 0.0; StateLoop: for (;;) { withoutExceptions: try { if (throwable != null) { // Need to return both 'frame' and 'throwable' from // 'processThrowable', so just added a 'throwable' // member in 'frame'. frame = processThrowable(cx, throwable, frame, indexReg, instructionCounting); throwable = frame.throwable; frame.throwable = null; } else { if (generatorState == null && frame.frozen) Kit.codeBug(); } // Use local variables for constant values in frame // for faster access Object[] stack = frame.stack; double[] sDbl = frame.sDbl; Object[] vars = frame.varSource.stack; double[] varDbls = frame.varSource.sDbl; int[] varAttributes = frame.varSource.stackAttributes; byte[] iCode = frame.idata.itsICode; String[] strings = frame.idata.itsStringTable; // Use local for stackTop as well. Since execption handlers // can only exist at statement level where stack is empty, // it is necessary to save/restore stackTop only across // function calls and normal returns. int stackTop = frame.savedStackTop; // Store new frame in cx which is used for error reporting etc. cx.lastInterpreterFrame = frame; Loop: for (;;) { // Exception handler assumes that PC is already incremented // pass the instruction start when it searches the // exception handler int op = iCode[frame.pc++]; jumplessRun: { // Back indent to ease implementation reading switch (op) { case Icode_GENERATOR: { if (!frame.frozen) { // First time encountering this opcode: create new generator // object and return frame.pc--; // we want to come back here when we resume CallFrame generatorFrame = captureFrameForGenerator(frame); generatorFrame.frozen = true; NativeGenerator generator = new NativeGenerator(frame.scope, generatorFrame.fnOrScript, generatorFrame); frame.result = generator; break Loop; } else { // We are now resuming execution. Fall through to YIELD case. } } // fall through... case Token.YIELD: { if (!frame.frozen) { return freezeGenerator(cx, frame, stackTop, generatorState); } else { Object obj = thawGenerator(frame, stackTop, generatorState, op); if (obj != Scriptable.NOT_FOUND) { throwable = obj; break withoutExceptions; } continue Loop; } } case Icode_GENERATOR_END: { // throw StopIteration frame.frozen = true; int sourceLine = getIndex(iCode, frame.pc); generatorState.returnedException = new JavaScriptException( NativeIterator.getStopIterationObject(frame.scope), frame.idata.itsSourceFile, sourceLine); break Loop; } case Token.THROW: { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int sourceLine = getIndex(iCode, frame.pc); throwable = new JavaScriptException(value, frame.idata.itsSourceFile, sourceLine); break withoutExceptions; } case Token.RETHROW: { indexReg += frame.localShift; throwable = stack[indexReg]; break withoutExceptions; } case Token.GE : case Token.LE : case Token.GT : case Token.LT : { stackTop = doCompare(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.IN : case Token.INSTANCEOF : { stackTop = doInOrInstanceof(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.EQ : case Token.NE : { --stackTop; boolean valBln = doEquals(stack, sDbl, stackTop); valBln ^= (op == Token.NE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.SHEQ : case Token.SHNE : { --stackTop; boolean valBln = doShallowEquals(stack, sDbl, stackTop); valBln ^= (op == Token.SHNE); stack[stackTop] = ScriptRuntime.wrapBoolean(valBln); continue Loop; } case Token.IFNE : if (stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Token.IFEQ : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } break jumplessRun; case Icode_IFEQ_POP : if (!stack_boolean(frame, stackTop--)) { frame.pc += 2; continue Loop; } stack[stackTop--] = null; break jumplessRun; case Token.GOTO : break jumplessRun; case Icode_GOSUB : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.pc + 2; break jumplessRun; case Icode_STARTSUB : if (stackTop == frame.emptyStackTop + 1) { // Call from Icode_GOSUB: store return PC address in the local indexReg += frame.localShift; stack[indexReg] = stack[stackTop]; sDbl[indexReg] = sDbl[stackTop]; --stackTop; } else { // Call from exception handler: exception object is already stored // in the local if (stackTop != frame.emptyStackTop) Kit.codeBug(); } continue Loop; case Icode_RETSUB : { // indexReg: local to store return address if (instructionCounting) { addInstructionCount(cx, frame, 0); } indexReg += frame.localShift; Object value = stack[indexReg]; if (value != DBL_MRK) { // Invocation from exception handler, restore object to rethrow throwable = value; break withoutExceptions; } // Normal return from GOSUB frame.pc = (int)sDbl[indexReg]; if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } case Icode_POP : stack[stackTop] = null; stackTop--; continue Loop; case Icode_POP_RESULT : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; stack[stackTop] = null; --stackTop; continue Loop; case Icode_DUP : stack[stackTop + 1] = stack[stackTop]; sDbl[stackTop + 1] = sDbl[stackTop]; stackTop++; continue Loop; case Icode_DUP2 : stack[stackTop + 1] = stack[stackTop - 1]; sDbl[stackTop + 1] = sDbl[stackTop - 1]; stack[stackTop + 2] = stack[stackTop]; sDbl[stackTop + 2] = sDbl[stackTop]; stackTop += 2; continue Loop; case Icode_SWAP : { Object o = stack[stackTop]; stack[stackTop] = stack[stackTop - 1]; stack[stackTop - 1] = o; double d = sDbl[stackTop]; sDbl[stackTop] = sDbl[stackTop - 1]; sDbl[stackTop - 1] = d; continue Loop; } case Token.RETURN : frame.result = stack[stackTop]; frame.resultDbl = sDbl[stackTop]; --stackTop; break Loop; case Token.RETURN_RESULT : break Loop; case Icode_RETUNDEF : frame.result = undefined; break Loop; case Token.BITNOT : { int rIntValue = stack_int32(frame, stackTop); stack[stackTop] = DBL_MRK; sDbl[stackTop] = ~rIntValue; continue Loop; } case Token.BITAND : case Token.BITOR : case Token.BITXOR : case Token.LSH : case Token.RSH : { stackTop = doBitOp(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.URSH : { double lDbl = stack_double(frame, stackTop - 1); int rIntValue = stack_int32(frame, stackTop) & 0x1F; stack[--stackTop] = DBL_MRK; sDbl[stackTop] = ScriptRuntime.toUint32(lDbl) >>> rIntValue; continue Loop; } case Token.NEG : case Token.POS : { double rDbl = stack_double(frame, stackTop); stack[stackTop] = DBL_MRK; if (op == Token.NEG) { rDbl = -rDbl; } sDbl[stackTop] = rDbl; continue Loop; } case Token.ADD : --stackTop; doAdd(stack, sDbl, stackTop, cx); continue Loop; case Token.SUB : case Token.MUL : case Token.DIV : case Token.MOD : { stackTop = doArithmetic(frame, op, stack, sDbl, stackTop); continue Loop; } case Token.NOT : stack[stackTop] = ScriptRuntime.wrapBoolean( !stack_boolean(frame, stackTop)); continue Loop; case Token.BINDNAME : stack[++stackTop] = ScriptRuntime.bind(cx, frame.scope, stringReg); continue Loop; case Token.STRICT_SETNAME: case Token.SETNAME : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = op == Token.SETNAME ? ScriptRuntime.setName(lhs, rhs, cx, frame.scope, stringReg) : ScriptRuntime.strictSetName(lhs, rhs, cx, frame.scope, stringReg); continue Loop; } case Icode_SETCONST: { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Scriptable lhs = (Scriptable)stack[stackTop]; stack[stackTop] = ScriptRuntime.setConst(lhs, rhs, cx, stringReg); continue Loop; } case Token.DELPROP : case Icode_DELNAME : { stackTop = doDelName(cx, op, stack, sDbl, stackTop); continue Loop; } case Token.GETPROPNOWARN : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectPropNoWarn(lhs, stringReg, cx); continue Loop; } case Token.GETPROP : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx, frame.scope); continue Loop; } case Token.SETPROP : { Object rhs = stack[stackTop]; if (rhs == DBL_MRK) rhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setObjectProp(lhs, stringReg, rhs, cx); continue Loop; } case Icode_PROP_INC_DEC : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.propIncrDecr(lhs, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.GETELEM : { stackTop = doGetElem(cx, frame, stack, sDbl, stackTop); continue Loop; } case Token.SETELEM : { stackTop = doSetElem(cx, stack, sDbl, stackTop); continue Loop; } case Icode_ELEM_INC_DEC: { stackTop = doElemIncDec(cx, frame, iCode, stack, sDbl, stackTop); continue Loop; } case Token.GET_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refGet(ref, cx); continue Loop; } case Token.SET_REF : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refSet(ref, value, cx); continue Loop; } case Token.DEL_REF : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refDel(ref, cx); continue Loop; } case Icode_REF_INC_DEC : { Ref ref = (Ref)stack[stackTop]; stack[stackTop] = ScriptRuntime.refIncrDecr(ref, cx, iCode[frame.pc]); ++frame.pc; continue Loop; } case Token.LOCAL_LOAD : ++stackTop; indexReg += frame.localShift; stack[stackTop] = stack[indexReg]; sDbl[stackTop] = sDbl[indexReg]; continue Loop; case Icode_LOCAL_CLEAR : indexReg += frame.localShift; stack[indexReg] = null; continue Loop; case Icode_NAME_AND_THIS : // stringReg: name ++stackTop; stack[stackTop] = ScriptRuntime.getNameFunctionAndThis(stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; case Icode_PROP_AND_THIS: { Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); // stringReg: property stack[stackTop] = ScriptRuntime.getPropFunctionAndThis(obj, stringReg, cx, frame.scope); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_ELEM_AND_THIS: { Object obj = stack[stackTop - 1]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop - 1]); Object id = stack[stackTop]; if (id == DBL_MRK) id = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id, cx); stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_VALUE_AND_THIS : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getValueFunctionAndThis(value, cx); ++stackTop; stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx); continue Loop; } case Icode_CALLSPECIAL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } stackTop = doCallSpecial(cx, frame, stack, sDbl, stackTop, iCode, indexReg); continue Loop; } case Token.CALL : case Icode_TAIL_CALL : case Token.REF_CALL : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function thisObj arg0 .. argN -> result // indexReg: number of arguments stackTop -= 1 + indexReg; // CALL generation ensures that fun and funThisObj // are already Scriptable and Callable objects respectively Callable fun = (Callable)stack[stackTop]; Scriptable funThisObj = (Scriptable)stack[stackTop + 1]; if (op == Token.REF_CALL) { Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 2, indexReg); stack[stackTop] = ScriptRuntime.callRef(fun, funThisObj, outArgs, cx); continue Loop; } Scriptable calleeScope = frame.scope; if (frame.useActivation) { calleeScope = ScriptableObject.getTopLevelScope(frame.scope); } if (fun instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction)fun; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { CallFrame callParentFrame = frame; CallFrame calleeFrame = new CallFrame(); if (op == Icode_TAIL_CALL) { // In principle tail call can re-use the current // frame and its stack arrays but it is hard to // do properly. Any exceptions that can legally // happen during frame re-initialization including // StackOverflowException during innocent looking // System.arraycopy may leave the current frame // data corrupted leading to undefined behaviour // in the catch code bellow that unwinds JS stack // on exceptions. Then there is issue about frame release // end exceptions there. // To avoid frame allocation a released frame // can be cached for re-use which would also benefit // non-tail calls but it is not clear that this caching // would gain in performance due to potentially // bad interaction with GC. callParentFrame = frame.parentFrame; // Release the current frame. See Bug #344501 to see why // it is being done here. exitFrame(cx, frame, null); } initFrame(cx, calleeScope, funThisObj, stack, sDbl, stackTop + 2, indexReg, ifun, callParentFrame, calleeFrame); if (op != Icode_TAIL_CALL) { frame.savedStackTop = stackTop; frame.savedCallOp = op; } frame = calleeFrame; continue StateLoop; } } if (fun instanceof NativeContinuation) { // Jump to the captured continuation ContinuationJump cjump; cjump = new ContinuationJump((NativeContinuation)fun, frame); // continuation result is the first argument if any // of continuation call if (indexReg == 0) { cjump.result = undefined; } else { cjump.result = stack[stackTop + 2]; cjump.resultDbl = sDbl[stackTop + 2]; } // Start the real unwind job throwable = cjump; break withoutExceptions; } if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } // Bug 405654 -- make best effort to keep Function.apply and // Function.call within this interpreter loop invocation if (BaseFunction.isApplyOrCall(ifun)) { Callable applyCallable = ScriptRuntime.getCallable(funThisObj); if (applyCallable instanceof InterpretedFunction) { InterpretedFunction iApplyCallable = (InterpretedFunction)applyCallable; if (frame.fnOrScript.securityDomain == iApplyCallable.securityDomain) { frame = initFrameForApplyOrCall(cx, frame, indexReg, stack, sDbl, stackTop, op, calleeScope, ifun, iApplyCallable); continue StateLoop; } } } } // Bug 447697 -- make best effort to keep __noSuchMethod__ within this // interpreter loop invocation if (fun instanceof NoSuchMethodShim) { // get the shim and the actual method NoSuchMethodShim noSuchMethodShim = (NoSuchMethodShim) fun; Callable noSuchMethodMethod = noSuchMethodShim.noSuchMethodMethod; // if the method is in fact an InterpretedFunction if (noSuchMethodMethod instanceof InterpretedFunction) { InterpretedFunction ifun = (InterpretedFunction) noSuchMethodMethod; if (frame.fnOrScript.securityDomain == ifun.securityDomain) { frame = initFrameForNoSuchMethod(cx, frame, indexReg, stack, sDbl, stackTop, op, funThisObj, calleeScope, noSuchMethodShim, ifun); continue StateLoop; } } } cx.lastInterpreterFrame = frame; frame.savedCallOp = op; frame.savedStackTop = stackTop; stack[stackTop] = fun.call(cx, calleeScope, funThisObj, getArgsArray(stack, sDbl, stackTop + 2, indexReg)); continue Loop; } case Token.NEW : { if (instructionCounting) { cx.instructionCount += INVOCATION_COST; } // stack change: function arg0 .. argN -> newResult // indexReg: number of arguments stackTop -= indexReg; Object lhs = stack[stackTop]; if (lhs instanceof InterpretedFunction) { InterpretedFunction f = (InterpretedFunction)lhs; if (frame.fnOrScript.securityDomain == f.securityDomain) { Scriptable newInstance = f.createObject(cx, frame.scope); CallFrame calleeFrame = new CallFrame(); initFrame(cx, frame.scope, newInstance, stack, sDbl, stackTop + 1, indexReg, f, frame, calleeFrame); stack[stackTop] = newInstance; frame.savedStackTop = stackTop; frame.savedCallOp = op; frame = calleeFrame; continue StateLoop; } } if (!(lhs instanceof Function)) { if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); throw ScriptRuntime.notFunctionError(lhs); } Function fun = (Function)lhs; if (fun instanceof IdFunctionObject) { IdFunctionObject ifun = (IdFunctionObject)fun; if (NativeContinuation.isContinuationConstructor(ifun)) { frame.stack[stackTop] = captureContinuation(cx, frame.parentFrame, false); continue Loop; } } Object[] outArgs = getArgsArray(stack, sDbl, stackTop + 1, indexReg); stack[stackTop] = fun.construct(cx, frame.scope, outArgs); continue Loop; } case Token.TYPEOF : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.typeof(lhs); continue Loop; } case Icode_TYPEOFNAME : stack[++stackTop] = ScriptRuntime.typeofName(frame.scope, stringReg); continue Loop; case Token.STRING : stack[++stackTop] = stringReg; continue Loop; case Icode_SHORTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getShort(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_INTNUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Token.NUMBER : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = frame.idata.itsDoubleTable[indexReg]; continue Loop; case Token.NAME : stack[++stackTop] = ScriptRuntime.name(cx, frame.scope, stringReg); continue Loop; case Icode_NAME_INC_DEC : stack[++stackTop] = ScriptRuntime.nameIncrDecr(frame.scope, stringReg, cx, iCode[frame.pc]); ++frame.pc; continue Loop; case Icode_SETCONSTVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETCONSTVAR : stackTop = doSetConstVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_SETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.SETVAR : stackTop = doSetVar(frame, stack, sDbl, stackTop, vars, varDbls, varAttributes, indexReg); continue Loop; case Icode_GETVAR1: indexReg = iCode[frame.pc++]; // fallthrough case Token.GETVAR : stackTop = doGetVar(frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; case Icode_VAR_INC_DEC : { stackTop = doVarIncDec(cx, frame, stack, sDbl, stackTop, vars, varDbls, indexReg); continue Loop; } case Icode_ZERO : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 0; continue Loop; case Icode_ONE : ++stackTop; stack[stackTop] = DBL_MRK; sDbl[stackTop] = 1; continue Loop; case Token.NULL : stack[++stackTop] = null; continue Loop; case Token.THIS : stack[++stackTop] = frame.thisObj; continue Loop; case Token.THISFN : stack[++stackTop] = frame.fnOrScript; continue Loop; case Token.FALSE : stack[++stackTop] = Boolean.FALSE; continue Loop; case Token.TRUE : stack[++stackTop] = Boolean.TRUE; continue Loop; case Icode_UNDEF : stack[++stackTop] = undefined; continue Loop; case Token.ENTERWITH : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterWith(lhs, cx, frame.scope); continue Loop; } case Token.LEAVEWITH : frame.scope = ScriptRuntime.leaveWith(frame.scope); continue Loop; case Token.CATCH_SCOPE : { // stack top: exception object // stringReg: name of exception variable // indexReg: local for exception scope --stackTop; indexReg += frame.localShift; boolean afterFirstScope = (frame.idata.itsICode[frame.pc] != 0); Throwable caughtException = (Throwable)stack[stackTop + 1]; Scriptable lastCatchScope; if (!afterFirstScope) { lastCatchScope = null; } else { lastCatchScope = (Scriptable)stack[indexReg]; } stack[indexReg] = ScriptRuntime.newCatchScope(caughtException, lastCatchScope, stringReg, cx, frame.scope); ++frame.pc; continue Loop; } case Token.ENUM_INIT_KEYS : case Token.ENUM_INIT_VALUES : case Token.ENUM_INIT_ARRAY : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; indexReg += frame.localShift; int enumType = op == Token.ENUM_INIT_KEYS ? ScriptRuntime.ENUMERATE_KEYS : op == Token.ENUM_INIT_VALUES ? ScriptRuntime.ENUMERATE_VALUES : ScriptRuntime.ENUMERATE_ARRAY; stack[indexReg] = ScriptRuntime.enumInit(lhs, cx, enumType); continue Loop; } case Token.ENUM_NEXT : case Token.ENUM_ID : { indexReg += frame.localShift; Object val = stack[indexReg]; ++stackTop; stack[stackTop] = (op == Token.ENUM_NEXT) ? (Object)ScriptRuntime.enumNext(val) : (Object)ScriptRuntime.enumId(val, cx); continue Loop; } case Token.REF_SPECIAL : { //stringReg: name of special property Object obj = stack[stackTop]; if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg, cx); continue Loop; } case Token.REF_MEMBER: { //indexReg: flags stackTop = doRefMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NS_MEMBER: { //indexReg: flags stackTop = doRefNsMember(cx, stack, sDbl, stackTop, indexReg); continue Loop; } case Token.REF_NAME: { //indexReg: flags Object name = stack[stackTop]; if (name == DBL_MRK) name = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.nameRef(name, cx, frame.scope, indexReg); continue Loop; } case Token.REF_NS_NAME: { //indexReg: flags stackTop = doRefNsName(cx, frame, stack, sDbl, stackTop, indexReg); continue Loop; } case Icode_SCOPE_LOAD : indexReg += frame.localShift; frame.scope = (Scriptable)stack[indexReg]; continue Loop; case Icode_SCOPE_SAVE : indexReg += frame.localShift; stack[indexReg] = frame.scope; continue Loop; case Icode_CLOSURE_EXPR : stack[++stackTop] = InterpretedFunction.createFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Icode_CLOSURE_STMT : initFunction(cx, frame.scope, frame.fnOrScript, indexReg); continue Loop; case Token.REGEXP : Object re = frame.idata.itsRegExpLiterals[indexReg]; stack[++stackTop] = ScriptRuntime.wrapRegExp(cx, frame.scope, re); continue Loop; case Icode_LITERAL_NEW : // indexReg: number of values in the literal ++stackTop; stack[stackTop] = new int[indexReg]; ++stackTop; stack[stackTop] = new Object[indexReg]; sDbl[stackTop] = 0; continue Loop; case Icode_LITERAL_SET : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_GETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = -1; sDbl[stackTop] = i + 1; continue Loop; } case Icode_LITERAL_SETTER : { Object value = stack[stackTop]; --stackTop; int i = (int)sDbl[stackTop]; ((Object[])stack[stackTop])[i] = value; ((int[])stack[stackTop - 1])[i] = +1; sDbl[stackTop] = i + 1; continue Loop; } case Token.ARRAYLIT : case Icode_SPARE_ARRAYLIT : case Token.OBJECTLIT : { Object[] data = (Object[])stack[stackTop]; --stackTop; int[] getterSetters = (int[])stack[stackTop]; Object val; if (op == Token.OBJECTLIT) { Object[] ids = (Object[])frame.idata.literalIds[indexReg]; val = ScriptRuntime.newObjectLiteral(ids, data, getterSetters, cx, frame.scope); } else { int[] skipIndexces = null; if (op == Icode_SPARE_ARRAYLIT) { skipIndexces = (int[])frame.idata.literalIds[indexReg]; } val = ScriptRuntime.newArrayLiteral(data, skipIndexces, cx, frame.scope); } stack[stackTop] = val; continue Loop; } case Icode_ENTERDQ : { Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); --stackTop; frame.scope = ScriptRuntime.enterDotQuery(lhs, frame.scope); continue Loop; } case Icode_LEAVEDQ : { boolean valBln = stack_boolean(frame, stackTop); Object x = ScriptRuntime.updateDotQuery(valBln, frame.scope); if (x != null) { stack[stackTop] = x; frame.scope = ScriptRuntime.leaveDotQuery(frame.scope); frame.pc += 2; continue Loop; } // reset stack and PC to code after ENTERDQ --stackTop; break jumplessRun; } case Token.DEFAULTNAMESPACE : { Object value = stack[stackTop]; if (value == DBL_MRK) value = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.setDefaultNamespace(value, cx); continue Loop; } case Token.ESCXMLATTR : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeAttributeValue(value, cx); } continue Loop; } case Token.ESCXMLTEXT : { Object value = stack[stackTop]; if (value != DBL_MRK) { stack[stackTop] = ScriptRuntime.escapeTextValue(value, cx); } continue Loop; } case Icode_DEBUGGER: if (frame.debuggerFrame != null) { frame.debuggerFrame.onDebuggerStatement(cx); } continue Loop; case Icode_LINE : frame.pcSourceLineStart = frame.pc; if (frame.debuggerFrame != null) { int line = getIndex(iCode, frame.pc); frame.debuggerFrame.onLineChange(cx, line); } frame.pc += 2; continue Loop; case Icode_REG_IND_C0: indexReg = 0; continue Loop; case Icode_REG_IND_C1: indexReg = 1; continue Loop; case Icode_REG_IND_C2: indexReg = 2; continue Loop; case Icode_REG_IND_C3: indexReg = 3; continue Loop; case Icode_REG_IND_C4: indexReg = 4; continue Loop; case Icode_REG_IND_C5: indexReg = 5; continue Loop; case Icode_REG_IND1: indexReg = 0xFF & iCode[frame.pc]; ++frame.pc; continue Loop; case Icode_REG_IND2: indexReg = getIndex(iCode, frame.pc); frame.pc += 2; continue Loop; case Icode_REG_IND4: indexReg = getInt(iCode, frame.pc); frame.pc += 4; continue Loop; case Icode_REG_STR_C0: stringReg = strings[0]; continue Loop; case Icode_REG_STR_C1: stringReg = strings[1]; continue Loop; case Icode_REG_STR_C2: stringReg = strings[2]; continue Loop; case Icode_REG_STR_C3: stringReg = strings[3]; continue Loop; case Icode_REG_STR1: stringReg = strings[0xFF & iCode[frame.pc]]; ++frame.pc; continue Loop; case Icode_REG_STR2: stringReg = strings[getIndex(iCode, frame.pc)]; frame.pc += 2; continue Loop; case Icode_REG_STR4: stringReg = strings[getInt(iCode, frame.pc)]; frame.pc += 4; continue Loop; default : dumpICode(frame.idata); throw new RuntimeException("Unknown icode : " + op + " @ pc : " + (frame.pc-1)); } // end of interpreter switch } // end of jumplessRun label block // This should be reachable only for jump implementation // when pc points to encoded target offset if (instructionCounting) { addInstructionCount(cx, frame, 2); } int offset = getShort(iCode, frame.pc); if (offset != 0) { // -1 accounts for pc pointing to jump opcode + 1 frame.pc += offset - 1; } else { frame.pc = frame.idata.longJumps. getExistingInt(frame.pc); } if (instructionCounting) { frame.pcPrevBranch = frame.pc; } continue Loop; } // end of Loop: for exitFrame(cx, frame, null); interpreterResult = frame.result; interpreterResultDbl = frame.resultDbl; if (frame.parentFrame != null) { frame = frame.parentFrame; if (frame.frozen) { frame = frame.cloneFrozen(); } setCallResult( frame, interpreterResult, interpreterResultDbl); interpreterResult = null; // Help GC continue StateLoop; } break StateLoop; } // end of interpreter withoutExceptions: try catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; } // This should be reachable only after above catch or from // finally when it needs to propagate exception or from // explicit throw if (throwable == null) Kit.codeBug(); // Exception type final int EX_CATCH_STATE = 2; // Can execute JS catch final int EX_FINALLY_STATE = 1; // Can execute JS finally final int EX_NO_JS_STATE = 0; // Terminate JS execution int exState; ContinuationJump cjump = null; if (generatorState != null && generatorState.operation == NativeGenerator.GENERATOR_CLOSE && throwable == generatorState.value) { exState = EX_FINALLY_STATE; } else if (throwable instanceof JavaScriptException) { exState = EX_CATCH_STATE; } else if (throwable instanceof EcmaError) { // an offical ECMA error object, exState = EX_CATCH_STATE; } else if (throwable instanceof EvaluatorException) { exState = EX_CATCH_STATE; } else if (throwable instanceof RuntimeException) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } else if (throwable instanceof Error) { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_NO_JS_STATE; } else if (throwable instanceof ContinuationJump) { // It must be ContinuationJump exState = EX_FINALLY_STATE; cjump = (ContinuationJump)throwable; } else { exState = cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) ? EX_CATCH_STATE : EX_FINALLY_STATE; } if (instructionCounting) { try { addInstructionCount(cx, frame, EXCEPTION_COST); } catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; } catch (Error ex) { // Error from instruction counting // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } if (frame.debuggerFrame != null && throwable instanceof RuntimeException) { // Call debugger only for RuntimeException RuntimeException rex = (RuntimeException)throwable; try { frame.debuggerFrame.onExceptionThrown(cx, rex); } catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; } } for (;;) { if (exState != EX_NO_JS_STATE) { boolean onlyFinally = (exState != EX_CATCH_STATE); indexReg = getExceptionHandler(frame, onlyFinally); if (indexReg >= 0) { // We caught an exception, restart the loop // with exception pending the processing at the loop // start continue StateLoop; } } // No allowed exception handlers in this frame, unwind // to parent and try to look there exitFrame(cx, frame, throwable); frame = frame.parentFrame; if (frame == null) { break; } if (cjump != null && cjump.branchFrame == frame) { // Continuation branch point was hit, // restart the state loop to reenter continuation indexReg = -1; continue StateLoop; } } // No more frames, rethrow the exception or deal with continuation if (cjump != null) { if (cjump.branchFrame != null) { // The above loop should locate the top frame Kit.codeBug(); } if (cjump.capturedFrame != null) { // Restarting detached continuation indexReg = -1; continue StateLoop; } // Return continuation result to the caller interpreterResult = cjump.result; interpreterResultDbl = cjump.resultDbl; throwable = null; } break StateLoop; } // end of StateLoop: for(;;) // Do cleanups/restorations before the final return or throw if (cx.previousInterpreterInvocations != null && cx.previousInterpreterInvocations.size() != 0) { cx.lastInterpreterFrame = cx.previousInterpreterInvocations.pop(); } else { // It was the last interpreter frame on the stack cx.lastInterpreterFrame = null; // Force GC of the value cx.previousInterpreterInvocations cx.previousInterpreterInvocations = null; } if (throwable != null) { if (throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else { // Must be instance of Error or code bug throw (Error)throwable; } } return (interpreterResult != DBL_MRK) ? interpreterResult : ScriptRuntime.wrapNumber(interpreterResultDbl); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
public String getMessage(String messageId, Object[] arguments) { final String defaultResource = "org.mozilla.javascript.resources.Messages"; Context cx = Context.getCurrentContext(); Locale locale = cx != null ? cx.getLocale() : Locale.getDefault(); // ResourceBundle does caching. ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale); String formatString; try { formatString = rb.getString(messageId); } catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); } /* * It's OK to format the string, even if 'arguments' is null; * we need to format it anyway, to make double ''s collapse to * single 's. */ MessageFormat formatter = new MessageFormat(formatString); return formatter.format(arguments); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaMethod.java
Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { // Find a method that matches the types given. if (methods.length == 0) { throw new RuntimeException("No methods defined for call"); } int index = findCachedFunction(cx, args); if (index < 0) { Class<?> c = methods[0].method().getDeclaringClass(); String sig = c.getName() + '.' + getFunctionName() + '(' + scriptSignature(args) + ')'; throw Context.reportRuntimeError1("msg.java.no_such_method", sig); } MemberBox meth = methods[index]; Class<?>[] argTypes = meth.argTypes; if (meth.vararg) { // marshall the explicit parameters Object[] newArgs = new Object[argTypes.length]; for (int i = 0; i < argTypes.length-1; i++) { newArgs[i] = Context.jsToJava(args[i], argTypes[i]); } Object varArgs; // Handle special situation where a single variable parameter // is given and it is a Java or ECMA array or is null. if (args.length == argTypes.length && (args[args.length-1] == null || args[args.length-1] instanceof NativeArray || args[args.length-1] instanceof NativeJavaArray)) { // convert the ECMA array into a native array varArgs = Context.jsToJava(args[args.length-1], argTypes[argTypes.length - 1]); } else { // marshall the variable parameters Class<?> componentType = argTypes[argTypes.length - 1]. getComponentType(); varArgs = Array.newInstance(componentType, args.length - argTypes.length + 1); for (int i = 0; i < Array.getLength(varArgs); i++) { Object value = Context.jsToJava(args[argTypes.length-1 + i], componentType); Array.set(varArgs, i, value); } } // add varargs newArgs[argTypes.length-1] = varArgs; // replace the original args with the new one args = newArgs; } else { // First, we marshall the args. Object[] origArgs = args; for (int i = 0; i < args.length; i++) { Object arg = args[i]; Object coerced = Context.jsToJava(arg, argTypes[i]); if (coerced != arg) { if (origArgs == args) { args = args.clone(); } args[i] = coerced; } } } Object javaObject; if (meth.isStatic()) { javaObject = null; // don't need an object } else { Scriptable o = thisObj; Class<?> c = meth.getDeclaringClass(); for (;;) { if (o == null) { throw Context.reportRuntimeError3( "msg.nonjava.method", getFunctionName(), ScriptRuntime.toString(thisObj), c.getName()); } if (o instanceof Wrapper) { javaObject = ((Wrapper)o).unwrap(); if (c.isInstance(javaObject)) { break; } } o = o.getPrototype(); } } if (debug) { printDebug("Calling ", meth, args); } Object retval = meth.invoke(javaObject, args); Class<?> staticType = meth.method().getReturnType(); if (debug) { Class<?> actualType = (retval == null) ? null : retval.getClass(); System.err.println(" ----- Returned " + retval + " actual = " + actualType + " expect = " + staticType); } Object wrapped = cx.getWrapFactory().wrap(cx, scope, retval, staticType); if (debug) { Class<?> actualType = (wrapped == null) ? null : wrapped.getClass(); System.err.println(" ----- Wrapped as " + wrapped + " class = " + actualType); } if (wrapped == null && staticType == Void.TYPE) { wrapped = Undefined.instance; } return wrapped; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
final Script compileString(String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain) { try { return (Script) compileImpl(null, null, source, sourceName, lineno, securityDomain, false, compiler, compilationErrorReporter); } catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
final Function compileFunction(Scriptable scope, String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain) { try { return (Function) compileImpl(scope, null, source, sourceName, lineno, securityDomain, true, compiler, compilationErrorReporter); } catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
static Context getContext() { Context cx = getCurrentContext(); if (cx == null) { throw new RuntimeException( "No Context associated with current Thread"); } return cx; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
private Object compileImpl(Scriptable scope, Reader sourceReader, String sourceString, String sourceName, int lineno, Object securityDomain, boolean returnFunction, Evaluator compiler, ErrorReporter compilationErrorReporter) throws IOException { if(sourceName == null) { sourceName = "unnamed script"; } if (securityDomain != null && getSecurityController() == null) { throw new IllegalArgumentException( "securityDomain should be null if setSecurityController() was never called"); } // One of sourceReader or sourceString has to be null if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug(); // scope should be given if and only if compiling function if (!(scope == null ^ returnFunction)) Kit.codeBug(); CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.initFromContext(this); if (compilationErrorReporter == null) { compilationErrorReporter = compilerEnv.getErrorReporter(); } if (debugger != null) { if (sourceReader != null) { sourceString = Kit.readReader(sourceReader); sourceReader = null; } } Parser p = new Parser(compilerEnv, compilationErrorReporter); if (returnFunction) { p.calledByCompileFunction = true; } AstRoot ast; if (sourceString != null) { ast = p.parse(sourceString, sourceName, lineno); } else { ast = p.parse(sourceReader, sourceName, lineno); } if (returnFunction) { // parser no longer adds function to script node if (!(ast.getFirstChild() != null && ast.getFirstChild().getType() == Token.FUNCTION)) { // XXX: the check just looks for the first child // and allows for more nodes after it for compatibility // with sources like function() {};;; throw new IllegalArgumentException( "compileFunction only accepts source with single JS function: "+sourceString); } } IRFactory irf = new IRFactory(compilerEnv, compilationErrorReporter); ScriptNode tree = irf.transformTree(ast); // discard everything but the IR tree p = null; ast = null; irf = null; if (compiler == null) { compiler = createCompiler(); } Object bytecode = compiler.compile(compilerEnv, tree, tree.getEncodedSource(), returnFunction); if (debugger != null) { if (sourceString == null) Kit.codeBug(); if (bytecode instanceof DebuggableScript) { DebuggableScript dscript = (DebuggableScript)bytecode; notifyDebugger_r(this, dscript, sourceString); } else { throw new RuntimeException("NOT SUPPORTED"); } } Object result; if (returnFunction) { result = compiler.createFunctionObject(this, scope, bytecode, securityDomain); } else { result = compiler.createScriptObject(bytecode, securityDomain); } return result; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
private void fixLabelGotos() { byte[] codeBuffer = itsCodeBuffer; for (int i = 0; i < itsFixupTableTop; i++) { long fixup = itsFixupTable[i]; int label = (int)(fixup >> 32); int fixupSite = (int)fixup; int pc = itsLabelTable[label]; if (pc == -1) { // Unlocated label throw new RuntimeException(); } // -1 to get delta from instruction start addSuperBlockStart(pc); itsJumpFroms.put(pc, fixupSite - 1); int offset = pc - (fixupSite - 1); if ((short)offset != offset) { throw new ClassFileFormatException ("Program too complex: too big jump offset"); } codeBuffer[fixupSite] = (byte)(offset >> 8); codeBuffer[fixupSite + 1] = (byte)offset; } itsFixupTableTop = 0; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
public byte[] toByteArray() { int dataSize = getWriteSize(); byte[] data = new byte[dataSize]; int offset = 0; short sourceFileAttributeNameIndex = 0; if (itsSourceFileNameIndex != 0) { sourceFileAttributeNameIndex = itsConstantPool.addUtf8( "SourceFile"); } offset = putInt32(FileHeaderConstant, data, offset); offset = putInt16(MinorVersion, data, offset); offset = putInt16(MajorVersion, data, offset); offset = itsConstantPool.write(data, offset); offset = putInt16(itsFlags, data, offset); offset = putInt16(itsThisClassIndex, data, offset); offset = putInt16(itsSuperClassIndex, data, offset); offset = putInt16(itsInterfaces.size(), data, offset); for (int i = 0; i < itsInterfaces.size(); i++) { int interfaceIndex = ((Short)(itsInterfaces.get(i))).shortValue(); offset = putInt16(interfaceIndex, data, offset); } offset = putInt16(itsFields.size(), data, offset); for (int i = 0; i < itsFields.size(); i++) { ClassFileField field = (ClassFileField)itsFields.get(i); offset = field.write(data, offset); } offset = putInt16(itsMethods.size(), data, offset); for (int i = 0; i < itsMethods.size(); i++) { ClassFileMethod method = (ClassFileMethod)itsMethods.get(i); offset = method.write(data, offset); } if (itsSourceFileNameIndex != 0) { offset = putInt16(1, data, offset); // attributes count offset = putInt16(sourceFileAttributeNameIndex, data, offset); offset = putInt32(2, data, offset); offset = putInt16(itsSourceFileNameIndex, data, offset); } else { offset = putInt16(0, data, offset); // no attributes } if (offset != dataSize) { // Check getWriteSize is consistent with write! throw new RuntimeException(); } return data; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
static Class getClassFromInternalName(String internalName) { try { return Class.forName(internalName.replace('/', '.')); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
9
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:" + ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (Exception ex) { throw new RuntimeException ("Unable to instantiate compiled class:"+ex.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (Exception x) { throw new RuntimeException(x); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeError.java
catch (NoSuchMethodException nsm) { // should not happen throw new RuntimeException(nsm); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/v8dtoa/DiyFp.java
catch (CloneNotSupportedException e) { throw new RuntimeException(); // won't happen }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ex) { // Should not happen when dealing with source as string throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
catch (IOException ioe) { // Should never happen because we just made the reader // from a String throw new RuntimeException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/classfile/ClassFileWriter.java
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
private RuntimeException codeBug() throws RuntimeException { throw Kit.codeBug("ts.cursor=" + ts.cursor + ", ts.tokenBeg=" + ts.tokenBeg + ", currentToken=" + currentToken); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static RuntimeException codeBug() throws RuntimeException { RuntimeException ex = new IllegalStateException("FAILED ASSERTION"); // Print stack trace ASAP ex.printStackTrace(System.err); throw ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
public static RuntimeException codeBug(String msg) throws RuntimeException { msg = "FAILED ASSERTION: " + msg; RuntimeException ex = new IllegalStateException(msg); // Print stack trace ASAP ex.printStackTrace(System.err); throw ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/AstNode.java
public static RuntimeException codeBug() throws RuntimeException { throw Kit.codeBug(); }
8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (RuntimeException x) { throw x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaScriptException.java
catch (RuntimeException rte) { // ScriptRuntime.toString may throw a RuntimeException if (value instanceof Scriptable) { return ScriptRuntime.defaultObjectToString((Scriptable)value); } else { return value.toString(); } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException e) { // Only propagate exceptions other than closingException if (e != value) throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException ex) { throwable = ex; exState = EX_FINALLY_STATE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (RuntimeException e) { throw e; }
6
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
catch(RuntimeException e) { close(urlConnection); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (RuntimeException x) { throw x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { // Throw loaded module away if there was an exception threadLoadingModules.remove(id); throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch(RuntimeException e) { throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (RuntimeException e) { // Only propagate exceptions other than closingException if (e != value) throw e; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ScriptRuntime.java
catch (RuntimeException e) { throw e; }
0
unknown (Lib) SecurityException 4
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecurityController.java
public static void initGlobal(SecurityController controller) { if (controller == null) throw new IllegalArgumentException(); if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public final void setSecurityController(SecurityController controller) { if (sealed) onSealedMutation(); if (controller == null) throw new IllegalArgumentException(); if (securityController != null) { throw new SecurityException("Can not overwrite existing SecurityController object"); } if (SecurityController.hasGlobal()) { throw new SecurityException("Can not overwrite existing global SecurityController object"); } securityController = controller; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public synchronized final void setClassShutter(ClassShutter shutter) { if (sealed) onSealedMutation(); if (shutter == null) throw new IllegalArgumentException(); if (hasClassShutter) { throw new SecurityException("Cannot overwrite existing " + "ClassShutter object"); } classShutter = shutter; hasClassShutter = true; }
0 1 15
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeJavaObject.java
catch (SecurityException e) { meth = null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
catch (SecurityException x) { e = x; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Some security settings (i.e., applets) disallow // access to Class.getDeclaredMethods. Fall back to // Class.getMethods. Method[] methods = clazz.getMethods(); for (Method method : methods) { MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); } break; // getMethods gets superclass methods, no // need to loop any more }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { Context.reportWarning( "Could not discover accessible methods of class " + clazz.getName() + " due to lack of privileges, " + "attemping superclasses/interfaces."); // Fall through and attempt to discover superclass/interface // methods }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // skip this field Context.reportWarning("Could not access field " + name + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Fall through to !includePrivate case Context.reportWarning("Could not access constructor " + " of class " + cl.getName() + " due to lack of privileges."); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // fall through to !includePrivate case }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/MemberBox.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException ex) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Kit.java
catch (SecurityException x) { }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/FunctionObject.java
catch (SecurityException e) { // If we get an exception once, give up on getDeclaredMethods sawSecurityException = true; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/LazilyLoadedCtor.java
catch (SecurityException ex) { }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/JavaMembers.java
catch (SecurityException e) { // Reflection may fail for objects that are in a restricted // access package (e.g. sun.*). If we get a security // exception, try again with the static type if it is interface. // Otherwise, try superclass if (staticType != null && staticType.isInterface()) { cl = staticType; staticType = null; // try staticType only once } else { Class<?> parent = cl.getSuperclass(); if (parent == null) { if (cl.isInterface()) { // last resort after failed staticType interface parent = ScriptRuntime.ObjectClass; } else { throw e; } } cl = parent; } }
0
unknown (Lib) StackOverflowError 0 0 0 1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Parser.java
catch (StackOverflowError ex) { String msg = lookupMessage("msg.too.deep.parser.recursion"); if (!compilerEnv.isIdeMode()) throw Context.reportRuntimeError(msg, sourceURI, ts.lineno, null, 0); }
0
checked (Lib) Throwable 0 0 0 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { // Any exception from debugger // => unconditionally terminate JS throwable = ex; cjump = null; exState = EX_NO_JS_STATE; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { System.err.println( "RHINO USAGE WARNING: onExit terminated with exception"); ex.printStackTrace(System.err); }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Interpreter.java
catch (Throwable ex) { if (throwable != null) { // This is serious bug and it is better to track it ASAP ex.printStackTrace(System.err); throw new IllegalStateException(); } throwable = ex; }
1
unknown (Lib) URISyntaxException 0 0 8
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, privilegedUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return loadFromPathList(moduleId, validator, fallbackUris); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
private ModuleSource loadFromPathList(String moduleId, Object validator, Iterable<URI> paths) throws IOException, URISyntaxException { if(paths == null) { return null; } for (URI path : paths) { final ModuleSource moduleSource = loadFromUri( path.resolve(moduleId), path, validator); if (moduleSource != null) { return moduleSource; } } return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/UrlModuleSourceProvider.java
Override protected ModuleSource loadFromUri(URI uri, URI base, Object validator) throws IOException, URISyntaxException { // We expect modules to have a ".js" file name extension ... URI fullUri = new URI(uri + ".js"); ModuleSource source = loadFromActualUri(fullUri, base, validator); // ... but for compatibility we support modules without extension, // or ids with explicit extension. return source != null ? source : loadFromActualUri(uri, base, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws IOException, URISyntaxException { if(!entityNeedsRevalidation(validator)) { return NOT_MODIFIED; } ModuleSource moduleSource = loadFromPrivilegedLocations( moduleId, validator); if(moduleSource != null) { return moduleSource; } if(paths != null) { moduleSource = loadFromPathArray(moduleId, paths, validator); if(moduleSource != null) { return moduleSource; } } return loadFromFallbackLocations(moduleId, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
public ModuleSource loadSource(URI uri, Object validator) throws IOException, URISyntaxException { return loadFromUri(uri, null, validator); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromPrivilegedLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
protected ModuleSource loadFromFallbackLocations( String moduleId, Object validator) throws IOException, URISyntaxException { return null; }
2
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/Require.java
catch (URISyntaxException usx) { // fall through }
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java
catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); }
0
unknown (Lib) UndeclaredThrowableException 3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
Override public Object callWithDomain(final Object securityDomain, final Context cx, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args) { // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return cx.getApplicationClassLoader(); } }); final CodeSource codeSource = (CodeSource)securityDomain; Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized (callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized (classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { Loader loader = new Loader(classLoader, codeSource); Class<?> c = loader.defineClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { public Object run() { return thread.getContextClassLoader(); } }); Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized(callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized(classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
private static byte[] loadBytecodePrivileged() { URL url = SecureCaller.class.getResource("SecureCallerImpl.clazz"); try { InputStream in = url.openStream(); try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); for(;;) { int r = in.read(); if(r == -1) { return bout.toByteArray(); } bout.write(r); } } finally { in.close(); } } catch(IOException e) { throw new UndeclaredThrowableException(e); } }
3
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/PolicySecurityController.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/SecureCaller.java
catch(IOException e) { throw new UndeclaredThrowableException(e); }
0 0 0 0
runtime (Lib) UnsupportedOperationException 40
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreComments(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreWhitespace(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setIgnoreProcessingInstructions(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setPrettyPrinting(boolean b) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public void setPrettyIndent(int i) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreComments() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreProcessingInstructions() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isIgnoreWhitespace() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public boolean isPrettyPrinting() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/xml/XMLLib.java
public int getPrettyIndent() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object put(Object key, Object value) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void putAll(Map m) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public void clear() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeObject.java
public Object setValue(Object value) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public void captureStackInfo(RhinoException ex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public String getSourcePositionFromStack(Context cx, int[] linep) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public String getPatchedStack(RhinoException ex, String nativeStackTrace) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public List<String> getScriptStack(RhinoException ex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/optimizer/Codegen.java
public void setEvalScriptFlag(Script script) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void remove() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void add(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void set(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean add(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean addAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean removeAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean retainAll(Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void clear() { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public void add(int index, Object element) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public boolean addAll(int index, Collection c) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object set(int index, Object element) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public Object remove(int index) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/NativeArray.java
public List subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public void error(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ErrorCollector.java
public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) { throw new UnsupportedOperationException(); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Jump.java
Override public void visit(NodeVisitor visitor) { throw new UnsupportedOperationException(this.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/Jump.java
Override public String toSource(int depth) { throw new UnsupportedOperationException(this.toString()); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/ArrayComprehensionLoop.java
public void setBody(AstNode body) { throw new UnsupportedOperationException("this node type has no body"); }
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/ast/GeneratorExpressionLoop.java
Override public void setIsForEach(boolean isForEach) { throw new UnsupportedOperationException("this node type does not support for each"); }
0 0 0 0 0
runtime (Domain) WrappedException
public class WrappedException extends EvaluatorException
{
    static final long serialVersionUID = -1551979216966520648L;

    /**
     * @see Context#throwAsScriptRuntimeEx(Throwable e)
     */
    public WrappedException(Throwable exception)
    {
        super("Wrapped "+exception.toString());
        this.exception = exception;
        Kit.initCause(this, exception);

        int[] linep = { 0 };
        String sourceName = Context.getSourcePositionFromStack(linep);
        int lineNumber = linep[0];
        if (sourceName != null) {
            initSourceName(sourceName);
        }
        if (lineNumber != 0) {
            initLineNumber(lineNumber);
        }
    }

    /**
     * Get the wrapped exception.
     *
     * @return the exception that was presented as a argument to the
     *         constructor when this object was created
     */
    public Throwable getWrappedException()
    {
        return exception;
    }

    /**
     * @deprecated Use {@link #getWrappedException()} instead.
     */
    public Object unwrap()
    {
        return getWrappedException();
    }

    private Throwable exception;
}
1
            
// in /home/martin-no-backup/testoss/rhino/src/org/mozilla/javascript/Context.java
public static RuntimeException throwAsScriptRuntimeEx(Throwable e) { while ((e instanceof InvocationTargetException)) { e = ((InvocationTargetException) e).getTargetException(); } // special handling of Error so scripts would not catch them if (e instanceof Error) { Context cx = getContext(); if (cx == null || !cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS)) { throw (Error)e; } } if (e instanceof RhinoException) { throw (RhinoException)e; } throw new WrappedException(e); }
0 0 0 0 0

Miscellanous Metrics

nF = Number of Finally 47
nF = Number of Try-Finally (without catch) 40
Number of Methods with Finally (nMF) 47 / 3613 (1.3%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 1
Number of Finally with a Break 0
Number of different exception types thrown 19
Number of Domain exception types thrown 6
Number of different exception types caught 29
Number of Domain exception types caught 7
Number of exception declarations in signatures 215
Number of different exceptions types declared in method signatures 15
Number of library exceptions types declared in method signatures 11
Number of Domain exceptions types declared in method signatures 4
Number of Catch with a continue 0
Number of Catch with a return 12
Number of Catch with a Break 3
nbIf = Number of If 5476
nbFor = Number of For 591
Number of Method with an if 1550 / 3613
Number of Methods with a for 396 / 3613
Number of Method starting with a try 14 / 3613 (0.4%)
Number of Expressions 57558
Number of Expressions in try 3047 (5.3%)