[pypy-commit] pypy rtyper-stuff: add missing decorators

rlamy noreply at buildbot.pypy.org
Sat Oct 4 04:17:01 CEST 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rtyper-stuff
Changeset: r73766:66422d374461
Date: 2014-10-04 02:25 +0100
http://bitbucket.org/pypy/pypy/changeset/66422d374461/

Log:	add missing decorators

diff --git a/rpython/rtyper/lltypesystem/rbytearray.py b/rpython/rtyper/lltypesystem/rbytearray.py
--- a/rpython/rtyper/lltypesystem/rbytearray.py
+++ b/rpython/rtyper/lltypesystem/rbytearray.py
@@ -38,12 +38,14 @@
             i += s.length()
         cls.ll_strsetitem_nonneg(s, i, item)
 
+    @staticmethod
     def ll_strsetitem_nonneg(s, i, item):
         chars = s.chars
         ll_assert(i >= 0, "negative str getitem index")
         ll_assert(i < len(chars), "str getitem index out of bound")
         chars[i] = chr(item)
 
+    @staticmethod
     def ll_stritem_nonneg(s, i):
         return ord(rstr.LLHelpers.ll_stritem_nonneg(s, i))
 
diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -270,6 +270,7 @@
 class LLHelpers(AbstractLLHelpers):
     from rpython.rtyper.annlowlevel import llstr, llunicode
 
+    @staticmethod
     @jit.elidable
     def ll_str_mul(s, times):
         if times < 0:
@@ -292,6 +293,7 @@
             i += j
         return newstr
 
+    @staticmethod
     @jit.elidable
     def ll_char_mul(ch, times):
         if typeOf(ch) is Char:
@@ -308,9 +310,11 @@
             j += 1
         return newstr
 
+    @staticmethod
     def ll_strlen(s):
         return len(s.chars)
 
+    @staticmethod
     @signature(types.any(), types.int(), returns=types.any())
     def ll_stritem_nonneg(s, i):
         chars = s.chars
@@ -318,6 +322,7 @@
         ll_assert(i < len(chars), "str getitem index out of bound")
         return chars[i]
 
+    @staticmethod
     def ll_chr2str(ch):
         if typeOf(ch) is Char:
             malloc = mallocstr
@@ -328,6 +333,7 @@
         return s
 
     # @jit.look_inside_iff(lambda str: jit.isconstant(len(str.chars)) and len(str.chars) == 1)
+    @staticmethod
     @jit.oopspec("str.str2unicode(str)")
     def ll_str2unicode(str):
         lgt = len(str.chars)
@@ -338,6 +344,7 @@
             s.chars[i] = cast_primitive(UniChar, str.chars[i])
         return s
 
+    @staticmethod
     def ll_str2bytearray(str):
         from rpython.rtyper.lltypesystem.rbytearray import BYTEARRAY
 
@@ -347,6 +354,7 @@
             b.chars[i] = str.chars[i]
         return b
 
+    @staticmethod
     @jit.elidable
     def ll_strhash(s):
         # unlike CPython, there is no reason to avoid to return -1
@@ -362,13 +370,17 @@
             s.hash = x
         return x
 
+    @staticmethod
     def ll_length(s):
         return len(s.chars)
 
+    @staticmethod
     def ll_strfasthash(s):
         return s.hash     # assumes that the hash is already computed
 
+    @staticmethod
     @jit.elidable
+    @jit.oopspec('stroruni.concat(s1, s2)')
     def ll_strconcat(s1, s2):
         len1 = s1.length()
         len2 = s2.length()
@@ -386,8 +398,8 @@
         else:
             newstr.copy_contents(s2, newstr, 0, len1, len2)
         return newstr
-    ll_strconcat.oopspec = 'stroruni.concat(s1, s2)'
 
+    @staticmethod
     @jit.elidable
     def ll_strip(s, ch, left, right):
         s_len = len(s.chars)
@@ -408,6 +420,7 @@
         s.copy_contents(s, result, lpos, 0, r_len)
         return result
 
