From ecc8f2ec8b06f3fc291d298476cc1cae2959bac3 Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Wed, 11 Jan 2023 07:20:29 +0100 Subject: [PATCH] Removed various bits of unused code --- src/interpreter/classes.rs | 12 ++---------- src/tokens.rs | 20 -------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/interpreter/classes.rs b/src/interpreter/classes.rs index bde5c2d..6b3f48a 100644 --- a/src/interpreter/classes.rs +++ b/src/interpreter/classes.rs @@ -2,11 +2,10 @@ use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc}; use crate::{ errors::{ErrorKind, SloxError, SloxResult}, - interpreter::EnvironmentRef, - tokens::{Token, TokenType}, + tokens::Token, }; -use super::{functions::Function, Callable, Environment, InterpreterState, Value}; +use super::{functions::Function, Callable, InterpreterState, Value}; /// A Lox class. #[derive(Debug, Clone)] @@ -25,13 +24,6 @@ pub struct Instance { fields: HashMap, } -/// A method bound to an instance. -#[derive(Debug, Clone)] -pub struct BoundMethod { - instance: Value, - method: String, -} - /* -------------------- * * Class implementation * * -------------------- */ diff --git a/src/tokens.rs b/src/tokens.rs index 0bd7c0b..6e0ccb9 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -58,28 +58,8 @@ pub struct Token { } impl Token { - /// Check whether a token corresponds to a litteral value. - pub fn is_litteral(&self) -> bool { - matches!( - self.token_type, - TokenType::True - | TokenType::False - | TokenType::Nil - | TokenType::String(_) - | TokenType::Number(_) - ) - } - /// Check whether a token is an identifier. pub fn is_identifier(&self) -> bool { matches!(self.token_type, TokenType::Identifier(_)) } - - /// Get the name from an identifier token, returning an error otherwise. - pub fn as_identifier(&self) -> Result<&str, &'static str> { - match &self.token_type { - TokenType::Identifier(name) => Ok(name), - _ => Err("token is not an identifier"), - } - } }