Esempio n. 1
0
 def __init__(self, cpu, cliloop):
     self.setoptions()
     self.cpu = cpu
     self.name = cliloop.get_fresh_cli_name()
     self.cliloop = cliloop
     self.boxes = {}  # box --> local var
     self.branches = []
     self.branchlabels = []
     self.consts = {}  # object --> index
     self.meth_wrapper = self._get_meth_wrapper()
     self.il = self.meth_wrapper.get_il_generator()
     self.av_consts = MethodArgument(0,
                                     System.Type.GetType("System.Object[]"))
     t_InputArgs = dotnet.typeof(InputArgs)
     self.av_inputargs = MethodArgument(1, t_InputArgs)
     self.av_ovf_flag = BoxInt()
     self.exc_value_field = t_InputArgs.GetField('exc_value')
     if cpu.rtyper:
         self.av_OverflowError = ConstObj(
             ootype.cast_to_object(cpu.ll_ovf_exc))
         self.av_ZeroDivisionError = ConstObj(
             ootype.cast_to_object(cpu.ll_zero_exc))
     else:
         self.av_OverflowError = None
         self.av_ZeroDivisionError = None
     self.box2type = {}
Esempio n. 2
0
File: runner.py Progetto: sota/pypy
 def get_exception(self):
     exc_value = self.get_inputargs().get_exc_value()
     if exc_value:
         exc_obj = dotnet.cast_from_native_object(exc_value)
         exc_inst = ootype.cast_from_object(ootype.ROOT, exc_obj)
         cls = ootype.classof(exc_value)
         return ootype.cast_to_object(cls)
     return ootype.cast_to_object(ootype.nullruntimeclass)
Esempio n. 3
0
 def get_exception(self):
     exc_value = self.get_inputargs().get_exc_value()
     if exc_value:
         exc_obj = dotnet.cast_from_native_object(exc_value)
         exc_inst = ootype.cast_from_object(ootype.ROOT, exc_obj)
         cls = ootype.classof(exc_value)
         return ootype.cast_to_object(cls)
     return ootype.cast_to_object(ootype.nullruntimeclass)
Esempio n. 4
0
 def test_unwrap_object(self):
     A = ootype.Instance("A", ootype.ROOT, {})
     a1 = ootype.new(A)
     a2 = ootype.new(A)
     obj1 = ootype.cast_to_object(a1)
     obj2 = ootype.cast_to_object(a2)
     def fn(flag):
         if flag:
             obj = obj1
         else:
             obj = obj2
         a3 = ootype.cast_from_object(A, obj)
         return a3 is a1
     res = self.interpret(fn, [True], backendopt=False)
     assert res is True
Esempio n. 5
0
 def test_convert_string_to_object(self):
     s = self.string_to_ll("hello world")
     obj = ootype.cast_to_object(s)
     def fn():
         s1 = ootype.cast_from_object(ootype.String, obj)
         return s1
     res = self.interpret(fn, [], backendopt=False)
     assert res == 'hello world'
Esempio n. 6
0
 def fn():
     a = ootype.new(A)
     ahash = ootype.identityhash(a)
     obj = ootype.cast_to_object(a)
     native = cast_to_native_object(obj)
     name = native.GetType().get_Name()
     obj2 = cast_from_native_object(native)
     a2 = ootype.cast_from_object(A, obj2)
     a2hash = ootype.identityhash(a2)
     return name, ahash == a2hash
Esempio n. 7
0
 def fn():
     a = ootype.new(A)
     ahash = ootype.identityhash(a)
     obj = ootype.cast_to_object(a)
     native = cast_to_native_object(obj)
     name = native.GetType().get_Name()
     obj2 = cast_from_native_object(native)
     a2 = ootype.cast_from_object(A, obj2)
     a2hash = ootype.identityhash(a2)
     return name, ahash == a2hash
Esempio n. 8
0
File: method.py Progetto: sota/pypy
 def __init__(self, cpu, cliloop):
     self.setoptions()
     self.cpu = cpu
     self.name = cliloop.get_fresh_cli_name()
     self.cliloop = cliloop
     self.boxes = {}  # box --> local var
     self.branches = []
     self.branchlabels = []
     self.consts = {}  # object --> index
     self.meth_wrapper = self._get_meth_wrapper()
     self.il = self.meth_wrapper.get_il_generator()
     self.av_consts = MethodArgument(0, System.Type.GetType("System.Object[]"))
     t_InputArgs = dotnet.typeof(InputArgs)
     self.av_inputargs = MethodArgument(1, t_InputArgs)
     self.av_ovf_flag = BoxInt()
     self.exc_value_field = t_InputArgs.GetField("exc_value")
     if cpu.rtyper:
         self.av_OverflowError = ConstObj(ootype.cast_to_object(cpu.ll_ovf_exc))
         self.av_ZeroDivisionError = ConstObj(ootype.cast_to_object(cpu.ll_zero_exc))
     else:
         self.av_OverflowError = None
         self.av_ZeroDivisionError = None
     self.box2type = {}
