Ejemplo n.º 1
0
def run():
    space = getspace()
    interp = Interpreter(space)
    bc = unserialize(hlstr(read_code_ptr()), space)
    interp.setup(False, {})
    try:
        interp.run_main(space, bc)
    except ExplicitExitException, e:
        print "EXITED WITH %d" % e.code
        return
Ejemplo n.º 2
0
def run():
    space = getspace()
    interp = Interpreter(space)
    bc = unserialize(hlstr(read_code_ptr()), space)
    interp.setup(False, {})
    try:
        interp.run_main(space, bc)
    except ExplicitExitException, e:
        print "EXITED WITH %d" % e.code
        return
Ejemplo n.º 3
0
 def test_serialize_with_calls(self):
     source = """<?
     function f($a) {
         return $a + 4;
     }
     echo f(3);
     ?>"""
     space = getspace()
     bc = compile_php('<input>', source, space)
     dump = bc.serialize(space)
     bc2 = unserialize(dump, space)
     interp = MockInterpreter(space)
     interp.run_main(space, bc2)
     assert space.int_w(interp.output[0]) == 3 + 4
Ejemplo n.º 4
0
 def test_serialize_array_constants(self):
     source = """<?
     $a = array("a", "b");
     $b = array("a"=>"b");
     echo $a[1];
     echo $b["a"];
     ?>"""
     space = getspace()
     bc = compile_php('<input>', source, space)
     dump = bc.serialize(space)
     bc2 = unserialize(dump, space)
     interp = MockInterpreter(space)
     interp.run_main(space, bc2)
     assert space.str_w(interp.output[0]) == "b"
     assert space.str_w(interp.output[1]) == "b"
Ejemplo n.º 5
0
 def test_serialize_with_classes(self):
     source = """<?
     class X {
         function __construct() {
            $this->x = 3;
         }
     }
     $x = new X();
     echo $x->x;
     ?>"""
     space = getspace()
     bc = compile_php('<input>', source, space)
     dump = bc.serialize(space)
     bc2 = unserialize(dump, space)
     interp = MockInterpreter(space)
     interp.run_main(space, bc2)
     assert space.int_w(interp.output[0]) == 3
Ejemplo n.º 6
0
 def test_basic_serialize(self):
     source = "<? $a = 3; var_dump($a);?>"
     space = getspace()
     bc = compile_php('<input>', source, space)
     dump = bc.serialize(space)
     bc2 = unserialize(dump, space)
     assert bc.dump() == bc2.dump()
     assert space.int_w(bc2.consts[0]) == 3
     assert bc2.name == bc.name
     assert bc2.filename == bc.filename
     assert bc2.startlineno == bc.startlineno
     assert bc2.sourcelines == bc.sourcelines
     assert bc.names == bc2.names
     assert bc.varnames == bc2.varnames
     interp = MockInterpreter(space)
     interp.run_main(space, bc2)
     assert interp.output[0] == 'int(3)\n'