Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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))