avm1: put an assert to ensure that `avm::Value`'s size doesn't grow again

This commit is contained in:
Moulins 2023-04-21 16:33:22 +02:00 committed by Nathan Adams
parent bb08d356b1
commit 60f34f8056
1 changed files with 8 additions and 1 deletions

View File

@ -11,7 +11,7 @@ use crate::ecma_conversions::{
};
use crate::string::{AvmString, Integer, WStr};
use gc_arena::Collect;
use std::{borrow::Cow, io::Write, num::Wrapping};
use std::{borrow::Cow, io::Write, mem::size_of, num::Wrapping};
use super::object_reference::MovieClipReference;
@ -28,6 +28,13 @@ pub enum Value<'gc> {
MovieClip(MovieClipReference<'gc>),
}
// This type is used very frequently, so make sure it doesn't unexpectedly grow.
#[cfg(target_pointer_width = "32")]
const _: () = assert!(size_of::<Value<'_>>() == 16);
#[cfg(target_pointer_width = "64")]
const _: () = assert!(size_of::<Value<'_>>() == 24);
impl<'gc> From<AvmString<'gc>> for Value<'gc> {
fn from(string: AvmString<'gc>) -> Self {
Value::String(string)