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 classNew helper Type class, used for "lenient" conversions.static classstatic classA 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 IntegercheckIntValue(Expression exp) static LongcheckLongValue(Expression exp) checkType(Expression exp, Type required) protected booleandeferableInit(Expression init) fixIntValue(Expression exp) fixLongValue(Expression exp) static ExpressioninlineCall(LambdaExp lexp, ApplyExp aexp, boolean makeCopy) Attempt to inline a function call.static ExpressioninlineCalls(Expression exp, Compilation comp) static intisCompatibleWithValue(Type required, Type expType) maybeInline(ApplyExp exp, Type required, Procedure proc) booleanIf currently processing an annotation belonging to a declaration.static TypeReturn a required type for procedure application context.visit(Expression exp, Type required) Call the visit method of argument Expression.protected voidvisitAnnotations(Declaration decl) protected ExpressionvisitApplyExp(ApplyExp exp, Type required) final ExpressionvisitApplyOnly(ApplyExp exp, Type required) Visit an ApplyExp assuming function and arguments have been visited.protected ExpressionvisitBeginExp(BeginExp exp, Type required) protected ExpressionvisitCaseExp(CaseExp exp, Type required) protected ExpressionvisitClassExp(ClassExp exp, Type required) voidvisitDefaultArgs(LambdaExp exp, Type required) protected ExpressionvisitFluidLetExp(FluidLetExp exp, Type required) protected ExpressionvisitIfExp(IfExp exp, Type required) protected ExpressionvisitLambdaExp(LambdaExp exp, Type required) protected ExpressionvisitLetExp(LetExp exp, Type required) protected ExpressionvisitModuleExp(ModuleExp exp, Type required) protected ExpressionvisitQuoteExp(QuoteExp exp, Type required) protected ExpressionvisitReferenceExp(ReferenceExp exp, Type required) protected voidVisit any named functions that haven't been visit yet.protected ExpressionvisitScopeExp(ScopeExp exp, Type required) protected ExpressionvisitSetExp(SetExp exp, Type required) protected ExpressionvisitTryExp(TryExp exp, Type required) Methods inherited from class gnu.expr.ExpExpVisitor
defaultValue, error, error, updateMethods 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:ExpVisitorCall 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:
visitin classExpVisitor<Expression,Type>
-
isCompatibleWithValue
-
checkType
-
visitApplyExp
- Overrides:
visitApplyExpin 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:
visitQuoteExpin classExpVisitor<Expression,Type>
-
visitReferenceExp
- Overrides:
visitReferenceExpin classExpVisitor<Expression,Type>
-
visitIfExp
- Overrides:
visitIfExpin classExpVisitor<Expression,Type>
-
visitBeginExp
- Overrides:
visitBeginExpin classExpVisitor<Expression,Type>
-
visitCaseExp
- Overrides:
visitCaseExpin classExpVisitor<Expression,Type>
-
visitScopeExp
- Overrides:
visitScopeExpin 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:
visitModuleExpin classExpVisitor<Expression,Type>
-
visitLetExp
- Overrides:
visitLetExpin classExpVisitor<Expression,Type>
-
deferableInit
-
visitFluidLetExp
- Overrides:
visitFluidLetExpin classExpVisitor<Expression,Type>
-
visitLambdaExp
- Overrides:
visitLambdaExpin classExpVisitor<Expression,Type>
-
visitDefaultArgs
- Overrides:
visitDefaultArgsin classExpVisitor<Expression,Type>
-
visitClassExp
- Overrides:
visitClassExpin classExpVisitor<Expression,Type>
-
visitTryExp
- Overrides:
visitTryExpin 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:
visitSetExpin 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.
-