def init(): from system.core import symbol from system.evaluation import ResolveFrame import sys from system.reader import read_from_string from system.app_compiler import compile_in_module form = read_from_string("((fn baz [x y] (add x y)))") comped = compile_in_module(form, sys.modules["system.rt"]) globals()["baz"] = comped() names = [] values = [] for k in globals(): val = globals()[k] if isinstance(val, Object) and hasattr(val, "_symbol_"): names.append(symbol(None, val._symbol_)) values.append(val) globals()["builtins"] = ResolveFrame(names, values)
def test_compiler(self): form = read_from_string("((fn foo [x y] (add x y)))") fn = compile_in_module(form, system.rt) self.assertEqual(fn().invoke2(integer(1), integer(2)).int(), 3)