From c3be64413351df45c57e1825d99e7c889aa98bbc Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 10 May 2018 22:32:36 -0700 Subject: [PATCH] Optional scope name --- schala-lang/src/util.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/schala-lang/src/util.rs b/schala-lang/src/util.rs index f8c187e..2289e9e 100644 --- a/schala-lang/src/util.rs +++ b/schala-lang/src/util.rs @@ -5,7 +5,8 @@ use std::cmp::Eq; #[derive(Default, Debug)] pub struct StateStack<'a, T: 'a, V: 'a> where T: Hash + Eq { parent: Option<&'a StateStack<'a, T, V>>, - values: HashMap + values: HashMap, + scope_name: Option } impl<'a, T, V> StateStack<'a, T, V> where T: Hash + Eq { @@ -19,11 +20,15 @@ impl<'a, T, V> StateStack<'a, T, V> where T: Hash + Eq { (Some(value), _) => Some(value), } } - pub fn new_frame(&'a self) -> StateStack<'a, T, V> where T: Hash + Eq { + pub fn new_frame(&'a self, name: Option) -> StateStack<'a, T, V> where T: Hash + Eq { StateStack { parent: Some(self), - values: HashMap::default() + values: HashMap::default(), + scope_name: name, } } + pub fn get_name(&self) -> Option<&String> { + self.scope_name.as_ref() + } }