Package gnu.expr
Class InlineCalls
- All Implemented Interfaces:
SourceLocator
,SourceLocator
,Locator
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
New helper Type class, used for "lenient" conversions.static class
static class
A marker type to indicate that void is invalid.Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
Field Summary
FieldsFields inherited from class gnu.expr.ExpVisitor
currentLambda, exitValue, messages
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Integer
checkIntValue
(Expression exp) static Long
checkLongValue
(Expression exp) checkType
(Expression exp, Type required) protected boolean
deferableInit
(Expression init) fixIntValue
(Expression exp) fixLongValue
(Expression exp) static Expression
inlineCall
(LambdaExp lexp, ApplyExp aexp, boolean makeCopy) Attempt to inline a function call.static Expression
inlineCalls
(Expression exp, Compilation comp) static int
isCompatibleWithValue
(Type required, Type expType) maybeInline
(ApplyExp exp, Type required, Procedure proc) boolean
If currently processing an annotation belonging to a declaration.static Type
Return a required type for procedure application context.visit
(Expression exp, Type required) Call the visit method of argument Expression.protected void
visitAnnotations
(Declaration decl) protected Expression
visitApplyExp
(ApplyExp exp, Type required) final 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
visitCaseExp
(CaseExp exp, Type required) protected Expression
visitClassExp
(ClassExp exp, Type required) void
visitDefaultArgs
(LambdaExp exp, Type required) protected Expression
visitFluidLetExp
(FluidLetExp 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
visitModuleExp
(ModuleExp exp, Type required) protected Expression
visitQuoteExp
(QuoteExp exp, Type required) protected Expression
visitReferenceExp
(ReferenceExp exp, Type required) protected void
Visit any named functions that haven't been visit yet.protected Expression
visitScopeExp
(ScopeExp exp, Type required) protected Expression
visitSetExp
(SetExp exp, Type required) protected Expression
visitTryExp
(TryExp exp, Type required) Methods inherited from class gnu.expr.ExpExpVisitor
defaultValue, error, error, update
Methods inherited from class gnu.expr.ExpVisitor
error, getColumnNumber, getCompilation, getCurrentLambda, getEndColumn, getEndLine, getExitValue, getFileName, getLanguage, getLineNumber, getMessages, getPublicId, getStartColumn, getStartLine, getSystemId, isStableSourceLocation, noteError, setColumn, setContext, setFile, setLine, setLine, visit, visitAndUpdate, visitBlockExp, visitDeclarationType, visitDeclarationTypes, visitExitExp, visitExpression, visitExps, visitExps, visitLangExp, visitObjectExp, visitSynchronizedExp, visitThisExp
-
Field Details
-
currentVisitor
-
-
Constructor Details
-
InlineCalls
-
-
Method Details
-
inlineCalls
-
visit
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 classExpVisitor<Expression,
Type>
-
isCompatibleWithValue
-
checkType
-
visitApplyExp
- Overrides:
visitApplyExp
in classExpVisitor<Expression,
Type>
-
typeForCalledFunction
Return a required type for procedure application context. This is ProcedureInCallContext.INSTANCE or null. The value ProcedureInCallContext.INSTANCE indicates the expression is used in application context and setCanCall is appropriate. This means the function expression must be a lambda or reference. (Consider a function that is an IfExp: If the required type is passed down to two branches that are both lambdas, we might think the lambdas are called but not read and thus safe for inlining - but that would be false, since we need the If to yield a procedure value.) -
visitApplyOnly
Visit an ApplyExp assuming function and arguments have been visited. -
checkIntValue
-
checkLongValue
-
fixIntValue
-
fixLongValue
-
visitQuoteExp
- Overrides:
visitQuoteExp
in classExpVisitor<Expression,
Type>
-
visitReferenceExp
- Overrides:
visitReferenceExp
in classExpVisitor<Expression,
Type>
-
visitIfExp
- Overrides:
visitIfExp
in classExpVisitor<Expression,
Type>
-
visitBeginExp
- Overrides:
visitBeginExp
in classExpVisitor<Expression,
Type>
-
visitCaseExp
- Overrides:
visitCaseExp
in classExpVisitor<Expression,
Type>
-
visitScopeExp
- Overrides:
visitScopeExp
in classExpVisitor<Expression,
Type>
-
visitRemainingDeclaredLambdas
Visit any named functions that haven't been visit yet. This should be called at the end of a LetExp or ModuleExp. -
visitModuleExp
- Overrides:
visitModuleExp
in classExpVisitor<Expression,
Type>
-
visitLetExp
- Overrides:
visitLetExp
in classExpVisitor<Expression,
Type>
-
deferableInit
-
visitFluidLetExp
- Overrides:
visitFluidLetExp
in classExpVisitor<Expression,
Type>
-
visitLambdaExp
- Overrides:
visitLambdaExp
in classExpVisitor<Expression,
Type>
-
visitDefaultArgs
- Overrides:
visitDefaultArgs
in classExpVisitor<Expression,
Type>
-
visitClassExp
- Overrides:
visitClassExp
in classExpVisitor<Expression,
Type>
-
visitTryExp
- Overrides:
visitTryExp
in classExpVisitor<Expression,
Type>
-
processingAnnotations
public boolean processingAnnotations()If currently processing an annotation belonging to a declaration. In this case expressions must resolve to constants, annotations must resolve to know annotation types. -
visitAnnotations
-
visitSetExp
- Overrides:
visitSetExp
in classExpVisitor<Expression,
Type>
-
maybeInline
-
inlineCall
Attempt to inline a function call.- Parameters:
lexp
- function to inlinemakeCopy
- 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.
-