示例#1
0
 def call(self, argv):
     if len(argv) != 1:
         raise space.unwind(space.LCallError(1, 1, False, len(argv)))
     module = argv[0]
     assert isinstance(module, space.Module)
     entry = self.unit.functions[0]
     frame = Frame(entry, module, None)
     regv = new_register_array(entry.regc)
     return interpret(0, entry.block, regv, frame)
示例#2
0
 def call(self, argv):
     if len(argv) != 1:
         raise space.unwind(space.LCallError(1, 1, False, len(argv)))
     module = argv[0]
     if not isinstance(module, space.Module):
         raise space.unwind(
             space.LError(u"Argument to program must be a module"))
     entry = self.unit.functions[0]
     frame = Frame(entry, module, None, entry.regc)
     #regv = new_register_array(entry.regc)
     return interpret(0, entry.block, frame)
示例#3
0
 def call(self, argv):
     varargs = self.function.flags & 1 == 1
     argc = self.function.argc
     topc = self.function.topc
     L = len(argv)
     if L < argc:
         raise space.unwind(space.LCallError(argc, topc, varargs, L))
     # We are using this trait.
     #if L > topc and not varargs:
     #    raise space.Error(u"too many arguments [%d], from %d to %d arguments allowed" % (L, argc, topc))
     frame = Frame(self.function, self.frame.module, self.frame)
     for i in range(min(topc, L)):
         frame.local[i] = argv[i]
     if varargs:
         frame.local[topc] = space.List(argv[min(topc, L):])
     regv = new_register_array(self.function.regc)
     return interpret(0, self.function.block, regv, frame)
示例#4
0
def create_frame(parent, function, argv):
    varargs = jit.promote(function.flags & 1 == 1)
    argc = function.argc
    topc = function.topc
    L = len(argv)
    if L < argc:
        # The pc=0 refers to the function itself. This entry
        # is really helpful when trying to determine the origin of a CallError.
        head_entry = TraceEntry(rffi.r_long(0), function.unit.sources,
                                function.sourcemap, function.unit.path)
        unwinder = space.unwind(space.LCallError(argc, topc, varargs, L))
        unwinder.traceback.contents.append(head_entry)
        raise unwinder
    # We are using this trait.
    #if L > topc and not varargs:
    #    raise space.Error(u"too many arguments [%d], from %d to %d arguments allowed" % (L, argc, topc))
    frame = Frame(function, parent.module, parent, function.regc)
    A = min(topc, L)
    for i in range(A):
        frame.store_local(i, argv[i])
    if varargs:
        frame.store_local(topc, space.List(argv[A:]))
    return frame
示例#5
0
文件: builtin.py 项目: Eirikur/lever
 def fancy_frame(argv):
     args = ()
     L = len(argv)
     if L < argc or (L > topc and not variadic):
         raise space.unwind(space.LCallError(argc, topc, variadic, L))
     for i in argi:
         arg = argv[i]
         if isinstance(arg, argtypes[i]):
             args += (arg, )
         else:
             args += (space.cast(arg, argtypes[i], u"arg:%d" % i), )
     for j in argj:
         if j < L:
             arg = argv[j]
             if arg is null:
                 arg = None
             elif not isinstance(arg, argtypes[j]):
                 arg = space.cast(arg, argtypes[j], u"arg:%d" % j)
         else:
             arg = None
         args += (arg, )
     if variadic:
         args += (argv[min(topc, L):], )
     return func(*args)