예제 #1
0
파일: fixup.py 프로젝트: fuzzie/slcore
def filter(fbegin, finner, fcinner, fend, *args):
    """ 
    Transform compiler output (invalid, raw asm) to good-looking
    .s files that can be assembled by an external assembler.
    """

    opts = makestageopts([fbegin, finner, fcinner, fend], args)
    fname = opts.resolved.output
    if fname == "-":
        outf = sys.stdout
    else:
        try:
            outf = file(fname, "w")
        except Exception, e:
            die('%s: %r' % (fname, e))
예제 #2
0
파일: enhance.py 프로젝트: fuzzie/slcore
def filter(fbegin, fstages, fend, *args):
    """
    Enhance already valid assembly.
    """

    opts = makestageopts([fbegin, fstages, fend], args)
    filter_stagenames = [s.__name__ for s in fstages]

    # parse flags
    sel = dict(((s,True) for s in filter_stagenames))
    
    for f in opts.resolved.selection:
        if f == 'no-all' or f == 'none':
            for k in sel.keys(): sel[k] = False
        elif f == 'all':
            for k in sel.keys(): sel[k] = True
        else:
            if f.startswith('no-'):
                name = f[3:]
                value = False
            else:
                name = f
                value = True
            if name not in filter_stagenames:
                die('error: unrecognized command line option "-f%s-%s"' %
                     (value and "asmopt" or "no-asmopt", name))
            sel[name] = value

    verbose = opts.resolved.verbose

    if verbose: log('asmsel: %r' % sel)

    fname = opts.resolved.output
    if fname == "-":
        outf = sys.stdout
    else:
        try:
            outf = file(fname, "w")
        except Exception, e:
            die('%s: %r' % (fname, e))