avm1: address Scope nitpicks
This commit is contained in:
parent
05e3e6434b
commit
9529a1cbdb
|
@ -2220,8 +2220,10 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
value => {
|
||||
// Note that primitives get boxed at this point.
|
||||
let object = value.coerce_to_object(self);
|
||||
let with_scope =
|
||||
Scope::new_with_scope(self.scope(), object, self.context.gc_context);
|
||||
let with_scope = Gc::allocate(
|
||||
self.context.gc_context,
|
||||
Scope::new_with_scope(self.scope(), object),
|
||||
);
|
||||
let mut new_activation = self.with_new_scope("[With]", with_scope);
|
||||
if let ReturnType::Explicit(value) = new_activation.run_actions(code)? {
|
||||
Ok(FrameControl::Return(ReturnType::Explicit(value)))
|
||||
|
|
|
@ -29,7 +29,7 @@ pub enum ScopeClass {
|
|||
}
|
||||
|
||||
/// Represents a scope chain for an AVM1 activation.
|
||||
#[derive(Copy, Clone, Debug, Collect)]
|
||||
#[derive(Clone, Debug, Collect)]
|
||||
#[collect(no_drop)]
|
||||
pub struct Scope<'gc> {
|
||||
parent: Option<Gc<'gc, Scope<'gc>>>,
|
||||
|
@ -39,7 +39,7 @@ pub struct Scope<'gc> {
|
|||
|
||||
impl<'gc> Scope<'gc> {
|
||||
/// Construct a global scope (one without a parent).
|
||||
pub fn from_global_object(globals: Object<'gc>) -> Scope<'gc> {
|
||||
pub fn from_global_object(globals: Object<'gc>) -> Self {
|
||||
Scope {
|
||||
parent: None,
|
||||
class: ScopeClass::Global,
|
||||
|
@ -48,7 +48,7 @@ impl<'gc> Scope<'gc> {
|
|||
}
|
||||
|
||||
/// Construct a child scope of another scope.
|
||||
pub fn new_local_scope(parent: Gc<'gc, Self>, mc: MutationContext<'gc, '_>) -> Scope<'gc> {
|
||||
pub fn new_local_scope(parent: Gc<'gc, Self>, mc: MutationContext<'gc, '_>) -> Self {
|
||||
Scope {
|
||||
parent: Some(parent),
|
||||
class: ScopeClass::Local,
|
||||
|
@ -63,7 +63,7 @@ impl<'gc> Scope<'gc> {
|
|||
clip: Object<'gc>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Gc<'gc, Self> {
|
||||
let mut scope = *parent;
|
||||
let mut scope = (*parent).clone();
|
||||
|
||||
if scope.class == ScopeClass::Target {
|
||||
scope.values = clip;
|
||||
|
@ -78,23 +78,16 @@ impl<'gc> Scope<'gc> {
|
|||
///
|
||||
/// A with block adds an object to the top of the scope chain, so unqualified
|
||||
/// references will try to resolve on that object first.
|
||||
pub fn new_with_scope(
|
||||
parent_scope: Gc<'gc, Self>,
|
||||
with_object: Object<'gc>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Gc<'gc, Self> {
|
||||
Gc::allocate(
|
||||
mc,
|
||||
Scope {
|
||||
parent: Some(parent_scope),
|
||||
class: ScopeClass::With,
|
||||
values: with_object,
|
||||
},
|
||||
)
|
||||
pub fn new_with_scope(parent_scope: Gc<'gc, Self>, with_object: Object<'gc>) -> Self {
|
||||
Scope {
|
||||
parent: Some(parent_scope),
|
||||
class: ScopeClass::With,
|
||||
values: with_object,
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct an arbitrary scope.
|
||||
pub fn new(parent: Gc<'gc, Self>, class: ScopeClass, with_object: Object<'gc>) -> Scope<'gc> {
|
||||
pub fn new(parent: Gc<'gc, Self>, class: ScopeClass, with_object: Object<'gc>) -> Self {
|
||||
Scope {
|
||||
parent: Some(parent),
|
||||
class,
|
||||
|
|
Loading…
Reference in New Issue