Lines
71.43 %
Functions
20 %
Branches
100 %
//! `QUOTE` special form. Evaluation returns the argument verbatim;
//! compilation routes through `compile_quoted_expr` so list literals
//! materialize via the proper cons-cell allocator instead of being
//! re-evaluated.
use crate::ast::Expr;
use crate::compiler::context::CompileContext;
use crate::compiler::emit::FunctionEmitter;
use crate::compiler::expr::compile_quoted_expr;
use crate::error::{Error, Result};
use crate::runtime::SymbolTable;
pub(super) fn eval_quote(_symbols: &mut SymbolTable, args: &[Expr]) -> Result<Expr> {
quote(args)
}
pub(super) fn spec_compile_quote(
ctx: &mut CompileContext,
emit: &mut FunctionEmitter,
_symbols: &mut SymbolTable,
args: &[Expr],
) -> Result<()> {
compile_quote(ctx, emit, args)
pub(super) fn compile_quote(
if args.len() != 1 {
return Err(Error::Arity {
name: "quote".to_string(),
expected: 1,
actual: args.len(),
});
compile_quoted_expr(ctx, emit, &args[0])
pub(super) fn quote(args: &[Expr]) -> Result<Expr> {
Ok(args[0].clone())