2020-02-04 02:22:44 +00:00
|
|
|
//! ActionScript Virtual Machine 2 (AS3) support
|
|
|
|
|
2022-07-21 06:11:46 +00:00
|
|
|
use crate::avm2::class::AllocatorFn;
|
2022-06-29 14:28:42 +00:00
|
|
|
use crate::avm2::globals::SystemClasses;
|
2022-06-16 02:11:14 +00:00
|
|
|
use crate::avm2::method::{Method, NativeMethodImpl};
|
2020-09-24 00:07:09 +00:00
|
|
|
use crate::avm2::script::{Script, TranslationUnit};
|
2020-02-04 18:51:18 +00:00
|
|
|
use crate::context::UpdateContext;
|
2021-09-12 10:20:51 +00:00
|
|
|
use crate::string::AvmString;
|
2022-06-15 19:00:17 +00:00
|
|
|
use crate::tag_utils::{SwfSlice, SwfStream};
|
2021-11-27 20:49:54 +00:00
|
|
|
use fnv::FnvHashMap;
|
2020-10-09 01:54:51 +00:00
|
|
|
use gc_arena::{Collect, MutationContext};
|
2020-02-07 00:28:54 +00:00
|
|
|
use std::rc::Rc;
|
2020-02-04 18:51:18 +00:00
|
|
|
use swf::avm2::read::Reader;
|
2022-06-15 19:00:17 +00:00
|
|
|
use swf::extensions::ReadSwfExt;
|
2020-02-04 02:22:44 +00:00
|
|
|
|
2020-02-20 19:41:15 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! avm_debug {
|
2020-07-23 20:19:52 +00:00
|
|
|
($avm: expr, $($arg:tt)*) => (
|
|
|
|
if $avm.show_debug_output() {
|
|
|
|
log::debug!($($arg)*)
|
|
|
|
}
|
2020-02-20 19:41:15 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-03-07 20:03:04 +00:00
|
|
|
pub mod activation;
|
2020-08-25 03:00:08 +00:00
|
|
|
mod array;
|
avm2: Partially implement `URLLoader` and related classes
This PR implements the `URLLoader` class, allowing AVM2 scripts
to load data from a URL. This requires several other related
classes (`URLLoaderDataFormat`, `URLRequest`, `IOError`) to be
implemented as well.
Currently implemented:
* Fetching from URLs using the 'navigator' backend
* The `text` and `binary` data formats (which store data
in a `String` or `ByteArray` respectively)
* The `open`, `complete`, and `ioError` events
* The `bytesLoaded`, `bytesTotal`, and `data` properties
Not yet implemented:
* The HTTP and security events
* All of the properties of `IOError`
* The properties on `URLRequest` (besides `url`)
* The "variables" data format
This should be enough to get some basic uses of `URLLoader` working
(e.g. simple GET requests to a particular website).
Note that in Flash's `playerglobal`, the `URLLoader` class is just
a think wrapper around the more general `URLStream`. However,
implementing `URLStream` will require changes to `Navigator``
to support notifications when data arrives in the stream. When
that happens, we should be able to re-use a large amount of the
code in this PR.
2022-04-06 01:27:39 +00:00
|
|
|
pub mod bytearray;
|
2020-06-30 03:58:48 +00:00
|
|
|
mod class;
|
2020-09-24 00:07:09 +00:00
|
|
|
mod domain;
|
2020-12-08 02:37:43 +00:00
|
|
|
mod events;
|
2020-02-06 04:15:03 +00:00
|
|
|
mod function;
|
2020-02-12 19:58:33 +00:00
|
|
|
mod globals;
|
2020-07-03 01:49:53 +00:00
|
|
|
mod method;
|
2022-08-12 22:29:46 +00:00
|
|
|
mod multiname;
|
|
|
|
mod namespace;
|
2022-03-07 20:03:04 +00:00
|
|
|
pub mod object;
|
2020-02-15 01:30:19 +00:00
|
|
|
mod property;
|
2020-07-18 20:41:35 +00:00
|
|
|
mod property_map;
|
2022-08-12 22:29:46 +00:00
|
|
|
mod qname;
|
2021-02-11 07:56:21 +00:00
|
|
|
mod regexp;
|
2020-02-10 19:54:55 +00:00
|
|
|
mod scope;
|
2020-07-02 03:21:30 +00:00
|
|
|
mod script;
|
2020-07-18 20:20:58 +00:00
|
|
|
mod string;
|
2020-08-15 01:20:41 +00:00
|
|
|
mod traits;
|
2020-02-04 02:22:44 +00:00
|
|
|
mod value;
|
2021-03-11 02:41:20 +00:00
|
|
|
mod vector;
|
2021-12-01 09:08:25 +00:00
|
|
|
mod vtable;
|
2020-02-04 02:22:44 +00:00
|
|
|
|
2020-08-06 02:11:52 +00:00
|
|
|
pub use crate::avm2::activation::Activation;
|
2021-02-26 00:04:25 +00:00
|
|
|
pub use crate::avm2::array::ArrayStorage;
|
2020-10-07 03:48:43 +00:00
|
|
|
pub use crate::avm2::domain::Domain;
|
2022-08-12 22:29:46 +00:00
|
|
|
pub use crate::avm2::multiname::Multiname;
|
|
|
|
pub use crate::avm2::namespace::Namespace;
|
2021-09-24 20:54:36 +00:00
|
|
|
pub use crate::avm2::object::{
|
2022-07-27 14:44:42 +00:00
|
|
|
ArrayObject, ClassObject, EventObject, Object, ScriptObject, SoundChannelObject, StageObject,
|
|
|
|
TObject,
|
2021-09-24 20:54:36 +00:00
|
|
|
};
|
2022-08-12 22:29:46 +00:00
|
|
|
pub use crate::avm2::qname::QName;
|
2020-07-21 04:24:02 +00:00
|
|
|
pub use crate::avm2::value::Value;
|
|
|
|
|
2021-02-24 03:03:23 +00:00
|
|
|
const BROADCAST_WHITELIST: [&str; 3] = ["enterFrame", "exitFrame", "frameConstructed"];
|
|
|
|
|
2020-02-04 18:51:18 +00:00
|
|
|
/// Boxed error alias.
|
|
|
|
///
|
|
|
|
/// As AVM2 is a far stricter VM than AVM1, this may eventually be replaced
|
|
|
|
/// with a proper Avm2Error enum.
|
2020-08-08 00:39:15 +00:00
|
|
|
pub type Error = Box<dyn std::error::Error>;
|
2020-02-04 18:51:18 +00:00
|
|
|
|
2020-02-04 02:22:44 +00:00
|
|
|
/// The state of an AVM2 interpreter.
|
|
|
|
#[derive(Collect)]
|
|
|
|
#[collect(no_drop)]
|
|
|
|
pub struct Avm2<'gc> {
|
|
|
|
/// Values currently present on the operand stack.
|
|
|
|
stack: Vec<Value<'gc>>,
|
2020-02-12 19:58:33 +00:00
|
|
|
|
|
|
|
/// Global scope object.
|
2020-10-09 01:54:51 +00:00
|
|
|
globals: Domain<'gc>,
|
2020-02-19 03:26:08 +00:00
|
|
|
|
2021-06-25 22:01:27 +00:00
|
|
|
/// System classes.
|
2021-06-18 22:11:37 +00:00
|
|
|
system_classes: Option<SystemClasses<'gc>>,
|
2021-05-28 02:22:38 +00:00
|
|
|
|
2022-06-16 02:11:14 +00:00
|
|
|
#[collect(require_static)]
|
2022-07-21 06:11:46 +00:00
|
|
|
native_method_table: &'static [Option<NativeMethodImpl>],
|
|
|
|
|
|
|
|
#[collect(require_static)]
|
|
|
|
native_instance_allocator_table: &'static [Option<AllocatorFn>],
|
2022-06-16 02:11:14 +00:00
|
|
|
|
2021-01-22 01:09:08 +00:00
|
|
|
/// A list of objects which are capable of recieving broadcasts.
|
|
|
|
///
|
|
|
|
/// Certain types of events are "broadcast events" that are emitted on all
|
|
|
|
/// constructed objects in order of their creation, whether or not they are
|
|
|
|
/// currently present on the display list. This list keeps track of that.
|
|
|
|
///
|
|
|
|
/// TODO: These should be weak object pointers, but our current garbage
|
|
|
|
/// collector does not support weak references.
|
2021-11-27 20:49:54 +00:00
|
|
|
broadcast_list: FnvHashMap<AvmString<'gc>, Vec<Object<'gc>>>,
|
2021-01-22 01:09:08 +00:00
|
|
|
|
2020-07-23 20:19:52 +00:00
|
|
|
#[cfg(feature = "avm_debug")]
|
|
|
|
pub debug_output: bool,
|
2020-02-04 02:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gc> Avm2<'gc> {
|
|
|
|
/// Construct a new AVM interpreter.
|
2020-02-12 19:58:33 +00:00
|
|
|
pub fn new(mc: MutationContext<'gc, '_>) -> Self {
|
2020-09-24 03:35:11 +00:00
|
|
|
let globals = Domain::global_domain(mc);
|
2020-02-19 03:26:08 +00:00
|
|
|
|
2020-02-06 04:15:03 +00:00
|
|
|
Self {
|
|
|
|
stack: Vec::new(),
|
2020-02-19 03:26:08 +00:00
|
|
|
globals,
|
2021-06-18 22:11:37 +00:00
|
|
|
system_classes: None,
|
2022-07-21 06:11:46 +00:00
|
|
|
native_method_table: Default::default(),
|
|
|
|
native_instance_allocator_table: Default::default(),
|
2021-11-27 20:49:54 +00:00
|
|
|
broadcast_list: Default::default(),
|
2020-07-23 20:19:52 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "avm_debug")]
|
|
|
|
debug_output: false,
|
2020-02-06 04:15:03 +00:00
|
|
|
}
|
2020-02-04 02:22:44 +00:00
|
|
|
}
|
2020-02-04 18:51:18 +00:00
|
|
|
|
2020-07-07 04:24:16 +00:00
|
|
|
pub fn load_player_globals(context: &mut UpdateContext<'_, 'gc, '_>) -> Result<(), Error> {
|
2020-09-24 03:35:11 +00:00
|
|
|
let globals = context.avm2.globals;
|
2020-07-07 04:24:16 +00:00
|
|
|
let mut activation = Activation::from_nothing(context.reborrow());
|
2020-09-24 03:35:11 +00:00
|
|
|
globals::load_player_globals(&mut activation, globals)
|
2020-07-07 04:24:16 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 22:11:37 +00:00
|
|
|
/// Return the current set of system classes.
|
2021-05-28 02:22:38 +00:00
|
|
|
///
|
|
|
|
/// This function panics if the interpreter has not yet been initialized.
|
2021-06-18 22:11:37 +00:00
|
|
|
pub fn classes(&self) -> &SystemClasses<'gc> {
|
|
|
|
self.system_classes.as_ref().unwrap()
|
2021-05-28 02:22:38 +00:00
|
|
|
}
|
|
|
|
|
2020-07-04 21:18:41 +00:00
|
|
|
/// Run a script's initializer method.
|
|
|
|
pub fn run_script_initializer(
|
2020-10-09 01:54:51 +00:00
|
|
|
script: Script<'gc>,
|
2020-07-04 21:18:41 +00:00
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
) -> Result<(), Error> {
|
2020-09-24 03:35:11 +00:00
|
|
|
let mut init_activation = Activation::from_script(context.reborrow(), script)?;
|
2020-07-04 21:18:41 +00:00
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
let (method, scope, _domain) = script.init();
|
2020-10-09 01:54:51 +00:00
|
|
|
match method {
|
2021-06-19 01:49:40 +00:00
|
|
|
Method::Native(method) => {
|
2021-06-13 04:03:41 +00:00
|
|
|
//This exists purely to check if the builtin is OK with being called with
|
|
|
|
//no parameters.
|
2022-06-16 02:11:14 +00:00
|
|
|
init_activation.resolve_parameters(&method.name, &[], &method.signature)?;
|
2021-06-13 04:03:41 +00:00
|
|
|
|
2021-06-19 01:49:40 +00:00
|
|
|
(method.method)(&mut init_activation, Some(scope), &[])?;
|
2020-10-09 01:54:51 +00:00
|
|
|
}
|
2022-07-15 21:18:49 +00:00
|
|
|
Method::Bytecode(method) => {
|
|
|
|
init_activation.run_actions(method)?;
|
2020-10-09 01:54:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(())
|
2020-07-04 21:18:41 +00:00
|
|
|
}
|
|
|
|
|
2021-01-13 01:02:07 +00:00
|
|
|
/// Dispatch an event on an object.
|
|
|
|
///
|
|
|
|
/// The `bool` parameter reads true if the event was cancelled.
|
|
|
|
pub fn dispatch_event(
|
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
2022-07-27 14:44:42 +00:00
|
|
|
event: Object<'gc>,
|
2021-01-13 01:02:07 +00:00
|
|
|
target: Object<'gc>,
|
|
|
|
) -> Result<bool, Error> {
|
|
|
|
use crate::avm2::events::dispatch_event;
|
|
|
|
let mut activation = Activation::from_nothing(context.reborrow());
|
2022-07-27 14:44:42 +00:00
|
|
|
dispatch_event(&mut activation, target, event)
|
2021-01-13 01:02:07 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 01:09:08 +00:00
|
|
|
/// Add an object to the broadcast list.
|
|
|
|
///
|
2021-02-24 03:03:23 +00:00
|
|
|
/// Each broadcastable event contains it's own broadcast list. You must
|
|
|
|
/// register all objects that have event handlers with that event's
|
|
|
|
/// broadcast list by calling this function. Attempting to register a
|
|
|
|
/// broadcast listener for a non-broadcast event will do nothing.
|
|
|
|
///
|
|
|
|
/// Attempts to register the same listener for the same event will also do
|
|
|
|
/// nothing.
|
2021-01-22 01:09:08 +00:00
|
|
|
pub fn register_broadcast_listener(
|
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
object: Object<'gc>,
|
2021-02-24 02:49:42 +00:00
|
|
|
event_name: AvmString<'gc>,
|
2021-01-22 01:09:08 +00:00
|
|
|
) {
|
2021-10-05 17:25:46 +00:00
|
|
|
if !BROADCAST_WHITELIST
|
|
|
|
.iter()
|
|
|
|
.any(|x| AvmString::from(*x) == event_name)
|
|
|
|
{
|
2021-02-24 03:03:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-24 02:49:42 +00:00
|
|
|
let bucket = context.avm2.broadcast_list.entry(event_name).or_default();
|
|
|
|
|
|
|
|
if bucket.iter().any(|x| Object::ptr_eq(*x, object)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bucket.push(object);
|
2021-01-22 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Dispatch an event on all objects in the current execution list.
|
|
|
|
///
|
2021-06-03 02:15:26 +00:00
|
|
|
/// `on_type` specifies a class or interface constructor whose instances,
|
|
|
|
/// implementers, and/or subclasses define the set of objects that will
|
|
|
|
/// receive the event. You can broadcast to just display objects, or
|
|
|
|
/// specific interfaces, and so on.
|
2021-02-24 03:03:23 +00:00
|
|
|
///
|
2021-06-03 02:15:26 +00:00
|
|
|
/// Attempts to broadcast a non-broadcast event will do nothing. To add a
|
|
|
|
/// new broadcast type, you must add it to the `BROADCAST_WHITELIST` first.
|
2021-01-22 01:09:08 +00:00
|
|
|
pub fn broadcast_event(
|
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
2022-07-27 14:44:42 +00:00
|
|
|
event: Object<'gc>,
|
2021-09-24 20:54:36 +00:00
|
|
|
on_type: ClassObject<'gc>,
|
2021-01-22 01:09:08 +00:00
|
|
|
) -> Result<(), Error> {
|
2022-07-27 14:44:42 +00:00
|
|
|
let base_event = event.as_event().unwrap(); // TODO: unwrap?
|
|
|
|
let event_name = base_event.event_type();
|
|
|
|
drop(base_event);
|
2021-10-05 17:25:46 +00:00
|
|
|
if !BROADCAST_WHITELIST
|
|
|
|
.iter()
|
|
|
|
.any(|x| AvmString::from(*x) == event_name)
|
|
|
|
{
|
2021-02-24 03:03:23 +00:00
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
2021-02-24 02:49:42 +00:00
|
|
|
let el_length = context
|
|
|
|
.avm2
|
|
|
|
.broadcast_list
|
|
|
|
.entry(event_name)
|
|
|
|
.or_default()
|
|
|
|
.len();
|
2021-01-22 01:09:08 +00:00
|
|
|
|
|
|
|
for i in 0..el_length {
|
2021-02-24 02:49:42 +00:00
|
|
|
let object = context
|
|
|
|
.avm2
|
|
|
|
.broadcast_list
|
|
|
|
.get(&event_name)
|
|
|
|
.unwrap()
|
|
|
|
.get(i)
|
|
|
|
.copied();
|
2021-01-22 01:09:08 +00:00
|
|
|
|
|
|
|
if let Some(object) = object {
|
2021-07-01 02:16:57 +00:00
|
|
|
let mut activation = Activation::from_nothing(context.reborrow());
|
|
|
|
|
|
|
|
if object.is_of_type(on_type, &mut activation)? {
|
2022-07-27 14:44:42 +00:00
|
|
|
Avm2::dispatch_event(&mut activation.context, event, object)?;
|
2021-01-22 01:09:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-08-22 20:16:47 +00:00
|
|
|
pub fn run_stack_frame_for_callable(
|
|
|
|
callable: Object<'gc>,
|
|
|
|
reciever: Option<Object<'gc>>,
|
|
|
|
args: &[Value<'gc>],
|
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let mut evt_activation = Activation::from_nothing(context.reborrow());
|
2021-10-24 02:48:48 +00:00
|
|
|
callable.call(reciever, args, &mut evt_activation)?;
|
2020-08-22 20:16:47 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-15 19:00:17 +00:00
|
|
|
pub fn load_abc_from_do_abc(
|
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
swf: &SwfSlice,
|
|
|
|
domain: Domain<'gc>,
|
|
|
|
reader: &mut SwfStream<'_>,
|
|
|
|
tag_len: usize,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let start = reader.as_slice();
|
|
|
|
// Queue the actions.
|
|
|
|
// TODO: The tag reader parses the entire ABC file, instead of just
|
|
|
|
// giving us a `SwfSlice` for later parsing, so we have to replcate the
|
|
|
|
// *entire* parsing code here. This sucks.
|
|
|
|
let flags = reader.read_u32()?;
|
|
|
|
let name = reader.read_str()?.to_string_lossy(reader.encoding());
|
|
|
|
let is_lazy_initialize = flags & 1 != 0;
|
|
|
|
let num_read = reader.pos(start);
|
|
|
|
|
|
|
|
// The rest of the tag is an ABC file so we can take our SwfSlice now.
|
|
|
|
let slice = swf
|
|
|
|
.resize_to_reader(reader, tag_len - num_read)
|
|
|
|
.ok_or_else(|| {
|
|
|
|
std::io::Error::new(
|
|
|
|
std::io::ErrorKind::Other,
|
|
|
|
"Invalid source or tag length when running init action",
|
|
|
|
)
|
|
|
|
})?;
|
|
|
|
|
|
|
|
Avm2::load_abc(slice, &name, is_lazy_initialize, context, domain)?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-02-04 18:51:18 +00:00
|
|
|
/// Load an ABC file embedded in a `SwfSlice`.
|
|
|
|
///
|
|
|
|
/// The `SwfSlice` must resolve to the contents of an ABC file.
|
|
|
|
pub fn load_abc(
|
|
|
|
abc: SwfSlice,
|
2020-03-01 00:59:54 +00:00
|
|
|
_abc_name: &str,
|
2020-10-09 01:54:51 +00:00
|
|
|
lazy_init: bool,
|
2020-02-04 18:51:18 +00:00
|
|
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
2020-10-09 01:54:51 +00:00
|
|
|
domain: Domain<'gc>,
|
2020-02-04 18:51:18 +00:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let mut read = Reader::new(abc.as_ref());
|
|
|
|
|
2020-02-18 22:54:39 +00:00
|
|
|
let abc_file = Rc::new(read.read()?);
|
2020-09-24 00:07:09 +00:00
|
|
|
let tunit = TranslationUnit::from_abc(abc_file.clone(), domain, context.gc_context);
|
2020-02-18 22:54:39 +00:00
|
|
|
|
2020-02-23 21:32:16 +00:00
|
|
|
for i in (0..abc_file.scripts.len()).rev() {
|
2021-05-22 02:46:17 +00:00
|
|
|
let mut script = tunit.load_script(i as u32, context)?;
|
2020-07-04 21:18:41 +00:00
|
|
|
|
2020-10-09 01:54:51 +00:00
|
|
|
if !lazy_init {
|
|
|
|
script.globals(context)?;
|
|
|
|
}
|
2020-02-18 22:54:39 +00:00
|
|
|
}
|
2020-02-04 18:51:18 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2020-02-06 04:15:03 +00:00
|
|
|
|
2020-10-09 01:54:51 +00:00
|
|
|
pub fn global_domain(&self) -> Domain<'gc> {
|
2020-02-12 19:58:33 +00:00
|
|
|
self.globals
|
|
|
|
}
|
|
|
|
|
2020-02-07 00:28:54 +00:00
|
|
|
/// Push a value onto the operand stack.
|
|
|
|
fn push(&mut self, value: impl Into<Value<'gc>>) {
|
2021-09-28 01:41:29 +00:00
|
|
|
let mut value = value.into();
|
|
|
|
if let Value::Object(o) = value {
|
|
|
|
if let Some(prim) = o.as_primitive() {
|
2021-12-07 01:19:12 +00:00
|
|
|
value = *prim;
|
2021-09-28 01:41:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-23 20:19:52 +00:00
|
|
|
avm_debug!(self, "Stack push {}: {:?}", self.stack.len(), value);
|
2020-02-07 00:28:54 +00:00
|
|
|
self.stack.push(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Retrieve the top-most value on the operand stack.
|
|
|
|
#[allow(clippy::let_and_return)]
|
|
|
|
fn pop(&mut self) -> Value<'gc> {
|
|
|
|
let value = self.stack.pop().unwrap_or_else(|| {
|
|
|
|
log::warn!("Avm1::pop: Stack underflow");
|
|
|
|
Value::Undefined
|
|
|
|
});
|
|
|
|
|
2020-07-23 20:19:52 +00:00
|
|
|
avm_debug!(self, "Stack pop {}: {:?}", self.stack.len(), value);
|
2020-02-07 00:28:54 +00:00
|
|
|
|
|
|
|
value
|
|
|
|
}
|
|
|
|
|
2020-02-24 19:12:36 +00:00
|
|
|
fn pop_args(&mut self, arg_count: u32) -> Vec<Value<'gc>> {
|
2022-03-14 20:10:18 +00:00
|
|
|
let mut args = vec![Value::Undefined; arg_count as usize];
|
2020-02-24 19:12:36 +00:00
|
|
|
for arg in args.iter_mut().rev() {
|
|
|
|
*arg = self.pop();
|
|
|
|
}
|
|
|
|
args
|
|
|
|
}
|
2020-07-23 20:19:52 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "avm_debug")]
|
|
|
|
#[inline]
|
|
|
|
pub fn show_debug_output(&self) -> bool {
|
|
|
|
self.debug_output
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(feature = "avm_debug"))]
|
|
|
|
pub const fn show_debug_output(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "avm_debug")]
|
|
|
|
pub fn set_show_debug_output(&mut self, visible: bool) {
|
|
|
|
self.debug_output = visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(feature = "avm_debug"))]
|
|
|
|
pub const fn set_show_debug_output(&self, _visible: bool) {}
|
2020-02-04 02:22:44 +00:00
|
|
|
}
|