| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript; |
| 8 |
|
| 9 |
import java.io.Serializable; |
| 10 |
|
| 11 |
import org.mozilla.javascript.debug.DebuggableScript; |
| 12 |
|
| 13 |
final class InterpreterData implements Serializable, DebuggableScript |
| 14 |
{ |
| 15 |
static final long serialVersionUID = 5067677351589230234L; |
| 16 |
|
| 17 |
static final int INITIAL_MAX_ICODE_LENGTH = 1024; |
| 18 |
static final int INITIAL_STRINGTABLE_SIZE = 64; |
| 19 |
static final int INITIAL_NUMBERTABLE_SIZE = 64; |
| 20 |
|
| 21 |
InterpreterData(int languageVersion, String sourceFile, |
| 22 |
String encodedSource, boolean isStrict) |
| 23 |
{ |
| 24 |
this.languageVersion = languageVersion; |
| 25 |
this.itsSourceFile = sourceFile; |
| 26 |
this.encodedSource = encodedSource; |
| 27 |
this.isStrict = isStrict; |
| 28 |
init(); |
| 29 |
} |
| 30 |
|
| 31 |
InterpreterData(InterpreterData parent) |
| 32 |
{ |
| 33 |
this.parentData = parent; |
| 34 |
this.languageVersion = parent.languageVersion; |
| 35 |
this.itsSourceFile = parent.itsSourceFile; |
| 36 |
this.encodedSource = parent.encodedSource; |
| 37 |
this.isStrict = parent.isStrict; |
| 38 |
init(); |
| 39 |
} |
| 40 |
|
| 41 |
private void init() |
| 42 |
{ |
| 43 |
itsICode = new byte[INITIAL_MAX_ICODE_LENGTH]; |
| 44 |
itsStringTable = new String[INITIAL_STRINGTABLE_SIZE]; |
| 45 |
} |
| 46 |
|
| 47 |
String itsName; |
| 48 |
String itsSourceFile; |
| 49 |
boolean itsNeedsActivation; |
| 50 |
int itsFunctionType; |
| 51 |
|
| 52 |
String[] itsStringTable; |
| 53 |
double[] itsDoubleTable; |
| 54 |
InterpreterData[] itsNestedFunctions; |
| 55 |
Object[] itsRegExpLiterals; |
| 56 |
|
| 57 |
byte[] itsICode; |
| 58 |
|
| 59 |
int[] itsExceptionTable; |
| 60 |
|
| 61 |
int itsMaxVars; |
| 62 |
int itsMaxLocals; |
| 63 |
int itsMaxStack; |
| 64 |
int itsMaxFrameArray; |
| 65 |
|
| 66 |
|
| 67 |
String[] argNames; |
| 68 |
boolean[] argIsConst; |
| 69 |
int argCount; |
| 70 |
|
| 71 |
int itsMaxCalleeArgs; |
| 72 |
|
| 73 |
String encodedSource; |
| 74 |
int encodedSourceStart; |
| 75 |
int encodedSourceEnd; |
| 76 |
|
| 77 |
int languageVersion; |
| 78 |
|
| 79 |
boolean isStrict; |
| 80 |
boolean topLevel; |
| 81 |
|
| 82 |
Object[] literalIds; |
| 83 |
|
| 84 |
UintMap longJumps; |
| 85 |
|
| 86 |
int firstLinePC = -1; |
| 87 |
|
| 88 |
InterpreterData parentData; |
| 89 |
|
| 90 |
boolean evalScriptFlag; |
| 91 |
|
| 92 |
public boolean isTopLevel() |
| 93 |
{ |
| 94 |
return topLevel; |
| 95 |
} |
| 96 |
|
| 97 |
public boolean isFunction() |
| 98 |
{ |
| 99 |
return itsFunctionType != 0; |
| 100 |
} |
| 101 |
|
| 102 |
public String getFunctionName() |
| 103 |
{ |
| 104 |
return itsName; |
| 105 |
} |
| 106 |
|
| 107 |
public int getParamCount() |
| 108 |
{ |
| 109 |
return argCount; |
| 110 |
} |
| 111 |
|
| 112 |
public int getParamAndVarCount() |
| 113 |
{ |
| 114 |
return argNames.length; |
| 115 |
} |
| 116 |
|
| 117 |
public String getParamOrVarName(int index) |
| 118 |
{ |
| 119 |
return argNames[index]; |
| 120 |
} |
| 121 |
|
| 122 |
public boolean getParamOrVarConst(int index) |
| 123 |
{ |
| 124 |
return argIsConst[index]; |
| 125 |
} |
| 126 |
|
| 127 |
public String getSourceName() |
| 128 |
{ |
| 129 |
return itsSourceFile; |
| 130 |
} |
| 131 |
|
| 132 |
public boolean isGeneratedScript() |
| 133 |
{ |
| 134 |
return ScriptRuntime.isGeneratedScript(itsSourceFile); |
| 135 |
} |
| 136 |
|
| 137 |
public int[] getLineNumbers() |
| 138 |
{ |
| 139 |
return Interpreter.getLineNumbers(this); |
| 140 |
} |
| 141 |
|
| 142 |
public int getFunctionCount() |
| 143 |
{ |
| 144 |
return (itsNestedFunctions == null) ? 0 : itsNestedFunctions.length; |
| 145 |
} |
| 146 |
|
| 147 |
public DebuggableScript getFunction(int index) |
| 148 |
{ |
| 149 |
return itsNestedFunctions[index]; |
| 150 |
} |
| 151 |
|
| 152 |
public DebuggableScript getParent() |
| 153 |
{ |
| 154 |
return parentData; |
| 155 |
} |
| 156 |
} |