avm2: Remove `_slot_local` methods as we no longer do anything special with slots.
This commit is contained in:
parent
5dcc3a58f2
commit
a112192c96
|
@ -1377,7 +1377,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
||||||
|
|
||||||
fn op_get_slot(&mut self, index: u32) -> Result<FrameControl<'gc>, Error> {
|
fn op_get_slot(&mut self, index: u32) -> Result<FrameControl<'gc>, Error> {
|
||||||
let object = self.context.avm2.pop().coerce_to_object(self)?;
|
let object = self.context.avm2.pop().coerce_to_object(self)?;
|
||||||
let value = object.get_slot(self, index)?;
|
let value = object.get_slot(index)?;
|
||||||
|
|
||||||
self.context.avm2.push(value);
|
self.context.avm2.push(value);
|
||||||
|
|
||||||
|
@ -1388,13 +1388,13 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
||||||
let value = self.context.avm2.pop();
|
let value = self.context.avm2.pop();
|
||||||
let object = self.context.avm2.pop().coerce_to_object(self)?;
|
let object = self.context.avm2.pop().coerce_to_object(self)?;
|
||||||
|
|
||||||
object.set_slot(self, index, value)?;
|
object.set_slot(index, value, self.context.gc_context)?;
|
||||||
|
|
||||||
Ok(FrameControl::Continue)
|
Ok(FrameControl::Continue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_get_global_slot(&mut self, index: u32) -> Result<FrameControl<'gc>, Error> {
|
fn op_get_global_slot(&mut self, index: u32) -> Result<FrameControl<'gc>, Error> {
|
||||||
let value = self.scope.unwrap().read().globals().get_slot(self, index)?;
|
let value = self.scope.unwrap().read().globals().get_slot(index)?;
|
||||||
|
|
||||||
self.context.avm2.push(value);
|
self.context.avm2.push(value);
|
||||||
|
|
||||||
|
@ -1408,7 +1408,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.read()
|
.read()
|
||||||
.globals()
|
.globals()
|
||||||
.set_slot(self, index, value)?;
|
.set_slot(index, value, self.context.gc_context)?;
|
||||||
|
|
||||||
Ok(FrameControl::Continue)
|
Ok(FrameControl::Continue)
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,31 +188,10 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve a slot by its index.
|
/// Retrieve a slot by its index.
|
||||||
#[allow(unused_mut)]
|
fn get_slot(self, id: u32) -> Result<Value<'gc>, Error>;
|
||||||
fn get_slot(
|
|
||||||
mut self,
|
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
|
||||||
id: u32,
|
|
||||||
) -> Result<Value<'gc>, Error> {
|
|
||||||
self.get_slot_local(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieve a slot by its index, ignoring uninstalled traits.
|
|
||||||
fn get_slot_local(self, id: u32) -> Result<Value<'gc>, Error>;
|
|
||||||
|
|
||||||
/// Set a slot by its index.
|
/// Set a slot by its index.
|
||||||
#[allow(unused_mut)]
|
|
||||||
fn set_slot(
|
fn set_slot(
|
||||||
mut self,
|
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
|
||||||
id: u32,
|
|
||||||
value: Value<'gc>,
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
self.set_slot_local(id, value, activation.context.gc_context)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set a slot by its index, ignoring uninstalled traits.
|
|
||||||
fn set_slot_local(
|
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
|
@ -220,18 +199,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
||||||
) -> Result<(), Error>;
|
) -> Result<(), Error>;
|
||||||
|
|
||||||
/// Initialize a slot by its index.
|
/// Initialize a slot by its index.
|
||||||
#[allow(unused_mut)]
|
|
||||||
fn init_slot(
|
fn init_slot(
|
||||||
mut self,
|
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
|
||||||
id: u32,
|
|
||||||
value: Value<'gc>,
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
self.init_slot_local(id, value, activation.context.gc_context)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize a slot by its index, ignoring uninstalled traits.
|
|
||||||
fn init_slot_local(
|
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
|
|
|
@ -94,26 +94,26 @@ macro_rules! impl_avm2_custom_object_properties {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_avm2_custom_object {
|
macro_rules! impl_avm2_custom_object {
|
||||||
($field:ident) => {
|
($field:ident) => {
|
||||||
fn get_slot_local(self, id: u32) -> Result<Value<'gc>, Error> {
|
fn get_slot(self, id: u32) -> Result<Value<'gc>, Error> {
|
||||||
self.0.read().$field.get_slot_local(id)
|
self.0.read().$field.get_slot(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_slot_local(
|
fn set_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).$field.set_slot_local(id, value, mc)
|
self.0.write(mc).$field.set_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_slot_local(
|
fn init_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).$field.init_slot_local(id, value, mc)
|
self.0.write(mc).$field.init_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
||||||
|
|
|
@ -133,26 +133,26 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
|
||||||
self.0.write(gc_context).delete_property(name)
|
self.0.write(gc_context).delete_property(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_slot_local(self, id: u32) -> Result<Value<'gc>, Error> {
|
fn get_slot(self, id: u32) -> Result<Value<'gc>, Error> {
|
||||||
self.0.read().get_slot_local(id)
|
self.0.read().get_slot(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_slot_local(
|
fn set_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).set_slot_local(id, value, mc)
|
self.0.write(mc).set_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_slot_local(
|
fn init_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).init_slot_local(id, value, mc)
|
self.0.write(mc).init_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
||||||
|
@ -409,9 +409,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(slot_id) = slot_id {
|
if let Some(slot_id) = slot_id {
|
||||||
// This doesn't need the non-local version of this property because
|
self.set_slot(slot_id, value, activation.context.gc_context)?;
|
||||||
// by the time this has called the slot was already installed
|
|
||||||
self.set_slot_local(slot_id, value, activation.context.gc_context)?;
|
|
||||||
Ok(Value::Undefined.into())
|
Ok(Value::Undefined.into())
|
||||||
} else if self.values.contains_key(name) {
|
} else if self.values.contains_key(name) {
|
||||||
let prop = self.values.get_mut(name).unwrap();
|
let prop = self.values.get_mut(name).unwrap();
|
||||||
|
@ -440,10 +438,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
let constr = self.as_constr();
|
let constr = self.as_constr();
|
||||||
if let Some(prop) = self.values.get_mut(name) {
|
if let Some(prop) = self.values.get_mut(name) {
|
||||||
if let Some(slot_id) = prop.slot_id() {
|
if let Some(slot_id) = prop.slot_id() {
|
||||||
// This doesn't need the non-local version of this property
|
self.init_slot(slot_id, value, activation.context.gc_context)?;
|
||||||
// because by the time this has called the slot was already
|
|
||||||
// installed
|
|
||||||
self.init_slot_local(slot_id, value, activation.context.gc_context)?;
|
|
||||||
Ok(Value::Undefined.into())
|
Ok(Value::Undefined.into())
|
||||||
} else {
|
} else {
|
||||||
prop.init(
|
prop.init(
|
||||||
|
@ -482,7 +477,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
can_delete
|
can_delete
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_slot_local(&self, id: u32) -> Result<Value<'gc>, Error> {
|
pub fn get_slot(&self, id: u32) -> Result<Value<'gc>, Error> {
|
||||||
self.slots
|
self.slots
|
||||||
.get(id as usize)
|
.get(id as usize)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
@ -491,7 +486,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a slot by its index.
|
/// Set a slot by its index.
|
||||||
pub fn set_slot_local(
|
pub fn set_slot(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
|
@ -505,7 +500,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize a slot by its index.
|
/// Initialize a slot by its index.
|
||||||
pub fn init_slot_local(
|
pub fn init_slot(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
|
|
|
@ -195,26 +195,26 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
||||||
self.0.write(gc_context).base.delete_property(multiname)
|
self.0.write(gc_context).base.delete_property(multiname)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_slot_local(self, id: u32) -> Result<Value<'gc>, Error> {
|
fn get_slot(self, id: u32) -> Result<Value<'gc>, Error> {
|
||||||
self.0.read().base.get_slot_local(id)
|
self.0.read().base.get_slot(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_slot_local(
|
fn set_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).base.set_slot_local(id, value, mc)
|
self.0.write(mc).base.set_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_slot_local(
|
fn init_slot(
|
||||||
self,
|
self,
|
||||||
id: u32,
|
id: u32,
|
||||||
value: Value<'gc>,
|
value: Value<'gc>,
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.0.write(mc).base.init_slot_local(id, value, mc)
|
self.0.write(mc).base.init_slot(id, value, mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
fn get_method(self, id: u32) -> Option<Object<'gc>> {
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl<'gc> Property<'gc> {
|
||||||
|
|
||||||
// This doesn't need the non-local version of this property because
|
// This doesn't need the non-local version of this property because
|
||||||
// by the time this has called the slot was already installed
|
// by the time this has called the slot was already installed
|
||||||
Property::Slot { slot_id, .. } => this.get_slot_local(*slot_id).map(|v| v.into()),
|
Property::Slot { slot_id, .. } => this.get_slot(*slot_id).map(|v| v.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue