pypy-postgresql / pypy / rpython / ootypesystem / ooregistry.py

from pypy.rpython.extregistry import ExtRegistryEntry
from pypy.annotation import model as annmodel
from pypy.rpython.ootypesystem import ootype

class Entry_oostring(ExtRegistryEntry):
    _about_ = ootype.oostring

    def compute_result_annotation(self, obj_s, base_s):
        assert isinstance(obj_s, (annmodel.SomeInteger,
                                  annmodel.SomeChar,
                                  annmodel.SomeFloat,
                                  annmodel.SomeOOInstance,
                                  annmodel.SomeString))
        assert isinstance(base_s, annmodel.SomeInteger)
        return annmodel.SomeOOInstance(ootype.String)

    def specialize_call(self, hop):
        assert isinstance(hop.args_s[0],(annmodel.SomeInteger,
                                         annmodel.SomeChar,
                                         annmodel.SomeString,
                                         annmodel.SomeFloat,
                                         annmodel.SomeOOInstance,
                                         annmodel.SomeString))
        vlist = hop.inputargs(hop.args_r[0], ootype.Signed)
        hop.exception_cannot_occur()
        return hop.genop('oostring', vlist, resulttype = ootype.String)

class Entry_oounicode(ExtRegistryEntry):
    _about_ = ootype.oounicode

    def compute_result_annotation(self, obj_s, base_s):
        assert isinstance(obj_s, annmodel.SomeUnicodeCodePoint) or \
               (isinstance(obj_s, annmodel.SomeOOInstance)
                and obj_s.ootype in (ootype.String, ootype.Unicode))
        assert isinstance(base_s, annmodel.SomeInteger)
        return annmodel.SomeOOInstance(ootype.Unicode)

    def specialize_call(self, hop):
        assert isinstance(hop.args_s[0], (annmodel.SomeUnicodeCodePoint,
                                          annmodel.SomeOOInstance))
        vlist = hop.inputargs(hop.args_r[0], ootype.Signed)
        hop.exception_cannot_occur()
        return hop.genop('oounicode', vlist, resulttype = ootype.Unicode)
    

class Entry_ootype_string(ExtRegistryEntry):
    _type_ = ootype._string

    def compute_annotation(self):
        return annmodel.SomeOOInstance(ootype=ootype.String)


class Entry_ooparse_int(ExtRegistryEntry):
    _about_ = ootype.ooparse_int

    def compute_result_annotation(self, str_s, base_s):
        assert isinstance(str_s, annmodel.SomeOOInstance)\
               and str_s.ootype is ootype.String
        assert isinstance(base_s, annmodel.SomeInteger)
        return annmodel.SomeInteger()

    def specialize_call(self, hop):
        assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)\
               and hop.args_s[0].ootype is ootype.String
        vlist = hop.inputargs(hop.args_r[0], ootype.Signed)
        hop.has_implicit_exception(ValueError)
        hop.exception_is_here()
        return hop.genop('ooparse_int', vlist, resulttype = ootype.Signed)


class Entry_ooparse_float(ExtRegistryEntry):
    _about_ = ootype.ooparse_float

    def compute_result_annotation(self, str_s):
        assert isinstance(str_s, annmodel.SomeOOInstance)\
               and str_s.ootype is ootype.String
        return annmodel.SomeFloat()

    def specialize_call(self, hop):
        assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)\
               and hop.args_s[0].ootype is ootype.String
        vlist = hop.inputargs(hop.args_r[0])
        hop.has_implicit_exception(ValueError)
        hop.exception_is_here()
        return hop.genop('ooparse_float', vlist, resulttype = ootype.Float)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.