def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) policy = PyPyAnnotatorPolicy(single_space=space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space, '?') print " operror-value: " + space.str_w( space.str(e.get_w_value(space))) return 1 return 0
def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) ctx = JavaScriptContext(space) policy = PyPyAnnotatorPolicy(single_space=space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() ctx._ctx = context glob = ctx.globals() lst = ctx.propertylist(glob.js_val) for elem in lst: w_val = space.wrap(JSObject(ctx, ctx.get(glob.js_val, elem))) space.setitem(w_dict, space.wrap(elem), w_val) try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space, '?') print " operror-value: " + space.str_w(space.str(e.w_value)) return 1 return 0
def get_entry_point(self, config): space = make_objspace(config) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') w_dict = space.newdict() space.exec_(open(filename).read(), w_dict, w_dict) entry_point = create_entry_point(space, w_dict) return entry_point, None, PyPyAnnotatorPolicy(single_space = space)
def get_entry_point(self, config): space = make_objspace(config) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') w_dict = space.newdict() space.exec_(open(filename).read(), w_dict, w_dict) for modulename in EXTRA_MODULES: print 'pre-importing', modulename space.exec_("import " + modulename, w_dict, w_dict) print 'phew, ready' entry_point = create_entry_point(space, w_dict) return entry_point, None, PyPyAnnotatorPolicy(single_space=space)
def test_run_translation(): from pypy.translator.goal.ann_override import PyPyAnnotatorPolicy from pypy.rpython.test.test_llinterp import get_interpreter # first annotate and rtype try: interp, graph = get_interpreter( entry_point, [], backendopt=False, config=config, type_system=config.translation.type_system, policy=PyPyAnnotatorPolicy(space)) except Exception, e: print '%s: %s' % (e.__class__, e) pdb.post_mortem(sys.exc_info()[2]) raise
def get_entry_point(self, config): from pypy.tool.lib_pypy import import_from_lib_pypy rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild') rebuild.try_rebuild() space = make_objspace(config) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') app = gateway.applevel( open(filename).read(), 'app_main.py', 'app_main') app.hidden_applevel = False w_dict = app.getwdict(space) entry_point = create_entry_point(space, w_dict) return entry_point, None, PyPyAnnotatorPolicy(single_space=space)
def get_entry_point(self, config): global space1, space2, w_entry_point_1, w_entry_point_2 space1 = StdObjSpace(config) space2 = StdObjSpace(config) space1.setattr(space1.getbuiltinmodule('sys'), space1.wrap('pypy_space'), space1.wrap(1)) space2.setattr(space2.getbuiltinmodule('sys'), space2.wrap('pypy_space'), space2.wrap(2)) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') w_dict = space1.newdict() space1.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_1 = space1.getitem(w_dict, space1.wrap('entry_point')) w_dict = space2.newdict() space2.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_2 = space2.getitem(w_dict, space2.wrap('entry_point')) return entry_point, None, PyPyAnnotatorPolicy()