boa-cat 0.4.0

Tree-walking ECMAScript interpreter built on ecma-syntax-cat. v0.4.0 opens the async track (chunk 1 of 5-7): adds a `Value::Promise(PromiseId)` variant + heap-stored `PromiseState::{Pending, Resolved, Rejected}` + synchronous `.then` / `.catch` dispatch with chained-promise return values. Embedders build promises from Rust via `Heap::alloc_promise(state)` -- a JS-side `Promise.resolve` / `reject` / `all` / `race` constructor surface lands in ecma-runtime-cat 0.3 once boa-cat 0.5 ships `await` and the microtask driver.
//! 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(_))
    }
}