Implement validated wordcode execution with shared code objects and frames
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 14m27s

This commit is contained in:
2026-10-18 20:41:56 +08:00
parent 50e8fcb5e7
commit 6fa95b64b0
18 changed files with 2327 additions and 152 deletions
+33 -2
View File
@@ -1,4 +1,5 @@
//! Embeddable object runtime. No language type system, parser or executor.
//! Embeddable object runtime and a small wordcode interpreter. No parser or
//! Python language type system; wordcode is not CPython bytecode compatible.
//!
//! ```
//! use aster_core::{Value, Vm};
@@ -13,19 +14,49 @@
//! assert_eq!(vm.object_count(), 0);
//! # Ok::<(), aster_core::VmError>(())
//! ```
//!
//! Execute validated wordcode without a source parser:
//! ```
//! use aster_core::{CodeLayout, EndorCode, Instruction, Opcode, Value, Vm};
//! let mut vm = Vm::new()?;
//! let globals = vm.new_dict()?;
//! let code = EndorCode::from_instructions(
//! &[
//! Instruction::new(Opcode::LoadConst, 0),
//! Instruction::simple(Opcode::ReturnValue),
//! ],
//! vec![Value::Text("Hello Endor".into())],
//! CodeLayout::default(),
//! )?;
//! let code = vm.new_code(code)?;
//! let result = vm.execute(code, globals)?;
//! assert_eq!(result, Value::Text("Hello Endor".into()));
//! vm.release_value(result)?; // Object results own one external reference.
//! vm.release(code)?;
//! vm.release(globals)?;
//! assert_eq!(vm.object_count(), 0);
//! # Ok::<(), aster_core::VmError>(())
//! ```
mod builtins;
mod code;
mod eval;
mod frame;
mod heap;
mod instruction;
mod number;
mod object;
mod vm;
mod vm_builtins;
pub use builtins::{
EndorBaseExceptionObject, EndorCellObject, EndorCode, EndorDictObject, EndorFunctionObject,
EndorBaseExceptionObject, EndorCellObject, EndorDictObject, EndorFunctionObject,
EndorStringObject, EndorTracebackEntry,
};
pub use code::{CodeLayout, EndorCode, EndorCodeObject};
pub use frame::{EndorFrame, ExecutionLimits, ExecutionLocation};
pub use heap::ObjectRef;
pub use instruction::{DecodedInstruction, Instruction, Opcode};
pub use number::{
EndorDecimal, EndorInteger, EndorNumber, EndorNumberObject, EndorRational, EndorReal,
};