def qpu(f):
    """Decorator for writing QPU assembly language.

    To write a QPU assembly program, decorate a function which has a parameter
    ``asm`` as the first argument with @qpu like this::

        @qpu
        def code(asm):
            mov(r0, uniform)
            iadd(r0, r0, 1)

            ...

            exit()

    This code is equivalent to::

        def code(asm):
            asm.mov(asm.r0, asm.uniform)
            asm.iadd(asm.r0, asm.r0, 1)

            ...

            asm.exit()
    """
    args, _, _, _ = inspect.getargspec(f)

    if 'asm' not in args:
        raise AssembleError('Argument named \'asm\' is necessary')

    tree = ast.parse(inspect.getsource(f))

    fundef = tree.body[0]
    fundef.body = SETUP_ASM_ALIASES.body + fundef.body
    fundef.decorator_list = []

    code = compile(tree, '<qpu>', 'exec')
    scope = {}
    exec(code, f.__globals__, scope)
    return scope[f.__name__]
dataset/ETHPy150Open nineties/py-videocore/videocore/assembler.py/qpu/original