Skip to content

Commit

Permalink
avm2: Simplify uses of GcCell<'gc, Class<'gc>>
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Apr 27, 2024
1 parent 15c076f commit d222033
Show file tree
Hide file tree
Showing 45 changed files with 548 additions and 596 deletions.
20 changes: 5 additions & 15 deletions core/src/avm2/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::avm2::{Avm2, Error};
use crate::context::{GcContext, UpdateContext};
use crate::string::{AvmAtom, AvmString};
use crate::tag_utils::SwfMovie;
use gc_arena::{Gc, GcCell};
use gc_arena::Gc;
use smallvec::SmallVec;
use std::cmp::{min, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -779,7 +779,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
&mut self,
method: Gc<'gc, BytecodeMethod<'gc>>,
index: Index<AbcClass>,
) -> Result<GcCell<'gc, Class<'gc>>, Error<'gc>> {
) -> Result<Class<'gc>, Error<'gc>> {
method.translation_unit().load_class(index.0, self)
}

Expand Down Expand Up @@ -1723,7 +1723,6 @@ impl<'a, 'gc> Activation<'a, 'gc> {
.instance_of()
.map(|cls| {
cls.inner_class_definition()
.read()
.name()
.to_qualified_name_err_message(self.context.gc_context)
})
Expand Down Expand Up @@ -2620,10 +2619,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
Ok(FrameControl::Continue)
}

fn op_is_type(
&mut self,
class: GcCell<'gc, Class<'gc>>,
) -> Result<FrameControl<'gc>, Error<'gc>> {
fn op_is_type(&mut self, class: Class<'gc>) -> Result<FrameControl<'gc>, Error<'gc>> {
let value = self.pop_stack();

let is_instance_of = value.is_of_type(self, class);
Expand Down Expand Up @@ -2652,10 +2648,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
Ok(FrameControl::Continue)
}

fn op_as_type(
&mut self,
class: GcCell<'gc, Class<'gc>>,
) -> Result<FrameControl<'gc>, Error<'gc>> {
fn op_as_type(&mut self, class: Class<'gc>) -> Result<FrameControl<'gc>, Error<'gc>> {
let value = self.pop_stack();

if value.is_of_type(self, class) {
Expand Down Expand Up @@ -2821,10 +2814,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
}

/// Implements `Op::Coerce`
fn op_coerce(
&mut self,
class: GcCell<'gc, Class<'gc>>,
) -> Result<FrameControl<'gc>, Error<'gc>> {
fn op_coerce(&mut self, class: Class<'gc>) -> Result<FrameControl<'gc>, Error<'gc>> {
let val = self.pop_stack();
let x = val.coerce_to_type(self, class)?;

Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/amf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn serialize_value<'gc>(
let name = class_to_alias(activation, class);

let mut attributes = EnumSet::empty();
if !class.inner_class_definition().read().is_sealed() {
if !class.inner_class_definition().is_sealed() {
attributes.insert(Attribute::Dynamic);
}

Expand Down
Loading

0 comments on commit d222033

Please sign in to comment.