gnu.expr
Class InlineCalls
java.lang.Object
gnu.expr.ExpVisitor<Expression,D>
gnu.expr.ExpExpVisitor<Type>
gnu.expr.InlineCalls
- All Implemented Interfaces:
- javax.xml.transform.SourceLocator, org.xml.sax.Locator
public class InlineCalls
- extends ExpExpVisitor<Type>
The main Expression re-writing pass.
This pass handles type-checking (work in progress).
Also checks for calls to known Procedures, and may call
a procedure-specific handler, which may do inlining, constant-folding,
error-checking, and general munging.
Should perhaps rename to something like "Validate" since
we do type-checking and other stuff beyond inlining.
Method Summary |
static java.lang.Integer |
checkIntValue(Expression exp)
|
static java.lang.Long |
checkLongValue(Expression exp)
|
Expression |
checkType(Expression exp,
Type required)
|
QuoteExp |
fixIntValue(Expression exp)
|
QuoteExp |
fixLongValue(Expression exp)
|
static Expression |
inlineCall(LambdaExp lexp,
Expression[] args,
boolean makeCopy)
Attempt to inline a function call. |
static Expression |
inlineCalls(Expression exp,
Compilation comp)
|
Expression |
maybeInline(ApplyExp exp,
Type required,
Procedure proc)
|
Expression |
visit(Expression exp,
Type required)
Call the visit method of argument Expression. |
protected Expression |
visitApplyExp(ApplyExp exp,
Type required)
|
Expression |
visitApplyOnly(ApplyExp exp,
Type required)
Visit an ApplyExp assuming function and arguments have been visited. |
protected Expression |
visitBeginExp(BeginExp exp,
Type required)
|
protected Expression |
visitIfExp(IfExp exp,
Type required)
|
protected Expression |
visitLambdaExp(LambdaExp exp,
Type required)
|
protected Expression |
visitLetExp(LetExp exp,
Type required)
|
protected Expression |
visitQuoteExp(QuoteExp exp,
Type required)
|
protected Expression |
visitReferenceExp(ReferenceExp exp,
Type required)
|
protected Expression |
visitScopeExp(ScopeExp exp,
Type required)
|
protected Expression |
visitSetExp(SetExp exp,
Type required)
|
protected Expression |
visitSetExpValue(Expression new_value,
Type required,
Declaration decl)
|
protected Expression |
visitTryExp(TryExp exp,
Type required)
|
Methods inherited from class gnu.expr.ExpVisitor |
error, getColumnNumber, getCompilation, getCurrentLambda, getExitValue, getFileName, getLineNumber, getMessages, getPublicId, getSystemId, isStableSourceLocation, noteError, setColumn, setContext, setFile, setLine, setLine, visitAndUpdate, visitBlockExp, visitClassExp, visitDeclarationType, visitDeclarationTypes, visitDefaultArgs, visitExitExp, visitExpression, visitExps, visitExps, visitFluidLetExp, visitLangExp, visitModuleExp, visitObjectExp, visitSynchronizedExp, visitThisExp |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InlineCalls
public InlineCalls(Compilation comp)
inlineCalls
public static Expression inlineCalls(Expression exp,
Compilation comp)
visit
public Expression visit(Expression exp,
Type required)
- Description copied from class:
ExpVisitor
- 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.
- Overrides:
visit
in class ExpVisitor<Expression,Type>
checkType
public Expression checkType(Expression exp,
Type required)
visitApplyExp
protected Expression visitApplyExp(ApplyExp exp,
Type required)
- Overrides:
visitApplyExp
in class ExpVisitor<Expression,Type>
visitApplyOnly
public final Expression visitApplyOnly(ApplyExp exp,
Type required)
- Visit an ApplyExp assuming function and arguments have been visited.
checkIntValue
public static java.lang.Integer checkIntValue(Expression exp)
checkLongValue
public static java.lang.Long checkLongValue(Expression exp)
fixIntValue
public QuoteExp fixIntValue(Expression exp)
fixLongValue
public QuoteExp fixLongValue(Expression exp)
visitQuoteExp
protected Expression visitQuoteExp(QuoteExp exp,
Type required)
- Overrides:
visitQuoteExp
in class ExpVisitor<Expression,Type>
visitReferenceExp
protected Expression visitReferenceExp(ReferenceExp exp,
Type required)
- Overrides:
visitReferenceExp
in class ExpVisitor<Expression,Type>
visitIfExp
protected Expression visitIfExp(IfExp exp,
Type required)
- Overrides:
visitIfExp
in class ExpVisitor<Expression,Type>
visitBeginExp
protected Expression visitBeginExp(BeginExp exp,
Type required)
- Overrides:
visitBeginExp
in class ExpVisitor<Expression,Type>
visitScopeExp
protected Expression visitScopeExp(ScopeExp exp,
Type required)
- Overrides:
visitScopeExp
in class ExpVisitor<Expression,Type>
visitLetExp
protected Expression visitLetExp(LetExp exp,
Type required)
- Overrides:
visitLetExp
in class ExpVisitor<Expression,Type>
visitLambdaExp
protected Expression visitLambdaExp(LambdaExp exp,
Type required)
- Overrides:
visitLambdaExp
in class ExpVisitor<Expression,Type>
visitTryExp
protected Expression visitTryExp(TryExp exp,
Type required)
- Overrides:
visitTryExp
in class ExpVisitor<Expression,Type>
visitSetExpValue
protected Expression visitSetExpValue(Expression new_value,
Type required,
Declaration decl)
- Overrides:
visitSetExpValue
in class ExpVisitor<Expression,Type>
visitSetExp
protected Expression visitSetExp(SetExp exp,
Type required)
- Overrides:
visitSetExp
in class ExpVisitor<Expression,Type>
maybeInline
public Expression maybeInline(ApplyExp exp,
Type required,
Procedure proc)
inlineCall
public static Expression inlineCall(LambdaExp lexp,
Expression[] args,
boolean makeCopy)
- Attempt to inline a function call.
- Parameters:
lexp
- function to inlineargs
- list of actual arguments of function callmakeCopy
- true if the body of lexp should of copied; false
if we can re-use lexp because it is no longer needed.
- Returns:
- the inlined expression (a LetExp), or null if we
weren't able to inline.