gnu.expr

Class ExpWalker

Implemented Interfaces:
org.xml.sax.Locator, SourceLocator
Known Direct 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

Method Summary

void
error(char kind, String message)
int
getColumnNumber()
Compilation
getCompilation()
Get the Compilation associated with this walker.
LambdaExp
getCurrentLambda()
String
getFileName()
int
getLineNumber()
SourceMessages
getMessages()
String
getPublicId()
String
getSystemId()
boolean
isStableSourceLocation()
Normally same as getSystemId.
Expression
noteError(String message)
void
setColumn(int column)
void
setContext(Compilation comp)
void
setFile(String filename)
void
setLine(String filename, int line, int column)
void
setLine(int line)
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)

Field Details

currentLambda

protected LambdaExp currentLambda

messages

protected SourceMessages messages

Method Details

error

public void error(char kind,
                  String message)

getColumnNumber

public final int getColumnNumber()
Specified by:
getColumnNumber in interface SourceLocator

getCompilation

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

getCurrentLambda

public final LambdaExp getCurrentLambda()

getFileName

public final String getFileName()
Specified by:
getFileName in interface SourceLocator

getLineNumber

public final int getLineNumber()
Specified by:
getLineNumber in interface SourceLocator

getMessages

public SourceMessages getMessages()

getPublicId

public String getPublicId()
Specified by:
getPublicId in interface SourceLocator

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface SourceLocator

isStableSourceLocation

public boolean isStableSourceLocation()
Normally same as getSystemId.
Specified by:
isStableSourceLocation in interface SourceLocator

noteError

public Expression noteError(String message)

setColumn

public void setColumn(int column)

setContext

public void setContext(Compilation comp)

setFile

public void setFile(String filename)

setLine

public void setLine(String filename,
                    int line,
                    int column)

setLine

public void setLine(int line)

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)

walkBeginExp

protected Expression walkBeginExp(BeginExp exp)

walkBlockExp

protected Expression walkBlockExp(BlockExp exp)

walkClassExp

protected Expression walkClassExp(ClassExp exp)

walkDeclarationType

protected final void walkDeclarationType(Declaration decl)

walkDeclarationTypes

protected final void walkDeclarationTypes(ScopeExp exp)

walkDefaultArgs

public void walkDefaultArgs(LambdaExp exp)

walkExitExp

protected Expression walkExitExp(ExitExp exp)

walkExpression

protected Expression walkExpression(Expression exp)

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.

walkFluidLetExp

protected Expression walkFluidLetExp(FluidLetExp exp)

walkIfExp

protected Expression walkIfExp(IfExp exp)

walkLambdaExp

protected Expression walkLambdaExp(LambdaExp exp)

walkLangExp

protected Expression walkLangExp(LangExp exp)

walkLetExp

protected Expression walkLetExp(LetExp exp)

walkModuleExp

protected Expression walkModuleExp(ModuleExp exp)

walkObjectExp

protected Expression walkObjectExp(ObjectExp exp)

walkQuoteExp

protected Expression walkQuoteExp(QuoteExp exp)

walkReferenceExp

protected Expression walkReferenceExp(ReferenceExp exp)

walkScopeExp

protected Expression walkScopeExp(ScopeExp exp)

walkSetExp

protected Expression walkSetExp(SetExp exp)

walkSynchronizedExp

protected Expression walkSynchronizedExp(SynchronizedExp exp)

walkThisExp

protected Expression walkThisExp(ThisExp exp)

walkTryExp

protected Expression walkTryExp(TryExp exp)