Skip to content

[avm1] Better handling of preload/suppress functions flags #7239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions core/src/avm1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ impl<'gc> Avm1<'gc> {
active_clip,
clip_obj.into(),
None,
None,
);
if let Err(e) = child_activation.run_actions(code) {
root_error_handler(&mut child_activation, e);
Expand Down Expand Up @@ -251,7 +250,6 @@ impl<'gc> Avm1<'gc> {
active_clip,
clip_obj.into(),
None,
None,
);
function(&mut activation)
}
Expand Down Expand Up @@ -300,7 +298,6 @@ impl<'gc> Avm1<'gc> {
active_clip,
clip_obj.into(),
None,
None,
);
if let Err(e) = child_activation.run_actions(code) {
root_error_handler(&mut child_activation, e);
Expand Down
25 changes: 9 additions & 16 deletions core/src/avm1/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,20 @@ pub struct Activation<'a, 'gc: 'a, 'gc_context: 'a> {
constant_pool: GcCell<'gc, Vec<Value<'gc>>>,

/// The immutable value of `this`.
///
/// This differs from Flash Player, where `this` is mutable and seems
/// to be part of the scope chain (e.g. a function with the `suppress_this` flag
/// set can modify the `this` value of its closure).
///
/// Fortunately, ActionScript syntax prevents mutating `this` altogether, so
/// observing this behavior requires manually-crafted bytecode.
///
/// TODO: implement correct semantics for mutable `this`.
this: Value<'gc>,

/// The function object being called.
pub callee: Option<Object<'gc>>,

/// The arguments this function was called by.
pub arguments: Option<Object<'gc>>,

/// Local registers, if any.
///
/// None indicates a function executing out of the global register set.
Expand Down Expand Up @@ -254,7 +260,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
base_clip: DisplayObject<'gc>,
this: Value<'gc>,
callee: Option<Object<'gc>>,
arguments: Option<Object<'gc>>,
) -> Self {
avm_debug!(context.avm1, "START {}", id);
Self {
Expand All @@ -268,7 +273,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
base_clip_unloaded: base_clip.removed(),
this,
callee,
arguments,
local_registers: None,
actions_since_timeout_check: 0,
}
Expand All @@ -293,7 +297,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
base_clip_unloaded: self.base_clip_unloaded,
this: self.this,
callee: self.callee,
arguments: self.arguments,
local_registers: self.local_registers,
actions_since_timeout_check: 0,
}
Expand Down Expand Up @@ -329,7 +332,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
base_clip_unloaded: base_clip.removed(),
this: globals.into(),
callee: None,
arguments: None,
local_registers: None,
actions_since_timeout_check: 0,
}
Expand Down Expand Up @@ -383,7 +385,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
active_clip,
clip_obj.into(),
None,
None,
);
child_activation.run_actions(code)
}
Expand Down Expand Up @@ -421,7 +422,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
active_clip,
clip_obj.into(),
None,
None,
);
function(&mut activation)
}
Expand Down Expand Up @@ -2131,7 +2131,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
self.base_clip,
self.this,
self.callee,
self.arguments,
);

match catch_vars {
Expand Down Expand Up @@ -2737,12 +2736,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
return Ok(CallableValue::UnCallable(self.this_cell()));
}

if &name == b"arguments" && self.arguments.is_some() {
return Ok(CallableValue::UnCallable(Value::Object(
self.arguments.unwrap(),
)));
}

self.scope_cell().read().resolve(name, self)
}

Expand Down
Loading