org.erights.e.elang.visitors
Class RenameVisitor

java.lang.Object
  |
  +--org.erights.e.elang.visitors.KernelECopyVisitor
        |
        +--org.erights.e.elang.visitors.CopyVisitor
              |
              +--org.erights.e.elang.visitors.RenameVisitor
All Implemented Interfaces:
ETreeVisitor

public class RenameVisitor
extends CopyVisitor

Untamed: 'renamings' contains a set of oldName => newName pairs. 'rename' returns a new expression like this one, except that wherever 'oldName' is used in this expression to refer to a definition of 'oldName' not provided by this expression, 'newName' is substituted. It is assumed that 'newName' cannot conflict with any name already in this expression, which is safe if 'newName' is a newly generated temporary name. In the resulting expression's staticScope's namesUsed, 'oldName' should not appear.

For each 'oldName' that appears in this expressions's staticScope's outNames (and therefore in the result's staticScope's outNames), that 'oldName' => 'newName' association is removed from 'renamings'. Therefore, 'renamings' is left in a valid state to apply to expressions at the same scope level, but to the right of this one.

Note to implementors: The Java Language Specification defines that argument evaluation order is left to right (as does E). Therefore, you may make several calls to 'rename' using the same 'renamings', confident that the earlier ones will modify the 'renamings' as seen by the later ones. Should these methods be translated to a language without this guarantee (like C++), this ordering will have to be recoded.


Field Summary
private  FlexMap myRenamings
           
 
Fields inherited from class org.erights.e.elang.visitors.KernelECopyVisitor
 
Constructor Summary
RenameVisitor(FlexMap renamings)
          Enabled:
 
Method Summary
 Object visitCatchExpr(ENode optOriginal, EExpr attempt, Pattern patt, EExpr catcher)
          Enabled:
 Object visitEMethod(ENode optOriginal, String docComment, String verb, Pattern[] patterns, EExpr returnGuard, EExpr body)
          Enabled:
 Object visitEscapeExpr(ENode optOriginal, Pattern hatch, EExpr body)
          Enabled:
 Object visitFinallyExpr(ENode optOriginal, EExpr attempt, EExpr unwinder)
          Enabled:
 Object visitFinalPattern(ENode optOriginal, String varName, EExpr valueGuardExpr)
          Enabled:
 Object visitHideExpr(ENode optOriginal, EExpr body)
          Enabled:
 Object visitIfExpr(ENode optOriginal, EExpr test, EExpr then, EExpr els)
          Enabled:
 Object visitMatcher(Matcher optOriginal, Pattern patt, EExpr body)
          Enabled:
 Object visitNounExpr(ENode optOriginal, String varName)
          Enabled:
 Object visitVarPattern(ENode optOriginal, String varName, EExpr slotGuardExpr)
          Enabled:
 
Methods inherited from class org.erights.e.elang.visitors.CopyVisitor
visitQuasiLiteralExpr, visitQuasiLiteralPatt, visitQuasiPatternExpr, visitQuasiPatternPatt
 
Methods inherited from class org.erights.e.elang.visitors.KernelECopyVisitor
nest, optSpan, run, visitAssignExpr, visitCallExpr, visitCdrPattern, visitDefineExpr, visitEScript, visitIgnorePattern, visitListPattern, visitLiteralExpr, visitMatchBindExpr, visitMatcher, visitObjectExpr, visitScopeExpr, visitSendExpr, visitSeqExpr, visitSlotExpr, visitSuchThatPattern, xformEExpr, xformEExprs, xformEScript, xformMatcher, xformMethod, xformNode, xformPattern, xformPatterns
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myRenamings

private FlexMap myRenamings
Constructor Detail

RenameVisitor

public RenameVisitor(FlexMap renamings)
Enabled:

Method Detail

visitEscapeExpr

public Object visitEscapeExpr(ENode optOriginal,
                              Pattern hatch,
                              EExpr body)
Enabled:

Specified by:
visitEscapeExpr in interface ETreeVisitor
Overrides:
visitEscapeExpr in class KernelECopyVisitor
See Also:
The Kernel-E Escape Expression

visitHideExpr

public Object visitHideExpr(ENode optOriginal,
                            EExpr body)
Enabled:

Specified by:
visitHideExpr in interface ETreeVisitor
Overrides:
visitHideExpr in class KernelECopyVisitor
See Also:
The Kernel-E Hide Expression

visitIfExpr

public Object visitIfExpr(ENode optOriginal,
                          EExpr test,
                          EExpr then,
                          EExpr els)
Enabled:

Specified by:
visitIfExpr in interface ETreeVisitor
Overrides:
visitIfExpr in class KernelECopyVisitor
See Also:
The Kernel-E If Expression

visitNounExpr

public Object visitNounExpr(ENode optOriginal,
                            String varName)
Enabled:

Specified by:
visitNounExpr in interface ETreeVisitor
Overrides:
visitNounExpr in class KernelECopyVisitor
See Also:
The Kernel-E Noun Expression

visitCatchExpr

public Object visitCatchExpr(ENode optOriginal,
                             EExpr attempt,
                             Pattern patt,
                             EExpr catcher)
Enabled:

Specified by:
visitCatchExpr in interface ETreeVisitor
Overrides:
visitCatchExpr in class KernelECopyVisitor
See Also:
The Kernel-E Try-Catch Expression

visitFinallyExpr

public Object visitFinallyExpr(ENode optOriginal,
                               EExpr attempt,
                               EExpr unwinder)
Enabled:

Specified by:
visitFinallyExpr in interface ETreeVisitor
Overrides:
visitFinallyExpr in class KernelECopyVisitor
See Also:
The Kernel-E Try-Finally Expression

visitFinalPattern

public Object visitFinalPattern(ENode optOriginal,
                                String varName,
                                EExpr valueGuardExpr)
Enabled:

Specified by:
visitFinalPattern in interface ETreeVisitor
Overrides:
visitFinalPattern in class KernelECopyVisitor
See Also:
The Kernel-E Final Pattern

visitVarPattern

public Object visitVarPattern(ENode optOriginal,
                              String varName,
                              EExpr slotGuardExpr)
Enabled:

Specified by:
visitVarPattern in interface ETreeVisitor
Overrides:
visitVarPattern in class KernelECopyVisitor
See Also:
The Kernel-E Var Pattern

visitEMethod

public Object visitEMethod(ENode optOriginal,
                           String docComment,
                           String verb,
                           Pattern[] patterns,
                           EExpr returnGuard,
                           EExpr body)
Enabled:

Specified by:
visitEMethod in interface ETreeVisitor
Overrides:
visitEMethod in class KernelECopyVisitor
See Also:
The Kernel-E Method Node

visitMatcher

public Object visitMatcher(Matcher optOriginal,
                           Pattern patt,
                           EExpr body)
Enabled:



comments?