✨ Major code quality improvements: • Fixed all unused variable and parameter warnings • Added appropriate #[allow(dead_code)] annotations • Renamed constants to follow Rust naming conventions • Achieved completely warning-free codebase 🔧 Key changes: • Parser expressions: Fixed arg_count and statement_count usage • MIR modules: Added dead_code allows for future-use code • Backend modules: Prefixed unused parameters with underscore • Effect constants: Renamed 'read' to 'READ_ALIAS' for conventions 📊 Results: • Before: 106 warnings (noisy build output) • After: 0 warnings (clean build) • Improvement: 100% warning reduction 🎯 This continues the bug fixing initiative "つづきのしゅうせいおねがいにゃ!" from Phase 9.75i (birth() fixes, static methods, Copilot apps). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
124 lines
5.2 KiB
Rust
124 lines
5.2 KiB
Rust
/*!
|
|
* Network and Communication Box Methods Module
|
|
*
|
|
* Contains method implementations for network-related Box types:
|
|
* - HttpClientBox (execute_http_method) - HTTP client operations
|
|
* - StreamBox (execute_stream_method) - Stream processing operations
|
|
*/
|
|
|
|
use super::super::*;
|
|
use crate::box_trait::NyashBox;
|
|
use crate::boxes::{HttpClientBox, StreamBox};
|
|
|
|
impl NyashInterpreter {
|
|
/// HttpClientBoxのメソッド呼び出しを実行
|
|
pub(in crate::interpreter) fn execute_http_method(&mut self, http_box: &HttpClientBox, method: &str, arguments: &[ASTNode])
|
|
-> Result<Box<dyn NyashBox>, RuntimeError> {
|
|
match method {
|
|
"get" => {
|
|
if arguments.len() != 1 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("get() expects 1 argument, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let url = self.execute_expression(&arguments[0])?;
|
|
Ok(http_box.http_get(url))
|
|
}
|
|
"post" => {
|
|
if arguments.len() != 2 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("post() expects 2 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let url = self.execute_expression(&arguments[0])?;
|
|
let body = self.execute_expression(&arguments[1])?;
|
|
Ok(http_box.post(url, body))
|
|
}
|
|
"put" => {
|
|
if arguments.len() != 2 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("put() expects 2 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let url = self.execute_expression(&arguments[0])?;
|
|
let body = self.execute_expression(&arguments[1])?;
|
|
Ok(http_box.put(url, body))
|
|
}
|
|
"delete" => {
|
|
if arguments.len() != 1 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("delete() expects 1 argument, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let url = self.execute_expression(&arguments[0])?;
|
|
Ok(http_box.delete(url))
|
|
}
|
|
"request" => {
|
|
if arguments.len() != 3 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("request() expects 3 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let method_arg = self.execute_expression(&arguments[0])?;
|
|
let url = self.execute_expression(&arguments[1])?;
|
|
let options = self.execute_expression(&arguments[2])?;
|
|
Ok(http_box.request(method_arg, url, options))
|
|
}
|
|
_ => Err(RuntimeError::InvalidOperation {
|
|
message: format!("Unknown method '{}' for HttpClientBox", method),
|
|
})
|
|
}
|
|
}
|
|
|
|
/// StreamBoxのメソッド呼び出しを実行
|
|
pub(in crate::interpreter) fn execute_stream_method(&mut self, stream_box: &StreamBox, method: &str, arguments: &[ASTNode])
|
|
-> Result<Box<dyn NyashBox>, RuntimeError> {
|
|
match method {
|
|
"write" => {
|
|
if arguments.len() != 1 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("write() expects 1 argument, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let data = self.execute_expression(&arguments[0])?;
|
|
Ok(stream_box.stream_write(data))
|
|
}
|
|
"read" => {
|
|
if arguments.len() != 1 {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("read() expects 1 argument, got {}", arguments.len()),
|
|
});
|
|
}
|
|
let count = self.execute_expression(&arguments[0])?;
|
|
Ok(stream_box.stream_read(count))
|
|
}
|
|
"position" => {
|
|
if !arguments.is_empty() {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("position() expects 0 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
Ok(stream_box.get_position())
|
|
}
|
|
"length" => {
|
|
if !arguments.is_empty() {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("length() expects 0 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
Ok(stream_box.get_length())
|
|
}
|
|
"reset" => {
|
|
if !arguments.is_empty() {
|
|
return Err(RuntimeError::InvalidOperation {
|
|
message: format!("reset() expects 0 arguments, got {}", arguments.len()),
|
|
});
|
|
}
|
|
Ok(stream_box.stream_reset())
|
|
}
|
|
_ => Err(RuntimeError::InvalidOperation {
|
|
message: format!("Unknown method '{}' for StreamBox", method),
|
|
})
|
|
}
|
|
}
|
|
} |