From e6cadf7de48edbd735c3ebb47584160e65aa7dfe Mon Sep 17 00:00:00 2001 From: Mike Welsh Date: Sun, 17 Apr 2022 11:12:43 -0700 Subject: [PATCH] avm1: Use u16 for Property::attributes --- core/src/avm1/globals/object.rs | 4 ++-- core/src/avm1/property.rs | 9 +++++---- core/src/avm1/property_decl.rs | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/avm1/globals/object.rs b/core/src/avm1/globals/object.rs index 0824a8b4d..2a090503b 100644 --- a/core/src/avm1/globals/object.rs +++ b/core/src/avm1/globals/object.rs @@ -267,10 +267,10 @@ pub fn as_set_prop_flags<'gc>( return Ok(Value::Undefined); }; - let set_flags = args.get(2).unwrap_or(&0.into()).coerce_to_f64(activation)? as u8; + let set_flags = args.get(2).unwrap_or(&0.into()).coerce_to_f64(activation)? as u16; let set_attributes = Attribute::from_bits_truncate(set_flags); - let clear_flags = args.get(3).unwrap_or(&0.into()).coerce_to_f64(activation)? as u8; + let clear_flags = args.get(3).unwrap_or(&0.into()).coerce_to_f64(activation)? as u16; let clear_attributes = Attribute::from_bits_truncate(clear_flags); if set_attributes.bits() != set_flags || clear_attributes.bits() != clear_flags { diff --git a/core/src/avm1/property.rs b/core/src/avm1/property.rs index 82b246e19..cd6e019cd 100644 --- a/core/src/avm1/property.rs +++ b/core/src/avm1/property.rs @@ -10,10 +10,11 @@ bitflags! { /// The values are significant and should match the order used by `object::as_set_prop_flags`. #[derive(Collect)] #[collect(require_static)] - pub struct Attribute: u8 { - const DONT_ENUM = 1 << 0; - const DONT_DELETE = 1 << 1; - const READ_ONLY = 1 << 2; + pub struct Attribute: u16 { + const DONT_ENUM = 1 << 0; + const DONT_DELETE = 1 << 1; + const READ_ONLY = 1 << 2; + const VERSION_MASK = 0xf << 9; } } diff --git a/core/src/avm1/property_decl.rs b/core/src/avm1/property_decl.rs index 3f422de6f..f04af01e9 100644 --- a/core/src/avm1/property_decl.rs +++ b/core/src/avm1/property_decl.rs @@ -27,7 +27,7 @@ pub struct Declaration { // This should be an `Attribute`, but because of `const` shenanigans // we need to store the raw flags. // See the comment in the `declare_properties!` macro. - pub attributes: u8, + pub attributes: u16, } /// All the possible types of a [`Declaration`].