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.
//!
//! ```text
//! old stack offset ╮ old *mut FnBlock ╮ ╭ Parameters ╮ ╭ local
//! v v v v v
//! ───────┬─────────────┬────────────┬──────────┬─────────┬──────────┬─────────╮
//! Num(6) │ NativeU(20) │ NativeU(4) │ Ptr │ Num(5) │ Num(6) │ Num(5) │
//! ───────┴─────────────┴────────────┴──────────┴─────────┴──────────┴─────────╯
//! ^ ╰──────────────────────────────────────────────────────────────────── current stack frame
//! │ ^ ^
//! ╰─ old local ╰╮ ╰─ old PC
//! old stack offset─╮
//! ╭─Parameters─╮ │ old FnBlock index─╮ local─╮
//! v v v v v
//! ───────┬─────────┬──────────┬─────────────┬────────────┬────────────┬─────────╮
//! Num(6) │ Num(5) │ Num(6) │ NativeU(20) │ NativeU(4) │ NativeU(1) │ Num(5) │
//! ───────┴─────────┴──────────┴─────────────┴────────────┴────────────┴─────────╯
//! ^ ╰────────────────────────────────────────────────────────────────── current stack frame
//! │ ^
//! ╰─ old local ╰─old PC
//!
//! ^
//! Vm ╰────────────╮
//! │
//! │
//! Vm │
//! Current stack offset ╯
//! Current stack offset─╯
//!
//! ```

View file

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

View file

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

View file

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