1 55 56 package org.apache.bsf.engines.javascript; 57 58 import java.rmi.RemoteException ; 59 import org.apache.bsf.debug.util.DebugLog; 60 61 import org.apache.bsf.util.*; 62 import org.apache.bsf.debug.jsdi.*; 63 import org.mozilla.javascript.Context; 64 import org.mozilla.javascript.Script; 65 import org.mozilla.javascript.debug.DebuggableEngine; 66 67 72 public class JsEngineStub 73 extends org.apache.bsf.debug.util.Skeleton 74 implements JsEngine { 75 76 RhinoEngineDebugger m_rhinoDbg; 77 boolean m_inCallback; 78 boolean m_resumeExecution; 79 Object m_lock; 80 81 84 public JsEngineStub(RhinoEngineDebugger rhinoDbg) 85 throws RemoteException { 86 super(org.apache.bsf.debug.util.DebugConstants.JS_ENGINE_TID); 87 m_rhinoDbg = rhinoDbg; 88 m_lock = new Object (); 89 } 90 91 public boolean isSuspended() throws RemoteException { 92 return m_inCallback; 93 } 94 95 public boolean poll() { return true; } 96 97 public Object eval(String docname, String exp, int lineNo) 98 throws RemoteException { 99 100 Object retval = null; 101 102 Context.enter(); 103 try { 104 retval = m_rhinoDbg.eval(docname, exp, lineNo); 105 } catch (Throwable ex) { 106 throw new RemoteException ("Failed eval", ex); 107 } finally { 108 Context.exit(); 109 } 110 return retval; 111 } 112 113 public JsContext getContext(int depth) throws RemoteException { 114 try { 115 Context.enter(); 116 return m_rhinoDbg.getContext(depth); 117 } finally { 118 Context.exit(); 119 } 120 121 } 122 123 public int getContextCount() throws RemoteException { 124 int count; 125 try { 126 Context.enter(); 127 count = m_rhinoDbg.getContextCount(); 128 DebugLog.stdoutPrintln(" count = "+count, 129 DebugLog.BSF_LOG_L3); 130 return count; 131 } finally { 132 Context.exit(); 133 } 134 135 } 136 137 public String getThread() throws RemoteException { 138 return m_rhinoDbg.getThread(); 139 } 140 141 public String getThreadGroup() throws RemoteException { 142 return m_rhinoDbg.getThreadGroup(); 143 } 144 145 149 public JsCallbacks getDebugger() throws RemoteException { 150 try { 151 Context.enter(); 152 return m_rhinoDbg.getDebugger(); 153 } finally { 154 Context.exit(); 155 } 156 } 157 158 public JsObject getGlobalObject() throws RemoteException { 159 try { 160 Context.enter(); 161 return m_rhinoDbg.getGlobalObject(); 162 } finally { 163 Context.exit(); 164 } 165 } 166 167 public JsObject getUndefinedValue() throws RemoteException { 168 try { 169 Context.enter(); 170 return m_rhinoDbg.getUndefinedValue(); 171 } finally { 172 Context.exit(); 173 } 174 } 175 176 public void run() throws RemoteException { 177 try { 178 Context.enter(); 179 m_rhinoDbg.run(this); 180 } catch (Exception ex) { 181 throw new RemoteException ("Internal JSDI error",ex); 182 } finally { 183 Context.exit(); 184 } 185 } 186 187 192 public void setDebugger(JsCallbacks debugger) throws RemoteException { 193 try { 194 Context.enter(); 195 m_rhinoDbg.setDebugger(debugger); 196 } catch (Exception ex) { 197 throw new RemoteException ("Internal JSDI error",ex); 198 } finally { 199 Context.exit(); 200 } 201 } 202 203 public void stepIn() throws RemoteException { 204 try { 205 Context.enter(); 206 DebugLog.stdoutPrintln("Step In command on "+this, 207 DebugLog.BSF_LOG_L3); 208 m_rhinoDbg.stepIn(this); 209 } catch (Exception ex) { 210 throw new RemoteException ("Internal JSDI error",ex); 211 } finally { 212 Context.exit(); 213 } 214 } 215 216 public void stepOut() throws RemoteException { 217 try { 218 Context.enter(); 219 m_rhinoDbg.stepOut(this); 220 } catch (Exception ex) { 221 throw new RemoteException ("Internal JSDI error",ex); 222 } finally { 223 Context.exit(); 224 } 225 } 226 227 public void stepOver() throws RemoteException { 228 RhinoContextProxy rcp; 229 try { 230 Context.enter(); 231 m_rhinoDbg.stepOver(this); 232 } catch (Exception ex) { 233 throw new RemoteException ("Internal JSDI error",ex); 234 } finally { 235 Context.exit(); 236 } 237 } 238 } 239 | Popular Tags |