feat: 支持访问器描述符与 get/set 语法

This commit is contained in:
2026-06-09 16:22:24 +08:00
parent 15f1bce1e5
commit a654b5834f
13 changed files with 457 additions and 77 deletions
+22 -1
View File
@@ -1,4 +1,6 @@
use oxide_parser::{ClassElement, Expression, ForStatementInit, PropertyKey, SimpleAssignmentTarget, Statement};
use oxide_parser::{
ClassElement, Expression, ForStatementInit, ObjectPropertyKind, PropertyKey, SimpleAssignmentTarget, Statement,
};
pub fn structural_hash(program: &oxide_parser::Program) -> u64 {
use std::hash::Hasher;
@@ -329,6 +331,25 @@ fn hash_expression(expr: &Expression, h: &mut rustc_hash::FxHasher) {
hash_class_element(element, h);
}
}
Expression::ObjectExpression(obj) => {
20u8.hash(h);
(obj.properties.len() as u32).hash(h);
for prop in &obj.properties {
match prop {
ObjectPropertyKind::ObjectProperty(p) => {
0u8.hash(h);
std::mem::discriminant(&p.kind).hash(h);
p.method.hash(h);
p.computed.hash(h);
hash_property_key(&p.key, h);
hash_expression(&p.value, h);
}
ObjectPropertyKind::SpreadProperty(_) => {
1u8.hash(h);
}
}
}
}
Expression::NewExpression(ne) => {
14u8.hash(h);
hash_expression(&ne.callee, h);