+    @staticmethod
     @jit.elidable
     def ll_strip_default(s, left, right):
         s_len = len(s.chars)
@@ -428,6 +441,7 @@
         s.copy_contents(s, result, lpos, 0, r_len)
         return result
 
+    @staticmethod
     @jit.elidable
     def ll_strip_multiple(s, s2, left, right):
         s_len = len(s.chars)
@@ -448,6 +462,7 @@
         s.copy_contents(s, result, lpos, 0, r_len)
         return result
 
+    @staticmethod
     @jit.elidable
     def ll_upper(s):
         s_chars = s.chars
@@ -462,6 +477,7 @@
             i += 1
         return result
 
+    @staticmethod
     @jit.elidable
     def ll_lower(s):
         s_chars = s.chars
@@ -476,6 +492,7 @@
             i += 1
         return result
 
+    @staticmethod
     def ll_join(s, length, items):
         s_chars = s.chars
         s_len = len(s_chars)
@@ -509,7 +526,9 @@
             i += 1
         return result
 
+    @staticmethod
     @jit.elidable
+    @jit.oopspec('stroruni.cmp(s1, s2)')
     def ll_strcmp(s1, s2):
         if not s1 and not s2:
             return True
@@ -531,9 +550,10 @@
                 return diff
             i += 1
         return len1 - len2
-    ll_strcmp.oopspec = 'stroruni.cmp(s1, s2)'
 
+    @staticmethod
     @jit.elidable
+    @jit.oopspec('stroruni.equal(s1, s2)')
     def ll_streq(s1, s2):
         if s1 == s2:       # also if both are NULLs
             return True
@@ -551,8 +571,8 @@
                 return False
             j += 1
         return True
-    ll_streq.oopspec = 'stroruni.equal(s1, s2)'
 
+    @staticmethod
     @jit.elidable
     def ll_startswith(s1, s2):
         len1 = len(s1.chars)
@@ -569,11 +589,13 @@
 
         return True
 
+    @staticmethod
     def ll_startswith_char(s, ch):
         if not len(s.chars):
             return False
         return s.chars[0] == ch
 
+    @staticmethod
     @jit.elidable
     def ll_endswith(s1, s2):
         len1 = len(s1.chars)
@@ -591,11 +613,13 @@
 
         return True
 
+    @staticmethod
     def ll_endswith_char(s, ch):
         if not len(s.chars):
             return False
         return s.chars[len(s.chars) - 1] == ch
 
+    @staticmethod
     @jit.elidable
     @signature(types.any(), types.any(), types.int(), types.int(), returns=types.int())
     def ll_find_char(s, ch, start, end):
@@ -608,6 +632,7 @@
             i += 1
         return -1
 
+    @staticmethod
     @jit.elidable
     def ll_rfind_char(s, ch, start, end):
         if end > len(s.chars):
@@ -619,6 +644,7 @@
                 return i
         return -1
 
+    @staticmethod
     @jit.elidable
     def ll_count_char(s, ch, start, end):
         count = 0
@@ -631,6 +657,7 @@
             i += 1
         return count
 
+    @staticmethod
     @signature(types.any(), types.any(), types.int(), types.int(), returns=types.int())
     def ll_find(s1, s2, start, end):
         if start < 0:
@@ -646,6 +673,7 @@
 
         return LLHelpers.ll_search(s1, s2, start, end, FAST_FIND)
 
+    @staticmethod
     @signature(types.any(), types.any(), types.int(), types.int(), returns=types.int())
     def ll_rfind(s1, s2, start, end):
         if start < 0:
@@ -681,6 +709,7 @@
             res = 0
         return res
 
+    @staticmethod
     @jit.elidable
     def ll_search(s1, s2, start, end, mode):
         count = 0
@@ -768,6 +797,7 @@
             return -1
         return count
 
+    @staticmethod
     @signature(types.int(), types.any(), returns=types.any())
     @jit.look_inside_iff(lambda length, items: jit.loop_unrolling_heuristic(
         items, length))
@@ -802,6 +832,7 @@
             i += 1
         return result
 
