From 7a8288632b3b7cd85c0e75c7becbf5710cb9f108 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sun, 23 Dec 2012 14:06:00 -0500 Subject: [PATCH] blasting kruft --- hy/compiler/modfaker.py | 49 ----------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 hy/compiler/modfaker.py diff --git a/hy/compiler/modfaker.py b/hy/compiler/modfaker.py deleted file mode 100644 index d2a22cd..0000000 --- a/hy/compiler/modfaker.py +++ /dev/null @@ -1,49 +0,0 @@ -from __future__ import print_function -from hy.lex.tokenize import tokenize -import imp - - -def _add_native_methods(mod): - def shim(): - from hy.lang.natives import natives, _lex - - def _eval(*args): - """ - This needs to be in here, since we need to assign the - global namespace of evaluated nodes in the same namespace - as the caller. - """ - ret = [] - for node in _lex(*args): - for tree in node: - tree.set_namespace(globals()) - ret.append(tree()) - return ret - globals()['eval'] = _eval - - for native in natives: - globals()[native] = natives[native] - - del(natives) - - eval(shim.__code__, mod.__dict__) - - -def forge_module(name, fpath, forest): - mod = imp.new_module(name) - mod.__file__ = fpath - mod._hy_forest = forest - _add_native_methods(mod) - - def shim(): - ns = globals() - for tree in _hy_forest: - tree.set_namespace(ns) - - for tree in _hy_forest: - tree() - - mod.__dict__['_hy_self'] = mod - eval(shim.__code__, mod.__dict__) - - return mod