pypy-for-upstream-vincent-legoll / pypy / translator / cli /

from pypy.translator.cli.cts import CTS
from pypy.translator.cli.database import LowLevelDatabase
from pypy.translator.cli.node import Node
from pypy.rpython.ootypesystem import ootype

def get_entrypoint(graph):
    from pypy.translator.cli.test.runtest import TestEntryPoint
        ARG0 = graph.getargs()[0].concretetype
    except IndexError:
        ARG0 = None
    if isinstance(ARG0, ootype.List) and ARG0.ITEM is ootype.String:
        return StandaloneEntryPoint(graph)
        return TestEntryPoint(graph)

class BaseEntryPoint(Node):
    isnetmodule = False
    def set_db(self, db):
        self.db = db
        self.cts = CTS(db)

    def ilasm_flags(self):
        return []

    def output_filename(self, il_filename):
        return il_filename.replace('.il', '.exe')

class StandaloneEntryPoint(BaseEntryPoint):
    This class produces a 'main' method that converts the argv in a
    List of Strings and pass it to the real entry point.
    def __init__(self, graph_to_call):
        self.graph = graph_to_call

    def get_name(self):
        return 'main'

    def render(self, ilasm):
            ARG0 = self.graph.getargs()[0].concretetype
        except IndexError:
            ARG0 = None
        assert isinstance(ARG0, ootype.List) and ARG0.ITEM is ootype.String,\
               'Wrong entry point signature: List(String) expected'

        ilasm.begin_function('main', [('string[]', 'argv')], 'void', True, 'static')'instance void class [pypylib]pypy.runtime.List`1<string>::.ctor()')

        # fake argv[0]
        ilasm.opcode('dup')'class [mscorlib]System.Reflection.Assembly class [mscorlib]System.Reflection.Assembly::GetEntryAssembly()')
        ilasm.call_method('string class [mscorlib]System.Reflection.Assembly::get_Location()', True)
        ilasm.call_method('void class [mscorlib]System.Collections.Generic.List`1<string>::Add(!0)', True)

        # add real argv
        ilasm.call_method('void class [mscorlib]System.Collections.Generic.List`1<string>::'
                          'AddRange(class [mscorlib]System.Collections.Generic.IEnumerable`1<!0>)', True)
        ilasm.opcode('pop') # XXX: return this value, if it's an int32'void [pypylib]pypy.runtime.DebugPrint::close_file()')

class DllEntryPoint(BaseEntryPoint):
    def __init__(self, name, graphs, isnetmodule=False): = name
        self.graphs = graphs
        self.isnetmodule = isnetmodule

    def get_name(self):

    def ilasm_flags(self):
        return BaseEntryPoint.ilasm_flags(self) + ['/dll']

    def output_filename(self, il_filename):
        ext = '.dll'
        if self.isnetmodule:
            ext = '.netmodule'
        return il_filename.replace('.il', ext)

    def render(self, ilasm):
        for graph in self.graphs:
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
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.