context: switch to BimapTypeDict

This commit is contained in:
Michael Sippel 2024-10-28 21:27:20 +01:00
parent af34fc9976
commit 50fe43df97
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -1,9 +1,15 @@
use { use {
r3vi::{view::{OuterViewPort, singleton::*}, buffer::{singleton::*}},
laddertypes::{TypeDict, TypeTerm, TypeID, MorphismType, MorphismBase, Morphism},
crate::{ crate::{
repr_tree::{ReprTree, ReprTreeExt, GenericReprTreeMorphism}, edit_tree::EditTree,
edit_tree::EditTree repr_tree::{GenericReprTreeMorphism, ReprTree, ReprTreeExt},
},
laddertypes::{
parser::ParseLadderType, sugar::SugaredTypeTerm, unparser::UnparseLadderType,
BimapTypeDict, Morphism, MorphismBase, MorphismType, TypeDict, TypeID, TypeTerm,
},
r3vi::{
buffer::singleton::*,
view::{singleton::*, OuterViewPort},
}, },
std::{ std::{
collections::HashMap, collections::HashMap,
@ -24,7 +30,7 @@ pub static TYPEID_vec : TypeID = TypeID::Fun(4);
#[derive(Clone)] #[derive(Clone)]
pub struct Context { pub struct Context {
/// assigns a name to every type /// assigns a name to every type
pub type_dict: Arc<RwLock<TypeDict>>, pub type_dict: Arc<RwLock<BimapTypeDict>>,
pub morphisms: laddertypes::morphism::MorphismBase< GenericReprTreeMorphism >, pub morphisms: laddertypes::morphism::MorphismBase< GenericReprTreeMorphism >,
@ -53,12 +59,12 @@ impl Context {
type_dict: match parent.as_ref() { type_dict: match parent.as_ref() {
Some(p) => p.read().unwrap().type_dict.clone(), Some(p) => p.read().unwrap().type_dict.clone(),
None => { None => {
let mut dict = TypeDict::new(); let mut dict = BimapTypeDict::new();
assert_eq!( TYPEID_edittree, dict.add_typename("EditTree".into()) ); assert_eq!(TYPEID_edittree, dict.add_typename("EditTree".into()));
assert_eq!( TYPEID_char, dict.add_typename("Char".into()) ); assert_eq!(TYPEID_char, dict.add_typename("Char".into()));
assert_eq!( TYPEID_u64, dict.add_typename("machine.UInt64".into()) ); assert_eq!(TYPEID_u64, dict.add_typename("machine.UInt64".into()));
assert_eq!( TYPEID_list, dict.add_typename("List".into()) ); assert_eq!(TYPEID_list, dict.add_typename("List".into()));
assert_eq!( TYPEID_vec, dict.add_typename("Vec".into()) ); assert_eq!(TYPEID_vec, dict.add_typename("Vec".into()));
Arc::new(RwLock::new(dict)) Arc::new(RwLock::new(dict))
} }