Пример #1
0
    def VisitLibrary(self, o, **kwargs):

        removed = []
        for aKey in o._eqn_assignment.keys():
            a = o._eqn_assignment[aKey]
            alhs = a.lhs
            fixed_value = self.visit(a.rhs)
            if fixed_value:

                sym_suffix = '_as_symconst'
                sym_suffix = ''
                s = ast.SymbolicConstant(symbol=aKey.symbol
                        + sym_suffix, value=fixed_value)

                #assert False
                #print 'Replacing Node:', a.lhs.symbol
                ReplaceNode(a.lhs, s).visit(o)

                #o._cache_nodes()
                #print 'Done replacing symbol'

                o._symbolicconstants[aKey.symbol] = s
                del o._eqn_assignment[aKey]

                removed.append(alhs)


        # Double check they have gone:
        for a in removed:
            nc = EqnsetVisitorNodeCollector()
            nc.visit(o)
            assert not a in nc.all()

        # Should be no more assignments:
        assert len(o._eqn_assignment) == 0