gnu.expr
Class ExpWalker

java.lang.Object
  extended by gnu.expr.ExpWalker
All Implemented Interfaces:
SourceLocator, org.xml.sax.Locator
Direct Known Subclasses:
ChainLambdas, FindCapturedVars, FindTailCalls, InlineCalls, PushApply, ResolveNames

public class ExpWalker
extends java.lang.Object
implements SourceLocator

Class for doing a tree-walk over an Expression tree.


Field Summary
protected  LambdaExp currentLambda
           
protected  SourceMessages messages
           
 
Constructor Summary
ExpWalker()
           
 
Method Summary
 void error(char kind, java.lang.String message)
           
 int getColumnNumber()
          Return current column number.
 Compilation getCompilation()
          Get the Compilation associated with this walker.
 LambdaExp getCurrentLambda()
           
 java.lang.String getFileName()
          Normally same as getSystemId.
 int getLineNumber()
          Return current line number.
 SourceMessages getMessages()
           
 java.lang.String getPublicId()
           
 java.lang.String getSystemId()
           
 boolean isStableSourceLocation()
          Normally same as getSystemId.
 Expression noteError(java.lang.String message)
           
 void setColumn(int column)
           
 void setContext(Compilation comp)
           
 void setFile(java.lang.String filename)
           
 void setLine(int line)
           
 void setLine(java.lang.String filename, int line, int column)
           
 Expression walk(Expression exp)
          Call the walk method of argument Expression.
protected  Expression walkApplyExp(ApplyExp exp)
           
protected  Expression walkBeginExp(BeginExp exp)
           
protected  Expression walkBlockExp(BlockExp exp)
           
protected  Expression walkClassExp(ClassExp exp)
           
protected  void walkDeclarationType(Declaration decl)
           
protected  void walkDeclarationTypes(ScopeExp exp)
           
 void walkDefaultArgs(LambdaExp exp)
           
protected  Expression walkExitExp(ExitExp exp)
           
protected  Expression walkExpression(Expression exp)
           
 Expression[] walkExps(Expression[] exps)
           
 Expression[] walkExps(Expression[] exps, int n)
          Call walk on the Expressions in an array.
protected  Expression walkFluidLetExp(FluidLetExp exp)
           
protected  Expression walkIfExp(IfExp exp)
           
protected  Expression walkLambdaExp(LambdaExp exp)
           
protected  Expression walkLangExp(LangExp exp)
           
protected  Expression walkLetExp(LetExp exp)
           
protected  Expression walkModuleExp(ModuleExp exp)
           
protected  Expression walkObjectExp(ObjectExp exp)
           
protected  Expression walkQuoteExp(QuoteExp exp)
           
protected  Expression walkReferenceExp(ReferenceExp exp)
           
protected  Expression walkScopeExp(ScopeExp exp)
           
protected  Expression walkSetExp(SetExp exp)
           
protected  Expression walkSynchronizedExp(SynchronizedExp exp)
           
protected  Expression walkThisExp(ThisExp exp)
           
protected  Expression walkTryExp(TryExp exp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected SourceMessages messages

currentLambda

protected LambdaExp currentLambda
Constructor Detail

ExpWalker

public ExpWalker()
Method Detail

getCompilation

public Compilation getCompilation()
Get the Compilation associated with this walker.


getMessages

public SourceMessages getMessages()

walkExpression

protected Expression walkExpression(Expression exp)

setContext

public void setContext(Compilation comp)

walk

public Expression walk(Expression exp)
Call the walk method of argument Expression. Could call Expression's walk directly, but this allows us to interpose a method call on each Expression. We use it to note the Expression's line number. Should not need to be overridden; if you do, you may also want to override walkExps.


walkApplyExp

protected Expression walkApplyExp(ApplyExp exp)

walkIfExp

protected Expression walkIfExp(IfExp exp)

walkDeclarationType

protected final void walkDeclarationType(Declaration decl)

walkDeclarationTypes

protected final void walkDeclarationTypes(ScopeExp exp)

walkScopeExp

protected Expression walkScopeExp(ScopeExp exp)

walkLetExp

protected Expression walkLetExp(LetExp exp)

walkLambdaExp

protected Expression walkLambdaExp(LambdaExp exp)

walkClassExp

protected Expression walkClassExp(ClassExp exp)

walkObjectExp

protected Expression walkObjectExp(ObjectExp exp)

walkModuleExp

protected Expression walkModuleExp(ModuleExp exp)

walkSetExp

protected Expression walkSetExp(SetExp exp)

walkTryExp

protected Expression walkTryExp(TryExp exp)

walkBeginExp

protected Expression walkBeginExp(BeginExp exp)

walkQuoteExp

protected Expression walkQuoteExp(QuoteExp exp)

walkReferenceExp

protected Expression walkReferenceExp(ReferenceExp exp)

walkThisExp

protected Expression walkThisExp(ThisExp exp)

walkSynchronizedExp

protected Expression walkSynchronizedExp(SynchronizedExp exp)

walkBlockExp

protected Expression walkBlockExp(BlockExp exp)

walkExitExp

protected Expression walkExitExp(ExitExp exp)

walkFluidLetExp

protected Expression walkFluidLetExp(FluidLetExp exp)

walkLangExp

protected Expression walkLangExp(LangExp exp)

getCurrentLambda

public final LambdaExp getCurrentLambda()

walkExps

public Expression[] walkExps(Expression[] exps)

walkExps

public Expression[] walkExps(Expression[] exps,
                             int n)
Call walk on the Expressions in an array. However, the walk method is inlined for speed.


walkDefaultArgs

public void walkDefaultArgs(LambdaExp exp)

error

public void error(char kind,
                  java.lang.String message)

noteError

public Expression noteError(java.lang.String message)

getFileName

public final java.lang.String getFileName()
Description copied from interface: SourceLocator
Normally same as getSystemId.

Specified by:
getFileName in interface SourceLocator

getLineNumber

public final int getLineNumber()
Description copied from interface: SourceLocator
Return current line number. The "first" line is line 1; unknown is -1.

Specified by:
getLineNumber in interface SourceLocator
Specified by:
getLineNumber in interface org.xml.sax.Locator

getColumnNumber

public final int getColumnNumber()
Description copied from interface: SourceLocator
Return current column number. The "first" column is column 1; unknown is -1.

Specified by:
getColumnNumber in interface SourceLocator
Specified by:
getColumnNumber in interface org.xml.sax.Locator

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in interface SourceLocator
Specified by:
getPublicId in interface org.xml.sax.Locator

getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface SourceLocator
Specified by:
getSystemId in interface org.xml.sax.Locator

isStableSourceLocation

public boolean isStableSourceLocation()
Normally same as getSystemId.

Specified by:
isStableSourceLocation in interface SourceLocator

setFile

public void setFile(java.lang.String filename)

setLine

public void setLine(int line)

setColumn

public void setColumn(int column)

setLine

public void setLine(java.lang.String filename,
                    int line,
                    int column)