avm1: Migrate ScriptObject to proto_value

This commit is contained in:
relrelb 2021-04-01 10:11:44 +03:00 committed by kmeisthax
parent 18a32424bd
commit 766a5db31c
1 changed files with 14 additions and 11 deletions

View File

@ -275,16 +275,16 @@ impl<'gc> ScriptObject<'gc> {
let mut worked = false; let mut worked = false;
if is_vacant { if is_vacant {
let mut proto: Option<Object<'gc>> = Some((*self).into()); let mut proto: Value<'gc> = (*self).into();
while let Some(this_proto) = proto { while let Value::Object(this_proto) = proto {
if this_proto.has_own_virtual(activation, name) { if this_proto.has_own_virtual(activation, name) {
break; break;
} }
proto = this_proto.proto(); proto = this_proto.proto_value();
} }
if let Some(this_proto) = proto { if let Value::Object(this_proto) = proto {
worked = true; worked = true;
if let Some(rval) = this_proto.call_setter(name, value, activation) { if let Some(rval) = this_proto.call_setter(name, value, activation) {
if let Some(exec) = rval.as_executable() { if let Some(exec) = rval.as_executable() {
@ -621,10 +621,11 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
/// Checks if the object has a given named property. /// Checks if the object has a given named property.
fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool { fn has_property(&self, activation: &mut Activation<'_, 'gc, '_>, name: &str) -> bool {
self.has_own_property(activation, name) self.has_own_property(activation, name)
|| self || if let Value::Object(proto) = self.proto_value() {
.proto() proto.has_property(activation, name)
.as_ref() } else {
.map_or(false, |p| p.has_property(activation, name)) false
}
} }
/// Checks if the object has a given named property on itself (and not, /// Checks if the object has a given named property on itself (and not,
@ -668,9 +669,11 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
/// Enumerate the object. /// Enumerate the object.
fn get_keys(&self, activation: &mut Activation<'_, 'gc, '_>) -> Vec<String> { fn get_keys(&self, activation: &mut Activation<'_, 'gc, '_>) -> Vec<String> {
let proto_keys = self let proto_keys = if let Value::Object(proto) = self.proto_value() {
.proto() proto.get_keys(activation)
.map_or_else(Vec::new, |p| p.get_keys(activation)); } else {
Vec::new()
};
let mut out_keys = vec![]; let mut out_keys = vec![];
let object = self.0.read(); let object = self.0.read();