def call_with_frame(self, args_w, frame, tailp): assert len(args_w) == 1 w_arg, = args_w w_func = load_bytecode_function(w_arg, frame.w_func.module_w) # XXX w_closure = w_func.build_closure([]) if tailp: frame.leave_with_retval(w_closure) else: frame.push(w_closure)
def run_bytecode(w_expr, w_global): w_func = load_bytecode_function(w_expr, w_global) execute_function(w_func, [])
def test_load_dump(): w_expr, = read_string(compiled_source) w_func0 = load_bytecode_function(w_expr, None) w_expr0 = dump_bytecode_function(w_func0) assert w_expr.to_string() == w_expr0.to_string()
def compile_expr(w_expr, w_module): w_expanded = execute_function(w_macro_expander, [w_expr]) w_compiled = execute_function(w_code_compiler, [w_expanded]) return load_bytecode_function(w_compiled, w_module)
from tvm.asm.assembler import load_bytecode_function from tvm.lang.reader import read_string from tvm.lang.model import symbol from tvm.util import localpath from tvm.lang.env import ModuleDict from tvm.rt.prelude import populate_module from tvm.rt.execution import execute_function with open(localpath(__file__, 'stage2-compiled-lib.ss')) as f: content = f.read() w_lib_expr = read_string(content)[0] lib_module = ModuleDict() populate_module(lib_module) w_lib_function = load_bytecode_function(w_lib_expr, lib_module) execute_function(w_lib_function, []) w_macro_expander = lib_module.getitem(symbol("expand-builtin-macro")).w_func w_code_compiler = lib_module.getitem(symbol("compile-program")).w_func def compile_expr(w_expr, w_module): w_expanded = execute_function(w_macro_expander, [w_expr]) w_compiled = execute_function(w_code_compiler, [w_expanded]) return load_bytecode_function(w_compiled, w_module)