chore: clippy
This commit is contained in:
parent
1311b0a3d0
commit
1f5979f168
|
@ -589,7 +589,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
||||||
let new_slot_id = self
|
let new_slot_id = self
|
||||||
.vtable()
|
.vtable()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.install_const_trait_late(mc, name, value.clone());
|
.install_const_trait_late(mc, name, value);
|
||||||
self.base_mut(mc)
|
self.base_mut(mc)
|
||||||
.install_const_slot_late(new_slot_id, value);
|
.install_const_slot_late(new_slot_id, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,11 +154,9 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
let value = self.values.get(&local_name);
|
let value = self.values.get(&local_name);
|
||||||
|
|
||||||
if let Some(value) = value {
|
if let Some(value) = value {
|
||||||
return Ok(value.clone());
|
return Ok(*value);
|
||||||
} else {
|
} else if let Some(proto) = self.proto() {
|
||||||
if let Some(proto) = self.proto() {
|
return proto.get_property_local(multiname, activation);
|
||||||
return proto.get_property_local(multiname, activation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: Unresolvable properties on dynamic classes are treated
|
// Special case: Unresolvable properties on dynamic classes are treated
|
||||||
|
@ -169,9 +167,9 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
.map(|cls| cls.inner_class_definition().read().is_sealed())
|
.map(|cls| cls.inner_class_definition().read().is_sealed())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
return Err(format!("Cannot get undefined property {:?}", local_name).into());
|
Err(format!("Cannot get undefined property {:?}", local_name).into())
|
||||||
} else {
|
} else {
|
||||||
return Ok(Value::Undefined);
|
Ok(Value::Undefined)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +275,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
||||||
let default_slots = vtable.default_slots();
|
let default_slots = vtable.default_slots();
|
||||||
for value in default_slots.deref() {
|
for value in default_slots.deref() {
|
||||||
if let Some(value) = value {
|
if let Some(value) = value {
|
||||||
self.slots.push(value.clone());
|
self.slots.push(*value);
|
||||||
} else {
|
} else {
|
||||||
self.slots.push(Value::Undefined)
|
self.slots.push(Value::Undefined)
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl<'gc, V> PropertyMap<'gc, V> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|v| {
|
.filter_map(|v| {
|
||||||
v.iter()
|
v.iter()
|
||||||
.filter(|(n, _)| name.namespace_set().find(|ns| *ns == n).is_some())
|
.filter(|(n, _)| name.namespace_set().any(|ns| *ns == *n))
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
.next()
|
.next()
|
||||||
})
|
})
|
||||||
|
|
|
@ -117,6 +117,7 @@ impl<'gc> ScopeChain<'gc> {
|
||||||
self.domain
|
self.domain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::collapsible_if)]
|
||||||
pub fn find(
|
pub fn find(
|
||||||
&self,
|
&self,
|
||||||
multiname: &Multiname<'gc>,
|
multiname: &Multiname<'gc>,
|
||||||
|
@ -134,11 +135,9 @@ impl<'gc> ScopeChain<'gc> {
|
||||||
// But no matter what, we always search traits first.
|
// But no matter what, we always search traits first.
|
||||||
if values.has_trait(multiname) {
|
if values.has_trait(multiname) {
|
||||||
return Ok(Some(values));
|
return Ok(Some(values));
|
||||||
} else {
|
} else if scope.with() || depth == 0 {
|
||||||
if scope.with() || depth == 0 {
|
if values.has_own_property(multiname) {
|
||||||
if values.has_own_property(multiname) {
|
return Ok(Some(values));
|
||||||
return Ok(Some(values));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +197,7 @@ impl<'gc> ScopeStack<'gc> {
|
||||||
/// The `global` parameter indicates whether we are on global$init (script initializer).
|
/// The `global` parameter indicates whether we are on global$init (script initializer).
|
||||||
/// When the `global` parameter is true, the scope at depth 0 is considered the global scope, and is
|
/// When the `global` parameter is true, the scope at depth 0 is considered the global scope, and is
|
||||||
/// searched for dynamic properties.
|
/// searched for dynamic properties.
|
||||||
|
#[allow(clippy::collapsible_if)]
|
||||||
pub fn find(
|
pub fn find(
|
||||||
&self,
|
&self,
|
||||||
multiname: &Multiname<'gc>,
|
multiname: &Multiname<'gc>,
|
||||||
|
@ -208,14 +208,12 @@ impl<'gc> ScopeStack<'gc> {
|
||||||
|
|
||||||
if values.has_trait(multiname) {
|
if values.has_trait(multiname) {
|
||||||
return Ok(Some(values));
|
return Ok(Some(values));
|
||||||
} else {
|
} else if scope.with() || (global && depth == 0) {
|
||||||
// We search the dynamic properties if either conditions are met:
|
// We search the dynamic properties if either conditions are met:
|
||||||
// 1. Scope is a `with` scope
|
// 1. Scope is a `with` scope
|
||||||
// 2. We are at depth 0 AND we are at global$init (script initializer).
|
// 2. We are at depth 0 AND we are at global$init (script initializer).
|
||||||
if scope.with() || (global && depth == 0) {
|
if values.has_own_property(multiname) {
|
||||||
if values.has_own_property(multiname) {
|
return Ok(Some(values));
|
||||||
return Ok(Some(values));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ impl<'gc> VTable<'gc> {
|
||||||
///
|
///
|
||||||
/// This should be run during the class finalization step, before instances
|
/// This should be run during the class finalization step, before instances
|
||||||
/// are linked (as instances will further add traits to the list).
|
/// are linked (as instances will further add traits to the list).
|
||||||
|
#[allow(clippy::if_same_then_else)]
|
||||||
pub fn init_vtable(
|
pub fn init_vtable(
|
||||||
self,
|
self,
|
||||||
defining_class: Option<ClassObject<'gc>>,
|
defining_class: Option<ClassObject<'gc>>,
|
||||||
|
@ -231,25 +232,23 @@ impl<'gc> VTable<'gc> {
|
||||||
| TraitKind::Class { slot_id, .. } => {
|
| TraitKind::Class { slot_id, .. } => {
|
||||||
let slot_id = *slot_id;
|
let slot_id = *slot_id;
|
||||||
|
|
||||||
let value = trait_to_default_value(scope, &trait_data, activation);
|
let value = trait_to_default_value(scope, trait_data, activation);
|
||||||
let value = Some(value);
|
let value = Some(value);
|
||||||
|
|
||||||
let new_slot_id = if slot_id == 0 {
|
let new_slot_id = if slot_id == 0 {
|
||||||
default_slots.push(value);
|
default_slots.push(value);
|
||||||
default_slots.len() as u32 - 1
|
default_slots.len() as u32 - 1
|
||||||
|
} else if let Some(Some(_)) = default_slots.get(slot_id as usize) {
|
||||||
|
// slot_id conflict
|
||||||
|
default_slots.push(value);
|
||||||
|
default_slots.len() as u32 - 1
|
||||||
} else {
|
} else {
|
||||||
if let Some(Some(_)) = default_slots.get(slot_id as usize) {
|
if slot_id as usize >= default_slots.len() {
|
||||||
// slot_id conflict
|
default_slots.resize_with(slot_id as usize + 1, Default::default);
|
||||||
default_slots.push(value);
|
|
||||||
default_slots.len() as u32 - 1
|
|
||||||
} else {
|
|
||||||
if slot_id as usize >= default_slots.len() {
|
|
||||||
default_slots.resize_with(slot_id as usize + 1, Default::default);
|
|
||||||
}
|
|
||||||
default_slots[slot_id as usize] = value;
|
|
||||||
slot_id
|
|
||||||
}
|
}
|
||||||
} as u32;
|
default_slots[slot_id as usize] = value;
|
||||||
|
slot_id
|
||||||
|
};
|
||||||
|
|
||||||
let new_prop = match trait_data.kind() {
|
let new_prop = match trait_data.kind() {
|
||||||
TraitKind::Slot { .. } | TraitKind::Function { .. } => {
|
TraitKind::Slot { .. } | TraitKind::Function { .. } => {
|
||||||
|
@ -343,8 +342,8 @@ fn trait_to_default_value<'gc>(
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
activation: &mut Activation<'_, 'gc, '_>,
|
||||||
) -> Value<'gc> {
|
) -> Value<'gc> {
|
||||||
match trait_data.kind() {
|
match trait_data.kind() {
|
||||||
TraitKind::Slot { default_value, .. } => default_value.clone(),
|
TraitKind::Slot { default_value, .. } => *default_value,
|
||||||
TraitKind::Const { default_value, .. } => default_value.clone(),
|
TraitKind::Const { default_value, .. } => *default_value,
|
||||||
TraitKind::Function { function, .. } => {
|
TraitKind::Function { function, .. } => {
|
||||||
FunctionObject::from_function(activation, function.clone(), scope)
|
FunctionObject::from_function(activation, function.clone(), scope)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in New Issue