Refactor Value enum for Quote node
Replaces `Value::Object(Rc<dyn Object>)` for SyntaxNodes with a dedicated `Value::Quote(Rc<SyntaxNode>)`. This provides better type safety and clarity when dealing with AST nodes as values. Refactor Value enum for Quote node This commit introduces a new `Value::Quote` variant to represent quoted AST nodes directly, replacing the generic `Value::Object` for this purpose. This change simplifies the handling of quoted nodes by: - Directly storing an `Rc<SyntaxNode>` instead of relying on dynamic downcasting from `Rc<dyn Object>`. - Streamlining macro expansion logic by removing the need to check for `SyntaxNode` within `Value::Object`. - Improving type safety and explicitness in the `Value` enum.
This commit is contained in:
@@ -22,7 +22,7 @@ use crate::ast::compiler::optimizer::Optimizer;
|
||||
use crate::ast::compiler::specializer::{FunctionRegistry, MonoCache, Specializer};
|
||||
use crate::ast::rtl::{self, intrinsics};
|
||||
use crate::ast::types::{
|
||||
NativeFunction, NodeIdentity, Object, Purity, SourceLocation, StaticType, Value,
|
||||
NativeFunction, NodeIdentity, Purity, SourceLocation, StaticType, Value,
|
||||
};
|
||||
|
||||
use crate::ast::diagnostics::{DiagnosticLevel, Diagnostics};
|
||||
@@ -121,7 +121,7 @@ impl MacroEvaluator for RuntimeMacroEvaluator {
|
||||
if let SyntaxKind::Identifier { symbol: sym, .. } = &node.kind
|
||||
&& let Some(arg_node) = bindings.get(&sym.name)
|
||||
{
|
||||
return Ok(Value::Object(Rc::new(arg_node.clone()) as Rc<dyn Object>));
|
||||
return Ok(Value::Quote(Rc::new(arg_node.clone())));
|
||||
}
|
||||
|
||||
let mut diag = Diagnostics::new();
|
||||
|
||||
Reference in New Issue
Block a user