'Process list of free vars from nested scope.
Returns a list of names that are either 1) declared global in the
parent or 2) undefined in a top-level parent.  In either case,
the nested scope should treat them as globals.'

def add_frees(self, names):

    child_globals = []
    for name in names:
        sc = self.check_name(name)
        if self.nested:
            if ((sc == SC_UNKNOWN) or (sc == SC_FREE) or isinstance(self, ClassScope)):
                self.frees[name] = 1
            elif (sc == SC_GLOBAL_IMPLICIT):
                child_globals.append(name)
            elif (isinstance(self, FunctionScope) and (sc == SC_LOCAL)):
                self.cells[name] = 1
            elif (sc != SC_CELL):
                child_globals.append(name)
        elif (sc == SC_LOCAL):
            self.cells[name] = 1
        elif (sc != SC_CELL):
            child_globals.append(name)
    return child_globals
