Ejemplo n.º 1
0
    def get_simulator_vars(self, debug=0):
        simvars = set()
        ignored = set(self.source_macros.keys())
        for macval in self.source_macros.values():
            ## This could be replaced by a functools.reduce()
            for val in macval:
                simvars = simvars.union(set(SPM.extract_variables(val)))

        for sim in self.simulators.values():
            simvars = simvars.union(sim.get_source_vars().union(
                sim.get_include_vars()))

        simvars = simvars.difference(ignored).difference(SPM._special_vars)
        SU.emit_debug(debug, 2, 'simvars {0}'.format(simvars))
        return simvars
Ejemplo n.º 2
0
    def write_vars(self, stream):
        def collect_vars(varlist, var):
            varlist.extend(SPM.extract_variables(var))
            return varlist

        varnames = list(self.vars.keys())
        namewidth = max(map(lambda s: len(s), varnames))
        # vardeps maps the parent variable to its dependents, e.g.,
        # INTELSYSD -> [ISYS8010D, ...]
        vardeps = dict()
        # alldeps is the set of all parent and dependents, which will be
        # deleted from a copy of self.vars. The copy has variables that
        # don't depend on anything (except for CMAKE_SOURCE_DIR, but we
        # know that's defined by CMake.)
        alldeps = set()
        for var in varnames:
            if isinstance(self.vars[var], list):
                mvars = functools.reduce(collect_vars, self.vars[var], [])
            else:
                mvars = SPM.extract_variables(self.vars[var])
            mvars = [mvar for mvar in mvars if mvar != "CMAKE_SOURCE_DIR"]
            if mvars:
                alldeps.add(var)
                for mvar in mvars:
                    if mvar not in vardeps:
                        vardeps[mvar] = []
                    vardeps[mvar].append(var)
                    alldeps.add(mvar)

        nodeps = self.vars.copy()
        ## SIMHD will never be used.
        if 'SIMHD' in nodeps:
            del nodeps['SIMHD']
        for dep in alldeps:
            del nodeps[dep]

        varnames = list(nodeps.keys())
        varnames.sort()
        for var in varnames:
            self.emit_value(var, self.vars[var], stream, namewidth)

        ## Now to emit the dependencies
        depnames = list(vardeps.keys())
        depnames.sort()
        for dep in depnames:
            self.write_dep(dep, vardeps, alldeps, namewidth, stream)
Ejemplo n.º 3
0
 def get_include_vars(self):
     incvars = set()
     for inc in self.includes:
         incvars = incvars.union(set(SPM.extract_variables(inc)))
     return incvars
Ejemplo n.º 4
0
 def get_source_vars(self):
     srcvars = set()
     for src in self.sources:
         srcvars = srcvars.union(set(SPM.extract_variables(src)))
     return srcvars
Ejemplo n.º 5
0
 def collect_vars(varlist, var):
     varlist.extend(SPM.extract_variables(var))
     return varlist
Ejemplo n.º 6
0
 def scan_var(varset, var):
     tmp = var
     return varset.union(set(SPM.extract_variables(tmp)))