gnu.expr
Class ExpVisitor<R,D>

java.lang.Object
  extended by gnu.expr.ExpVisitor<R,D>
All Implemented Interfaces:
javax.xml.transform.SourceLocator, org.xml.sax.Locator
Direct Known Subclasses:
ExpExpVisitor, PushApply

public class ExpVisitor<R,D>
extends java.lang.Object
implements SourceLocator

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


Field Summary
protected  LambdaExp currentLambda
           
protected  java.lang.Object exitValue
          If exitValue is set to non-null, the visit stops.
protected  SourceMessages messages
           
 
Constructor Summary
ExpVisitor()
           
 
Method Summary
protected  R defaultValue(Expression r, D d)
           
 void error(char kind, java.lang.String message)
           
 int getColumnNumber()
          Return current column number.
 Compilation getCompilation()
          Get the Compilation associated with this visitor.
 LambdaExp getCurrentLambda()
           
 java.lang.Object getExitValue()
           
 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)
           
protected  Expression update(Expression exp, R r)
           
 R visit(Expression exp, D d)
          Call the visit method of argument Expression.
 Expression visitAndUpdate(Expression exp, D d)
           
protected  R visitApplyExp(ApplyExp exp, D d)
           
protected  R visitBeginExp(BeginExp exp, D d)
           
protected  R visitBlockExp(BlockExp exp, D d)
           
protected  R visitClassExp(ClassExp exp, D d)
           
protected  void visitDeclarationType(Declaration decl)
           
protected  void visitDeclarationTypes(ScopeExp exp)
           
 void visitDefaultArgs(LambdaExp exp, D d)
           
protected  R visitExitExp(ExitExp exp, D d)
           
protected  R visitExpression(Expression exp, D d)
           
 Expression[] visitExps(Expression[] exps, D d)
           
 Expression[] visitExps(Expression[] exps, int n, D d)
          Call visit on the Expressions in an array.
protected  R visitFluidLetExp(FluidLetExp exp, D d)
           
protected  R visitIfExp(IfExp exp, D d)
           
protected  R visitLambdaExp(LambdaExp exp, D d)
           
protected  R visitLangExp(LangExp exp, D d)
           
protected  R visitLetExp(LetExp exp, D d)
           
protected  R visitModuleExp(ModuleExp exp, D d)
           
protected  R visitObjectExp(ObjectExp exp, D d)
           
protected  R visitQuoteExp(QuoteExp exp, D d)
           
protected  R visitReferenceExp(ReferenceExp exp, D d)
           
protected  R visitScopeExp(ScopeExp exp, D d)
           
protected  R visitSetExp(SetExp exp, D d)
           
protected  Expression visitSetExpValue(Expression new_value, D d, Declaration decl)
           
protected  R visitSynchronizedExp(SynchronizedExp exp, D d)
           
protected  R visitThisExp(ThisExp exp, D d)
           
protected  R visitTryExp(TryExp exp, D d)
           
 
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

exitValue

protected java.lang.Object exitValue
If exitValue is set to non-null, the visit stops.

Constructor Detail

ExpVisitor

public ExpVisitor()
Method Detail

getCompilation

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


getMessages

public SourceMessages getMessages()

defaultValue

protected R defaultValue(Expression r,
                         D d)

visitExpression

protected R visitExpression(Expression exp,
                            D d)

setContext

public void setContext(Compilation comp)

visit

public R visit(Expression exp,
               D d)
Call the visit method of argument Expression. Could call Expression's visit 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 visitExps.


update

protected Expression update(Expression exp,
                            R r)

visitApplyExp

protected R visitApplyExp(ApplyExp exp,
                          D d)

visitIfExp

protected R visitIfExp(IfExp exp,
                       D d)

visitDeclarationType

protected final void visitDeclarationType(Declaration decl)

visitDeclarationTypes

protected final void visitDeclarationTypes(ScopeExp exp)

visitScopeExp

protected R visitScopeExp(ScopeExp exp,
                          D d)

visitLetExp

protected R visitLetExp(LetExp exp,
                        D d)

visitLambdaExp

protected R visitLambdaExp(LambdaExp exp,
                           D d)

visitClassExp

protected R visitClassExp(ClassExp exp,
                          D d)

visitObjectExp

protected R visitObjectExp(ObjectExp exp,
                           D d)

visitModuleExp

protected R visitModuleExp(ModuleExp exp,
                           D d)

visitSetExpValue

protected Expression visitSetExpValue(Expression new_value,
                                      D d,
                                      Declaration decl)

visitSetExp

protected R visitSetExp(SetExp exp,
                        D d)

visitTryExp

protected R visitTryExp(TryExp exp,
                        D d)

visitBeginExp

protected R visitBeginExp(BeginExp exp,
                          D d)

visitQuoteExp

protected R visitQuoteExp(QuoteExp exp,
                          D d)

visitReferenceExp

protected R visitReferenceExp(ReferenceExp exp,
                              D d)

visitThisExp

protected R visitThisExp(ThisExp exp,
                         D d)

visitSynchronizedExp

protected R visitSynchronizedExp(SynchronizedExp exp,
                                 D d)

visitBlockExp

protected R visitBlockExp(BlockExp exp,
                          D d)

visitExitExp

protected R visitExitExp(ExitExp exp,
                         D d)

visitFluidLetExp

protected R visitFluidLetExp(FluidLetExp exp,
                             D d)

visitLangExp

protected R visitLangExp(LangExp exp,
                         D d)

getExitValue

public java.lang.Object getExitValue()

getCurrentLambda

public final LambdaExp getCurrentLambda()

visitAndUpdate

public Expression visitAndUpdate(Expression exp,
                                 D d)

visitExps

public Expression[] visitExps(Expression[] exps,
                              D d)

visitExps

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


visitDefaultArgs

public void visitDefaultArgs(LambdaExp exp,
                             D d)

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.


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 javax.xml.transform.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 javax.xml.transform.SourceLocator
Specified by:
getColumnNumber in interface org.xml.sax.Locator

getPublicId

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

getSystemId

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

isStableSourceLocation

public boolean isStableSourceLocation()
Normally same as getSystemId.


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)