Author: Alex Gaynor <alex.gay...@gmail.com> Branch: kill-someobject Changeset: r57819:5397353bd973 Date: 2012-10-07 07:44 -0700 http://bitbucket.org/pypy/pypy/changeset/5397353bd973/
Log: Added rtyper_makekey to StringBuilder diff --git a/pypy/rlib/rstring.py b/pypy/rlib/rstring.py --- a/pypy/rlib/rstring.py +++ b/pypy/rlib/rstring.py @@ -134,6 +134,10 @@ def rtyper_makerepr(self, rtyper): return rtyper.type_system.rbuilder.stringbuilder_repr + def rtyper_makekey(self): + return self.__class__, + + class SomeUnicodeBuilder(SomeObject): def method_append(self, s_str): if s_str != s_None: @@ -166,6 +170,10 @@ def rtyper_makerepr(self, rtyper): return rtyper.type_system.rbuilder.unicodebuilder_repr + def rtyper_makekey(self): + return self.__class__, + + class BaseEntry(object): def compute_result_annotation(self, s_init_size=None): if s_init_size is not None: @@ -177,29 +185,35 @@ def specialize_call(self, hop): return hop.r_result.rtyper_new(hop) + class StringBuilderEntry(BaseEntry, ExtRegistryEntry): _about_ = StringBuilder use_unicode = False + class UnicodeBuilderEntry(BaseEntry, ExtRegistryEntry): _about_ = UnicodeBuilder use_unicode = True + class __extend__(pairtype(SomeStringBuilder, SomePBC)): def union((sb, p)): assert p.const is None return SomeStringBuilder(can_be_None=True) + class __extend__(pairtype(SomePBC, SomeStringBuilder)): def union((p, sb)): assert p.const is None return SomeStringBuilder(can_be_None=True) + class __extend__(pairtype(SomeUnicodeBuilder, SomePBC)): def union((sb, p)): assert p.const is None return SomeUnicodeBuilder(can_be_None=True) + class __extend__(pairtype(SomePBC, SomeUnicodeBuilder)): def union((p, sb)): assert p.const is None diff --git a/pypy/rpython/lltypesystem/rbuilder.py b/pypy/rpython/lltypesystem/rbuilder.py --- a/pypy/rpython/lltypesystem/rbuilder.py +++ b/pypy/rpython/lltypesystem/rbuilder.py @@ -1,7 +1,6 @@ from pypy.rlib import rgc, jit from pypy.rlib.objectmodel import enforceargs from pypy.rlib.rarithmetic import ovfcheck -from pypy.rpython.annlowlevel import llstr from pypy.rpython.rptr import PtrRepr from pypy.rpython.lltypesystem import lltype, rstr from pypy.rpython.lltypesystem.lltype import staticAdtMethod, nullptr @@ -13,7 +12,7 @@ # Think about heuristics below, maybe we can come up with something # better or at least compare it with list heuristics -GROW_FAST_UNTIL = 100*1024*1024 # 100 MB +GROW_FAST_UNTIL = 100 * 1024 * 1024 # 100 MB def new_grow_func(name, mallocfn, copycontentsfn): @enforceargs(None, int) diff --git a/pypy/rpython/rbuilder.py b/pypy/rpython/rbuilder.py --- a/pypy/rpython/rbuilder.py +++ b/pypy/rpython/rbuilder.py @@ -1,9 +1,9 @@ - from pypy.rpython.rmodel import Repr from pypy.rpython.lltypesystem import lltype from pypy.rlib.rstring import INIT_SIZE from pypy.annotation.model import SomeChar, SomeUnicodeCodePoint + class AbstractStringBuilderRepr(Repr): def rtyper_new(self, hop): if len(hop.args_v) == 0: @@ -53,7 +53,7 @@ vlist = hop.inputargs(self) hop.exception_cannot_occur() return hop.gendirectcall(self.ll_is_true, *vlist) - + def convert_const(self, value): if not value is None: raise TypeError("Prebuilt builedrs that are not none unsupported") _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit