pr47 0.0.3

A semi-experimental programming language. Still working in progress.
Documentation
use std::rc::Rc;
use std::collections::HashMap;

use crate::ast::decl::VarDecl;
use crate::ast::ty::Type;

use crate::util::mstring::StringHandle;

pub struct Scope<'a> {
    pub parent: Option<Rc<Scope<'a>>>,
    pub var_decls: HashMap<StringHandle, &'a VarDecl<'a>>,
    pub types: HashMap<StringHandle, &'a Type<'a>>,
    pub funcs: HashMap<StringHandle, Vec<&'a ()>>
}

impl<'a> Scope<'a> {
    fn new_intern(parent: Option<Rc<Scope<'a>>>) -> Self {
        Self {
            parent,
            var_decls: HashMap::new(),
            types: HashMap::new(),
            funcs: HashMap::new()
        }
    }

    pub fn new(parent: Rc<Scope<'a>>) -> Self {
        Self::new_intern(Some(parent))
    }

    pub fn root_scope() -> Self {
        Self::new_intern(None)
    }
}