fix performance issue by using reference counting for objects

This commit is contained in:
2024-10-22 13:18:26 -04:00
parent 605a6ae460
commit 0a40cca6ff
4 changed files with 35 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ use crate::executor::Executor;
use super::{Value, Type, Function, FunctionType};
use super::tokenizer::{Token, TokenizeError, Op};
use std::borrow::{BorrowMut, Cow};
use std::borrow::BorrowMut;
use std::error;
use std::collections::HashMap;
use std::fmt::Display;
@@ -106,7 +106,7 @@ pub(crate) struct Parser<'a, I: Iterator<Item = Result<Token, TokenizeError>>> {
impl<'a, I: Iterator<Item = Result<Token, TokenizeError>>> Parser<'a, I> {
pub fn new(tokens: &'a mut Peekable<I>, globals: &'a mut HashMap<String, Type>) -> Self {
Self {
tokens: tokens,
tokens,
globals,
locals: HashMap::new()
}