Confirmed users
497
edits
(→Debugging hooks: Describe "slow script"-style termination. Explain what non-function code is.) |
|||
| Line 47: | Line 47: | ||
<li>If it returns an object of the form <code>{ throw: <i>value</i> }</code>, then <i>value</i> is thrown as an exception from the current bytecode instruction. <i>value</i> must be a debuggee value. | <li>If it returns an object of the form <code>{ throw: <i>value</i> }</code>, then <i>value</i> is thrown as an exception from the current bytecode instruction. <i>value</i> must be a debuggee value. | ||
<li>If it returns an object of the form <code>{ return: <i>value</i> }</code>, then <i>value</i> is immediately returned as the current value of the function. <i>value</i> must be a debuggee value. | <li>If it returns an object of the form <code>{ return: <i>value</i> }</code>, then <i>value</i> is immediately returned as the current value of the function. <i>value</i> must be a debuggee value. | ||
<li>If it returns null, the calling code is terminated, as if it had been cancelled by the "slow script" dialog box. | |||
<li>If the hook throws an exception, ... well, we're in trouble. That's an error in the debugger which should be reported somehow, but certainly not handled by the debuggee. | <li>If the hook throws an exception, ... well, we're in trouble. That's an error in the debugger which should be reported somehow, but certainly not handled by the debuggee. | ||
</ul> | </ul> | ||
<dt>newScript(<i>script</i>, [<i>function</i>]) | <dt>newScript(<i>script</i>, [<i>function</i>]) | ||
<dd>New code, represented by the <code>Debug.Script</code> instance <i>script</i>, has been loaded into the debuggee's compartment. If the new code is part of a function, <i>function</i> is a Debug.Object reference to the function object. | <dd>New code, represented by the <code>Debug.Script</code> instance <i>script</i>, has been loaded into the debuggee's compartment. If the new code is part of a function, <i>function</i> is a Debug.Object reference to the function object. (Not all code is part of a function; for example, the code appearing in a <code><script></code> tag that is outside of any functions defined in that tag would be passed to <code>newScript</code> without an accompanying <i>function</i> argument.) | ||
Note that <i>script</i> may be a temporary script, created | Note that <i>script</i> may be a temporary script, created for a call to <i>eval</i> and destroyed when its execution is complete. | ||
<dt>destroyScript(<i>script</i>) | <dt>destroyScript(<i>script</i>) | ||
| Line 67: | Line 68: | ||
<dd>The stack frame <i>frame</i> is about to begin executing code. (Naturally, <i>frame</i> is currently the youngest debuggee frame.) If <i>call</i> is true, it is a function call; if <i>call</i> is false, it is global or eval code. | <dd>The stack frame <i>frame</i> is about to begin executing code. (Naturally, <i>frame</i> is currently the youngest debuggee frame.) If <i>call</i> is true, it is a function call; if <i>call</i> is false, it is global or eval code. | ||
If this hook function returns a function | If this hook function returns a function <i>f</i>, SpiderMonkey will call <i>f</i> when execution of <i>frame</i> completes, passing one argument indicating how it completed. | ||
<ul> | |||
<li>If the argument is of the form <code>{ return: <i>value</i> }</code>, then the code completed normally, yielding <i>value</i>. <i>Value</i> is a debuggee value. | |||
<li>If the argument is of the form <code>{ throw: <i>value</i> }</code>, then the code threw <i>value</i> as an exception. <i>Value</i> is a debuggee value. | |||
<li>If the argument is <code>null</code>, then the code was terminated, as if by the "slow script" dialog box. | |||
</ul> | |||
<dt>throw(<i>frame</i>, <i>value</i>) | <dt>throw(<i>frame</i>, <i>value</i>) | ||