Skip to content

Commit

Permalink
Rename GcObject to JsObject (#1489)
Browse files Browse the repository at this point in the history
* Rename `GcObject` to `JsObject`

* fmt
  • Loading branch information
bartlomieju authored Aug 24, 2021
1 parent 8c733c3 commit 26e1497
Show file tree
Hide file tree
Showing 29 changed files with 153 additions and 153 deletions.
4 changes: 2 additions & 2 deletions boa/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue},
gc::{Finalize, Trace},
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::{PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult,
Expand Down Expand Up @@ -117,7 +117,7 @@ impl ArrayIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
Expand Down
26 changes: 13 additions & 13 deletions boa/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
builtins::array::array_iterator::ArrayIterator,
builtins::BuiltIn,
builtins::Number,
object::{ConstructorBuilder, FunctionBuilder, GcObject, ObjectData, PROTOTYPE},
object::{ConstructorBuilder, FunctionBuilder, JsObject, ObjectData, PROTOTYPE},
property::{Attribute, PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
value::{IntegerOrInfinity, JsValue},
Expand Down Expand Up @@ -206,9 +206,9 @@ impl Array {
/// [spec]: https://tc39.es/ecma262/#sec-arraycreate
pub(crate) fn array_create(
length: usize,
prototype: Option<GcObject>,
prototype: Option<JsObject>,
context: &mut Context,
) -> JsResult<GcObject> {
) -> JsResult<JsObject> {
// 1. If length > 2^32 - 1, throw a RangeError exception.
if length > 2usize.pow(32) - 1 {
return Err(context.construct_range_error("array exceeded max size"));
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Array {
/// - [ECMAScript reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-createarrayfromlist
pub(crate) fn create_array_from_list<I>(elements: I, context: &mut Context) -> GcObject
pub(crate) fn create_array_from_list<I>(elements: I, context: &mut Context) -> JsObject
where
I: IntoIterator<Item = JsValue>,
{
Expand Down Expand Up @@ -335,10 +335,10 @@ impl Array {
///
/// see: <https://tc39.es/ecma262/#sec-arrayspeciescreate>
pub(crate) fn array_species_create(
original_array: &GcObject,
original_array: &JsObject,
length: usize,
context: &mut Context,
) -> JsResult<GcObject> {
) -> JsResult<JsObject> {
// 1. Let isArray be ? IsArray(originalArray).
// 2. If isArray is false, return ? ArrayCreate(length).
if !original_array.is_array() {
Expand Down Expand Up @@ -667,7 +667,7 @@ impl Array {
let callback = if let Some(arg) = args
.get(0)
.and_then(JsValue::as_object)
.filter(GcObject::is_callable)
.filter(JsObject::is_callable)
{
arg
} else {
Expand Down Expand Up @@ -772,7 +772,7 @@ impl Array {
let func = array.get("join", context)?;
// 3. If IsCallable(func) is false, set func to the intrinsic function %Object.prototype.toString%.
// 4. Return ? Call(func, array).
if let Some(func) = func.as_object().filter(GcObject::is_callable) {
if let Some(func) = func.as_object().filter(JsObject::is_callable) {
func.call(&array.into(), &[], context)
} else {
crate::builtins::object::Object::to_string(&array.into(), &[], context)
Expand Down Expand Up @@ -1013,7 +1013,7 @@ impl Array {
let callback = if let Some(arg) = args
.get(0)
.and_then(JsValue::as_object)
.filter(GcObject::is_callable)
.filter(JsObject::is_callable)
{
arg
} else {
Expand Down Expand Up @@ -1481,12 +1481,12 @@ impl Array {
/// [spec]: https://tc39.es/ecma262/#sec-flattenintoarray
#[allow(clippy::too_many_arguments)]
fn flatten_into_array(
target: &GcObject,
source: &GcObject,
target: &JsObject,
source: &JsObject,
source_len: u64,
start: u64,
depth: u64,
mapper_function: Option<GcObject>,
mapper_function: Option<JsObject>,
this_arg: &JsValue,
context: &mut Context,
) -> JsResult<u64> {
Expand Down Expand Up @@ -1879,7 +1879,7 @@ impl Array {
let callback = if let Some(arg) = args
.get(0)
.and_then(JsValue::as_object)
.filter(GcObject::is_callable)
.filter(JsObject::is_callable)
{
arg
} else {
Expand Down
6 changes: 3 additions & 3 deletions boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
builtins::{Array, BuiltIn},
environment::lexical_environment::Environment,
gc::{custom_trace, empty_trace, Finalize, Trace},
object::{ConstructorBuilder, FunctionBuilder, GcObject, Object, ObjectData},
object::{ConstructorBuilder, FunctionBuilder, JsObject, Object, ObjectData},
property::{Attribute, PropertyDescriptor},
syntax::ast::node::{FormalParameter, RcStatementList},
BoaProfiler, Context, JsResult, JsValue,
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Function {
/// <https://tc39.es/ecma262/#sec-createunmappedargumentsobject>
pub fn create_unmapped_arguments_object(arguments_list: &[JsValue]) -> JsValue {
let len = arguments_list.len();
let obj = GcObject::new(Object::default());
let obj = JsObject::new(Object::default());
// Set length
let length = PropertyDescriptor::builder()
.value(len)
Expand Down Expand Up @@ -225,7 +225,7 @@ pub fn create_unmapped_arguments_object(arguments_list: &[JsValue]) -> JsValue {
pub fn make_builtin_fn<N>(
function: NativeFunction,
name: N,
parent: &GcObject,
parent: &JsObject,
length: usize,
interpreter: &Context,
) where
Expand Down
32 changes: 16 additions & 16 deletions boa/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ use crate::{
string::string_iterator::StringIterator, ArrayIterator, ForInIterator, MapIterator,
SetIterator,
},
object::{GcObject, ObjectInitializer},
object::{JsObject, ObjectInitializer},
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult, JsValue,
};

#[derive(Debug, Default)]
pub struct IteratorPrototypes {
iterator_prototype: GcObject,
array_iterator: GcObject,
set_iterator: GcObject,
string_iterator: GcObject,
regexp_string_iterator: GcObject,
map_iterator: GcObject,
for_in_iterator: GcObject,
iterator_prototype: JsObject,
array_iterator: JsObject,
set_iterator: JsObject,
string_iterator: JsObject,
regexp_string_iterator: JsObject,
map_iterator: JsObject,
for_in_iterator: JsObject,
}

impl IteratorPrototypes {
Expand Down Expand Up @@ -47,37 +47,37 @@ impl IteratorPrototypes {
}

#[inline]
pub fn array_iterator(&self) -> GcObject {
pub fn array_iterator(&self) -> JsObject {
self.array_iterator.clone()
}

#[inline]
pub fn iterator_prototype(&self) -> GcObject {
pub fn iterator_prototype(&self) -> JsObject {
self.iterator_prototype.clone()
}

#[inline]
pub fn set_iterator(&self) -> GcObject {
pub fn set_iterator(&self) -> JsObject {
self.set_iterator.clone()
}

#[inline]
pub fn string_iterator(&self) -> GcObject {
pub fn string_iterator(&self) -> JsObject {
self.string_iterator.clone()
}

#[inline]
pub fn regexp_string_iterator(&self) -> GcObject {
pub fn regexp_string_iterator(&self) -> JsObject {
self.regexp_string_iterator.clone()
}

#[inline]
pub fn map_iterator(&self) -> GcObject {
pub fn map_iterator(&self) -> JsObject {
self.map_iterator.clone()
}

#[inline]
pub fn for_in_iterator(&self) -> GcObject {
pub fn for_in_iterator(&self) -> JsObject {
self.for_in_iterator.clone()
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn get_iterator(context: &mut Context, iterable: JsValue) -> JsResult<Iterat
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%iteratorprototype%-object
fn create_iterator_prototype(context: &mut Context) -> GcObject {
fn create_iterator_prototype(context: &mut Context) -> JsObject {
let _timer = BoaProfiler::global().start_event("Iterator Prototype", "init");

let symbol_iterator = WellKnownSymbols::iterator();
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/map/map_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue},
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::{PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult,
Expand Down Expand Up @@ -146,7 +146,7 @@ impl MapIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%mapiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
Expand Down
6 changes: 3 additions & 3 deletions boa/src/builtins/map/ordered_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
gc::{custom_trace, Finalize, Trace},
object::GcObject,
object::JsObject,
JsValue,
};
use indexmap::{Equivalent, IndexMap};
Expand Down Expand Up @@ -182,7 +182,7 @@ impl<V> OrderedMap<V> {
/// Increases the lock counter and returns a lock object that will decrement the counter when dropped.
///
/// This allows objects to be removed from the map during iteration without affecting the indexes until the iteration has completed.
pub(crate) fn lock(&mut self, map: GcObject) -> MapLock {
pub(crate) fn lock(&mut self, map: JsObject) -> MapLock {
self.lock += 1;
MapLock(map)
}
Expand All @@ -199,7 +199,7 @@ impl<V> OrderedMap<V> {

/// Increases the lock count of the map for the lifetime of the guard. This should not be dropped until iteration has completed.
#[derive(Debug, Trace)]
pub(crate) struct MapLock(GcObject);
pub(crate) struct MapLock(JsObject);

impl Clone for MapLock {
fn clone(&self) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/object/for_in_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object},
gc::{Finalize, Trace},
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::PropertyDescriptor,
property::PropertyKey,
symbol::WellKnownSymbols,
Expand Down Expand Up @@ -129,7 +129,7 @@ impl ForInIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%foriniteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
Expand Down
12 changes: 6 additions & 6 deletions boa/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod regexp_string_iterator;
use crate::{
builtins::{array::Array, string, BuiltIn},
gc::{empty_trace, Finalize, Trace},
object::{ConstructorBuilder, FunctionBuilder, GcObject, Object, ObjectData, PROTOTYPE},
object::{ConstructorBuilder, FunctionBuilder, JsObject, Object, ObjectData, PROTOTYPE},
property::Attribute,
symbol::WellKnownSymbols,
value::{IntegerOrInfinity, JsValue},
Expand Down Expand Up @@ -265,7 +265,7 @@ impl RegExp {
.into()
};

Ok(GcObject::new(Object::create(proto)).into())
Ok(JsObject::new(Object::create(proto)).into())
}

/// `22.2.3.2.2 RegExpInitialize ( obj, pattern, flags )`
Expand Down Expand Up @@ -415,7 +415,7 @@ impl RegExp {
}));
}

if GcObject::equals(
if JsObject::equals(
&object,
&context.standard_objects().regexp_object().prototype,
) {
Expand Down Expand Up @@ -779,7 +779,7 @@ impl RegExp {
this: &JsValue,
input: JsString,
context: &mut Context,
) -> JsResult<Option<GcObject>> {
) -> JsResult<Option<JsObject>> {
// 1. Assert: Type(R) is Object.
let object = this
.as_object()
Expand Down Expand Up @@ -821,10 +821,10 @@ impl RegExp {
///
/// [spec]: https://tc39.es/ecma262/#sec-regexpbuiltinexec
pub(crate) fn abstract_builtin_exec(
this: GcObject,
this: JsObject,
input: JsString,
context: &mut Context,
) -> JsResult<Option<GcObject>> {
) -> JsResult<Option<JsObject>> {
// 1. Assert: R is an initialized RegExp instance.
let rx = {
let obj = this.borrow();
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/regexp/regexp_string_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use regexp::{advance_string_index, RegExp};
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object, regexp},
gc::{Finalize, Trace},
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::PropertyDescriptor,
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult, JsString, JsValue,
Expand Down Expand Up @@ -161,7 +161,7 @@ impl RegExpStringIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event("RegExp String Iterator", "init");

// Create prototype
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/set/set_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
builtins::iterable::create_iter_result_object,
builtins::Array,
builtins::JsValue,
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::{PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult,
Expand Down Expand Up @@ -141,7 +141,7 @@ impl SetIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%setiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/string/string_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
function::make_builtin_fn, iterable::create_iter_result_object, string::code_point_at,
},
gc::{Finalize, Trace},
object::{GcObject, ObjectData},
object::{JsObject, ObjectData},
property::PropertyDescriptor,
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult, JsValue,
Expand Down Expand Up @@ -78,7 +78,7 @@ impl StringIterator {
/// - [ECMA reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> GcObject {
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: JsValue) -> JsObject {
let _timer = BoaProfiler::global().start_event("String Iterator", "init");

// Create prototype
Expand Down
Loading

0 comments on commit 26e1497

Please sign in to comment.