Files
hakorune/src/parser/items/static_items.rs
tomoaki 86dfa30abe chore(joinir): Phase 286C-5 Step 3 - Remove unused imports
Ran `cargo fix --allow-dirty --lib` to automatically remove unused imports
across the codebase. This cleanup is standard maintenance and improves code
hygiene.

**Files Modified**:
- instruction_rewriter.rs: Removed 6 unused imports
  - block_remapper::remap_block_id
  - LoweringDecision
  - ParameterBindingBox
  - propagate_value_type_for_inst (2 occurrences)
  - apply_remapped_terminator
  - PhiAdjustment, ParameterBinding from scan_box
- Other files: Minor unused import cleanup (12 files total)

**No Functional Changes**: Pure cleanup, all tests expected to pass.

Phase 286C-5 progress: 3/4 steps complete

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 05:18:06 +09:00

88 lines
3.3 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!
* Static declaration parsing
* Handles both static functions and static boxes
*/
use crate::ast::{ASTNode, Span};
use crate::parser::common::ParserUtils;
use crate::parser::{NyashParser, ParseError};
use crate::tokenizer::TokenType;
impl NyashParser {
/// 静的宣言をパース - 🔥 static function / static box 記法
pub fn parse_static_declaration(&mut self) -> Result<ASTNode, ParseError> {
self.consume(TokenType::STATIC)?;
// 次のトークンで分岐: function か box か
match &self.current_token().token_type {
TokenType::FUNCTION => self.parse_static_function(),
TokenType::BOX => crate::parser::declarations::static_def::parse_static_box(self),
_ => {
let line = self.current_token().line;
Err(ParseError::UnexpectedToken {
found: self.current_token().token_type.clone(),
expected: "function or box after static".to_string(),
line,
})
}
}
}
/// 静的関数宣言をパース - static function Name() { ... }
fn parse_static_function(&mut self) -> Result<ASTNode, ParseError> {
self.consume(TokenType::FUNCTION)?;
// 関数名を取得Box名.関数名の形式をサポート)
let name = if let TokenType::IDENTIFIER(first_part) = &self.current_token().token_type {
let mut full_name = first_part.clone();
self.advance();
// ドット記法をチェックMath.min
if self.match_token(&TokenType::DOT) {
self.advance(); // DOTを消費
if let TokenType::IDENTIFIER(method_name) = &self.current_token().token_type {
full_name = format!("{}.{}", full_name, method_name);
self.advance();
} else {
let line = self.current_token().line;
return Err(ParseError::UnexpectedToken {
found: self.current_token().token_type.clone(),
expected: "method name after dot".to_string(),
line,
});
}
}
full_name
} else {
let line = self.current_token().line;
return Err(ParseError::UnexpectedToken {
found: self.current_token().token_type.clone(),
expected: "static function name".to_string(),
line,
});
};
// パラメータリストをパース
self.consume(TokenType::LPAREN)?;
// Phase 285A1.5: Use shared helper to prevent parser hangs on unsupported type annotations
let params = crate::parser::common::params::parse_param_name_list(self, "static method")?;
self.consume(TokenType::RPAREN)?;
// 関数本体をパース(共通ブロックヘルパー)
let body = self.parse_block_statements()?;
Ok(ASTNode::FunctionDeclaration {
name,
params,
body,
is_static: true, // 🔥 静的関数フラグを設定
is_override: false, // デフォルトは非オーバーライド
span: Span::unknown(),
})
}
}