зеркало из https://github.com/mozilla/gecko-dev.git
Add args and argCount to InterpreterData to emphasize that InterpretedScript/InterpretedFunction are just runtime wrappers around InterpreterData
This commit is contained in:
Родитель
1e02010066
Коммит
3626a138ec
|
@ -45,26 +45,19 @@ final class InterpretedFunction extends NativeFunction
|
|||
|
||||
InterpretedFunction(Context cx, InterpreterData theData) {
|
||||
itsData = theData;
|
||||
init(cx);
|
||||
}
|
||||
|
||||
void init(Context cx)
|
||||
{
|
||||
functionName = itsData.itsName;
|
||||
source = itsData.itsSource;
|
||||
nestedFunctions = itsData.itsNestedFunctions;
|
||||
if (cx != null)
|
||||
version = (short)cx.getLanguageVersion();
|
||||
version = (short)cx.getLanguageVersion();
|
||||
argNames = itsData.argNames;
|
||||
argCount = (short)itsData.argCount;
|
||||
}
|
||||
|
||||
InterpretedFunction(InterpretedFunction theOther,
|
||||
Scriptable theScope, Context cx)
|
||||
{
|
||||
itsData = theOther.itsData;
|
||||
this.argNames = theOther.argNames;
|
||||
this.argCount = theOther.argCount;
|
||||
this(cx, theOther.itsData);
|
||||
itsClosure = theScope;
|
||||
init(cx);
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
|
@ -77,5 +70,6 @@ final class InterpretedFunction extends NativeFunction
|
|||
}
|
||||
|
||||
InterpreterData itsData;
|
||||
Scriptable itsClosure;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ final class InterpretedScript extends NativeScript
|
|||
functionName = "";
|
||||
nestedFunctions = itsData.itsNestedFunctions;
|
||||
version = (short)cx.getLanguageVersion();
|
||||
argNames = itsData.argNames;
|
||||
argCount = (short)itsData.argCount;
|
||||
}
|
||||
|
||||
public Object exec(Context cx, Scriptable scope)
|
||||
|
|
|
@ -103,12 +103,11 @@ public class Interpreter {
|
|||
generateICodeFromTree(tree);
|
||||
if (Context.printICode) dumpICode(itsData);
|
||||
|
||||
InterpretedScript result = new InterpretedScript(cx, itsData);
|
||||
setArgNames(result);
|
||||
if (cx.debugger != null) {
|
||||
cx.debugger.handleCompilationDone(cx, itsData, debugSource);
|
||||
}
|
||||
return result;
|
||||
|
||||
return new InterpretedScript(cx, itsData);
|
||||
}
|
||||
|
||||
private InterpretedFunction generateFunctionICode(Context cx,
|
||||
|
@ -137,20 +136,12 @@ public class Interpreter {
|
|||
itsData.itsSource = (String)theFunction.getProp(Node.SOURCE_PROP);
|
||||
if (Context.printICode) dumpICode(itsData);
|
||||
|
||||
InterpretedFunction result = new InterpretedFunction(cx, itsData);
|
||||
setArgNames(result);
|
||||
if (cx.debugger != null) {
|
||||
cx.debugger.handleCompilationDone(cx, itsData, debugSource);
|
||||
}
|
||||
debugSource = savedSource;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void setArgNames(NativeFunction f) {
|
||||
String[] argNames = new String[itsVariableTable.size()];
|
||||
itsVariableTable.getAllVariables(argNames);
|
||||
f.argNames = argNames;
|
||||
f.argCount = (short)itsVariableTable.getParameterCount();
|
||||
return new InterpretedFunction(cx, itsData);
|
||||
}
|
||||
|
||||
private void generateNestedFunctions(Context cx, Scriptable scope,
|
||||
|
@ -246,6 +237,10 @@ public class Interpreter {
|
|||
+ itsData.itsMaxLocals
|
||||
+ itsData.itsMaxTryDepth
|
||||
+ itsData.itsMaxStack;
|
||||
|
||||
itsData.argNames = new String[itsVariableTable.size()];
|
||||
itsVariableTable.getAllVariables(itsData.argNames);
|
||||
itsData.argCount = itsVariableTable.getParameterCount();
|
||||
}
|
||||
|
||||
private int updateLineNumber(Node node, int iCodeTop) {
|
||||
|
@ -1601,8 +1596,9 @@ public class Interpreter {
|
|||
}
|
||||
|
||||
if (idata.itsFunctionType != 0) {
|
||||
if (fnOrScript.itsClosure != null) {
|
||||
scope = fnOrScript.itsClosure;
|
||||
InterpretedFunction f = (InterpretedFunction)fnOrScript;
|
||||
if (f.itsClosure != null) {
|
||||
scope = f.itsClosure;
|
||||
} else if (!idata.itsUseDynamicScope) {
|
||||
scope = fnOrScript.getParentScope();
|
||||
}
|
||||
|
|
|
@ -81,6 +81,10 @@ final class InterpreterData implements Serializable, DebuggableScript {
|
|||
int itsMaxStack;
|
||||
int itsMaxFrameArray;
|
||||
|
||||
// see comments in NativeFuncion for definition of argNames and argCount
|
||||
String[] argNames;
|
||||
int argCount;
|
||||
|
||||
int itsMaxCalleeArgs;
|
||||
|
||||
Object securityDomain;
|
||||
|
|
|
@ -743,8 +743,6 @@ public class NativeFunction extends BaseFunction {
|
|||
*/
|
||||
protected String source;
|
||||
|
||||
Scriptable itsClosure;
|
||||
|
||||
/**
|
||||
* An array of NativeFunction values for each nested function.
|
||||
* Used internally, and also for decompiling nested functions.
|
||||
|
|
Загрузка…
Ссылка в новой задаче