Skip to main content

Crate mirascript

Crate mirascript 

Source
Expand description

§MiraScript for Rust

mirascript is the batteries-included Rust interface to the MiraScript compiler and virtual machine. It re-exports the complete mirascript-vm API, including the MiraRecord and MiraArray derive macros.

Compilation and execution are independent. A compiled script is reusable, while the runtime owns globals, standard-library values, execution state, and its arena:

use mirascript::{MiraValue, Runtime, compile};

let script = compile("answer + 1")?;
let mut runtime = Runtime::new();
runtime.insert_global("answer", 41)?;

assert_eq!(runtime.run(&script)?, MiraValue::number(42.0));

Compiler configuration and bytecode definitions are available through core, and the complete runtime crate is also available as vm.

let config = mirascript::core::CompileConfig::new();
let script = mirascript::compile_with("40 + 2", &config)?;
let mut runtime = mirascript::Runtime::new();

assert_eq!(
    runtime.run(&script)?,
    mirascript::MiraValue::number(42.0),
);

Re-exports§

pub use mirascript_vm as vm;

Modules§

core
mirascript-core

Macros§

global_builtin
A macro to define a global builtin function and insert it into the runtime.

Structs§

CompileConfig
Diagnostics
Represents a diagnostic message produced by the compiler.
MiraArrayEntry
One element produced by MiraArray::iter.
MiraHandle
A compact, runtime-checked handle to an arena-managed value.
MiraNativeFn
A named, single-threaded native function callable from MiraScript.
MiraRecordEntry
One field produced by MiraRecord::iter.
MiraScript
A validated, reusable MiraScript program.
MiraValue
A compact value understood by the Rust VM.
RunOptions
Limits and injectable providers used for each Runtime execution.
Runtime
Persistent state used to execute compiled MiraScript programs.
RuntimeTrace
Runtime source location and call stack attached to an execution error.
ScriptId
Stable identity shared by clones of one compiled script.

Enums§

ConversionPathSegment
One segment in a failed Rust value conversion path.
ConversionReason
The reason a MiraScript value could not be converted to a Rust type.
DiagnosticCode
Diagnostic codes for MiraScript compiler and tools.
DiagnosticPositionEncoding
Encoding for counting positions in diagnostics.
InputMode
Mode for reading input.
InvalidBytecodeReason
Represents the reason for an invalid bytecode error.
MiraError
An error produced while compiling, decoding, executing, or bridging values.
MiraManageable
An owned value waiting to be inserted into a Runtime arena.
MiraType
A MiraScript runtime value category.
RuntimeErrorKind
A VM or standard-library execution failure.

Traits§

MiraArray
A read-only MiraScript array view.
MiraExtern
Reserved marker for a future MiraScript external value implementation.
MiraFunction
A callable MiraScript function implementation.
MiraModule
A named collection of MiraScript-visible values.
MiraRecord
A read-only MiraScript record view.
MiraShapedArray
A fixed-shape array whose length is known from its Rust type.
MiraShapedRecord
A fixed-shape record whose field names are known from its Rust type.
RuntimeProviders
Host capabilities used by non-deterministic standard-library functions.
TryFromMira
A trait for converting values from the runtime into Rust types.

Functions§

compile
Compile source with the default compiler configuration.
compile_with
Compile source with an explicit CompileConfig.
default_runtime_providers
Return a reference-counted handle to the default runtime providers.

Type Aliases§

MiraArrayHandle
A handle to a MiraScript array value.
MiraArrayIter
A sequential iterator over array elements.
MiraExternHandle
A handle to a MiraScript extern value.
MiraFunctionHandle
A handle to a MiraScript function value.
MiraModuleHandle
A handle to a MiraScript module value.
MiraRecordHandle
A handle to a MiraScript record value.
MiraRecordIter
A sequential iterator over record fields.
MiraStringHandle
A handle to a MiraScript string value.
Result
Result type returned by the MiraScript VM.

Attribute Macros§

mira
Expose a Rust function or inline module as a MiraScript value.

Derive Macros§

MiraArray
Derive a read-only MiraScript array view for a tuple struct.
MiraRecord
Derive a read-only MiraScript record view for a named-field struct.