From 97df2fa344a3ef378df0dd198ef3ef9789741fc0 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 14 May 2018 09:46:25 -0700 Subject: [PATCH] I dunno --- schala-lang/src/eval.rs | 8 ++++++-- schala-lang/src/lib.rs | 2 +- schala-lang/src/typechecking.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/schala-lang/src/eval.rs b/schala-lang/src/eval.rs index bef1051..f42691b 100644 --- a/schala-lang/src/eval.rs +++ b/schala-lang/src/eval.rs @@ -11,7 +11,7 @@ use typechecking::TypeContext; pub struct State<'a> { values: StateStack<'a, Rc, ValueEntry>, - type_context_handle: Option>>, + type_context_handle: Rc>, } macro_rules! builtin_binding { @@ -21,7 +21,7 @@ macro_rules! builtin_binding { } impl<'a> State<'a> { - pub fn new(type_context_handle: Option>>) -> State<'a> { + pub fn new(type_context_handle: Rc>) -> State<'a> { let mut values = StateStack::new(Some(format!("global"))); builtin_binding!("print", values); builtin_binding!("println", values); @@ -261,6 +261,10 @@ impl<'a> State<'a> { use self::ValueEntry::*; //TODO add a layer of indirection here to talk to the symbol table first, and only then look up //in the values table + + let type_context = self.type_context_handle.borrow(); + type_context.symbol_table + match self.values.lookup(&name) { None => return Err(format!("Value {} not found", *name)), Some(lookup) => match lookup { diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index e8d0e1d..c9cb951 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -42,7 +42,7 @@ impl Schala { let type_context = Rc::new(RefCell::new(typechecking::TypeContext::new())); Schala { type_context: type_context.clone(), - state: eval::State::new(Some(type_context)), + state: eval::State::new(type_context), } } } diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index 4144a15..56ea804 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -11,7 +11,7 @@ use parsing; pub struct TypeContext { type_var_count: u64, bindings: HashMap, Type>, - symbol_table: SymbolTable + pub symbol_table: SymbolTable } //cf. p. 150 or so of Language Implementation Patterns