Skip to content

Commit c05f725

Browse files
authored
cleanup(engine): Handle traits (#927)
1 parent 16409f2 commit c05f725

File tree

218 files changed

+8036
-10596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+8036
-10596
lines changed

nova_cli/src/helper.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use nova_vm::{
2727
},
2828
scripts_and_modules::script::{parse_script, script_evaluation},
2929
types::{
30-
BigInt, Function, InternalMethods, IntoValue, Number, Object, OrdinaryObject,
31-
PropertyDescriptor, PropertyKey, String, Value,
30+
BigInt, Function, InternalMethods, Number, Object, OrdinaryObject, PropertyDescriptor,
31+
PropertyKey, String, Value,
3232
},
3333
},
3434
engine::{
@@ -185,7 +185,7 @@ pub fn initialize_global_object(agent: &mut Agent, global: Object, gc: GcScope)
185185
return Err(agent.throw_exception(ExceptionType::Error, e.to_string(), gc));
186186
}
187187
};
188-
Ok(String::from_string(agent, file, gc).into_value())
188+
Ok(String::from_string(agent, file, gc).into())
189189
}
190190

191191
// 'now' function
@@ -197,7 +197,7 @@ pub fn initialize_global_object(agent: &mut Agent, global: Object, gc: GcScope)
197197
) -> JsResult<'gc, Value<'gc>> {
198198
let nanos = START_TIME.elapsed().as_nanos();
199199
let bigint = BigInt::from_u128(agent, nanos, gc.into_nogc());
200-
Ok(bigint.into_value())
200+
Ok(bigint.into())
201201
}
202202

203203
let function = create_builtin_function(
@@ -291,7 +291,7 @@ fn monotonic_now<'gc>(
291291
let micros = ((START_TIME.elapsed().as_micros() as u16 % 1000) / 5 * 5) as f64 / 1000.0;
292292
let total = millis + micros;
293293
let number = Number::from_f64(agent, total, gc);
294-
Ok(number.into_value())
294+
Ok(number.into())
295295
}
296296

297297
fn create_obj_func(
@@ -337,7 +337,7 @@ pub fn initialize_global_object_with_internals(agent: &mut Agent, global: Object
337337
Some(initialize_global_object_with_internals),
338338
gc,
339339
);
340-
Ok(realm.global_object(agent).into_value().unbind())
340+
Ok(realm.global_object(agent).unbind().into())
341341
}
342342

343343
/// `detachArrayBuffer` function
@@ -660,7 +660,7 @@ fn initialize_child_global_object(agent: &mut Agent, global: Object, mut gc: GcS
660660

661661
let _ = cb
662662
.unbind()
663-
.call(agent, Value::Null, &mut [sab.into_value().unbind()], gc);
663+
.call(agent, Value::Null, &mut [sab.unbind().into()], gc);
664664

665665
Ok(Value::Undefined)
666666
}
@@ -726,7 +726,7 @@ fn initialize_child_global_object(agent: &mut Agent, global: Object, mut gc: GcS
726726
agent,
727727
property_key,
728728
PropertyDescriptor {
729-
value: Some(test262_obj.into_value()),
729+
value: Some(test262_obj.into()),
730730
writable: Some(true),
731731
enumerable: Some(false),
732732
configurable: Some(true),
@@ -742,7 +742,7 @@ fn initialize_child_global_object(agent: &mut Agent, global: Object, mut gc: GcS
742742
agent,
743743
property_key,
744744
PropertyDescriptor {
745-
value: Some(agent_obj.into_value()),
745+
value: Some(agent_obj.into()),
746746
writable: Some(true),
747747
enumerable: Some(false),
748748
configurable: Some(true),

nova_cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ enum Command {
7979
#[arg(short, long)]
8080
module: bool,
8181

82-
/// Sets the [[CanBlock]] value of the Agent Record to false.
82+
/// Sets the \[\[CanBlock]] value of the Agent Record to false.
8383
#[arg(long)]
8484
no_block: bool,
8585

nova_vm/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ const fn get_index(n: &'static str) -> usize {
130130
struct_const.push_str(string);
131131
struct_const.push_str("\") }),\n");
132132
} else {
133-
struct_const.push_str(": String::String(HeapString(BaseIndex::from_index(get_index(");
133+
struct_const
134+
.push_str(": String::String(HeapString(BaseIndex::from_index_const(get_index(");
134135
struct_const.push_str(&format!("\"{string}\")))),\n"));
135136
}
136137
}

nova_vm/src/ecmascript/abstract_operations/operations_on_iterator_objects.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ use crate::{
1818
Agent, JsResult,
1919
agent::{ExceptionType, JsError, try_result_into_option_js},
2020
},
21-
types::{
22-
BUILTIN_STRING_MEMORY, Function, IntoObject, IntoValue, Object, OrdinaryObject,
23-
PropertyKey, Value,
24-
},
21+
types::{BUILTIN_STRING_MEMORY, Function, Object, OrdinaryObject, PropertyKey, Value},
2522
},
2623
engine::{
2724
ScopableCollection, ScopedCollection, VmIteratorRecord,
@@ -39,7 +36,7 @@ use crate::{
3936
/// An Iterator Record is a Record value used to encapsulate an Iterator or
4037
/// AsyncIterator along with the next method.
4138
#[derive(Debug, Clone, Copy)]
42-
pub struct IteratorRecord<'a> {
39+
pub(crate) struct IteratorRecord<'a> {
4340
pub(crate) iterator: Object<'a>,
4441
pub(crate) next_method: Function<'a>,
4542
// Note: The done field doesn't seem to be used anywhere.
@@ -492,7 +489,7 @@ pub(crate) fn iterator_close_with_value<'a>(
492489
call_function(
493490
agent,
494491
return_function.unbind(),
495-
iterator.into_value().unbind(),
492+
iterator.unbind().into(),
496493
None,
497494
gc.reborrow(),
498495
)
@@ -566,7 +563,7 @@ pub(crate) fn iterator_close_with_error<'a>(
566563
let _ = call_function(
567564
agent,
568565
r#return.unbind(),
569-
iterator.into_value().unbind(),
566+
iterator.unbind().into(),
570567
None,
571568
gc.reborrow(),
572569
);
@@ -622,7 +619,7 @@ pub(crate) fn create_iter_result_object<'a>(
622619
.current_realm_record()
623620
.intrinsics()
624621
.object_prototype()
625-
.into_object(),
622+
.into(),
626623
),
627624
&[
628625
ObjectEntry {
@@ -637,7 +634,7 @@ pub(crate) fn create_iter_result_object<'a>(
637634
ObjectEntry {
638635
key: PropertyKey::from(BUILTIN_STRING_MEMORY.done),
639636
value: ObjectEntryPropertyDescriptor::Data {
640-
value: done.into_value(),
637+
value: done.into(),
641638
writable: true,
642639
enumerable: true,
643640
configurable: true,

0 commit comments

Comments
 (0)