Implement validated wordcode execution with shared code objects and frames
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 14m27s
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 14m27s
This commit is contained in:
+33
-2
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user