org.erights.e.elang.visitors
Class AlphaRenameVisitor

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

public class AlphaRenameVisitor
extends KernelECopyVisitor

Untamed: Like RenameVisitor, but does an 'alpha-renaming'.

An alpha renaming gives each distinct variable a unique name. Since we are not in control of top-level names, we rename exactly variables defined in nested scope boxes. We use a HilbertHotel to generate new names and to transform old ones. In order to deal with the varName problem in the varName way, we will transform top-level names according to the varName rename(). Since AlphaRenameVisitor needs to treat the expression top level specially, that's represented by a null 'myOptRenamings'. Assuming that top-level names should avoid being of a form that rename might relocate (ie, the form of name generated by newTemp()), then, by turning *all* non top-level names into this form, these won't conflict with such well formed top-level names. This is a bit of a kludge. Perhaps we should treat relocated top level names as an error?

Author:
Mark S. Miller

Field Summary
private  HilbertHotel myHilbert
           
private  FlexMap myOptRenamings
           
 
Fields inherited from class org.erights.e.elang.visitors.KernelECopyVisitor
 
Constructor Summary
AlphaRenameVisitor()
          Enabled:
AlphaRenameVisitor(ETreeVisitor decorator)
          Enabled:
 
Method Summary
private  FlexMap fork()
           
private  FlexMap innerRenames()
           
 Object visitCatchExpr(CatchExpr 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(FinallyExpr optOriginal, EExpr attempt, EExpr unwinder)
          Enabled:
 Object visitFinalPattern(ENode optOriginal, String varName, EExpr valueGuardExpr)
          Enabled:
 Object visitHideExpr(ENode optOriginal, EExpr body)
          Enabled:
 Object visitIfExpr(IfExpr optOriginal, EExpr test, EExpr then, EExpr els)
          Enabled:
 Object visitMatcher(ENode 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.KernelECopyVisitor
nest, optSpan, run, visitAssignExpr, visitCallExpr, visitCatchExpr, visitCdrPattern, visitDefineExpr, visitEScript, visitFinallyExpr, visitIfExpr, visitIgnorePattern, visitListPattern, visitLiteralExpr, visitMatchBindExpr, visitObjectExpr, visitQuasiLiteralExpr, visitQuasiLiteralPatt, visitQuasiPatternExpr, visitQuasiPatternPatt, 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

myOptRenamings

private FlexMap myOptRenamings

myHilbert

private final HilbertHotel myHilbert
Constructor Detail

AlphaRenameVisitor

public AlphaRenameVisitor(ETreeVisitor decorator)
Enabled:


AlphaRenameVisitor

public AlphaRenameVisitor()
Enabled:

Method Detail

fork

private FlexMap fork()

innerRenames

private FlexMap innerRenames()

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

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

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(IfExpr optOriginal,
                          EExpr test,
                          EExpr then,
                          EExpr els)
Enabled:


visitCatchExpr

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


visitFinallyExpr

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


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(ENode optOriginal,
                           Pattern patt,
                           EExpr body)
Enabled:

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


comments?