Program Listing for File patternRewrite.h

Program Listing for File patternRewrite.h#

Return to documentation for file (src/midend/programTransformation/finiteDifferencing/patternRewrite.h)

#ifndef PATTERNREWRITE_H
#define PATTERNREWRITE_H

// #include "config.h"

//#include "rose.h"
#include <vector>

class RewriteRule {
  public:
  virtual bool doRewrite(SgNode*& n) const = 0;
// Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
  virtual ~RewriteRule(){}
};

class RewriteRuleCombiner: public RewriteRule {
  std::vector<RewriteRule*> rules;

  public:
  std::vector<RewriteRule*>& getRules() {return rules;}
  const std::vector<RewriteRule*>& getRules() const {return rules;}

  void add(RewriteRule* r) {rules.push_back(r);}

  virtual bool doRewrite(SgNode*& n) const;

// DQ (12/16/2006): Added destructor to eliminate g++ compiler warning.
  virtual ~RewriteRuleCombiner() {}
};

ROSE_DLL_API void rewrite(RewriteRule* rule, SgNode*& top);

void replaceChild(SgNode* parent, SgNode* from, SgNode* to);

typedef std::map<std::string, SgNode*> PatternVariables;

class Pattern {
  public:
  virtual bool match(SgNode* top, PatternVariables& vars) const = 0;
  virtual SgNode* subst(PatternVariables& vars) const = 0;
// Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
  virtual ~Pattern(){}
};

class PatternActionRule: public RewriteRule {
  Pattern* pattern;
  Pattern* action;

  public:
  PatternActionRule(Pattern* pattern, Pattern* action):
    pattern(pattern), action(action) {}

  virtual bool doRewrite(SgNode*& n) const;
// Liao (2/7/2008): Added destructor to eliminate g++ compiler warning.
  virtual ~PatternActionRule(){}
};

PatternActionRule* patact(Pattern* pattern, Pattern* action);

Pattern* p_AddOp(Pattern* lhs, Pattern* rhs);

Pattern* p_MultiplyOp(Pattern* lhs, Pattern* rhs);

Pattern* p_PlusAssignOp(Pattern* lhs, Pattern* rhs);

Pattern* p_CommaOp(Pattern* lhs, Pattern* rhs);

Pattern* p_var(std::string name);

Pattern* p_value(std::string name);

Pattern* p_int(int x);

extern Pattern* p_wildcard;

ROSE_DLL_API RewriteRule* getAlgebraicRules();

RewriteRule* getFiniteDifferencingRules();

#endif // PATTERNREWRITE_H