Debian Codegraph @

rpython/jit/tl/tla/targettla.py

raw symbols SCIP
1 from __future__ import print_function
2
3 import py
4 py.path.local(__file__)
5 from rpython.jit.tl.tla import tla
6 from rpython.rlib import jit
7
8
9 def entry_point(args):
10 for i in range(len(args)):
11 if args[i] == "--jit":
12 if len(args) == i + 1:
13 print("missing argument after --jit")
14 return 2
15 jitarg = args[i + 1]
16 del args[i:i+2]
17 jit.set_user_param(None, jitarg)
18 break
19
20 if len(args) < 3:
21 print("Usage: %s filename x" % (args[0],))
22 return 2
23 filename = args[1]
24 x = int(args[2])
25 w_x = tla.W_IntObject(x)
26 bytecode = load_bytecode(filename)
27 w_res = tla.run(bytecode, w_x)
28 print(w_res.getrepr())
29 return 0
30
31 def load_bytecode(filename):
32 from rpython.rlib.streamio import open_file_as_stream
33 f = open_file_as_stream(filename)
34 bytecode = f.readall()
35 f.close()
36 return bytecode
37
38 def target(driver, args):
39 return entry_point
40
41 # ____________________________________________________________
42
43
44 if __name__ == '__main__':
45 import sys
46 sys.exit(entry_point(sys.argv))