예제 #1
0
def warnExtra(warn, src, matchSyms=[], excludeSyms=[]):
    if warn:
        extras = src.getTaggedSymbols(1)
        for i in extras:
            if not Misc.symbolContainsListItem(i, matchSyms):
                continue
            if len(excludeSyms) > 0 and Misc.symbolContainsListItem(i, excludeSyms):
                continue
            warnMessage("Unused splice from input: "+i, False)
예제 #2
0
def warnMissing( symbols, insertions, warn, warnCommon, commonSuppressions, fatal, matchSyms=[], excludeSyms=[]):
    if warn:
        for i in symbols:
            if not Misc.symbolContainsListItem(i, matchSyms):
                continue
            if len(excludeSyms) > 0 and Misc.symbolContainsListItem(i, excludeSyms):
                continue
            p = insertions.get(i, None)
            if  p == None and \
                (warnCommon or not Misc.isCommon(i, commonSuppressions)):
                msg = "No block or splice found for output symbol " + i
                warnMessage(msg,fatal)
예제 #3
0
def findSplices(symbols, insertions, sf, verbose, methodMatch=False, oldtype="", newtype="", matchSyms=[], excludeSyms=[]):
    """ find blocks from prepared src matching symbols
given and add them to the symbol keyed insertions list.
@param sf Source from which to splice.
@param methodMatch if True, then rename matches from sf are done for symbols,
       taking symbol $oldtype.$method to match $newtype.$method. To insure
       correct operation, oldtype, newtype should be fully qualified sidl names.
@param matchSyms if given is a list of symbols to match in target and ignore all others.
"""

    checkMatchSym = (len(matchSyms) > 0)
    if verbose:
        print "findSplices: user match list=" , matchSyms
        print "findSplices: user exclude list=", excludeSyms
        if methodMatch:
            print "fromType = ", oldtype, "toType = ", newtype

    for j in symbols:

        if excludeSyms and len(excludeSyms) > 0 and Misc.symbolContainsListItem(j, excludeSyms):
            if verbose: print 'Matched excluded symbol, skipping: ' , j
            continue

        if checkMatchSym:
            if not Misc.symbolContainsListItem(j, matchSyms):
                if verbose:
                    print "No Match of " , j 
                continue
            else:
                if verbose:
                    print "Match of " , j 

        p = insertions.get(j, None)
        if methodMatch:
            jold = j.replace(newtype, oldtype)
        else:
            jold = j
        ins = sf.getBlock(jold)

        if ins != None:
            if verbose:
                print "found an insertion for " , j
            if p != None:
                # FIXME whine about duplicate.
                pass
            else:
                if methodMatch:
# this is cleaner in some sense (readonly treatment) but messes up warning management
                    if False:
                        # make a new block from body of old and symbol of new.
                        insfixed = Block.Block()
                        oldlines = ins.getLines()
                        newbegin=oldlines[0].replace(oldtype, newtype)
                        newend=oldlines[len(oldlines)-1].replace(oldtype, newtype)
                        newlines = [newbegin] + oldlines[1:len(oldlines)-2] + [newend ]
                        insfixed.init(ins.key(), newlines, ins.source(), ins.start() )
                        insertions[j] = insfixed
                        if verbose:
                            print "it is len " , len(newlines)
                    else:
                        # modify in place
                        oldlines = ins.getLines()
                        newbegin=oldlines[0].replace(oldtype, newtype)
                        newend=oldlines[len(oldlines)-1].replace(oldtype, newtype)
                        oldlines[0] = newbegin
                        oldlines[len(oldlines)-1] = newend
                        insertions[j] = ins
                else:
                    # transfer from sf to insertions
                    insertions[j] = ins