Validated VM creator

pull/1/head
ondra05 2023-06-06 23:08:26 +02:00
parent 21a598df49
commit 1ba5e02b90
No known key found for this signature in database
GPG Key ID: 0DA6D2BB2285E881
2 changed files with 8 additions and 4 deletions

View File

@ -1,3 +1,5 @@
use crate::validate;
mod value;
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) {
use crate::bytecode::opcode::*;
loop {

View File

@ -1,7 +1,4 @@
use core::{
fmt::Debug,
ops::{Index, IndexMut},
};
use core::fmt::Debug;
/// # Safety
/// The macro invoker shall make sure that byte reinterpret-cast