Types need handle to symbol table
This commit is contained in:
parent
81ca9ee20f
commit
856a360aba
@ -44,8 +44,8 @@ impl Schala {
|
|||||||
let symbols = Rc::new(RefCell::new(symbol_table::SymbolTable::new()));
|
let symbols = Rc::new(RefCell::new(symbol_table::SymbolTable::new()));
|
||||||
Schala {
|
Schala {
|
||||||
symbol_table: symbols.clone(),
|
symbol_table: symbols.clone(),
|
||||||
|
type_context: typechecking::TypeContext::new(symbols.clone()),
|
||||||
state: eval::State::new(symbols),
|
state: eval::State::new(symbols),
|
||||||
type_context: typechecking::TypeContext::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::{HashSet, HashMap};
|
||||||
/*
|
/*
|
||||||
@ -10,6 +11,7 @@ use itertools::Itertools;
|
|||||||
|
|
||||||
use parsing;
|
use parsing;
|
||||||
use util::StateStack;
|
use util::StateStack;
|
||||||
|
use symbol_table::{SymbolSpec, Symbol, SymbolTable};
|
||||||
|
|
||||||
pub type TypeName = Rc<String>;
|
pub type TypeName = Rc<String>;
|
||||||
type TypeResult<T> = Result<T, String>;
|
type TypeResult<T> = Result<T, String>;
|
||||||
@ -54,12 +56,13 @@ impl TypeEnv {
|
|||||||
|
|
||||||
pub struct TypeContext<'a> {
|
pub struct TypeContext<'a> {
|
||||||
values: StateStack<'a, TypeName, Type>,
|
values: StateStack<'a, TypeName, Type>,
|
||||||
|
symbol_table_handle: Rc<RefCell<SymbolTable>>,
|
||||||
global_env: TypeEnv
|
global_env: TypeEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TypeContext<'a> {
|
impl<'a> TypeContext<'a> {
|
||||||
pub fn new() -> TypeContext<'static> {
|
pub fn new(symbol_table_handle: Rc<RefCell<SymbolTable>>) -> TypeContext<'static> {
|
||||||
TypeContext { values: StateStack::new(None), global_env: TypeEnv::default() }
|
TypeContext { values: StateStack::new(None), global_env: TypeEnv::default(), symbol_table_handle }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_types(&self) -> String {
|
pub fn debug_types(&self) -> String {
|
||||||
|
Loading…
Reference in New Issue
Block a user