| 1 |
from __future__ import print_function |
| 2 |
|
| 3 |
import py |
| 4 |
py.path.local(__file__) |
| 5 |
from rpython.jit.tl.tlr import interpret |
| 6 |
from rpython.jit.backend.hlinfo import highleveljitinfo |
| 7 |
|
| 8 |
|
| 9 |
def entry_point(args): |
| 10 |
"""Main entry point of the stand-alone executable: |
| 11 |
takes a list of strings and returns the exit code. |
| 12 |
""" |
| 13 |
|
| 14 |
|
| 15 |
highleveljitinfo.sys_executable = args[0] |
| 16 |
if len(args) < 3: |
| 17 |
print("Usage: %s filename x" % (args[0],)) |
| 18 |
return 2 |
| 19 |
filename = args[1] |
| 20 |
x = int(args[2]) |
| 21 |
bytecode = load_bytecode(filename) |
| 22 |
res = interpret(bytecode, x) |
| 23 |
print(res) |
| 24 |
return 0 |
| 25 |
|
| 26 |
def load_bytecode(filename): |
| 27 |
from rpython.rlib.streamio import open_file_as_stream |
| 28 |
f = open_file_as_stream(filename) |
| 29 |
bytecode = f.readall() |
| 30 |
f.close() |
| 31 |
return bytecode |
| 32 |
|
| 33 |
def target(driver, args): |
| 34 |
return entry_point |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
if __name__ == '__main__': |
| 39 |
import sys |
| 40 |
sys.exit(entry_point(sys.argv)) |