late night hacks
This commit is contained in:
parent
0081d4fdfc
commit
14e716f05f
@ -59,10 +59,14 @@ def forge_module(name, fpath, forest):
|
|||||||
_add_native_methods(mod)
|
_add_native_methods(mod)
|
||||||
|
|
||||||
def shim():
|
def shim():
|
||||||
|
ns = globals()
|
||||||
|
for tree in _hy_forest:
|
||||||
|
tree.set_namespace(ns)
|
||||||
|
|
||||||
for tree in _hy_forest:
|
for tree in _hy_forest:
|
||||||
tree.set_namespace(globals())
|
|
||||||
tree()
|
tree()
|
||||||
|
|
||||||
|
mod.__dict__['_hy_self'] = mod
|
||||||
eval(shim.__code__, mod.__dict__)
|
eval(shim.__code__, mod.__dict__)
|
||||||
|
|
||||||
return mod
|
return mod
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#
|
#
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def _define(obj):
|
def _define(obj):
|
||||||
@ -30,8 +31,10 @@ def _import(obj):
|
|||||||
mods = args[0]
|
mods = args[0]
|
||||||
|
|
||||||
for module in mods:
|
for module in mods:
|
||||||
|
basename = module.split(".", 1)[0]
|
||||||
mod = __import__(module)
|
mod = __import__(module)
|
||||||
obj.namespace[module] = mod
|
sys.modules[module] = mod
|
||||||
|
ns[basename] = mod
|
||||||
|
|
||||||
|
|
||||||
builtins = {
|
builtins = {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
|
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
|
||||||
|
|
||||||
(import ["sys"])
|
(import ["sys"
|
||||||
|
"os.path"])
|
||||||
|
|
||||||
(def square (fn [x]
|
(def square (fn [x]
|
||||||
(* x x)))
|
(* x x)))
|
||||||
|
|
||||||
(print (square 2))
|
(print os.path)
|
||||||
(print sys.argv)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user