feat: 支持 try-catch 语法字节码编译及缓存

This commit is contained in:
爱特每羊队
2026-06-07 21:31:05 +08:00
parent 3f41fe9d71
commit bd70fecea5
6 changed files with 210 additions and 6 deletions
+25 -1
View File
@@ -116,8 +116,32 @@ fn hash_statement(stmt: &Statement, h: &mut rustc_hash::FxHasher) {
}
}
}
Statement::ThrowStatement(_ts) => {
Statement::ThrowStatement(ts) => {
14u8.hash(h);
hash_expression(&ts.argument, h);
}
Statement::TryStatement(ts) => {
34u8.hash(h);
for s in &ts.block.body {
hash_statement(s, h);
}
if let Some(catch) = &ts.handler {
if let Some(param) = &catch.param {
if let oxide_parser::BindingPattern::BindingIdentifier(bi) =
&param.pattern
{
bi.name.as_str().hash(h);
}
}
for s in &catch.body.body {
hash_statement(s, h);
}
}
if let Some(finally) = &ts.finalizer {
for s in &finally.body {
hash_statement(s, h);
}
}
}
_ => {
std::mem::discriminant(stmt).hash(h);