diff --git a/core/src/avm2.rs b/core/src/avm2.rs index 6a490cfaf..e694ecd9c 100644 --- a/core/src/avm2.rs +++ b/core/src/avm2.rs @@ -6,6 +6,7 @@ use crate::avm2::object::{Object, TObject}; use crate::avm2::scope::Scope; use crate::avm2::script::Script; use crate::avm2::script::TranslationUnit; +use crate::avm2::script_object::ScriptObject; use crate::avm2::value::Value; use crate::context::UpdateContext; use crate::tag_utils::SwfSlice; @@ -56,7 +57,7 @@ pub struct Avm2<'gc> { globals: Object<'gc>, /// System prototypes. - system_prototypes: SystemPrototypes<'gc>, + system_prototypes: Option>, #[cfg(feature = "avm_debug")] pub debug_output: bool, @@ -65,12 +66,12 @@ pub struct Avm2<'gc> { impl<'gc> Avm2<'gc> { /// Construct a new AVM interpreter. pub fn new(mc: MutationContext<'gc, '_>) -> Self { - let (globals, system_prototypes) = globals::construct_global_scope(mc); + let globals = ScriptObject::bare_object(mc); Self { stack: Vec::new(), globals, - system_prototypes, + system_prototypes: None, #[cfg(feature = "avm_debug")] debug_output: false, @@ -83,8 +84,10 @@ impl<'gc> Avm2<'gc> { } /// Return the current set of system prototypes. + /// + /// This function panics if the interpreter has not yet been initialized. pub fn prototypes(&self) -> &SystemPrototypes<'gc> { - &self.system_prototypes + self.system_prototypes.as_ref().unwrap() } /// Run a script's initializer method.