mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 19:21:11 +08:00
refactor: 拆分 compiler hash 分发逻辑
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
use super::*;
|
||||
|
||||
pub(super) fn hash_property_key(key: &PropertyKey, h: &mut rustc_hash::FxHasher, include_binding_names: bool) {
|
||||
hash_match!(HashDomain::PropertyKey, key, h, {
|
||||
PropertyKey::StaticIdentifier(ident) => {
|
||||
ident.name.as_str().hash(h);
|
||||
}
|
||||
PropertyKey::Identifier(ident) => {
|
||||
ident.name.as_str().hash(h);
|
||||
}
|
||||
PropertyKey::StringLiteral(s) => {
|
||||
s.value.hash(h);
|
||||
}
|
||||
PropertyKey::NumericLiteral(n) => {
|
||||
n.value.to_bits().hash(h);
|
||||
}
|
||||
PropertyKey::PrivateIdentifier(pi) => {
|
||||
pi.name.as_str().hash(h);
|
||||
}
|
||||
_ => {
|
||||
expression::hash_expression(key.to_expression(), h, include_binding_names);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn hash_object_property_kind(
|
||||
prop: &ObjectPropertyKind, h: &mut rustc_hash::FxHasher, include_binding_names: bool,
|
||||
) {
|
||||
hash_match!(HashDomain::ObjectPropertyKind, prop, h, {
|
||||
ObjectPropertyKind::ObjectProperty(p) => {
|
||||
std::mem::discriminant(&p.kind).hash(h);
|
||||
p.method.hash(h);
|
||||
p.computed.hash(h);
|
||||
hash_property_key(&p.key, h, include_binding_names);
|
||||
expression::hash_expression(&p.value, h, include_binding_names);
|
||||
}
|
||||
ObjectPropertyKind::SpreadProperty(_) => {}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user