pub struct Realm {
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 error_proto: Gc<JsObject>,
}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.
error_proto: Gc<JsObject>Error.prototype, the prototype of every error instance.