Skip to content

Commit

Permalink
Change intrinsics access to a getter
Browse files Browse the repository at this point in the history
  • Loading branch information
aapoalas committed Oct 26, 2023
1 parent 97cb094 commit a8e2ab3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nova_vm/src/builtins/builtin_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn create_builtin_function<'a, 'b: 'a>(
let prototype = args.prototype.unwrap_or_else(|| {
agent
.get_realm(realm_id)
.intrinsics
.intrinsics()
.function_prototype()
.into()
});
Expand Down
6 changes: 5 additions & 1 deletion nova_vm/src/execution/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Realm<'ctx, 'host> {
// NOTE: We will need an rng here at some point.

// [[Intrinsics]]
pub intrinsics: Intrinsics,
intrinsics: Intrinsics,

/// [[GlobalObject]]
pub global_object: Object,
Expand Down Expand Up @@ -66,6 +66,10 @@ impl<'ctx, 'host> Realm<'ctx, 'host> {
agent.borrow_mut().heap.add_realm(realm)
}

pub(crate) fn intrinsics(&self) -> &Intrinsics {
&self.intrinsics
}

/// 9.3.3 SetRealmGlobalObject ( realmRec, globalObj, thisValue ), https://tc39.es/ecma262/#sec-setrealmglobalobject
pub(crate) fn set_global_object(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions nova_vm/src/types/language/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ impl Object {
let prototype = heap.get(object_index).prototype;
prototype.map(|v| v.into())
} else {
Some(realm.intrinsics.array_prototype().into_value())
Some(realm.intrinsics().array_prototype().into_value())
}
}
Object::Function(_) => Some(realm.intrinsics.function_prototype().into_value()),
Object::Function(_) => Some(realm.intrinsics().function_prototype().into_value()),
_ => unreachable!(),
}
}
Expand Down

0 comments on commit a8e2ab3

Please sign in to comment.