From 4ab900d6018df3b9fcf7731c80914739a9eadc29 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 23 Feb 2018 03:07:36 -0800 Subject: [PATCH] ReplState -> State Not everythign is a repl --- TODO.md | 2 -- src/schala_lang/eval.rs | 12 ++++++------ src/schala_lang/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 9b33ebc..4cc369d 100644 --- a/TODO.md +++ b/TODO.md @@ -42,5 +42,3 @@ struct CompilerPass { } -change "Type...." names in parser.rs to "Anno..." for non-collision with names in typechecking.rs - -* In eval.rs, change `ReplState` to something that assumes no repl diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 9ca40a9..39b23aa 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -2,7 +2,7 @@ use schala_lang::parsing::{AST, Statement, Declaration, Expression, Variant, Exp use std::collections::HashMap; use std::rc::Rc; -pub struct ReplState { +pub struct State { values: HashMap, ValueEntry>, } @@ -31,9 +31,9 @@ enum FullyEvaluatedExpr { Tuple(Vec), } -impl ReplState { - pub fn new() -> ReplState { - ReplState { values: HashMap::new() } +impl State { + pub fn new() -> State { + State { values: HashMap::new() } } pub fn evaluate(&mut self, ast: AST) -> Vec { @@ -55,7 +55,7 @@ impl ReplState { } } -impl ReplState { +impl State { fn eval_statement(&mut self, statement: Statement) -> EvalResult> { use self::FullyEvaluatedExpr::*; match statement { @@ -137,7 +137,7 @@ impl ReplState { Expression(Value(identifier, _), _) => { match self.values.get(&identifier) { Some(&ValueEntry::Function { ref body }) => { - let new_state = ReplState::new(); + let new_state = State::new(); let sub_ast = AST(body.clone()); println!("LOL ALL FUNCTIONS EVALUATE TO 2!"); Ok(FullyEvaluatedExpr::UnsignedInt(2)) diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index c2a24e2..f069416 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -15,14 +15,14 @@ mod eval; use self::typechecking::{TypeContext}; pub struct Schala { - state: eval::ReplState, + state: eval::State, type_context: TypeContext } impl Schala { pub fn new() -> Schala { Schala { - state: eval::ReplState::new(), + state: eval::State::new(), type_context: TypeContext::new(), } }