Example #1
0
 def test_new_obj(self):
     from pypy.jit.tl.tlc import interp_eval, InstanceObj, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert isinstance(obj, InstanceObj)
     assert len(obj.values) == 2
     assert sorted(obj.cls.attributes.keys()) == ['bar', 'foo']
Example #2
0
 def test_new_obj(self):
     from pypy.jit.tl.tlc import interp_eval, InstanceObj, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert isinstance(obj, InstanceObj)
     assert len(obj.values) == 2
     assert sorted(obj.cls.attributes.keys()) == ['bar', 'foo']
Example #3
0
 def test_obj_equality(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         NEW foo,bar
         EQ
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 0
Example #4
0
 def test_obj_equality(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         NEW foo,bar
         NEW foo,bar
         EQ
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 0
Example #5
0
 def test_call_without_return_value(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         CALL foo
         PUSH 42
         RETURN
     foo:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #6
0
 def test_getattr(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR bar
         GETATTR bar
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #7
0
 def test_setattr(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR foo
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert obj.values[0].int_o() == 42
     assert obj.values[1] is nil
Example #8
0
 def test_setattr(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR foo
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert obj.values[0].int_o() == 42
     assert obj.values[1] is nil
Example #9
0
 def test_call_without_return_value(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         CALL foo
         PUSH 42
         RETURN
     foo:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #10
0
 def test_getattr(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR bar
         GETATTR bar
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #11
0
 def test_obj_truth(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         BR_COND true
         PUSH 12
         PUSH 1
         BR_COND exit
     true:
         PUSH 42
     exit:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #12
0
 def test_method(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,meth=meth
         PICK 0
         PUSH 42
         SETATTR foo
         SEND meth/0
         RETURN
     meth:
         PUSHARG
         GETATTR foo
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #13
0
 def test_obj_truth(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         NEW foo,bar
         BR_COND true
         PUSH 12
         PUSH 1
         BR_COND exit
     true:
         PUSH 42
     exit:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #14
0
 def test_method(self):
     from pypy.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile(
         """
         NEW foo,meth=meth
         PICK 0
         PUSH 42
         SETATTR foo
         SEND meth/0
         RETURN
     meth:
         PUSHARG
         GETATTR foo
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
Example #15
0
 def interp(i, inputarg):
     args = [tlc.IntObj(inputarg)]
     obj = tlc.interp_eval(codes[i], 0, args, pools[i])
     return obj.int_o()
Example #16
0
 def fn(n):
     obj = IntObj(n)
     res = interp_eval(bytecode, 0, [obj], pool)
     return res.int_o()
Example #17
0
 def interp(i, inputarg):
     args = [tlc.IntObj(inputarg)]
     obj = tlc.interp_eval(codes[i], 0, args, pools[i])
     return obj.int_o()
Example #18
0
 def fn(n):
     obj = IntObj(n)
     res = interp_eval(bytecode, 0, [obj], pool)
     return res.int_o()