mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 修复字节码缓存未存值导致错误命中问题
This commit is contained in:
@@ -23,6 +23,11 @@ fn hash_statement(stmt: &Statement, h: &mut rustc_hash::FxHasher) {
|
||||
Statement::VariableDeclaration(decl) => {
|
||||
1u8.hash(h);
|
||||
(decl.declarations.len() as u32).hash(h);
|
||||
for d in &decl.declarations {
|
||||
if let Some(init) = &d.init {
|
||||
hash_expression(init, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
Statement::ReturnStatement(ret) => {
|
||||
2u8.hash(h);
|
||||
@@ -108,6 +113,21 @@ fn hash_expression(expr: &Expression, h: &mut rustc_hash::FxHasher) {
|
||||
hash_expression(&cond.consequent, h);
|
||||
hash_expression(&cond.alternate, h);
|
||||
}
|
||||
Expression::Identifier(_) => {
|
||||
5u8.hash(h);
|
||||
}
|
||||
Expression::NumericLiteral(num) => {
|
||||
6u8.hash(h);
|
||||
num.value.to_bits().hash(h);
|
||||
}
|
||||
Expression::StringLiteral(s) => {
|
||||
7u8.hash(h);
|
||||
s.value.hash(h);
|
||||
}
|
||||
Expression::BooleanLiteral(b) => {
|
||||
8u8.hash(h);
|
||||
b.value.hash(h);
|
||||
}
|
||||
_ => {
|
||||
std::mem::discriminant(expr).hash(h);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user