// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Interpreter.java
package org.mozilla.javascript;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.mozilla.javascript.continuations.Continuation;
import org.mozilla.javascript.debug.DebugFrame;
import org.mozilla.javascript.debug.Debugger;
// Referenced classes of package org.mozilla.javascript:
// ObjToIntMap, ObjArray, NodeTransformer, InterpreterData,
// InterpretedFunction, FunctionNode, Node, UintMap,
// NativeGenerator, JavaScriptException, Scriptable, Ref,
// Callable, IdFunctionObject, Function, ConstProperties,
// EcmaError, EvaluatorException, NativeWith, Evaluator,
// ScriptOrFnNode, CompilerEnvirons, Kit, Context,
// ScriptRuntime, RegExpProxy, RhinoException, SecurityUtilities,
// SecurityController, Undefined, UniqueTag, NativeIterator,
// ScriptableObject, BaseFunction, Script
public class Interpreter
implements Evaluator
{
static class GeneratorState
{
int operation;
Object value;
RuntimeException returnedException;
GeneratorState(int operation, Object value)
{
this.operation = operation;
this.value = value;
}
}
private static final class ContinuationJump
implements Serializable
{
static final long serialVersionUID = 0x6ab05607ef7f8517L;
CallFrame capturedFrame;
CallFrame branchFrame;
Object result;
double resultDbl;
ContinuationJump(Continuation c, CallFrame current)
{
capturedFrame = (CallFrame)c.getImplementation();
if (capturedFrame == null || current == null)
{
branchFrame = null;
} else
{
CallFrame chain1 = capturedFrame;
CallFrame chain2 = current;
int diff = chain1.frameIndex - chain2.frameIndex;
if (diff != 0)
{
if (diff < 0)
{
chain1 = current;
chain2 = capturedFrame;
diff = -diff;
}
do
chain1 = chain1.parentFrame;
while (--diff != 0);
if (chain1.frameIndex != chain2.frameIndex)
Kit.codeBug();
}
for (; chain1 != chain2 && chain1 != null; chain2 = chain2.parentFrame)
chain1 = chain1.parentFrame;
branchFrame = chain1;
if (branchFrame != null && !branchFrame.frozen)
Kit.codeBug();
}
}
}
private static class CallFrame
implements Cloneable, Serializable
{
static final long serialVersionUID = 0xd888d1c7b670497eL;
CallFrame parentFrame;
int frameIndex;
boolean frozen;
InterpretedFunction fnOrScript;
InterpreterData idata;
Object stack[];
int stackAttributes[];
double sDbl[];
CallFrame varSource;
int localShift;
int emptyStackTop;
DebugFrame debuggerFrame;
boolean useActivation;
Scriptable thisObj;
Scriptable scriptRegExps[];
Object result;
double resultDbl;
int pc;
int pcPrevBranch;
int pcSourceLineStart;
Scriptable scope;
int savedStackTop;
int savedCallOp;
Object throwable;
CallFrame cloneFrozen()
{
if (!frozen)
Kit.codeBug();
CallFrame copy;
try
{
copy = (CallFrame)clone();
}
catch (CloneNotSupportedException ex)
{
throw new IllegalStateException();
}
copy.stack = (Object[])((Object []) (stack)).clone();
copy.stackAttributes = (int[])stackAttributes.clone();
copy.sDbl = (double[])sDbl.clone();
copy.frozen = false;
return copy;
}
private CallFrame()
{
}
}
private static final int Icode_DUP = -1;
private static final int Icode_DUP2 = -2;
private static final int Icode_SWAP = -3;
private static final int Icode_POP = -4;
private static final int Icode_POP_RESULT = -5;
private static final int Icode_IFEQ_POP = -6;
private static final int Icode_VAR_INC_DEC = -7;
private static final int Icode_NAME_INC_DEC = -8;
private static final int Icode_PROP_INC_DEC = -9;
private static final int Icode_ELEM_INC_DEC = -10;
private static final int Icode_REF_INC_DEC = -11;
private static final int Icode_SCOPE_LOAD = -12;
private static final int Icode_SCOPE_SAVE = -13;
private static final int Icode_TYPEOFNAME = -14;
private static final int Icode_NAME_AND_THIS = -15;
private static final int Icode_PROP_AND_THIS = -16;
private static final int Icode_ELEM_AND_THIS = -17;
private static final int Icode_VALUE_AND_THIS = -18;
private static final int Icode_CLOSURE_EXPR = -19;
private static final int Icode_CLOSURE_STMT = -20;
private static final int Icode_CALLSPECIAL = -21;
private static final int Icode_RETUNDEF = -22;
private static final int Icode_GOSUB = -23;
private static final int Icode_STARTSUB = -24;
private static final int Icode_RETSUB = -25;
private static final int Icode_LINE = -26;
private static final int Icode_SHORTNUMBER = -27;
private static final int Icode_INTNUMBER = -28;
private static final int Icode_LITERAL_NEW = -29;
private static final int Icode_LITERAL_SET = -30;
private static final int Icode_SPARE_ARRAYLIT = -31;
private static final int Icode_REG_IND_C0 = -32;
private static final int Icode_REG_IND_C1 = -33;
private static final int Icode_REG_IND_C2 = -34;
private static final int Icode_REG_IND_C3 = -35;
private static final int Icode_REG_IND_C4 = -36;
private static final int Icode_REG_IND_C5 = -37;
private static final int Icode_REG_IND1 = -38;
private static final int Icode_REG_IND2 = -39;
private static final int Icode_REG_IND4 = -40;
private static final int Icode_REG_STR_C0 = -41;
private static final int Icode_REG_STR_C1 = -42;
private static final int Icode_REG_STR_C2 = -43;
private static final int Icode_REG_STR_C3 = -44;
private static final int Icode_REG_STR1 = -45;
private static final int Icode_REG_STR2 = -46;
private static final int Icode_REG_STR4 = -47;
private static final int Icode_GETVAR1 = -48;
private static final int Icode_SETVAR1 = -49;
private static final int Icode_UNDEF = -50;
private static final int Icode_ZERO = -51;
private static final int Icode_ONE = -52;
private static final int Icode_ENTERDQ = -53;
private static final int Icode_LEAVEDQ = -54;
private static final int Icode_TAIL_CALL = -55;
private static final int Icode_LOCAL_CLEAR = -56;
private static final int Icode_LITERAL_GETTER = -57;
private static final int Icode_LITERAL_SETTER = -58;
private static final int Icode_SETCONST = -59;
private static final int Icode_SETCONSTVAR = -60;
private static final int Icode_SETCONSTVAR1 = -61;
private static final int Icode_GENERATOR = -62;
private static final int Icode_GENERATOR_END = -63;
private static final int Icode_DEBUGGER = -64;
private static final int MIN_ICODE = -64;
private CompilerEnvirons compilerEnv;
private boolean itsInFunctionFlag;
private boolean itsInTryFlag;
private InterpreterData itsData;
private ScriptOrFnNode scriptOrFn;
private int itsICodeTop;
private int itsStackDepth;
private int itsLineNumber;
private int itsDoubleTableTop;
private ObjToIntMap itsStrings;
private int itsLocalTop;
private static final int MIN_LABEL_TABLE_SIZE = 32;
private static final int MIN_FIXUP_TABLE_SIZE = 40;
private int itsLabelTable[];
private int itsLabelTableTop;
private long itsFixupTable[];
private int itsFixupTableTop;
private ObjArray itsLiteralIds;
private int itsExceptionTableTop;
private static final int EXCEPTION_TRY_START_SLOT = 0;
private static final int EXCEPTION_TRY_END_SLOT = 1;
private static final int EXCEPTION_HANDLER_SLOT = 2;
private static final int EXCEPTION_TYPE_SLOT = 3;
private static final int EXCEPTION_LOCAL_SLOT = 4;
private static final int EXCEPTION_SCOPE_SLOT = 5;
private static final int EXCEPTION_SLOT_SIZE = 6;
private static final int ECF_TAI
评论17
最新资源