Exemplo n.º 1
0
 def test_sclist2pylist(self):
     from runtime import sclist2pylist, build_list
     x = [1, 2, 3]
     assert x == sclist2pylist(build_list(x))
     x = [1, 2, [3, 4]]
     assert x == sclist2pylist(build_list(x))
     x = [[3, 4], [5, 6]]
     assert x == sclist2pylist(build_list(x))
     x = [1]
     assert x == sclist2pylist(build_list(x))
     x = []
     assert x == sclist2pylist(build_list(x))
Exemplo n.º 2
0
    def __init__(self, proto, upvars, args):
        self.proto = proto
        self.insts = proto.insts
        self.args = args
        self.upvars = upvars
        self.to_be_forked = False

        self.localvars = [None] * proto.maxLocalvars

        argn = len(args)
        argc = proto.argc
        if proto.isVararg:
            if argn >= argc:
                self.localvars[:argc] = args[:argc]
                self.varargs = build_list(args[argc:])
            else:
                raise VMException("Expect equal or more than %s arguments, got %s"
                                  % (argc, argn))
        else:
            if argn == argc:
                self.localvars[:argc] = args[:]
            else:
                raise VMException("Expect %s arguments, got %s" % (argc, argn))

        self.stack = []
Exemplo n.º 3
0
 def newList(*args):
     return [runtime.build_list(args)]