Skip to content

Commit

Permalink
Add length to ordinary functions and arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed May 3, 2020
1 parent af85cfa commit 59022d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions boa/src/builtins/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl ValueData {
}

/// Set the field in the value
pub fn set_field_slice<'a>(&self, field: &'a str, val: Value) -> Value {
pub fn set_field_slice(&self, field: &str, val: Value) -> Value {
// set_field used to accept strings, but now Symbols accept it needs to accept a value
// So this function will now need to Box strings back into values (at least for now)
let f = Gc::new(Self::String(field.to_string()));
Expand Down Expand Up @@ -513,7 +513,7 @@ impl ValueData {
}

/// Set the property in the value
pub fn set_prop_slice<'t>(&self, field: &'t str, prop: Property) -> Property {
pub fn set_prop_slice(&self, field: &str, prop: Property) -> Property {
self.set_prop(field.to_string(), prop)
}

Expand Down
2 changes: 2 additions & 0 deletions boa/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl Executor for Interpreter {
let mut new_func = Object::function();
new_func.set_call(func);
let val = to_value(new_func);
val.set_field_slice("length", to_value(args.len()));

// Set the name and assign it in the current environment
if name.is_some() {
Expand Down Expand Up @@ -307,6 +308,7 @@ impl Executor for Interpreter {
let mut new_func = Object::function();
new_func.set_call(func);
let val = to_value(new_func);
val.set_field_slice("length", to_value(args.len()));

Ok(val)
}
Expand Down
3 changes: 2 additions & 1 deletion boa/src/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use crate::{
use gc::{Gc, GcCell};
use std::collections::{hash_map::HashMap, hash_set::HashSet};

/// Representation of a Realm.
/// Representation of a Realm.
///
/// In the specification these are called Realm Records.
#[derive(Debug)]
pub struct Realm {
Expand Down

0 comments on commit 59022d2

Please sign in to comment.