- def add_external_func(self, function):
- name = function.__name__
- invk = lambda *args, **kwargs: function(self, *args, **kwargs)
- self.__ext_function[name] = invk
-
- def external_func_table(self):
- return self.__ext_function
\ No newline at end of file
+ @staticmethod
+ def bind(context):
+ name = DirectoryTracker.context_name()
+ context[name] = DirectoryTracker()
+
+ @staticmethod
+ def emit_enter(dir):
+ name = DirectoryTracker.context_name()
+ return ast.Expr(
+ ast.Call(
+ func=ast.Attribute(
+ value=ast.Name(name, ctx=ast.Load()),
+ attr="push",
+ ctx=ast.Load()
+ ),
+ args=[
+ ast.Constant(str(dir))
+ ],
+ keywords=[]))
+
+ @staticmethod
+ def emit_leave():
+ name = DirectoryTracker.context_name()
+ return ast.Expr(
+ ast.Call(
+ func=ast.Attribute(
+ value=ast.Name(name, ctx=ast.Load()),
+ attr="pop",
+ ctx=ast.Load()
+ ),
+ args=[],
+ keywords=[]))