Esempio n. 1
0
    def specialize(self,
                   dont_simplify_again=False,
                   crash_on_first_typeerror=True):
        """Main entry point: specialize all annotated blocks of the program."""
        self.crash_on_first_typeerror = crash_on_first_typeerror
        # specialize depends on annotator simplifications
        assert dont_simplify_again in (False, True)  # safety check
        if not dont_simplify_again:
            self.annotator.simplify()

        # first make sure that all functions called in a group have exactly
        # the same signature, by hacking their flow graphs if needed
        self.type_system.perform_normalizations(self)
        self.exceptiondata.finish(self)
        # new blocks can be created as a result of specialize_block(), so
        # we need to be careful about the loop here.
        self.already_seen = {}

        self.specialize_more_blocks()
        if self.exceptiondata is not None:
            self.exceptiondata.make_helpers(self)
            self.specialize_more_blocks()  # for the helpers just made
        if self.type_system.name == 'ootypesystem':
            self.attach_methods_to_subclasses()

        #
        from pypy.annotation import listdef
        ldef = listdef.ListDef(None, annmodel.SomeString())
        self.list_of_str_repr = self.getrepr(annmodel.SomeList(ldef))
Esempio n. 2
0
def s_list_of_gcrefs():
    global _cache_s_list_of_gcrefs
    if _cache_s_list_of_gcrefs is None:
        from pypy.annotation import model as annmodel
        from pypy.annotation.listdef import ListDef
        s_gcref = annmodel.SomePtr(llmemory.GCREF)
        _cache_s_list_of_gcrefs = annmodel.SomeList(
            ListDef(None, s_gcref, mutated=True, resized=False))
    return _cache_s_list_of_gcrefs
Esempio n. 3
0
#
# Dumpers and loaders

TYPE_NONE = 'N'
TYPE_FALSE = 'F'
TYPE_TRUE = 'T'
TYPE_INT = 'i'
TYPE_INT64 = 'I'
TYPE_FLOAT = 'f'
TYPE_STRING = 's'
TYPE_TUPLE = '('
TYPE_LIST = '['

dumpers = []
loaders = []
s_list_of_chars = annmodel.SomeList(
    ListDef(None, annmodel.SomeChar(), mutated=True, resized=True))


def add_dumper(s_obj, dumper):
    dumpers.append((s_obj, dumper))
    dumper.s_obj = s_obj
    dumper._annenforceargs_ = [s_list_of_chars, s_obj]


def add_loader(s_obj, loader):
    loaders.append((s_obj, loader))


def get_dumper_annotation(dumper):
    return dumper.s_obj