Exemple #1
0
def rewrap_args(space, w_args, startfrom):
    args = space.unpackiterable(w_args)
    paramlen = len(args)-startfrom
    b_args = new_array(System.Object, paramlen)
    b_paramtypes = new_array(System.Type, paramlen)
    for i in range(startfrom, len(args)):
        j = i-startfrom
        b_obj = py2cli(space, args[i])
        b_args[j] = b_obj
        if b_obj is None:
            b_paramtypes[j] = typeof(System.Object) # we really can't be more precise
        else:
            b_paramtypes[j] = b_obj.GetType() # XXX: potentially inefficient
    return b_args, b_paramtypes
Exemple #2
0
def rewrap_args(space, w_args, startfrom):
    args = space.unpackiterable(w_args)
    paramlen = len(args)-startfrom
    b_args = new_array(System.Object, paramlen)
    b_paramtypes = new_array(System.Type, paramlen)
    for i in range(startfrom, len(args)):
        j = i-startfrom
        b_obj = py2cli(space, args[i])
        b_args[j] = b_obj
        if b_obj is None:
            b_paramtypes[j] = typeof(System.Object) # we really can't be more precise
        else:
            b_paramtypes[j] = b_obj.GetType() # XXX: potentially inefficient
    return b_args, b_paramtypes
Exemple #3
0
 def newgraph(self, sigtoken, name):
     argsclass = sigtoken.args
     args = new_array(System.Type, len(argsclass)+1)
     args[0] = System.Type.GetType("System.Object[]")
     for i in range(len(argsclass)):
         args[i+1] = class2type(argsclass[i])
     res = class2type(sigtoken.res)
     builder = Builder(self, name, res, args, sigtoken)
     return builder, builder.gv_entrypoint, builder.inputargs_gv[:]
Exemple #4
0
 def emit_new_arrayofvoids(self, op):
     clitype = dotnet.typeof(ListOfVoid)
     ctor = clitype.GetConstructor(dotnet.new_array(System.Type, 0))
     _ll_resize = clitype.GetMethod('_ll_resize')
     self.il.Emit(OpCodes.Newobj, ctor)
     self.il.Emit(OpCodes.Dup)
     op.args[0].load(self)
     self.il.Emit(OpCodes.Callvirt, _ll_resize)
     self.store_result(op)
Exemple #5
0
 def finish_code(self):
     delegatetype = dotnet.typeof(LoopDelegate)
     # initialize the array of genconsts
     consts = dotnet.new_array(System.Object, len(self.consts))
     for av_const, i in self.consts.iteritems():
         consts[i] = av_const.get_cliobj()
     # build the delegate
     func = self.meth_wrapper.create_delegate(delegatetype, consts)
     return dotnet.clidowncast(func, LoopDelegate)
 def build_fn():
     tObjArray = System.Type.GetType("System.Object[]")
     tInt = typeof(System.Int32)
     args = init_array(System.Type, tObjArray, tInt, tInt)
     meth = Utils.CreateDynamicMethod("add", tInt, args)
     il = meth.GetILGenerator()
     il.Emit(OpCodes.Ldarg_1)
     il.Emit(OpCodes.Ldarg_2)
     il.Emit(OpCodes.Add)
     il.Emit(OpCodes.Ret)
     array = new_array(System.Object, 0)
     myfunc = meth.CreateDelegate(typeof(FUNCTYPE), array)
     return myfunc
Exemple #7
0
 def build_fn():
     tObjArray = System.Type.GetType("System.Object[]")
     tInt = typeof(System.Int32)
     args = init_array(System.Type, tObjArray, tInt, tInt)
     meth = Utils.CreateDynamicMethod("add", tInt, args)
     il = meth.GetILGenerator()
     il.Emit(OpCodes.Ldarg_1)
     il.Emit(OpCodes.Ldarg_2)
     il.Emit(OpCodes.Add)
     il.Emit(OpCodes.Ret)
     array = new_array(System.Object, 0)
     myfunc = meth.CreateDelegate(typeof(FUNCTYPE), array)
     return myfunc
Exemple #8
0
    def end(self):
        # render all the pending branches
        for branch in self.branches:
            branch.replayops()

        # render the return blocks for last, else the verifier could complain
        for retlabel, gv_returnvar in self.returnblocks:
            self.il.MarkLabel(retlabel)
            op = ops.Return(self, gv_returnvar)
            self.emit(op)

        # initialize the array of genconsts
        consts = new_array(System.Object, len(self.genconsts))
        for gv_const, i in self.genconsts.iteritems():
            consts[i] = gv_const.getobj()
        # build the delegate
        myfunc = self.meth.CreateDelegate(self.delegatetype, consts)
        self.gv_entrypoint.holder.SetFunc(myfunc)
Exemple #9
0
 def get_constructor_info(self):
     clitype = self.get_clitype()
     return clitype.GetConstructor(dotnet.new_array(System.Type, 0))
Exemple #10
0
 def _get_args_array(self, arglist):
     array = dotnet.new_array(System.Type, len(arglist)+1)
     array[0] = System.Type.GetType("System.Object[]")
     for i in range(len(arglist)):
         array[i+1] = arglist[i]
     return array
 def fn():
     x = new_array(System.Object, 2)
     x[0] = box(42)
     x[1] = box(43)
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
Exemple #12
0
 def fn():
     x = new_array(System.Object, 2)
     x[0] = box(42)
     x[1] = box(43)
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
Exemple #13
0
 def fn():
     array = new_array(System.Object, 5)
     array[0] = ArrayList()
     return array[0].GetType().get_Name()
Exemple #14
0
 def fn():
     array = new_array(System.Object, 5)
     array[0] = ArrayList()
     return array[0].GetType().get_Name()