change abi

the thing C++ is afraid of
This commit is contained in:
nora 2022-01-09 11:58:58 +01:00
parent 5bce4cc21c
commit f23662c1f9
4 changed files with 19 additions and 18 deletions

View file

@ -41,18 +41,20 @@
//! returned value. //! returned value.
//! //!
//! ```text //! ```text
//! old stack offset ╮ old *mut FnBlock ╮ ╭ Parameters ╮ ╭ local //! old stack offset─╮
//! v v v v v //! ╭─Parameters─╮ │ old FnBlock index─╮ local─╮
//! ───────┬─────────────┬────────────┬──────────┬─────────┬──────────┬─────────╮ //! v v v v v
//! Num(6) │ NativeU(20) │ NativeU(4) │ Ptr │ Num(5) │ Num(6) │ Num(5) │ //! ───────┬─────────┬──────────┬─────────────┬────────────┬────────────┬─────────╮
//! ───────┴─────────────┴────────────┴──────────┴─────────┴──────────┴─────────╯ //! Num(6) │ Num(5) │ Num(6) │ NativeU(20) │ NativeU(4) │ NativeU(1) │ Num(5) │
//! ^ ╰──────────────────────────────────────────────────────────────────── current stack frame //! ───────┴─────────┴──────────┴─────────────┴────────────┴────────────┴─────────╯
//! │ ^ ^ //! ^ ╰────────────────────────────────────────────────────────────────── current stack frame
//! ╰─ old local ╰╮ ╰─ old PC //! │ ^
//! ╰─ old local ╰─old PC
//!
//! ^
//! Vm ╰────────────╮
//! │ //! │
//! │ //! Current stack offset─╯
//! Vm │
//! Current stack offset ╯
//! //!
//! ``` //! ```

View file

@ -152,7 +152,7 @@ impl<'bc, 'gc> Compiler<'bc, 'gc> {
Ok(()) Ok(())
} }
fn compile_fn_decl(&mut self, decl: &FnDecl) -> CResult { fn compile_fn_decl(&mut self, _: &FnDecl) -> CResult {
todo!() todo!()
} }

View file

@ -1,4 +1,4 @@
#![deny(clippy::disallowed_type)] #![deny(clippy::disallowed_types)]
mod ast; mod ast;
mod bytecode; mod bytecode;
@ -18,14 +18,14 @@ pub use lex::*;
pub use parse::*; pub use parse::*;
#[cfg(not(feature = "fxhash"))] #[cfg(not(feature = "fxhash"))]
#[allow(clippy::disallowed_type)] #[allow(clippy::disallowed_types)]
type HashMap<K, V> = std::collections::HashMap<K, V>; type HashMap<K, V> = std::collections::HashMap<K, V>;
#[cfg(feature = "fxhash")] #[cfg(feature = "fxhash")]
type HashMap<K, V> = rustc_hash::FxHashMap<K, V>; type HashMap<K, V> = rustc_hash::FxHashMap<K, V>;
#[cfg(not(feature = "fxhash"))] #[cfg(not(feature = "fxhash"))]
#[allow(clippy::disallowed_type)] #[allow(clippy::disallowed_types)]
type HashSet<T> = std::collections::HashSet<T>; type HashSet<T> = std::collections::HashSet<T>;
#[cfg(feature = "fxhash")] #[cfg(feature = "fxhash")]

View file

@ -14,6 +14,7 @@ pub fn execute<'bc>(
cfg: &mut Config, cfg: &mut Config,
) -> Result<(), VmError> { ) -> Result<(), VmError> {
let mut vm = Vm { let mut vm = Vm {
blocks: bytecode,
current: bytecode.first().ok_or("no bytecode found")?, current: bytecode.first().ok_or("no bytecode found")?,
pc: 0, pc: 0,
stack: Vec::with_capacity(1024 << 5), stack: Vec::with_capacity(1024 << 5),
@ -42,8 +43,6 @@ pub enum Value {
Object(Object), Object(Object),
/// A value that is stored by the vm for bookkeeping and should never be accessed for anything else /// A value that is stored by the vm for bookkeeping and should never be accessed for anything else
NativeU(usize), NativeU(usize),
/// A function
Fn(Ptr),
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -61,6 +60,7 @@ const FALSE: Value = Value::Bool(false);
struct Vm<'bc, 'io> { struct Vm<'bc, 'io> {
// -- global // -- global
blocks: &'bc [FnBlock<'bc>],
_alloc: RtAlloc, _alloc: RtAlloc,
stack: Vec<Value>, stack: Vec<Value>,
stdout: &'io mut dyn Write, stdout: &'io mut dyn Write,
@ -241,7 +241,6 @@ impl Display for Value {
Value::Array => todo!(), Value::Array => todo!(),
Value::Object(_) => todo!(), Value::Object(_) => todo!(),
Value::NativeU(_) => panic!("Called display on native value!"), Value::NativeU(_) => panic!("Called display on native value!"),
Value::Fn(_) => f.write_str("[function]"),
} }
} }
} }