Confirmed users
497
edits
(→Objects: Add request for accessing function scopes.) |
|||
| Line 228: | Line 228: | ||
<i>TODO: descriptors for Harmony proxies</i> | <i>TODO: descriptors for Harmony proxies</i> | ||
=== Functions === | |||
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>function-grip-actor</i>, "type":"name-and-parameters" } | |||
This requests the name of the function represented by <i>function-grip-actor</i>, and the names of its parameters. The reply has the form: | |||
{ "from":<i>function-grip-actor</i>, "name":<i>name</i>, "parameters":[ <i>parameter</i>, ... ] } | |||
where <i>name</i> is the name of the function, or <code>null</code> if the function is anonymous, and each <i>parameter</i> is the name of a formal parameter to the function as a string. If the function takes destructuring arguments, the <i>parameter</i> is a structure of JSON array and object forms matching the form of the destructuring arguments. | |||
{ "to":<i>function-grip-actor</i>, "type":"scope" } | |||
Return the lexical environment over which the function has closed. The reply has the form: | |||
{ "from":<i>function-grip-actor</i>, "scope":<i>environment</i> } | |||
where <i>environment</i> is a [[#Lexical_Environments|lexical environment]]. | |||
{ "to":<i>function-grip-actor</i>, "type":"decompile", "pretty":<i>pretty</i> } | |||
Return JavaScript source code for a function equivalent to the one represented by <i>function-grip-actor</i>. If the optional <code>pretty</code> parameter is present and <i>pretty</i> is <code>true</code>, then produce indented source code with line breaks. The reply has the form: | |||
{ "from":<i>function-grip-actor</i>, "decompiled-code":<i>code</i> } | |||
where <i>code</i> is a string. | |||
== Long Strings == | == Long Strings == | ||