mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-12 23:18:03 -05:00
Box<dyn StackFrameTrait> -> StackFrame
This commit is contained in:
@@ -6,7 +6,7 @@ use super::operations;
|
||||
use super::bytecode_decoder::BytecodeDecoder;
|
||||
use super::bytecode_decoder::BytecodeType;
|
||||
use super::instruction::Instruction;
|
||||
use super::stack_frame_trait::{StackFrameTrait, FrameStepResult, CallResult};
|
||||
use super::stack_frame::{StackFrame, StackFrameTrait, FrameStepResult, CallResult};
|
||||
|
||||
pub struct BytecodeStackFrame {
|
||||
pub decoder: BytecodeDecoder,
|
||||
@@ -47,7 +47,7 @@ impl BytecodeStackFrame {
|
||||
|
||||
pub fn transfer_parameters(
|
||||
&mut self,
|
||||
new_frame: &mut Box<dyn StackFrameTrait>,
|
||||
new_frame: &mut StackFrame,
|
||||
) {
|
||||
let bytecode_type = self.decoder.decode_type();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::stack_frame_trait::{StackFrameTrait, FrameStepResult, CallResult};
|
||||
use super::stack_frame::{StackFrameTrait, FrameStepResult, CallResult};
|
||||
use super::vs_value::Val;
|
||||
|
||||
pub struct FirstStackFrame {
|
||||
|
||||
@@ -12,7 +12,7 @@ mod builtins;
|
||||
mod math;
|
||||
mod vs_class;
|
||||
mod bytecode_stack_frame;
|
||||
mod stack_frame_trait;
|
||||
mod stack_frame;
|
||||
mod first_stack_frame;
|
||||
|
||||
pub use virtual_machine::VirtualMachine;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use super::vs_value::Val;
|
||||
|
||||
pub type StackFrame = Box<dyn StackFrameTrait>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CallResult {
|
||||
pub return_: Val,
|
||||
@@ -9,7 +11,7 @@ pub struct CallResult {
|
||||
pub enum FrameStepResult {
|
||||
Continue,
|
||||
Pop(CallResult),
|
||||
Push(Box<dyn StackFrameTrait>),
|
||||
Push(StackFrame),
|
||||
}
|
||||
|
||||
pub trait StackFrameTrait {
|
||||
@@ -2,12 +2,12 @@ use std::rc::Rc;
|
||||
|
||||
use super::vs_value::{Val, ValTrait, LoadFunctionResult};
|
||||
use super::bytecode_decoder::BytecodeDecoder;
|
||||
use super::stack_frame_trait::{StackFrameTrait, FrameStepResult};
|
||||
use super::stack_frame::{StackFrame, FrameStepResult};
|
||||
use super::first_stack_frame::FirstStackFrame;
|
||||
|
||||
pub struct VirtualMachine {
|
||||
pub frame: Box<dyn StackFrameTrait>,
|
||||
pub stack: Vec<Box<dyn StackFrameTrait>>,
|
||||
pub frame: StackFrame,
|
||||
pub stack: Vec<StackFrame>,
|
||||
}
|
||||
|
||||
impl VirtualMachine {
|
||||
@@ -61,7 +61,7 @@ impl VirtualMachine {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn push(&mut self, mut frame: Box<dyn StackFrameTrait>) {
|
||||
pub fn push(&mut self, mut frame: StackFrame) {
|
||||
std::mem::swap(&mut self.frame, &mut frame);
|
||||
self.stack.push(frame);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
use super::vs_value::Val;
|
||||
use super::bytecode_stack_frame::BytecodeStackFrame;
|
||||
use super::bytecode_decoder::BytecodeDecoder;
|
||||
use super::stack_frame_trait::StackFrameTrait;
|
||||
use super::stack_frame::StackFrame;
|
||||
|
||||
pub struct VsFunction {
|
||||
pub bytecode: Rc<Vec<u8>>,
|
||||
@@ -30,7 +30,7 @@ impl VsFunction {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn make_frame(&self) -> Box<dyn StackFrameTrait> {
|
||||
pub fn make_frame(&self) -> StackFrame {
|
||||
let mut registers: Vec<Val> = Vec::with_capacity(self.register_count - 1);
|
||||
|
||||
registers.push(Val::Undefined);
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::vs_object::VsObject;
|
||||
use super::vs_array::VsArray;
|
||||
use super::vs_class::VsClass;
|
||||
use super::operations::{op_sub, op_submov};
|
||||
use super::stack_frame_trait::StackFrameTrait;
|
||||
use super::stack_frame::StackFrame;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Val {
|
||||
@@ -39,7 +39,7 @@ pub enum VsType {
|
||||
|
||||
pub enum LoadFunctionResult {
|
||||
NotAFunction,
|
||||
StackFrame(Box<dyn StackFrameTrait>),
|
||||
StackFrame(StackFrame),
|
||||
NativeFunction(fn(this: &mut Val, params: Vec<Val>) -> Val),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user