X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSFunction.java;h=0bf580e42dae07564f9352f08411f5d0257bbd0f;hb=a6fb49b55117ea4cf330b412d2a2fff403fcd053;hp=03508b784ab5df6c4f5b61237a2ac68fbe7ee31b;hpb=361d18aff8f32e60fb8b6c5c52744a9f1e9890be;p=org.ibex.js.git diff --git a/src/org/ibex/js/JSFunction.java b/src/org/ibex/js/JSFunction.java index 03508b7..0bf580e 100644 --- a/src/org/ibex/js/JSFunction.java +++ b/src/org/ibex/js/JSFunction.java @@ -3,9 +3,10 @@ // You may not use this file except in compliance with the License. package org.ibex.js; +import org.ibex.util.*; /** A JavaScript function, compiled into bytecode */ -class JSFunction extends JS.Immutable implements ByteCodes, Tokens { +class JSFunction extends JS.Immutable implements ByteCodes, Tokens, Pausable { private static final JS[] emptyArgs = new JS[0]; // Fields and Accessors /////////////////////////////////////////////// @@ -25,7 +26,6 @@ class JSFunction extends JS.Immutable implements ByteCodes, Tokens { // Public ////////////////////////////////////////////////////////////////////////////// - // FIXME: what needs to be syncrhonized (if anything)? private Interpreter runner = null; public Object run(Object o) throws JSExn { if (runner == null) runner = new Interpreter(this, true, emptyArgs); @@ -50,7 +50,9 @@ class JSFunction extends JS.Immutable implements ByteCodes, Tokens { return ret; } - public JS call(JS[] args) throws JSExn { return (JS)new Interpreter(this, false, args).run(null); } + public JS call(JS method, JS[] args) throws JSExn { + if (method != null) return super.call(method, args); + return (JS)new Interpreter(this, false, args).run(null); } JSScope getParentScope() { return parentScope; } @@ -97,7 +99,7 @@ class JSFunction extends JS.Immutable implements ByteCodes, Tokens { if (op[i] < 0) sb.append(bytecodeToString[-op[i]]); else sb.append(codeToString[op[i]]); sb.append(" "); - sb.append(arg[i] == null ? "(no arg)" : arg[i] instanceof JS ? Script.str((JS)arg[i]) : arg[i]); + sb.append(arg[i] == null ? "(no arg)" : arg[i] instanceof JS ? JSU.str((JS)arg[i]) : arg[i]); if((op[i] == JF || op[i] == JT || op[i] == JMP) && arg[i] != null && arg[i] instanceof Number) { sb.append(" jump to ").append(i+((Number) arg[i]).intValue()); } else if(op[i] == TRY) {