ReplState -> State

Not everythign is a repl
This commit is contained in:
greg 2018-02-23 03:07:36 -08:00
parent 75ecfb4e86
commit 36174140bc
3 changed files with 8 additions and 10 deletions

View File

@ -42,5 +42,3 @@ struct CompilerPass {
} }
-change "Type...." names in parser.rs to "Anno..." for non-collision with names in typechecking.rs -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

View File

@ -2,7 +2,7 @@ use schala_lang::parsing::{AST, Statement, Declaration, Expression, Variant, Exp
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;
pub struct ReplState { pub struct State {
values: HashMap<Rc<String>, ValueEntry>, values: HashMap<Rc<String>, ValueEntry>,
} }
@ -31,9 +31,9 @@ enum FullyEvaluatedExpr {
Tuple(Vec<FullyEvaluatedExpr>), Tuple(Vec<FullyEvaluatedExpr>),
} }
impl ReplState { impl State {
pub fn new() -> ReplState { pub fn new() -> State {
ReplState { values: HashMap::new() } State { values: HashMap::new() }
} }
pub fn evaluate(&mut self, ast: AST) -> Vec<String> { pub fn evaluate(&mut self, ast: AST) -> Vec<String> {
@ -55,7 +55,7 @@ impl ReplState {
} }
} }
impl ReplState { impl State {
fn eval_statement(&mut self, statement: Statement) -> EvalResult<Option<String>> { fn eval_statement(&mut self, statement: Statement) -> EvalResult<Option<String>> {
use self::FullyEvaluatedExpr::*; use self::FullyEvaluatedExpr::*;
match statement { match statement {
@ -137,7 +137,7 @@ impl ReplState {
Expression(Value(identifier, _), _) => { Expression(Value(identifier, _), _) => {
match self.values.get(&identifier) { match self.values.get(&identifier) {
Some(&ValueEntry::Function { ref body }) => { Some(&ValueEntry::Function { ref body }) => {
let new_state = ReplState::new(); let new_state = State::new();
let sub_ast = AST(body.clone()); let sub_ast = AST(body.clone());
println!("LOL ALL FUNCTIONS EVALUATE TO 2!"); println!("LOL ALL FUNCTIONS EVALUATE TO 2!");
Ok(FullyEvaluatedExpr::UnsignedInt(2)) Ok(FullyEvaluatedExpr::UnsignedInt(2))

View File

@ -15,14 +15,14 @@ mod eval;
use self::typechecking::{TypeContext}; use self::typechecking::{TypeContext};
pub struct Schala { pub struct Schala {
state: eval::ReplState, state: eval::State,
type_context: TypeContext type_context: TypeContext
} }
impl Schala { impl Schala {
pub fn new() -> Schala { pub fn new() -> Schala {
Schala { Schala {
state: eval::ReplState::new(), state: eval::State::new(),
type_context: TypeContext::new(), type_context: TypeContext::new(),
} }
} }