mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 01:08:21 +00:00
Call createFunctionObject on closure created InterpretedFunction objects
so they can be real JS objects like they're supposed to be -with prototypes and everything.
This commit is contained in:
parent
74d1e39672
commit
acd3c7ef86
@ -40,7 +40,11 @@ class InterpretedFunction extends NativeFunction {
|
||||
InterpretedFunction(InterpreterData theData, Context cx)
|
||||
{
|
||||
itsData = theData;
|
||||
|
||||
init(cx);
|
||||
}
|
||||
|
||||
void init(Context cx)
|
||||
{
|
||||
// probably too much copying going on from theData to the InterpretedFunction object
|
||||
// should pass them as parameters - unless we need them in the data block anyway?
|
||||
|
||||
@ -51,13 +55,16 @@ class InterpretedFunction extends NativeFunction {
|
||||
argCount = (short)itsData.itsVariableTable.getParameterCount();
|
||||
source = itsData.itsSource;
|
||||
nestedFunctions = itsData.itsNestedFunctions;
|
||||
version = (short)cx.getLanguageVersion();
|
||||
if (cx != null)
|
||||
version = (short)cx.getLanguageVersion();
|
||||
}
|
||||
|
||||
InterpretedFunction(InterpretedFunction theOther, Scriptable theScope)
|
||||
InterpretedFunction(InterpretedFunction theOther,
|
||||
Scriptable theScope, Context cx)
|
||||
{
|
||||
itsData = theOther.itsData;
|
||||
itsClosure = theScope;
|
||||
init(cx);
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
@ -78,5 +85,6 @@ class InterpretedFunction extends NativeFunction {
|
||||
|
||||
InterpreterData itsData;
|
||||
Scriptable itsClosure;
|
||||
InterpretedFunction itsOtherSelf;
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ public class Interpreter extends LabelTable {
|
||||
{
|
||||
fn.setPrototype(ScriptableObject.getClassPrototype(scope, "Function"));
|
||||
fn.setParentScope(scope);
|
||||
if (fn.itsData.itsName.length() > 0)
|
||||
if ((fn.itsData.itsName.length() > 0) && (fn.itsClosure == null))
|
||||
ScriptRuntime.setName(scope, fn, scope, fn.itsData.itsName);
|
||||
}
|
||||
|
||||
@ -1808,14 +1808,19 @@ public class Interpreter extends LabelTable {
|
||||
case TokenStream.CLOSURE :
|
||||
i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF);
|
||||
if (theData.itsNestedFunctions[i]
|
||||
instanceof InterpretedFunction)
|
||||
instanceof InterpretedFunction) {
|
||||
stack[++stackTop]
|
||||
= new InterpretedFunction(
|
||||
(InterpretedFunction)
|
||||
(theData.itsNestedFunctions[i]),
|
||||
scope);
|
||||
scope, cx);
|
||||
createFunctionObject(
|
||||
(InterpretedFunction)stack[stackTop], scope);
|
||||
}
|
||||
else
|
||||
stack[++stackTop] = ScriptRuntime.createFunctionObject(scope, theData.itsNestedFunctions[i].getClass(), cx);
|
||||
stack[++stackTop]
|
||||
= ScriptRuntime.createFunctionObject(scope,
|
||||
theData.itsNestedFunctions[i].getClass(), cx);
|
||||
pc += 2;
|
||||
break;
|
||||
case TokenStream.OBJECT :
|
||||
|
@ -40,7 +40,11 @@ class InterpretedFunction extends NativeFunction {
|
||||
InterpretedFunction(InterpreterData theData, Context cx)
|
||||
{
|
||||
itsData = theData;
|
||||
|
||||
init(cx);
|
||||
}
|
||||
|
||||
void init(Context cx)
|
||||
{
|
||||
// probably too much copying going on from theData to the InterpretedFunction object
|
||||
// should pass them as parameters - unless we need them in the data block anyway?
|
||||
|
||||
@ -51,13 +55,16 @@ class InterpretedFunction extends NativeFunction {
|
||||
argCount = (short)itsData.itsVariableTable.getParameterCount();
|
||||
source = itsData.itsSource;
|
||||
nestedFunctions = itsData.itsNestedFunctions;
|
||||
version = (short)cx.getLanguageVersion();
|
||||
if (cx != null)
|
||||
version = (short)cx.getLanguageVersion();
|
||||
}
|
||||
|
||||
InterpretedFunction(InterpretedFunction theOther, Scriptable theScope)
|
||||
InterpretedFunction(InterpretedFunction theOther,
|
||||
Scriptable theScope, Context cx)
|
||||
{
|
||||
itsData = theOther.itsData;
|
||||
itsClosure = theScope;
|
||||
init(cx);
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
@ -78,5 +85,6 @@ class InterpretedFunction extends NativeFunction {
|
||||
|
||||
InterpreterData itsData;
|
||||
Scriptable itsClosure;
|
||||
InterpretedFunction itsOtherSelf;
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ public class Interpreter extends LabelTable {
|
||||
{
|
||||
fn.setPrototype(ScriptableObject.getClassPrototype(scope, "Function"));
|
||||
fn.setParentScope(scope);
|
||||
if (fn.itsData.itsName.length() > 0)
|
||||
if ((fn.itsData.itsName.length() > 0) && (fn.itsClosure == null))
|
||||
ScriptRuntime.setName(scope, fn, scope, fn.itsData.itsName);
|
||||
}
|
||||
|
||||
@ -1808,14 +1808,19 @@ public class Interpreter extends LabelTable {
|
||||
case TokenStream.CLOSURE :
|
||||
i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF);
|
||||
if (theData.itsNestedFunctions[i]
|
||||
instanceof InterpretedFunction)
|
||||
instanceof InterpretedFunction) {
|
||||
stack[++stackTop]
|
||||
= new InterpretedFunction(
|
||||
(InterpretedFunction)
|
||||
(theData.itsNestedFunctions[i]),
|
||||
scope);
|
||||
scope, cx);
|
||||
createFunctionObject(
|
||||
(InterpretedFunction)stack[stackTop], scope);
|
||||
}
|
||||
else
|
||||
stack[++stackTop] = ScriptRuntime.createFunctionObject(scope, theData.itsNestedFunctions[i].getClass(), cx);
|
||||
stack[++stackTop]
|
||||
= ScriptRuntime.createFunctionObject(scope,
|
||||
theData.itsNestedFunctions[i].getClass(), cx);
|
||||
pc += 2;
|
||||
break;
|
||||
case TokenStream.OBJECT :
|
||||
|
Loading…
x
Reference in New Issue
Block a user