|
|
@ -159,12 +159,13 @@ impl ValueData { |
|
|
|
/// Resolve the property in the object
|
|
|
|
/// Resolve the property in the object
|
|
|
|
/// Returns a copy of the Property
|
|
|
|
/// Returns a copy of the Property
|
|
|
|
pub fn get_prop(&self, field: String) -> Option<Property> { |
|
|
|
pub fn get_prop(&self, field: String) -> Option<Property> { |
|
|
|
// handle length
|
|
|
|
|
|
|
|
// Spidermonkey has its own GetLengthProperty: https://searchfox.org/mozilla-central/source/js/src/vm/Interpreter-inl.h#154
|
|
|
|
// Spidermonkey has its own GetLengthProperty: https://searchfox.org/mozilla-central/source/js/src/vm/Interpreter-inl.h#154
|
|
|
|
// TODO: Maybe we need a GetLengthProperty for value types
|
|
|
|
// TODO: Move this to a better place
|
|
|
|
|
|
|
|
if self.is_string() && field == "length" { |
|
|
|
if let ValueData::String(ref s) = *self { |
|
|
|
if let ValueData::String(ref s) = *self { |
|
|
|
return Some(Property::new(to_value(s.len() as f64))) |
|
|
|
return Some(Property::new(to_value(s.len() as f64))) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let obj: ObjectData = match *self { |
|
|
|
let obj: ObjectData = match *self { |
|
|
|
ValueData::Object(ref obj) => { |
|
|
|
ValueData::Object(ref obj) => { |
|
|
|