mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
feat: 支持公开类字段和静态块
This commit is contained in:
@@ -168,13 +168,21 @@ fn hash_property_key(key: &PropertyKey, h: &mut rustc_hash::FxHasher) {
|
||||
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);
|
||||
}
|
||||
_ => {}
|
||||
_ => {
|
||||
hash_expression(key.to_expression(), h);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -185,6 +193,9 @@ fn hash_class_element(element: &ClassElement, h: &mut rustc_hash::FxHasher) {
|
||||
method.computed.hash(h);
|
||||
std::mem::discriminant(&method.kind).hash(h);
|
||||
hash_property_key(&method.key, h);
|
||||
if method.computed {
|
||||
hash_property_key(&method.key, h);
|
||||
}
|
||||
(method.value.params.items.len() as u32).hash(h);
|
||||
if let Some(body) = &method.value.body {
|
||||
for stmt in &body.statements {
|
||||
@@ -192,6 +203,19 @@ fn hash_class_element(element: &ClassElement, h: &mut rustc_hash::FxHasher) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ClassElement::PropertyDefinition(prop) => {
|
||||
prop.r#static.hash(h);
|
||||
prop.computed.hash(h);
|
||||
hash_property_key(&prop.key, h);
|
||||
if let Some(value) = &prop.value {
|
||||
hash_expression(value, h);
|
||||
}
|
||||
}
|
||||
ClassElement::StaticBlock(block) => {
|
||||
for stmt in &block.body {
|
||||
hash_statement(stmt, h);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user