From 198bb7d428b8db540deafe8525579a98c718b4c8 Mon Sep 17 00:00:00 2001
From: pjh456 <147148383@qq.com>
Date: Wed, 5 Aug 2026 01:03:42 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E8=AF=AD?=
=?UTF-8?q?=E5=8F=A5=E8=AE=A1=E6=95=B0=E8=BE=85=E5=8A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crates/oxide_compiler/src/compiler.rs | 12 +++-------
.../src/stmt/basic/expression.rs | 6 -----
crates/oxide_compiler/src/stmt/basic/mod.rs | 2 --
.../src/stmt/basic/return_stmt.rs | 7 ------
crates/oxide_compiler/src/stmt/block.rs | 12 ----------
.../src/stmt/declaration/class_decl.rs | 6 -----
.../src/stmt/declaration/function_decl.rs | 13 +----------
.../src/stmt/declaration/mod.rs | 9 --------
.../src/stmt/declaration/var.rs | 23 -------------------
.../oxide_compiler/src/stmt/exception/mod.rs | 1 -
.../src/stmt/exception/throw.rs | 5 ----
11 files changed, 4 insertions(+), 92 deletions(-)
diff --git a/crates/oxide_compiler/src/compiler.rs b/crates/oxide_compiler/src/compiler.rs
index 3944b7b8..9bf3ccf5 100644
--- a/crates/oxide_compiler/src/compiler.rs
+++ b/crates/oxide_compiler/src/compiler.rs
@@ -1280,14 +1280,8 @@ impl Compiler {
pub(crate) fn count_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) {
match stmt {
- Statement::ExpressionStatement(_)
- | Statement::ReturnStatement(_)
- | Statement::BreakStatement(_)
- | Statement::ContinueStatement(_)
- | Statement::LabeledStatement(_) => self.count_basic(stmt, ctx),
- Statement::BlockStatement(_) => self.count_block_domain(stmt, ctx),
- Statement::VariableDeclaration(_) | Statement::FunctionDeclaration(_) | Statement::ClassDeclaration(_) => {
- self.count_declaration_domain(stmt, ctx)
+ Statement::BreakStatement(_) | Statement::ContinueStatement(_) | Statement::LabeledStatement(_) => {
+ self.count_basic(stmt, ctx)
}
Statement::IfStatement(_) => self.count_control_domain(stmt, ctx),
Statement::WhileStatement(_)
@@ -1296,7 +1290,7 @@ impl Compiler {
| Statement::ForInStatement(_)
| Statement::ForOfStatement(_) => self.count_iteration_domain(stmt, ctx),
Statement::SwitchStatement(_) => self.count_switch_domain(stmt, ctx),
- Statement::ThrowStatement(_) | Statement::TryStatement(_) => self.count_exception_domain(stmt, ctx),
+ Statement::TryStatement(_) => self.count_exception_domain(stmt, ctx),
_ => {}
}
}
diff --git a/crates/oxide_compiler/src/stmt/basic/expression.rs b/crates/oxide_compiler/src/stmt/basic/expression.rs
index f1767632..00861c22 100644
--- a/crates/oxide_compiler/src/stmt/basic/expression.rs
+++ b/crates/oxide_compiler/src/stmt/basic/expression.rs
@@ -2,12 +2,6 @@ use crate::compiler::{CompileCtx, Compiler};
use oxide_parser::Statement;
impl Compiler {
- pub(super) fn count_expression_statement(
- &self, stmt: &oxide_parser::ExpressionStatement<'_>, ctx: &mut CompileCtx,
- ) {
- self.count_expression(&stmt.expression, ctx);
- }
-
fn emit_expression_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result