Example #1
0
 def lookup_where_with_method_cache(w_self, name):
     space = w_self.space
     promote(w_self)
     assert space.config.objspace.std.withmethodcache
     version_tag = promote(w_self.version_tag())
     if version_tag is None:
         tup = w_self._lookup_where(name)
         return tup
     name = promote_string(name)
     w_class, w_value = w_self._pure_lookup_where_with_method_cache(name, version_tag)
     return w_class, unwrap_cell(space, w_value)
Example #2
0
 def lookup_where_with_method_cache(w_self, name):
     space = w_self.space
     promote(w_self)
     assert space.config.objspace.std.withmethodcache
     version_tag = promote(w_self.version_tag())
     if version_tag is None:
         tup = w_self._lookup_where(name)
         return tup
     name = promote_string(name)
     w_class, w_value = w_self._pure_lookup_where_with_method_cache(name, version_tag)
     return w_class, unwrap_cell(space, w_value)
Example #3
0
 def f(n):
     while n < 21:
         driver.jit_merge_point(n=n)
         promote_string(str(n % 3))
         n += 1
     return 0
Example #4
0
    def decode_args(self, mand="", opt="", vargs=False, self_of=None):
        cf = self.cur_cf
        nargs = cf.nargs # Number of arguments passed
        
        mand = jit.promote_string(mand)
        opt = jit.promote_string(opt)
        self_of = jit.promote(self_of)

        if nargs < len(mand):
            if vargs:
                self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, \
                  "Too few parameters (%d passed, but at least %d needed)." % (nargs, len(mand)))])
            else:
                self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, \
                  "Too few parameters (%d passed, but %d needed)." % (nargs, len(mand)))])
        elif nargs > (len(mand) + len(opt)) and not vargs:
            raise Exception("XXX")

        if nargs == 0:
            if vargs:
                return (None, [])
            else:
                return (None, None)
        
        nrmp = [None] * (len(mand) + len(opt)) # Normal params
        i = 0
        while i < (len(mand) + len(opt)):
            if i >= nargs:
                for j in range(i, nargs):
                    nrmp[j] = None
                break

            if i < len(mand):
                t = mand[i]
            else:
                t = opt[i - len(mand)]
        
            o = cf.stack_get(cf.stackpe - nargs + i)
            
            if t == "!":
                assert self_of is not None
                if not isinstance(o, self_of):
                    raise Exception("XXX")
                nrmp[i] = o
                i += 1
                continue
            
            if t >= "a":
                if o is self.get_builtin(Builtins.BUILTIN_NULL_OBJ):
                    nrmp[i] = None
                    i += 1
                    continue
                t = chr(ord("A") + ord(t) - ord("a"))
        
            if t == "O":
                nrmp[i] = o
            else:
                if t == "C":
                    Builtins.type_check_class(self, o)
                elif t == "D":
                    Builtins.type_check_dict(self, o)
                elif t == "E":
                    Builtins.type_check_exception(self, o)
                elif t == "F":
                    Builtins.type_check_func(self, o)
                elif t == "I":
                    Builtins.type_check_int(self, o)
                elif t == "L":
                    Builtins.type_check_list(self, o)
                elif t == "M":
                    Builtins.type_check_module(self, o)
                elif t == "N":
                    Builtins.type_check_number(self, o)
                elif t == "S":
                    Builtins.type_check_string(self, o)
                elif t == "W":
                    Builtins.type_check_set(self, o)
                else:
                    print t
                    raise Exception("XXX")
                nrmp[i] = o
            
            i += 1

        if vargs:
            vap = [None] * (nargs - i)
            for j in range(i, nargs):
                vap[j - i] = cf.stack_get(cf.stackpe - nargs + j)
        else:
            vap = None

        cf.stack_del_from(cf.stackpe - nargs)
        
        return (nrmp, vap)
Example #5
0
 def f(n):
     while n < 21:
         driver.jit_merge_point(n=n)
         promote_string(str(n % 3))
         n += 1
     return 0