Lines
96.43 %
Functions
80 %
Branches
100 %
//! `DO*` (sequential-step variant) entry points. Inits and steps apply one
//! variable at a time; the shared `DoLoop.sequential` flag carries that to the
//! DO code in `do_form`.
use crate::ast::{Expr, WasmType};
use crate::compiler::context::CompileContext;
use crate::compiler::emit::FunctionEmitter;
use crate::error::{Error, Result};
use crate::runtime::SymbolTable;
use super::do_form::{compile_in, eval_loop};
use super::unroll::Pos;
const KIND: (&str, bool) = ("DO*", true);
pub(super) fn compile_do_star_for_stack(
ctx: &mut CompileContext,
emit: &mut FunctionEmitter,
symbols: &mut SymbolTable,
args: &[Expr],
) -> Result<WasmType> {
compile_in(ctx, emit, symbols, KIND, args, Pos::Stack)?
.ok_or_else(|| Error::Compile("internal: DO* in stack position left no value".to_string()))
}
pub(super) fn compile_do_star(
) -> Result<()> {
compile_in(ctx, emit, symbols, KIND, args, Pos::Value).map(|_| ())
pub(super) fn compile_do_star_for_effect(
compile_in(ctx, emit, symbols, KIND, args, Pos::Effect).map(|_| ())
pub(super) fn do_star_form(symbols: &mut SymbolTable, args: &[Expr]) -> Result<Expr> {
eval_loop(symbols, KIND, args)