Exemple #1
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
Exemple #2
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)
    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
Exemple #3
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)
    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
Exemple #4
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