forked from AbleOS/holey-bytes
Validated VM creator
This commit is contained in:
parent
bb3a472eeb
commit
8d6e7af9d8
|
@ -1,3 +1,5 @@
|
||||||
|
use crate::validate;
|
||||||
|
|
||||||
mod value;
|
mod value;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
@ -43,6 +45,11 @@ impl<'a> Vm<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_validated(program: &'a [u8]) -> Result<Self, validate::Error> {
|
||||||
|
validate::validate(program)?;
|
||||||
|
Ok(unsafe { Self::new_unchecked(program) })
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
use crate::bytecode::opcode::*;
|
use crate::bytecode::opcode::*;
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use core::{
|
use core::fmt::Debug;
|
||||||
fmt::Debug,
|
|
||||||
ops::{Index, IndexMut},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// The macro invoker shall make sure that byte reinterpret-cast
|
/// The macro invoker shall make sure that byte reinterpret-cast
|
||||||
|
|
Loading…
Reference in a new issue