gecko-dev/js/js2/java/NativeFunction.java

35 строки
903 B
Java
Исходник Обычный вид История

import java.util.Vector;
1999-06-11 04:21:26 +04:00
class NativeFunction extends JSObject {
NativeFunction(ControlNode aBody)
{
super("Function");
1999-06-11 04:21:26 +04:00
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 );
}
1999-06-11 04:21:26 +04:00
ControlNode c = body;
while (c != null) c = c.eval(theEnv);
theEnv.leaveScope();
1999-06-11 04:21:26 +04:00
return theEnv.resultValue;
}
ControlNode body;
Vector parameters = new Vector();
1999-06-11 04:21:26 +04:00
}