Changes to get traditional functions with args. working

git-svn-id: svn://10.0.0.236/trunk@35302 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
1999-06-15 00:57:05 +00:00
parent 26c8590a2b
commit b5540991c3
10 changed files with 111 additions and 23 deletions

View File

@@ -1,19 +1,35 @@
import java.util.Vector;
class NativeFunction extends JSObject {
NativeFunction(ControlNode aBody)
{
super("Function", null);
super("Function");
body = aBody;
}
JSValue call(Environment theEnv, JSValue rV)
{
JSScope args = new JSScope("Arguments");
theEnv.enterNewScope(args);
for (int i = 0; i < parameters.size(); i++) {
if (rV instanceof JSValueList)
args.putProp(theEnv, (JSString)(parameters.elementAt(i)), (JSValue) ( ((JSValueList)rV).contents.elementAt(i)) );
else
args.putProp(theEnv, (JSString)(parameters.elementAt(i)), rV );
}
ControlNode c = body;
while (c != null) c = c.eval(theEnv);
theEnv.leaveScope();
return theEnv.resultValue;
}
ControlNode body;
Vector parameters = new Vector();
}