Esempio n. 9
0
 def _cast_instance_to_native_obj(self, e):
     from rpython.rtyper.annlowlevel import cast_instance_to_base_obj
     inst = cast_instance_to_base_obj(e)  # SomeOOInstance
     obj = ootype.cast_to_object(inst)  # SomeOOObject
     return dotnet.cast_to_native_object(obj)  # System.Object
Esempio n. 10
0
 def do_runtimenew(self, classbox):
     classobj = classbox.getref(ootype.Class)
     res = ootype.runtimenew(classobj)
     return BoxObj(ootype.cast_to_object(res))
Esempio n. 11
0
 def set_zero_division_error(self):
     exc_obj = ootype.cast_to_object(self.ll_zero_exc)
     exc_value = dotnet.cast_to_native_object(exc_obj)
     self.get_inputargs().set_exc_value(exc_value)
Esempio n. 12
0
 def set_overflow_error(self):
     exc_obj = ootype.cast_to_object(self.ll_ovf_exc)
     exc_value = dotnet.cast_to_native_object(exc_obj)
     self.get_inputargs().set_exc_value(exc_value)
Esempio n. 13
0
 def get_zero_division_error(self):
     exc_type = ootype.cast_to_object(ootype.classof(self.ll_zero_exc))
     exc_value = ootype.cast_to_object(self.ll_zero_exc)
     return exc_type, exc_value
Esempio n. 14
0
 def get_overflow_error(self):
     exc_type = ootype.cast_to_object(ootype.classof(self.ll_ovf_exc))
     exc_value = ootype.cast_to_object(self.ll_ovf_exc)
     return exc_type, exc_value
Esempio n. 15
0
File: runner.py Progetto: sota/pypy
 def set_overflow_error(self):
     exc_obj = ootype.cast_to_object(self.ll_ovf_exc)
     exc_value = dotnet.cast_to_native_object(exc_obj)
     self.get_inputargs().set_exc_value(exc_value)
Esempio n. 16
0
File: runner.py Progetto: sota/pypy
 def typedescr2classbox(self, descr):
     assert isinstance(descr, TypeDescr)
     return ConstObj(ootype.cast_to_object(descr.ooclass))
Esempio n. 17
0
File: runner.py Progetto: sota/pypy
 def _cast_instance_to_native_obj(self, e):
     from rpython.rtyper.annlowlevel import cast_instance_to_base_obj
     inst = cast_instance_to_base_obj(e)      # SomeOOInstance
     obj = ootype.cast_to_object(inst)        # SomeOOObject
     return dotnet.cast_to_native_object(obj) # System.Object
Esempio n. 18
0
File: runner.py Progetto: sota/pypy
 def do_runtimenew(self, classbox):
     classobj = classbox.getref(ootype.Class)
     res = ootype.runtimenew(classobj)
     return BoxObj(ootype.cast_to_object(res))
Esempio n. 19
0
File: runner.py Progetto: sota/pypy
 def set_zero_division_error(self):
     exc_obj = ootype.cast_to_object(self.ll_zero_exc)
     exc_value = dotnet.cast_to_native_object(exc_obj)
     self.get_inputargs().set_exc_value(exc_value)
Esempio n. 20
0
def op_cast_to_object(inst):
    return ootype.cast_to_object(inst)
Esempio n. 21
0
File: runner.py Progetto: sota/pypy
 def get_overflow_error(self):
     exc_type = ootype.cast_to_object(ootype.classof(self.ll_ovf_exc))
     exc_value = ootype.cast_to_object(self.ll_ovf_exc)
     return exc_type, exc_value
Esempio n. 22
0
File: runner.py Progetto: sota/pypy
 def get_zero_division_error(self):
     exc_type = ootype.cast_to_object(ootype.classof(self.ll_zero_exc))
     exc_value = ootype.cast_to_object(self.ll_zero_exc)
     return exc_type, exc_value
Esempio n. 23
0
 def typedescr2classbox(self, descr):
     assert isinstance(descr, TypeDescr)
     return ConstObj(ootype.cast_to_object(descr.ooclass))
Esempio n. 24
0
def op_cast_to_object(inst):
    return ootype.cast_to_object(inst)