summaryrefslogtreecommitdiffstats
path: root/src/front/scope.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/front/scope.py')
-rw-r--r--src/front/scope.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/front/scope.py b/src/front/scope.py
index 0df8729..a15ed1d 100644
--- a/src/front/scope.py
+++ b/src/front/scope.py
@@ -1,6 +1,24 @@
class Scope(object):
__shared_state = {}
- functions = {}
+ __current_function = None
+ __functions = {}
def __init__(self):
self.__dict__ = self.__shared_state
+
+ def new(self, name, symbols = []):
+ if getattr(self.__functions, name, None):
+ raise ScopeError("multiple definitions of %s" % name)
+ self.__functions[name] = []
+ self.__current_function = name
+ self.add(symbols)
+
+ def add(self, symbols):
+ if type(symbols) != type([]):
+ symbols = [symbols]
+ for symbol in symbols:
+ if symbol not in self.__functions[self.__current_function]:
+ self.__functions[self.__current_function].append(symbol)
+
+ def __str__(self):
+ return "<Scope: %s>" % str(self.__functions)