Continue working on realms (#4356)
- Rework symbols to have the same value across realms - Support realms for native functions - Support test262 - Use new.target realms for constructing intrinsics JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -164,10 +164,10 @@ Container object types:
|
||||
|
||||
Well-known symbols:
|
||||
|
||||
- JERRY_SYMBOL_ASYNC_ITERATOR - @@asyncIterator well-known symbol
|
||||
- JERRY_SYMBOL_HAS_INSTANCE - @@hasInstance well-known symbol
|
||||
- JERRY_SYMBOL_IS_CONCAT_SPREADABLE - @@isConcatSpreadable well-known symbol
|
||||
- JERRY_SYMBOL_ITERATOR - @@iterator well-known symbol
|
||||
- JERRY_SYMBOL_ASYNC_ITERATOR - @@asyncIterator well-known symbol
|
||||
- JERRY_SYMBOL_MATCH - @@match well-known symbol
|
||||
- JERRY_SYMBOL_REPLACE - @@replace well-known symbol
|
||||
- JERRY_SYMBOL_SEARCH - @@search well-known symbol
|
||||
@@ -9118,6 +9118,59 @@ main (int argc, char** argv)
|
||||
|
||||
- [jerry_construct_object](#jerry_construct_object)
|
||||
|
||||
## jerry_set_realm
|
||||
|
||||
**Summary**
|
||||
|
||||
Replaces the currently active realm (including the global object) with another realm.
|
||||
The replacement should be temporary, and the original realm must be restored after
|
||||
the tasks are completed. During the replacement, the realm must be referenced
|
||||
by the application (i.e. the gc must not reclaim it). This is also true to
|
||||
the returned previously active realm, so there is no need to free the value
|
||||
after the restoration. The function can only fail if realms are not supported
|
||||
or the passed argument is not a realm. In this case the returned exception must
|
||||
be freed by [jerry_release_value](#jerry_release_value).
|
||||
|
||||
This function is useful to parse a script, create a native function, load a snapshot
|
||||
or create an exception in another realm. Each ECMAScript code runs in the realm
|
||||
which was active when the code was parsed or loaded regardless of the current realm.
|
||||
|
||||
*Notes*:
|
||||
- This feature depends on build option (`JERRY_BUILTIN_REALMS`) and can be checked
|
||||
in runtime with the `JERRY_FEATURE_REALM` feature enum value,
|
||||
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerry_set_realm (jerry_value_t realm_value);
|
||||
```
|
||||
- `realm_value` - the new realm value
|
||||
- return
|
||||
- previous realm value - if the passed value is a realm
|
||||
- exception - otherwise
|
||||
|
||||
*New in version [[NEXT_RELEASE]]*.
|
||||
|
||||
**Example**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t realm_value = jerry_create_realm ();
|
||||
|
||||
jerry_value_t old_realm = jerry_set_realm (realm_value);
|
||||
|
||||
... // usage of the realm
|
||||
|
||||
jerry_set_realm (old_realm);
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_create_realm](#jerry_create_realm)
|
||||
|
||||
# ArrayBuffer and TypedArray functions
|
||||
|
||||
These APIs all depend on the es.next profile.
|
||||
|
||||
Reference in New Issue
Block a user