Remove a bunch of warnings

This commit is contained in:
Sofia 2026-03-17 21:56:42 +02:00
parent 0fcd00864b
commit e30ecd865a
4 changed files with 27 additions and 35 deletions

View File

@ -134,7 +134,7 @@ pub struct Function {
pub name: Option<Node<String>>,
pub params: Vec<Node<String>>,
pub block: Block,
pub meta: Metadata,
pub _meta: Metadata,
}
impl Parse for Function {
@ -165,7 +165,7 @@ impl Parse for Function {
name,
params,
block,
meta: Metadata::produce(&mut stream, pre),
_meta: Metadata::produce(&mut stream, pre),
})
}
}
@ -183,7 +183,7 @@ impl Parse for String {
#[derive(Debug, Clone)]
pub struct Block {
pub statements: Vec<Node<Statement>>,
pub meta: Metadata,
pub _meta: Metadata,
}
impl Parse for Block {
@ -200,7 +200,7 @@ impl Parse for Block {
Ok(Block {
statements,
meta: Metadata::produce(&mut stream, pre),
_meta: Metadata::produce(&mut stream, pre),
})
}
}

View File

@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
use crate::{
ast::{AccessModifier, BinaryOperator, Block, Expression, Literal, Statement, UnaryOperator},
vm::{Constant, Instruction, LuaBool, VMFloat},
vm::{Constant, Instruction, LuaBool},
};
#[derive(Clone, Debug)]
@ -16,7 +16,7 @@ impl State {
self.constants
.iter()
.enumerate()
.find(|(i, c)| *c == value)
.find(|(_, c)| *c == value)
.unwrap()
.0 as u32
}
@ -218,8 +218,7 @@ impl Statement {
None => {
for (i, (name, indexes)) in names.iter().enumerate() {
if indexes.len() > 0 {
let mut table_reg = if let Some(reg) = scope.locals.get(&name.kind)
{
let table_reg = if let Some(reg) = scope.locals.get(&name.kind) {
*reg
} else if let Some(upval_reg) = scope.upvalues.get(&name.kind) {
let local = scope.register_counter.next();

View File

@ -1,4 +1,4 @@
use std::{fmt::Debug, marker::PhantomData, path::PathBuf};
use std::{fmt::Debug, path::PathBuf};
use thiserror::Error;
@ -11,9 +11,9 @@ use crate::{
vm::{ClosureRunner, VirtualMachine},
};
pub mod ast;
pub mod compile;
pub mod token_stream;
mod ast;
mod compile;
mod token_stream;
pub mod vm;
#[derive(Error, Debug)]
@ -26,9 +26,9 @@ pub enum CompilationError {
#[derive(Clone)]
pub struct CompilationUnit {
instructions: Vec<vm::Instruction>,
state: compile::State,
constants: Vec<vm::Constant>,
pub instructions: Vec<vm::Instruction>,
pub state: compile::State,
pub constants: Vec<vm::Constant>,
}
impl Debug for CompilationUnit {

View File

@ -1,17 +1,10 @@
use thiserror::Error;
use std::{
cell::{RefCell, RefMut},
collections::HashMap,
fmt::Debug,
hash::Hash,
rc::Rc,
};
use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, rc::Rc};
use crate::{
CompilationUnit,
ast::{BinaryOperator, UnaryOperator},
compile,
};
#[derive(Clone, Hash, PartialEq, Eq, Copy)]
@ -221,7 +214,7 @@ pub enum RuntimeError {
}
#[derive(Debug, Clone, Default)]
pub struct Environment {
pub(crate) struct Environment {
pub globals: HashMap<Constant, Rc<RefCell<Value>>>,
}
@ -515,10 +508,10 @@ impl VirtualMachine {
#[derive(Debug, Clone)]
pub struct Closure {
pub vm: VirtualMachine,
pub prototype: u32,
pub environment: Rc<RefCell<Environment>>,
pub upvalues: HashMap<u16, Rc<RefCell<Value>>>,
vm: VirtualMachine,
prototype: u32,
environment: Rc<RefCell<Environment>>,
upvalues: HashMap<u16, Rc<RefCell<Value>>>,
}
impl Closure {
@ -551,13 +544,13 @@ impl Closure {
}
pub struct ClosureRunner {
pub closure: Closure,
pub program_counter: usize,
pub stack: HashMap<u16, Rc<RefCell<Value>>>,
pub inner: Option<Box<ClosureRunner>>,
pub function_register: u16,
pub return_registers: Vec<u16>,
pub top: u16,
closure: Closure,
program_counter: usize,
stack: HashMap<u16, Rc<RefCell<Value>>>,
inner: Option<Box<ClosureRunner>>,
function_register: u16,
return_registers: Vec<u16>,
top: u16,
}
#[derive(Clone, Debug)]