+    @staticmethod
     @jit.look_inside_iff(lambda length, chars, RES: jit.isconstant(length) and jit.isvirtual(chars))
     def ll_join_chars(length, chars, RES):
         # no need to optimize this, will be replaced by string builder
@@ -821,6 +852,7 @@
             i += 1
         return result
 
+    @staticmethod
     @jit.oopspec('stroruni.slice(s1, start, stop)')
     @signature(types.any(), types.int(), types.int(), returns=types.any())
     @jit.elidable
@@ -836,9 +868,11 @@
         s1.copy_contents(s1, newstr, start, 0, lgt)
         return newstr
 
+    @staticmethod
     def ll_stringslice_startonly(s1, start):
         return LLHelpers._ll_stringslice(s1, start, len(s1.chars))
 
+    @staticmethod
     @signature(types.any(), types.int(), types.int(), returns=types.any())
     def ll_stringslice_startstop(s1, start, stop):
         if jit.we_are_jitted():
@@ -851,10 +885,12 @@
                 stop = len(s1.chars)
         return LLHelpers._ll_stringslice(s1, start, stop)
 
+    @staticmethod
     def ll_stringslice_minusone(s1):
         newlen = len(s1.chars) - 1
         return LLHelpers._ll_stringslice(s1, 0, newlen)
 
+    @staticmethod
     def ll_split_chr(LIST, s, c, max):
         chars = s.chars
         strlen = len(chars)
@@ -889,6 +925,7 @@
         item.copy_contents(s, item, i, 0, j - i)
         return res
 
+    @staticmethod
     def ll_split(LIST, s, c, max):
         count = 1
         if max == -1:
@@ -920,6 +957,7 @@
         item.copy_contents(s, item, prev_pos, 0, last - prev_pos)
         return res
 
+    @staticmethod
     def ll_rsplit_chr(LIST, s, c, max):
         chars = s.chars
         strlen = len(chars)
@@ -955,6 +993,7 @@
         item.copy_contents(s, item, j, 0, i - j)
         return res
 
+    @staticmethod
     def ll_rsplit(LIST, s, c, max):
         count = 1
         if max == -1:
@@ -986,6 +1025,7 @@
         item.copy_contents(s, item, 0, 0, prev_pos)
         return res
 
+    @staticmethod
     @jit.elidable
     def ll_replace_chr_chr(s, c1, c2):
         length = len(s.chars)
@@ -1001,6 +1041,7 @@
             j += 1
         return newstr
 
+    @staticmethod
     @jit.elidable
     def ll_contains(s, c):
         chars = s.chars
@@ -1012,6 +1053,7 @@
             i += 1
         return False
 
+    @staticmethod
     @jit.elidable
     def ll_int(s, base):
         if not 2 <= base <= 36:
@@ -1068,23 +1110,29 @@
     #   ll_build_push(x, next_string, n-1)
     #   s = ll_build_finish(x)
 
+    @staticmethod
     def ll_build_start(parts_count):
         return malloc(TEMP, parts_count)
 
+    @staticmethod
     def ll_build_push(builder, next_string, index):
         builder[index] = next_string
 
+    @staticmethod
     def ll_build_finish(builder):
         return LLHelpers.ll_join_strs(len(builder), builder)
 
+    @staticmethod
     @specialize.memo()
     def ll_constant(s):
         return string_repr.convert_const(s)
 
+    @staticmethod
     @specialize.memo()
     def ll_constant_unicode(s):
         return unicode_repr.convert_const(s)
 
+    @classmethod
     def do_stringformat(cls, hop, sourcevarsrepr):
         s_str = hop.args_s[0]
         assert s_str.is_constant()
@@ -1150,8 +1198,8 @@
 
         hop.exception_cannot_occur()   # to ignore the ZeroDivisionError of '%'
         return hop.gendirectcall(cls.ll_join_strs, size, vtemp)
-    do_stringformat = classmethod(do_stringformat)
 
+    @staticmethod
     @jit.dont_look_inside
     def ll_string2list(RESLIST, src):
         length = len(src.chars)


More information about the pypy-commit mailing list