next up previous contents
Next: Using A Group Walker Up: Walkers Previous: Walkers   Contents

Using A Selective Walker

The following is a simple example of a walker. This walker visits all variable symbols and ensures that they have names. The full code can be found in nci/suif/suif2b/transforms/symbol_walkers.cpp. Only the traversal code is shown.

        class SymbolNamer : public SelectiveWalker {
            public:
                SymbolNamer(SuifEnv *env)
                     : SelectiveWalker(env,
                            VariableSymbol::get_class_name()) {}
                ApplyStatus operator () (SuifObject *x);
            };
        Walker::ApplyStatus SymbolNamer::operator () (SuifObject *x) {
            VariableSymbol *symbol = to<VariableSymbol>(x);
            name_variable(symbol); // not included in sample
            return Walker::Continue;
            }



SUIF Nightly Build
2000-08-14