[pypy-svn] r26493 - in pypy/dist/pypy: jit/llabstractinterp/test jit/timeshifter module/_socket/rpython rpython rpython/lltypesystem rpython/module rpython/ootypesystem rpython/rctypes rpython/rctypes/test translator/c translator/llvm
nik at codespeak.net
nik at codespeak.net
Fri Apr 28 08:42:56 CEST 2006
Author: nik
Date: Fri Apr 28 08:42:26 2006
New Revision: 26493
Added:
pypy/dist/pypy/rpython/lltypesystem/rstr.py (contents, props changed)
pypy/dist/pypy/rpython/ootypesystem/rstr.py (contents, props changed)
Modified:
pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tl.py
pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tlr.py
pypy/dist/pypy/jit/llabstractinterp/test/test_llabstractinterp.py
pypy/dist/pypy/jit/llabstractinterp/test/test_vlist.py
pypy/dist/pypy/jit/timeshifter/rtyper.py
pypy/dist/pypy/module/_socket/rpython/ll__socket.py
pypy/dist/pypy/rpython/lltypesystem/rclass.py
pypy/dist/pypy/rpython/lltypesystem/rlist.py
pypy/dist/pypy/rpython/module/ll_os.py
pypy/dist/pypy/rpython/module/ll_os_path.py
pypy/dist/pypy/rpython/module/support.py
pypy/dist/pypy/rpython/rctypes/achar_p.py
pypy/dist/pypy/rpython/rctypes/rarray.py
pypy/dist/pypy/rpython/rctypes/rchar_p.py
pypy/dist/pypy/rpython/rctypes/test/test_rfunc.py
pypy/dist/pypy/rpython/rfloat.py
pypy/dist/pypy/rpython/rint.py
pypy/dist/pypy/rpython/rstr.py
pypy/dist/pypy/rpython/typesystem.py
pypy/dist/pypy/translator/c/extfunc.py
pypy/dist/pypy/translator/llvm/extfunchelper.py
pypy/dist/pypy/translator/llvm/gc.py
Log:
split rstr into an lltype and minimal ootype version. fix a lot of imports of
rstr, but not all of them. some stuff relies too much on the fact
that there is only an lltype rstr and will have to be fixed somehwere
along the line.
Modified: pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tl.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tl.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tl.py Fri Apr 28 08:42:26 2006
@@ -4,7 +4,7 @@
from pypy.translator.translator import TranslationContext
from pypy.jit.tl import tl
from pypy.jit.llabstractinterp.llabstractinterp import LLAbstractInterp
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.llinterp import LLInterpreter
from pypy.jit.llabstractinterp.test.test_llabstractinterp import summary
#from pypy.translator.backendopt import inline
Modified: pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tlr.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tlr.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp/test/test_jit_tlr.py Fri Apr 28 08:42:26 2006
@@ -4,7 +4,7 @@
from pypy.jit.llabstractinterp.llabstractinterp import LLAbstractInterp
from pypy.jit.llabstractinterp.test.test_llabstractinterp import summary
from pypy.rpython.llinterp import LLInterpreter
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.jit.tl import tlr
Modified: pypy/dist/pypy/jit/llabstractinterp/test/test_llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/test/test_llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp/test/test_llabstractinterp.py Fri Apr 28 08:42:26 2006
@@ -3,7 +3,7 @@
from pypy.rpython.annlowlevel import annotate_lowlevel_helper
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.llinterp import LLInterpreter
-from pypy.rpython import rstr
+from pypy.rpython.lltypesystem import rstr
from pypy.annotation import model as annmodel
from pypy.jit.llabstractinterp.llabstractinterp import LLAbstractInterp, Policy
from pypy.objspace.flow import model as flowmodel
Modified: pypy/dist/pypy/jit/llabstractinterp/test/test_vlist.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/test/test_vlist.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp/test/test_vlist.py Fri Apr 28 08:42:26 2006
@@ -3,7 +3,7 @@
from pypy.jit.llabstractinterp.llabstractinterp import LLAbstractInterp, Policy
from pypy.jit.llabstractinterp.test.test_llabstractinterp import summary
from pypy.rpython.llinterp import LLInterpreter
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.objectmodel import hint
policy = Policy(inlining=True, const_propagate=True, concrete_args=False,
Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py Fri Apr 28 08:42:26 2006
@@ -4,7 +4,7 @@
from pypy.rpython import annlowlevel
from pypy.rpython.rtyper import RPythonTyper, LowLevelOpList, TyperError
from pypy.rpython.rmodel import Repr, inputconst
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.typesystem import TypeSystem
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython import rgenop
Modified: pypy/dist/pypy/module/_socket/rpython/ll__socket.py
==============================================================================
--- pypy/dist/pypy/module/_socket/rpython/ll__socket.py (original)
+++ pypy/dist/pypy/module/_socket/rpython/ll__socket.py Fri Apr 28 08:42:26 2006
@@ -1,6 +1,6 @@
import _socket
-from pypy.rpython.rstr import STR
+from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.lltypesystem.lltype import GcStruct, Signed, Array, Char, Ptr, malloc
from pypy.rpython.module.support import to_rstr, from_rstr
from pypy.rpython.module.support import to_opaque_object, from_opaque_object
Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py Fri Apr 28 08:42:26 2006
@@ -538,7 +538,7 @@
def ll_str(self, i): # doesn't work for non-gc classes!
instance = cast_pointer(OBJECTPTR, i)
- from pypy.rpython import rstr
+ from pypy.rpython.lltypesystem import rstr
nameLen = len(instance.typeptr.name)
nameString = malloc(rstr.STR, nameLen-1)
i = 0
Modified: pypy/dist/pypy/rpython/lltypesystem/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rlist.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rlist.py Fri Apr 28 08:42:26 2006
@@ -14,7 +14,7 @@
GcForwardReference, Ptr, GcArray, GcStruct, \
Void, Signed, malloc, typeOf, Primitive, \
Bool, nullptr, typeMethod
-from pypy.rpython import rstr
+from pypy.rpython.lltypesystem import rstr
from pypy.rpython import robject
# ____________________________________________________________
Added: pypy/dist/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/lltypesystem/rstr.py Fri Apr 28 08:42:26 2006
@@ -0,0 +1,37 @@
+from pypy.rpython.rstr import string_repr, StringRepr, STR, AbstractStringIteratorRepr, \
+ ll_strconcat, instance_str_prefix, instance_str_suffix, list_str_open_bracket, ll_join, list_str_sep, list_str_close_bracket
+from pypy.rpython.lltypesystem.lltype import malloc, GcStruct, Ptr, Signed
+
+class __extend__(StringRepr):
+
+ lowleveltype = Ptr(STR)
+
+ def make_iterator_repr(self):
+ return string_iterator_repr
+
+
+class StringIteratorRepr(AbstractStringIteratorRepr):
+
+ lowleveltype = Ptr(GcStruct('stringiter',
+ ('string', string_repr.lowleveltype),
+ ('index', Signed)))
+
+ def __init__(self):
+ self.ll_striter = ll_striter
+ self.ll_strnext = ll_strnext
+
+def ll_striter(string):
+ iter = malloc(string_iterator_repr.lowleveltype.TO)
+ iter.string = string
+ iter.index = 0
+ return iter
+
+def ll_strnext(iter):
+ chars = iter.string.chars
+ index = iter.index
+ if index >= len(chars):
+ raise StopIteration
+ iter.index = index + 1
+ return chars[index]
+
+string_iterator_repr = StringIteratorRepr()
Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os.py Fri Apr 28 08:42:26 2006
@@ -14,7 +14,7 @@
# and buffer preparation stuff is not useful.
import os, errno
-from pypy.rpython.rstr import STR
+from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.lltypesystem.lltype import \
GcStruct, Signed, Array, Char, Ptr, malloc
from pypy.rpython.module.support import to_rstr, from_rstr, ll_strcpy, _ll_strfill
Modified: pypy/dist/pypy/rpython/module/ll_os_path.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os_path.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os_path.py Fri Apr 28 08:42:26 2006
@@ -6,7 +6,7 @@
import os
import stat
-from pypy.rpython.rstr import STR
+from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.module.support import to_rstr, from_rstr, ll_strcpy
from pypy.rpython.module.ll_os import ll_os_stat
Modified: pypy/dist/pypy/rpython/module/support.py
==============================================================================
--- pypy/dist/pypy/rpython/module/support.py (original)
+++ pypy/dist/pypy/rpython/module/support.py Fri Apr 28 08:42:26 2006
@@ -1,6 +1,6 @@
from pypy.rpython.lltypesystem import lltype
from pypy.rpython import extfunctable
-from pypy.rpython.rstr import STR
+from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.lltypesystem.lltype import \
GcStruct, Signed, Array, Char, Ptr, malloc
Added: pypy/dist/pypy/rpython/ootypesystem/rstr.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/ootypesystem/rstr.py Fri Apr 28 08:42:26 2006
@@ -0,0 +1,17 @@
+from pypy.rpython.rstr import string_repr, StringRepr, STR, AbstractStringIteratorRepr
+from pypy.rpython.lltypesystem.lltype import Ptr
+from pypy.rpython.ootypesystem.ootype import Signed, Record
+
+class __extend__(StringRepr):
+
+ lowleveltype = Ptr(STR)
+
+ def make_iterator_repr(self):
+ return string_iterator_repr
+
+
+class StringIteratorRepr(AbstractStringIteratorRepr):
+
+ lowleveltype = Record({'string': string_repr.lowleveltype, 'index': Signed})
+
+string_iterator_repr = StringIteratorRepr
Modified: pypy/dist/pypy/rpython/rctypes/achar_p.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/achar_p.py (original)
+++ pypy/dist/pypy/rpython/rctypes/achar_p.py Fri Apr 28 08:42:26 2006
@@ -9,7 +9,7 @@
_about_ = c_char_p
def specialize_call(self, hop):
- from pypy.rpython.rstr import string_repr
+ string_repr = hop.rtyper.type_system.rstr.string_repr
r_char_p = hop.r_result
v_result = r_char_p.allocate_instance(hop.llops)
if len(hop.args_s):
Modified: pypy/dist/pypy/rpython/rctypes/rarray.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rarray.py (original)
+++ pypy/dist/pypy/rpython/rctypes/rarray.py Fri Apr 28 08:42:26 2006
@@ -1,5 +1,5 @@
from ctypes import ARRAY, c_int
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.rmodel import IntegerRepr, inputconst
from pypy.rpython.lltypesystem import lltype
from pypy.annotation.pairtype import pairtype
Modified: pypy/dist/pypy/rpython/rctypes/rchar_p.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rchar_p.py (original)
+++ pypy/dist/pypy/rpython/rctypes/rchar_p.py Fri Apr 28 08:42:26 2006
@@ -1,6 +1,7 @@
from pypy.rpython.rmodel import inputconst
from pypy.rpython.lltypesystem import lltype
-from pypy.rpython.rstr import StringRepr, string_repr
+from pypy.rpython.rstr import StringRepr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.rctypes.rmodel import CTypesValueRepr, C_ZERO
from pypy.rpython.rctypes.rarray import ArrayRepr
from pypy.rpython.rctypes.rstringbuf import StringBufRepr
Modified: pypy/dist/pypy/rpython/rctypes/test/test_rfunc.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rfunc.py (original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rfunc.py Fri Apr 28 08:42:26 2006
@@ -10,7 +10,7 @@
from pypy.rpython.test.test_llinterp import interpret
from pypy.translator.c.test.test_genc import compile
from pypy import conftest
-from pypy.rpython.rstr import string_repr
+from pypy.rpython.lltypesystem.rstr import string_repr
from pypy.rpython.lltypesystem import lltype
from ctypes import cdll, pythonapi, PyDLL, _FUNCFLAG_PYTHONAPI
Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py (original)
+++ pypy/dist/pypy/rpython/rfloat.py Fri Apr 28 08:42:26 2006
@@ -7,7 +7,6 @@
from pypy.rpython.rmodel import IntegerRepr, BoolRepr, StringRepr
from pypy.rpython.robject import PyObjRepr, pyobj_repr
from pypy.rpython.rstr import string_repr
-from pypy.rpython import rstr
from pypy.rpython.rmodel import log
import math
@@ -87,6 +86,7 @@
class __extend__(pairtype(StringRepr, FloatRepr)):
def rtype_mod(_, hop):
+ rstr = hop.rtyper.type_system.rstr
return rstr.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
#Helpers FloatRepr,FloatRepr
Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py (original)
+++ pypy/dist/pypy/rpython/rint.py Fri Apr 28 08:42:26 2006
@@ -307,7 +307,7 @@
return vlist[0]
def ll_str(self, i):
- from pypy.rpython.rstr import STR
+ from pypy.rpython.lltypesystem.rstr import STR
temp = malloc(CHAR_ARRAY, 20)
len = 0
sign = 0
@@ -358,7 +358,7 @@
hex_chars[i] = "%x"%i
def ll_int2hex(i, addPrefix):
- from pypy.rpython.rstr import STR
+ from pypy.rpython.lltypesystem.rstr import STR
temp = malloc(CHAR_ARRAY, 20)
len = 0
sign = 0
@@ -391,7 +391,7 @@
return result
def ll_int2oct(i, addPrefix):
- from pypy.rpython.rstr import STR
+ from pypy.rpython.lltypesystem.rstr import STR
if i == 0:
result = malloc(STR, 1)
result.chars[0] = '0'
Modified: pypy/dist/pypy/rpython/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/rstr.py (original)
+++ pypy/dist/pypy/rpython/rstr.py Fri Apr 28 08:42:26 2006
@@ -33,7 +33,7 @@
class __extend__(annmodel.SomeString):
def rtyper_makerepr(self, rtyper):
- return string_repr
+ return rtyper.type_system.rstr.string_repr
def rtyper_makekey(self):
return self.__class__,
@@ -56,7 +56,6 @@
class __extend__(StringRepr):
- lowleveltype = Ptr(STR)
def convert_const(self, value):
if value is None:
@@ -224,9 +223,6 @@
def ll_str(self, s):
return s
- def make_iterator_repr(self):
- return string_iterator_repr
-
class __extend__(pairtype(StringRepr, IntegerRepr)):
def rtype_getitem(_, hop):
v_str, v_index = hop.inputargs(string_repr, Signed)
@@ -1109,35 +1105,18 @@
#
# Iteration.
-class StringIteratorRepr(IteratorRepr):
- lowleveltype = Ptr(GcStruct('stringiter',
- ('string', string_repr.lowleveltype),
- ('index', Signed)))
+class AbstractStringIteratorRepr(IteratorRepr):
+
def newiter(self, hop):
v_str, = hop.inputargs(string_repr)
- return hop.gendirectcall(ll_striter, v_str)
+ return hop.gendirectcall(self.ll_striter, v_str)
def rtype_next(self, hop):
v_iter, = hop.inputargs(self)
hop.has_implicit_exception(StopIteration) # record that we know about it
hop.exception_is_here()
- return hop.gendirectcall(ll_strnext, v_iter)
-
-string_iterator_repr = StringIteratorRepr()
+ return hop.gendirectcall(self.ll_strnext, v_iter)
-def ll_striter(string):
- iter = malloc(string_iterator_repr.lowleveltype.TO)
- iter.string = string
- iter.index = 0
- return iter
-
-def ll_strnext(iter):
- chars = iter.string.chars
- index = iter.index
- if index >= len(chars):
- raise StopIteration
- iter.index = index + 1
- return chars[index]
# these should be in rclass, but circular imports prevent (also it's
# not that insane that a string constant is built in this file).
Modified: pypy/dist/pypy/rpython/typesystem.py
==============================================================================
--- pypy/dist/pypy/rpython/typesystem.py (original)
+++ pypy/dist/pypy/rpython/typesystem.py Fri Apr 28 08:42:26 2006
@@ -21,7 +21,7 @@
except ImportError:
return None
if name in ('rclass', 'rpbc', 'rbuiltin', 'rtuple', 'rlist',
- 'rslice', 'rdict', 'rrange', 'exceptiondata'):
+ 'rslice', 'rdict', 'rrange', 'rstr', 'exceptiondata'):
mod = load(name)
if mod is not None:
setattr(self, name, mod)
Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py (original)
+++ pypy/dist/pypy/translator/c/extfunc.py Fri Apr 28 08:42:26 2006
@@ -2,8 +2,8 @@
from pypy.objspace.flow.model import FunctionGraph
from pypy.rpython.lltypesystem import lltype
from pypy.translator.c.support import cdecl
-from pypy.rpython.rstr import STR
-from pypy.rpython import rstr
+from pypy.rpython.lltypesystem.rstr import STR
+from pypy.rpython.lltypesystem import rstr
from pypy.rpython.lltypesystem import rlist
from pypy.rpython.module import ll_os, ll_time, ll_math, ll_strtod
from pypy.rpython.module import ll_stackless, ll_stack
Modified: pypy/dist/pypy/translator/llvm/extfunchelper.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/extfunchelper.py (original)
+++ pypy/dist/pypy/translator/llvm/extfunchelper.py Fri Apr 28 08:42:26 2006
@@ -2,8 +2,8 @@
from pypy.objspace.flow.model import FunctionGraph
from pypy.rpython.lltypesystem import lltype
from pypy.translator.c.support import cdecl
-from pypy.rpython.rstr import STR
-from pypy.rpython import rstr
+from pypy.rpython.lltypesystem.rstr import STR
+from pypy.rpython.lltypesystem import rstr
from pypy.rpython.lltypesystem import rlist
from pypy.rpython.module import ll_os, ll_time, ll_math, ll_strtod
from pypy.rpython.module import ll_stackless, ll_stack
Modified: pypy/dist/pypy/translator/llvm/gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/gc.py (original)
+++ pypy/dist/pypy/translator/llvm/gc.py Fri Apr 28 08:42:26 2006
@@ -1,5 +1,5 @@
import sys
-from pypy.rpython.rstr import STR
+from pypy.rpython.lltypesystem.rstr import STR
from pypy.translator.llvm.log import log
log = log.gc
More information about the Pypy-commit
mailing list