pub struct Realm {Show 28 fields
pub global: Gc<JsObject>,
pub object_proto: Gc<JsObject>,
pub function_proto: Gc<JsObject>,
pub array_proto: Gc<JsObject>,
pub globals: BTreeMap<String, Gc<Cell>>,
pub declared: Vec<String>,
pub lexical_consts: BTreeSet<String>,
pub errors: BTreeMap<&'static str, Gc<JsObject>>,
pub string_proto: Option<Gc<JsObject>>,
pub number_proto: Option<Gc<JsObject>>,
pub boolean_proto: Option<Gc<JsObject>>,
pub bigint_proto: Option<Gc<JsObject>>,
pub error_proto: Gc<JsObject>,
pub date_proto: Gc<JsObject>,
pub generator_proto: Gc<JsObject>,
pub promise_proto: Option<Gc<JsObject>>,
pub async_generator_proto: Option<Gc<JsObject>>,
pub symbol_proto: Option<Gc<JsObject>>,
pub symbol_registry: BTreeMap<String, Value>,
pub regexp_proto: Option<Gc<JsObject>>,
pub regexp_ctor: Option<Gc<JsObject>>,
pub suppressed_error_proto: Option<Gc<JsObject>>,
pub disposable_stack_proto: Option<Gc<JsObject>>,
pub map_proto: Option<Gc<JsObject>>,
pub set_proto: Option<Gc<JsObject>>,
pub array_buffer_proto: Option<Gc<JsObject>>,
pub typed_array_proto: Option<Gc<JsObject>>,
pub async_disposable_stack_proto: Option<Gc<JsObject>>,
/* private fields */
}Expand description
Everything one JavaScript realm owns.
A realm is the set of objects a script can reach without naming them: the global object, the prototype chain roots, and the global binding cells.
Fields§
§global: Gc<JsObject>The global object.
object_proto: Gc<JsObject>Object.prototype.
function_proto: Gc<JsObject>Function.prototype, which is itself callable.
array_proto: Gc<JsObject>Array.prototype.
globals: BTreeMap<String, Gc<Cell>>Reference cells for globals declared by the script.
A declared global is read with get_var (by name) but written with
put_var_ref (through the cell), so the cell is what makes a function
declaration and its uses agree on one binding.
declared: Vec<String>Names of the globals that came from a declaration, which are non-configurable properties of the global object.
lexical_consts: BTreeSet<String>Names among the lexical globals that are const.
const-ness cannot be read back off the bytecode in every case: a closure that
refers to a global const gets a GlobalRef entry whose flags the forwarding
path does not carry, so a store through it would look like a plain let. The
realm records it once, at declaration, and answers for every reader.
errors: BTreeMap<&'static str, Gc<JsObject>>The error constructors by class name, so a runtime error can throw a real
TypeError instance rather than a look-alike object.
string_proto: Option<Gc<JsObject>>String.prototype, used by ToString on primitives and by the boxing path.
number_proto: Option<Gc<JsObject>>Number.prototype.
boolean_proto: Option<Gc<JsObject>>Boolean.prototype.
bigint_proto: Option<Gc<JsObject>>BigInt.prototype.
error_proto: Gc<JsObject>Error.prototype, the prototype of every error instance.
date_proto: Gc<JsObject>Date.prototype, so the constructor can build an instance in the
function-call form (Date() returns a string) without going through new.
generator_proto: Gc<JsObject>%GeneratorPrototype%, the prototype of every generator object.
promise_proto: Option<Gc<JsObject>>Promise.prototype, the prototype of every promise.
async_generator_proto: Option<Gc<JsObject>>%AsyncGeneratorPrototype%, the prototype of every async function* result.
symbol_proto: Option<Gc<JsObject>>Symbol.prototype.
symbol_registry: BTreeMap<String, Value>The Symbol.for registry: key -> symbol.
Scoped to the realm, which is what makes Symbol.for("k") answer the same
symbol every time within one script while a fresh realm starts empty.
regexp_proto: Option<Gc<JsObject>>RegExp.prototype, filled in by the RegExp builtin.
regexp_ctor: Option<Gc<JsObject>>The RegExp constructor.
suppressed_error_proto: Option<Gc<JsObject>>SuppressedError.prototype, which using builds its aggregates from.
The prototype rather than the constructor on purpose: a script that replaces
SuppressedError.prototype.constructor must not be able to divert the engine’s own
error wrapping, which the using test suite checks explicitly.
disposable_stack_proto: Option<Gc<JsObject>>The DisposableStack prototype, for move’s intrinsic construction.
map_proto: Option<Gc<JsObject>>Map.prototype.
set_proto: Option<Gc<JsObject>>Set.prototype.
array_buffer_proto: Option<Gc<JsObject>>ArrayBuffer.prototype.
typed_array_proto: Option<Gc<JsObject>>%TypedArray%.prototype, the prototype every view type inherits from.
async_disposable_stack_proto: Option<Gc<JsObject>>The AsyncDisposableStack prototype.
Implementations§
Source§impl Realm
impl Realm
Sourcepub fn set_well_known_symbols(&mut self, symbols: Vec<Value>)
pub fn set_well_known_symbols(&mut self, symbols: Vec<Value>)
Record the well-known symbols, in the order Symbol’s installer made them.
Sourcepub fn well_known(&self, which: WellKnown) -> Value
pub fn well_known(&self, which: WellKnown) -> Value
A well-known symbol.
Sourcepub fn well_known_key(&self, which: WellKnown) -> PropertyKey
pub fn well_known_key(&self, which: WellKnown) -> PropertyKey
The well-known symbol as a property key.