X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FJSFunction.java;fp=src%2Forg%2Fxwt%2Fjs%2FJSFunction.java;h=0000000000000000000000000000000000000000;hb=3591b88b94a6bb378af3d4abe6eb5233ce583104;hp=2f75ff2dfdc8de8d3be1592e25ed43960ec37423;hpb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;p=org.ibex.core.git
diff --git a/src/org/xwt/js/JSFunction.java b/src/org/xwt/js/JSFunction.java
deleted file mode 100644
index 2f75ff2..0000000
--- a/src/org/xwt/js/JSFunction.java
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
-package org.xwt.js;
-
-import org.xwt.util.*;
-import java.util.*;
-import java.io.*;
-
-/** A JavaScript function, compiled into bytecode */
-class JSFunction extends JS implements ByteCodes, Tokens, org.xwt.Scheduler.Task {
-
-
- // Fields and Accessors ///////////////////////////////////////////////
-
- int numFormalArgs = 0; ///< the number of formal arguments
-
- String sourceName; ///< the source code file that this block was drawn from
- private int firstLine = -1; ///< the first line of this script
-
- int[] line = new int[10]; ///< the line numbers
- int[] op = new int[10]; ///< the instructions
- Object[] arg = new Object[10]; ///< the arguments to the instructions
- int size = 0; ///< the number of instruction/argument pairs
-
- JSScope parentScope; ///< the default scope to use as a parent scope when executing this
-
-
- // Public //////////////////////////////////////////////////////////////////////////////
-
- // FEATURE: make sure that this can only be called from the Scheduler...
- /** if you enqueue a function, it gets invoked in its own pauseable context */
- public void perform() throws JSExn {
- Interpreter i = new Interpreter(this, true, new JSArray());
- int oldpausecount = i.pausecount;
- i.resume();
- }
-
- /** parse and compile a function */
- public static JSFunction _fromReader(String sourceName, int firstLine, Reader sourceCode) throws IOException {
- JSFunction ret = new JSFunction(sourceName, firstLine, null);
- if (sourceCode == null) return ret;
- Parser p = new Parser(sourceCode, sourceName, firstLine);
- while(true) {
- int s = ret.size;
- p.parseStatement(ret, null);
- if (s == ret.size) break;
- }
- ret.add(-1, LITERAL, null);
- ret.add(-1, RETURN);
- return ret;
- }
-
- public JSFunction _cloneWithNewParentScope(JSScope s) {
- JSFunction ret = new JSFunction(sourceName, firstLine, s);
- // Reuse the same op, arg, line, and size variables for the new "instance" of the function
- // NOTE: Neither *this* function nor the new function should be modified after this call
- ret.op = this.op;
- ret.arg = this.arg;
- ret.line = this.line;
- ret.size = this.size;
- ret.numFormalArgs = this.numFormalArgs;
- return ret;
- }
-
- /** Note: code gets run in an unpauseable context. */
- public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
- JSArray args = new JSArray();
- if (nargs > 0) args.addElement(a0);
- if (nargs > 1) args.addElement(a1);
- if (nargs > 2) args.addElement(a2);
- for(int i=3; i