avm2: Don't call global init in optimizer
This commit is contained in:
parent
12174b5219
commit
eb27151af7
|
@ -798,10 +798,9 @@ pub fn optimize<'gc>(
|
|||
{
|
||||
*op = Op::GetScriptGlobals { script };
|
||||
|
||||
let script_globals = script
|
||||
.globals(&mut activation.context)
|
||||
.expect("Script should be resolved if traits exist");
|
||||
let script_globals = script.globals_if_init();
|
||||
|
||||
if let Some(script_globals) = script_globals {
|
||||
stack_push_done = true;
|
||||
if let Some(global_class) = script_globals.instance_of() {
|
||||
stack.push_class_object(global_class);
|
||||
|
@ -810,6 +809,7 @@ pub fn optimize<'gc>(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore global scope for now
|
||||
}
|
||||
|
|
|
@ -597,6 +597,19 @@ impl<'gc> Script<'gc> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return the global scope for the script.
|
||||
///
|
||||
/// If the script has not yet been initialized, this will return None.
|
||||
pub fn globals_if_init(&self) -> Option<Object<'gc>> {
|
||||
let read = self.0.read();
|
||||
|
||||
if !read.initialized {
|
||||
None
|
||||
} else {
|
||||
Some(read.globals)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return traits for this script.
|
||||
///
|
||||
/// This function will return an error if it is incorrectly called before
|
||||
|
|
Loading…
Reference in New Issue