comma::AstRewriter Class Reference

Rewrites Ast nodes. More...

#include <AstRewriter.h>

Inheritance diagram for comma::AstRewriter:
Inheritance graph
[legend]
Collaboration diagram for comma::AstRewriter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AstRewriter (AstResource &resource)
 Constructs an empty rewriter with no rewrite rules.
void addTypeRewrite (Type *source, Type *target)
template<class Iter >
void addTypeRewrites (Iter I, Iter E)
 Adds a set of rewrites given by iterators over std::pair<Type*, Type*>.
void installRewrites (DomainType *context)
 Generates rewrite rules for a DomainType.
void installRewrites (SigInstanceDecl *context)
 Generates rewrite rules for a SigInstanceDecl.
bool hasRewriteRule (Type *source) const
 Returns true if a rewrite rule is associated with source.
void clear ()
 Remove all rewrite rules.
SigInstanceDeclrewriteSigInstance (SigInstanceDecl *sig) const
AstResourcegetAstResource () const
Type Rewriters.

Rewrites the given type using the installed rules.

If no rules apply to any component of the argument type, the argument is returned unchanged. If a rewrite rule does apply, then the a new rewritten type node is returned.



TyperewriteType (Type *type) const
DomainTyperewriteType (DomainType *dom) const
SubroutineTyperewriteType (SubroutineType *srType) const
FunctionTyperewriteType (FunctionType *ftype) const
ProcedureTyperewriteType (ProcedureType *ftype) const

Protected Member Functions

TypefindRewrite (Type *source) const
 Returns a rewrite if it exists, otherwise null.

Detailed Description

Rewrites Ast nodes.

This class implements a map from one set of nodes to another. In some ways, it is like a scope where the components of an AST can be resolved with respect to the "bindings" established in the rewriter. For example, the AstRewriter can encapsulate the mappings from the formal to actual parameters of a functor, or from a % node to a concrete domain type.

Methods are provided to build and interrogate the set of mappings, and to create new nodes using the installed set of rules.

Definition at line 35 of file AstRewriter.h.


Constructor & Destructor Documentation

comma::AstRewriter::AstRewriter ( AstResource resource  )  [inline]

Constructs an empty rewriter with no rewrite rules.

Definition at line 39 of file AstRewriter.h.


Member Function Documentation

void comma::AstRewriter::addTypeRewrite ( Type source,
Type target 
) [inline]

Adds a rewrite rule from source to target.

If a mapping from the given source already exists, this method will unconditionally re-target the rule -- it is the responsibility of the programmer to ensure that established rules are not mistakenly overwritten.

Definition at line 47 of file AstRewriter.h.

template<class Iter >
void comma::AstRewriter::addTypeRewrites ( Iter  I,
Iter  E 
) [inline]

Adds a set of rewrites given by iterators over std::pair<Type*, Type*>.

Definition at line 54 of file AstRewriter.h.

void comma::AstRewriter::clear (  )  [inline]

Remove all rewrite rules.

Definition at line 80 of file AstRewriter.h.

Type * AstRewriter::findRewrite ( Type source  )  const [protected]

Returns a rewrite if it exists, otherwise null.

Definition at line 23 of file AstRewriter.cpp.

AstResource& comma::AstRewriter::getAstResource (  )  const [inline]

Definition at line 109 of file AstRewriter.h.

bool comma::AstRewriter::hasRewriteRule ( Type source  )  const [inline]

Returns true if a rewrite rule is associated with source.

Definition at line 75 of file AstRewriter.h.

void AstRewriter::installRewrites ( SigInstanceDecl context  ) 

Generates rewrite rules for a SigInstanceDecl.

Populates this rewriter with rules mapping the formal argument nodes of the underlying signature declaration to the actual arguments provided by context. This method is a no-op when context is not parameterized.

Definition at line 54 of file AstRewriter.cpp.

void AstRewriter::installRewrites ( DomainType context  ) 

Generates rewrite rules for a DomainType.

Populates this rewriter with rules mapping the formal argument nodes of the underlying domain declaration to the actual arguments provided by context. This method is a no-op when context is not parameterized.

Definition at line 38 of file AstRewriter.cpp.

SigInstanceDecl * AstRewriter::rewriteSigInstance ( SigInstanceDecl sig  )  const

Rewrites the parameterization of the given SigInstanceDecl.

If no rewrite rules apply, the argument is returned unchanged. Otherwise, a uniqued SigInstanceDecl is returned representing the rewritten parameterization.

Definition at line 86 of file AstRewriter.cpp.

ProcedureType * AstRewriter::rewriteType ( ProcedureType ftype  )  const

Definition at line 155 of file AstRewriter.cpp.

FunctionType * AstRewriter::rewriteType ( FunctionType ftype  )  const

Definition at line 145 of file AstRewriter.cpp.

SubroutineType * AstRewriter::rewriteType ( SubroutineType srType  )  const

Definition at line 130 of file AstRewriter.cpp.

DomainType * AstRewriter::rewriteType ( DomainType dom  )  const

Definition at line 105 of file AstRewriter.cpp.

Type * AstRewriter::rewriteType ( Type type  )  const

Definition at line 68 of file AstRewriter.cpp.


The documentation for this class was generated from the following files:

Generated on 1 Feb 2010 for Comma by  doxygen 1.6.1

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.