Example #1
0
 def call(self, args_w):
     if len(args_w) == 0:  # from stdin XXX use current-input-port
         stdin = config.default.stdin
         content = stdin.readall()
         return list_to_pair(read_string(content)[:])  # XXX different
     else:
         assert len(args_w) == 1  # from given file
         w_file, = args_w
         assert isinstance(w_file, W_File)
         return list_to_pair(read_string(w_file.w_readall().content())[:])
Example #2
0
 def call(self, args_w):
     if len(args_w) == 0: # from stdin XXX use current-input-port
         stdin = config.default.stdin
         content = stdin.readall()
         return list_to_pair(read_string(content)[:]) # XXX different
     else:
         assert len(args_w) == 1 # from given file
         w_file, = args_w
         assert isinstance(w_file, W_File)
         return list_to_pair(read_string(w_file.w_readall().content())[:])
Example #3
0
def load_file(filename):
    from pypy.rlib.streamio import open_file_as_stream
    stream = open_file_as_stream(filename, 'r')
    content = stream.readall()
    stream.close()
    return read_string(content)
Example #4
0
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()
Example #5
0
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()
Example #6
0
#!/usr/bin/env python

import path_fix
import sys
from tvm.lang.reader import read_string

with open(sys.argv[1]) as f:
    sexpr_list = read_string(f.read())
    print '\n'.join(sexpr.to_string() for sexpr in sexpr_list)
Example #7
0
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)

Example #8
0
def load_file(filename):
    from pypy.rlib.streamio import open_file_as_stream
    stream = open_file_as_stream(filename, 'r')
    content = stream.readall()
    stream.close()
    return read_string(content)