Confirmed users
496
edits
(Move "Lexical Environments" back down towards the bottom.) |
(Expand lexical environments example; mention iterators.) |
||
Line 447: | Line 447: | ||
{ "type":"pre-call" } | { "type":"pre-call" } | ||
The client had asked the thread to pause before making each function call, and the thread is about to call a function. Single-stepping the thread will a place it at the head of the function's code, with all arguments, local variables, and local functions bound. | The client had asked the thread to pause before making each function call, and the thread is about to call a function. (Requesting the next value from an iterator, whether via the <tt>next</tt> or <tt>send</tt> methods, is considered a call for the purposes of these packets.) Single-stepping the thread will a place it at the head of the function's code, with all arguments, local variables, and local functions bound. | ||
{ "type":"pre-return" } | { "type":"pre-return" } | ||
The client had asked the thread to pause before returning from functions, and the thread is about to return from a function. Single-stepping the thread will return the thread to the calling frame. | The client had asked the thread to pause before returning from functions, and the thread is about to return from a function. (The JavaScript 1.7 <tt>yield</tt> operator is treated as a kind of return, for the sake of these packets.) Single-stepping the thread will return the thread to the calling frame. | ||
{ "type":"pre-throw", "exception":<i>grip</i> } | { "type":"pre-throw", "exception":<i>grip</i> } | ||
Line 769: | Line 769: | ||
} | } | ||
You can see here the three nested environment forms, starting with the <tt>environment</tt> property of the top stack frame, reported in the pause. | You can see here the three nested environment forms, starting with the <tt>environment</tt> property of the top stack frame, reported in the pause: | ||
* The first environment form shows the environment record created by the call to <tt>g</tt>, with the string <tt>"argument to g"</tt> passed as the value of <tt>y</tt>. | |||
* Because <tt>g</tt> is nested within <tt>f</tt>, each function object generated for <tt>g</tt> captures the environment of a call to the enclosing function <tt>f</tt>. Thus, the next thing on <tt>g</tt>'s scope chain is an environment form for the call to <tt>f</tt>, where <tt>"argument to f"</tt> was passed as the vale of <tt>x</tt>. | |||
* Because <tt>f</tt> is a top-level function, the (only) function object for <tt>f</tt> closes over the global object. This is the "type":"object" environment shown as the parent of <tt>f</tt>'s environment record. | |||
* Because the global object is at the end of the scope chain, its environment form has no <tt>parent</tt> property. | |||
= Breakpoints = | = Breakpoints = |