Confirmed users
497
edits
([whitespace af248e3] Remove trailing whitespace, to placate git.) |
([displayName c5d71e6] Provide function names in grip; drop extra name properties elsewhere.) |
||
| Line 106: | Line 106: | ||
This represents a JavaScript object whose class is <i>className</i>. (Arrays and functions are treated as objects for the sake of forming grips.) <i>Actor</i> can be consulted for the object's contents, as explained below. | This represents a JavaScript object whose class is <i>className</i>. (Arrays and functions are treated as objects for the sake of forming grips.) <i>Actor</i> can be consulted for the object's contents, as explained below. | ||
If the class is "Function", the grip may have additional properties: | |||
{ "type":"object", "class":"Function", "actor":<i>actor</i>, | |||
"name":<i>name</i>, "displayName":<i>displayName</i>, | |||
"userDisplayName":<i>userDisplayName</i> } | |||
These additional properties are: | |||
<dl> | |||
<dt><i>name</i> | |||
<dd>The function's name (as given in the source code, following the <code>function</code> keyword), as a string. If the function is anonymous, the <code>name</code> property is omitted. | |||
<dt><i>displayName</i> | |||
<dd>A name the system has inferred for the function (say, <code>"Foo.method"</code>). If the function has a given name (appearing in the grip as the <code>"name"</code> property), or if the system was unable to infer a suitable name for it, the <code>displayName</code> property is omitted. | |||
<dt><i>userDisplayName</i> | |||
<dd>If the function object has a <code>"displayName"</code> value property whose value is a string, this is that property's value. (Many JavaScript development tools consult such properties, to give developers a way to provide their own meaningful names for functions.) | |||
</dl> | |||
{ "type":"longString", "initial":<i>initial</i>, "length":<i>length</i>, "actor":<i>actor</i> } | { "type":"longString", "initial":<i>initial</i>, "length":<i>length</i>, "actor":<i>actor</i> } | ||
| Line 276: | Line 292: | ||
If an object's class as given in the grip is <code>"Function"</code>, then the grip's actor responds to the messages given here. | If an object's class as given in the grip is <code>"Function"</code>, then the grip's actor responds to the messages given here. | ||
{ "to":<i>functionGripActor</i>, "type":" | { "to":<i>functionGripActor</i>, "type":"parameterNames" } | ||
This requests the | This requests the names of the parameters of the function represented by <i>functionGripActor</i>. The reply has the form: | ||
{ "from":<i>functionGripActor</i>, " | { "from":<i>functionGripActor</i>, "parameterNames":[ <i>parameter</i>, ... ] } | ||
where | where each <i>parameter</i> is the name of a formal parameter to the function as a string. If the function takes destructuring arguments, then <i>parameter</i> is a structure of JSON array and object forms matching the form of the destructuring arguments. | ||
{ "to":<i>functionGripActor</i>, "type":"scope" } | { "to":<i>functionGripActor</i>, "type":"scope" } | ||
| Line 764: | Line 780: | ||
{ "actor":<i>actor</i>, "depth":<i>depth</i>, "type":"call", "this":<i>this</i>, | { "actor":<i>actor</i>, "depth":<i>depth</i>, "type":"call", "this":<i>this</i>, | ||
"where":<i>location</i>, "environment":<i>environment</i>, | "where":<i>location</i>, "environment":<i>environment</i>, | ||
"callee":<i>callee | "callee":<i>callee</i>, "arguments":<i>arguments</i> } | ||
where: | where: | ||
* <i>callee</i> is a grip on the function value being called; | * <i>callee</i> is a grip on the function value being called; | ||
* <i>arguments</i> is an array of grips on the actual values passed to the function; | * <i>arguments</i> is an array of grips on the actual values passed to the function; | ||
| Line 852: | Line 867: | ||
<i>ParentEnvironment</i> is a lexical environment describing the next enclosing environment; the <tt>parent</tt> property is omitted on the outermost environment. | <i>ParentEnvironment</i> is a lexical environment describing the next enclosing environment; the <tt>parent</tt> property is omitted on the outermost environment. | ||
{ "type":"function", "actor":<i>actor</i>, "function":<i>function | { "type":"function", "actor":<i>actor</i>, "function":<i>function</i>, | ||
"bindings":<i>bindings</i>, "parent":<i>parentEnvironment</i> } | "bindings":<i>bindings</i>, "parent":<i>parentEnvironment</i> } | ||
This represents the variable environment created by a call to <i>function</i> (a grip | This represents the variable environment created by a call to <i>function</i> (a grip). <i>Bindings</i> describes the bindings in scope, including the function's arguments, the <tt>arguments</tt> object, and local <tt>var</tt> and function bindings; its form is described in detail below. The other properties are as described above. | ||
{ "type":"with", "actor":<i>actor</i>, "object":<i>object</i>, "parent":<i>parentEnvironment</i> } | { "type":"with", "actor":<i>actor</i>, "object":<i>object</i>, "parent":<i>parentEnvironment</i> } | ||