mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-12 15:08:07 -05:00
Add unimplemented new instruction
This commit is contained in:
@@ -217,6 +217,7 @@ impl<'a> Assembler<'a> {
|
||||
("jmpif", Instruction::JmpIf),
|
||||
("unary+", Instruction::UnaryPlus),
|
||||
("unary-", Instruction::UnaryMinus),
|
||||
("new", Instruction::New),
|
||||
]);
|
||||
|
||||
for (word, instruction) in instruction_word_map {
|
||||
@@ -800,6 +801,7 @@ enum Instruction {
|
||||
JmpIf = 0x28,
|
||||
UnaryPlus = 0x29,
|
||||
UnaryMinus = 0x2a,
|
||||
New = 0x2b,
|
||||
}
|
||||
|
||||
enum InstructionArg {
|
||||
@@ -856,6 +858,7 @@ fn get_instruction_layout(instruction: Instruction) -> Vec<InstructionArg> {
|
||||
JmpIf => Vec::from([Value, Label]),
|
||||
UnaryPlus => Vec::from([Value, Register]),
|
||||
UnaryMinus => Vec::from([Value, Register]),
|
||||
New => Vec::from([Value, Value, Register]),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ pub enum Instruction {
|
||||
JmpIf = 0x28,
|
||||
UnaryPlus = 0x29,
|
||||
UnaryMinus = 0x2a,
|
||||
New = 0x2b,
|
||||
}
|
||||
|
||||
impl Instruction {
|
||||
|
||||
@@ -10,5 +10,6 @@ mod vs_array;
|
||||
mod native_function;
|
||||
mod builtins;
|
||||
mod math;
|
||||
mod vs_class;
|
||||
|
||||
pub use virtual_machine::VirtualMachine;
|
||||
|
||||
@@ -371,6 +371,8 @@ impl VirtualMachine {
|
||||
|
||||
UnaryPlus => frame.apply_unary_op(operations::op_unary_plus),
|
||||
UnaryMinus => frame.apply_unary_op(operations::op_unary_minus),
|
||||
|
||||
New => std::panic!("Not implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
11
src/vstc/virtual_machine/vs_class.rs
Normal file
11
src/vstc/virtual_machine/vs_class.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::vs_value::Val;
|
||||
use super::vs_function::VsFunction;
|
||||
|
||||
pub struct VsClass {
|
||||
pub constructor: Rc<VsFunction>,
|
||||
pub instance_prototype: Val,
|
||||
}
|
||||
|
||||
impl VsClass {}
|
||||
@@ -5,6 +5,7 @@ use super::vs_function::VsFunction;
|
||||
use super::virtual_machine::StackFrame;
|
||||
use super::vs_object::VsObject;
|
||||
use super::vs_array::VsArray;
|
||||
// use super::vs_class::VsClass;
|
||||
use super::operations::{op_sub, op_submov};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -18,6 +19,7 @@ pub enum Val {
|
||||
Array(Rc<VsArray>),
|
||||
Object(Rc<VsObject>),
|
||||
Function(Rc<VsFunction>),
|
||||
// Class(Rc<VsClass>),
|
||||
Static(&'static dyn ValTrait),
|
||||
Custom(Rc<dyn ValTrait>),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user