boa-cat 0.5.0

Tree-walking ECMAScript interpreter built on ecma-syntax-cat. v0.5.0 adds the microtask driver (async track chunk 2 of 5-7): `promise::resolve(id, value, heap, fuel)` / `reject(...)` transition a Pending promise and recursively drain its queued `.then` / `.catch` handlers, settling each chained child via its callback (callback throws become Rejected; missing callbacks pass the value through). Test hooks `__resolve_promise(p, v)` / `__reject_promise(p, v)` are installed via `promise::install_test_hooks(env, heap)` so the driver is exercisable from JS ahead of the `Promise.resolve` / `await` surface in chunks 3-4.
//! Completion records: the spec's abrupt-completion mechanism, lifted into
//! a sum type the interpreter can return from statement evaluation.

use crate::value::Value;

/// The result of evaluating a statement.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Completion {
    /// Normal completion with an optional value (the result of an
    /// `Expression` statement, the body of a block, etc.).
    Normal(Value),
    /// `return value;`
    Return(Value),
    /// `throw value;`
    Throw(Value),
    /// `break;` (labeled break deferred to v0.2).
    Break,
    /// `continue;` (labeled continue deferred to v0.2).
    Continue,
}

impl Completion {
    /// Whether this completion is abrupt (anything other than `Normal`).
    #[must_use]
    pub fn is_abrupt(&self) -> bool {
        !matches!(self, Self::Normal(_))
    }
}