pypy / spli / execution.py

from spli import interpreter, objects, pycode


def run_from_cpython_code(co, args=[], locs=None, globs=None):
    space = objects.DumbObjSpace()
    pyco = pycode.Code._from_code(space, co)
    return run(pyco, [space.wrap(arg) for arg in args], locs, globs)

def run(pyco, args, locs=None, globs=None):
    frame = interpreter.SPLIFrame(pyco, locs, globs)
    frame.set_args(args)
    return get_ec().execute_frame(frame)


def get_ec():
    ec = state.get()
    if ec is None:
        ec = ExecutionContext()
        state.set(ec)
    return ec


class State(object):

    def __init__(self):
        self.value = None

    def get(self):
        return self.value

    def set(self, new):
        self.value = new

state = State()


class ExecutionContext(object):

    def __init__(self):
        self.framestack = []

    def execute_frame(self, frame):
        self.framestack.append(frame)
        try:
            return frame.run()
        finally:
            self.framestack.pop()
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.