def compile_file(filename, outfname): """maybe rpython...""" w_skel = compile_list_of_expr(filename_to_expr_list(filename)) outf = open_file_as_stream(outfname, 'w') chunkio.dump(w_skel, outf) outf.close()
def repl(): stdin = fdopen_as_stream(0, 'r') stdout = fdopen_as_stream(1, 'a') vm = VM() open_lib(vm) while True: if we_are_translated(): # RPython -- cannot use readline stdout.write('> ') stdout.flush() raw_line_of_code = stdin.readline() else: # CPython -- use readline try: raw_line_of_code = raw_input('> ') except (EOFError, KeyboardInterrupt): raw_line_of_code = '' if not raw_line_of_code: break # handle EOF raw_line_of_code = raw_line_of_code.strip('\n') # RPy if not raw_line_of_code: continue # handle plain ENTER expr_list = parse_string(raw_line_of_code) if not expr_list: continue # handle whitespace in RPy w_skel = compile_list_of_expr(expr_list) # some hack so as to not return the vm? # to view code if DEBUG: print w_skel # to view code if DEBUG: continue vm.bootstrap(w_skel) vm.run() w_result = vm.exit_value if w_result is not w_unspecified: print w_result.to_string()
def disassemble_file(filename): """NOT_RPYTHON""" print compile_list_of_expr(filename_to_expr_list(filename))
def run_file(filename): vm = VM() open_lib(vm) vm.bootstrap(compile_list_of_expr(filename_to_expr_list(filename))) vm.run()