Package com.strobel.expressions
Class LambdaCompiler
java.lang.Object
com.strobel.expressions.LambdaCompiler
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BoundConstants
private FieldBuilder
private ConstructorBuilder
private FinallyInfo
private final KeyedQueue
<Type<?>, LocalBuilder> private boolean
private LabelScopeInfo
private final Map
<LabelTarget, LabelInfo> private CompilerScope
private final AnalyzedTree
(package private) final CodeGenerator
(package private) final LambdaExpression
<?> (package private) final MethodBuilder
(package private) static final AtomicInteger
(package private) final TypeBuilder
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
LambdaCompiler
(AnalyzedTree tree, LambdaExpression<?> lambda) (package private)
LambdaCompiler
(AnalyzedTree tree, LambdaExpression<?> lambda, MethodBuilder method, ConstructorBuilder constructor) private
LambdaCompiler
(LambdaCompiler parent, LambdaExpression lambda) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addReturnLabel
(LambdaExpression lambda) private static <T> Pair
<AnalyzedTree, LambdaExpression<T>> analyzeLambda
(LambdaExpression<T> lambda) (package private) boolean
private static boolean
canOptimizeSwitchType
(Type<?> valueType) private void
checkTry()
(package private) static <T> Delegate
<T> compile
(LambdaExpression<T> lambda, DebugInfoGenerator debugInfoGenerator) (package private) static <T> void
compile
(LambdaExpression<T> lambda, MethodBuilder methodBuilder, DebugInfoGenerator debugInfoGenerator) private <T> Delegate
<T> createDelegate
(Class<T> generatedClass) private FieldBuilder
createStaticField
(String name, Type type) private void
defineBlockLabels
(Expression node) private LabelInfo
defineLabel
(LabelTarget node) private void
emit
(BlockExpression node, int flags) private void
emitAndAlsoBinaryExpression
(Expression expr, int flags) private void
emitArguments
(MethodBase method, IArgumentProvider args) private void
emitArguments
(MethodBase method, IArgumentProvider args, int skipParameters) private void
emitArithmeticBinaryOp
(ExpressionType op, Type<?> operandType) private void
emitAssign
(BinaryExpression node, int emitAs) private void
private void
private void
emitBinaryExpression
(Expression expr, int flags) private void
emitBinaryMethod
(BinaryExpression b, int flags) private void
emitBinaryOperator
(ExpressionType op, Type<?> leftType, Type<?> rightType, Type resultType) private void
emitBlockExpression
(Expression expr, int flags) private void
emitBranchAnd
(boolean branch, BinaryExpression node, Label label) private void
emitBranchBlock
(boolean branch, BlockExpression node, Label label) private void
emitBranchLogical
(boolean branch, BinaryExpression node, Label label) private void
emitBranchNot
(boolean branch, UnaryExpression node, Label label) private void
emitBranchNullCheck
(boolean branch, UnaryExpression node, Label label) private void
emitBranchOp
(boolean branch, Label label) private void
emitBranchOr
(boolean branch, BinaryExpression node, Label label) private void
emitBranchRelation
(boolean branch, BinaryExpression node, Label label) private void
(package private) void
private void
private void
private void
emitConditionalExpression
(Expression expr, int flags) private void
emitConstant
(Object value, Type<?> type) (package private) final void
emitConstantArray
(Object array) private void
private void
emitConvert
(UnaryExpression node, int flags) private void
emitConvertArithmeticResult
(ExpressionType op, Type sourceType, Type resultType) private void
emitConvertUnaryExpression
(Expression expr, int flags) (package private) boolean
private void
private void
private void
(package private) void
emitExpression
(Expression node) private void
emitExpression
(Expression node, int flags) private void
emitExpressionAndBranch
(boolean branchValue, Expression node, Label label) private void
emitExpressionAsType
(Expression node, Type type, int flags) private void
private void
emitExpressionAsVoid
(Expression node, int flags) private void
emitExpressionEnd
(int flags) private int
private void
private void
emitGotoExpression
(Expression expr, int flags) private void
emitIndexAssignment
(BinaryExpression node, int flags) private void
emitInlinedInvoke
(InvocationExpression invoke, int flags) private void
emitInvocationExpression
(Expression expr, int flags) private void
emitLabelExpression
(Expression expr, int flags) (package private) void
emitLambdaArgument
(int index) private void
private void
emitLambdaBody
(CompilerScope parent, boolean inlined, int flags) private void
private void
private void
emitLiftedBooleanAnd
(Type leftType, Type rightType) private void
emitLiftedBooleanOr
(Type leftType, Type rightType) private void
emitLiftedRelational
(ExpressionType op, Type leftType, Type rightType, Type resultType) private void
emitLoopExpression
(Expression expr) private void
emitMemberAssignment
(BinaryExpression node, int flags) private void
private void
emitMemberGet
(MemberInfo member) private void
emitMethodCall
(Expression target, MethodInfo method, IArgumentProvider methodCallExpr) private void
emitMethodCall
(Expression target, MethodInfo method, IArgumentProvider expr, int flags) private void
emitMethodCall
(Expression target, MethodInfo method, MethodCallExpression expr, int flags) private void
emitMethodCall
(MethodInfo method, IArgumentProvider args, Type<?> objectType, int flags) private void
private void
emitMethodCallExpression
(Expression expr, int flags) private void
private void
emitNewExpression
(Expression expr) private void
private void
emitOrElseBinaryExpression
(Expression expr, int flags) private void
private void
private Type
<?> emitPrimitiveBinaryOp
(ExpressionType op, Type leftType, Type rightType) private void
private void
private void
emitRelationalBranchOp
(ExpressionType op, Type<?> operandType, boolean branch, Label label) private void
private void
private void
emitSetIndexCall
(BinaryExpression index) private void
emitSwitchExpression
(Expression expr, int flags) private void
emitThrow
(UnaryExpression expr, int flags) private void
private void
emitTryExpression
(Expression expr) private void
private void
emitUnary
(UnaryExpression node, int flags) private void
emitUnaryExpression
(Expression expr, int flags) private void
emitUnaryMethod
(UnaryExpression node, int flags) private void
emitUnaryOperator
(ExpressionType op, Type operandType, Type resultType) private void
private void
emitUnboxingBinaryArithmetic
(ExpressionType op, Type leftType, Type rightType, Type resultType) private void
emitUnboxingBinaryOp
(ExpressionType op, Type leftType, Type rightType, Type resultType) private void
private void
private void
emitUnreachable
(Expression node, int flags) private void
emitVariableAssignment
(BinaryExpression node, int flags) private void
private void
private LabelInfo
ensureLabel
(LabelTarget node) private void
enterScope
(Object node) private void
enterTry
(TryExpression tryExpression) private void
private void
exitTry
(TryExpression tryExpression) (package private) void
freeLocal
(LocalBuilder local) private Expression
getEqualityOperand
(Expression expression) (package private) int
getLambdaArgument
(int index) (package private) LocalBuilder
(package private) LocalBuilder
getNamedLocal
(Type type, ParameterExpression variable) (package private) ParameterExpressionList
private TypeList
getParameterTypes
(LambdaExpression<?> lambda) (package private) static String
getUniqueLambdaName
(String name, Class<?> creationContext) (package private) static String
private static boolean
hasVariables
(Object node) (package private) void
private static boolean
notEmpty
(Expression node) private void
popLabelBlock
(LabelScopeKind kind) private void
pushLabelBlock
(LabelScopeKind type) private LabelInfo
referenceLabel
(LabelTarget node) private static boolean
significant
(Expression node) private boolean
tryEmitLookupSwitch
(SwitchExpression node, int flags) private boolean
tryEmitStringSwitch
(SwitchExpression node, int flags) private boolean
tryPushLabelBlock
(Expression node) private Type
unboxLeftBinaryOperand
(Type leftType, Type rightType) private Type
unboxRightBinaryOperand
(Type rightType) private static int
updateEmitAsTailCallFlag
(int flags, int newValue) private static int
updateEmitAsTypeFlag
(int flags, int newValue) private static int
updateEmitExpressionStartFlag
(int flags, int newValue)
-
Field Details
-
nextId
-
closureType
-
lambda
-
typeBuilder
-
methodBuilder
-
generator
-
_tree
-
_freeLocals
-
_boundConstants
-
_labelInfo
-
_constructorBuilder
-
_hasClosureArgument
private boolean _hasClosureArgument -
_closureField
-
_scope
-
_labelBlock
-
_finallyInfo
-
-
Constructor Details
-
LambdaCompiler
LambdaCompiler(AnalyzedTree tree, LambdaExpression<?> lambda) -
LambdaCompiler
LambdaCompiler(AnalyzedTree tree, LambdaExpression<?> lambda, MethodBuilder method, ConstructorBuilder constructor) -
LambdaCompiler
-
-
Method Details
-
getParameterTypes
-
getParameters
ParameterExpressionList getParameters() -
canEmitBoundConstants
boolean canEmitBoundConstants() -
emitDebugSymbols
boolean emitDebugSymbols() -
emitClosureArgument
void emitClosureArgument() -
emitLambdaArgument
void emitLambdaArgument(int index) -
createStaticField
-
initializeMethod
void initializeMethod() -
addReturnLabel
-
notEmpty
-
significant
-
compile
-
createDelegate
-
compile
static <T> void compile(LambdaExpression<T> lambda, MethodBuilder methodBuilder, DebugInfoGenerator debugInfoGenerator) -
analyzeLambda
-
getNamedLocal
-
getLambdaArgument
int getLambdaArgument(int index) -
getLocal
-
freeLocal
-
updateEmitAsTailCallFlag
private static int updateEmitAsTailCallFlag(int flags, int newValue) -
updateEmitExpressionStartFlag
private static int updateEmitExpressionStartFlag(int flags, int newValue) -
updateEmitAsTypeFlag
private static int updateEmitAsTypeFlag(int flags, int newValue) -
emitExpression
-
emitExpressionStart
-
emitExpressionEnd
private void emitExpressionEnd(int flags) -
emitExpression
-
emitExtensionExpression
-
emitExpressionAsVoid
-
emitExpressionAsVoid
-
emitExpressionAsType
-
emitAssignBinaryExpression
-
emitAssign
-
emitMemberAssignment
-
emitVariableAssignment
-
emitIndexAssignment
-
emitSetIndexCall
-
hasVariables
-
enterTry
-
exitTry
-
enterScope
-
exitScope
-
emitBlockExpression
-
emit
-
emitAndAlsoBinaryExpression
-
emitPrimitiveAndAlso
-
emitUnboxingAndAlso
-
emitOrElseBinaryExpression
-
emitPrimitiveOrElse
-
emitUnboxingOrElse
-
emitCoalesceBinaryExpression
-
emitReferenceCoalesceWithoutConversion
-
emitLambdaReferenceCoalesce
-
emitConditionalExpression
-
emitBinaryExpression
-
emitBinaryExpression
-
getEqualityOperand
-
emitBinaryMethod
-
emitBinaryOperator
private void emitBinaryOperator(ExpressionType op, Type<?> leftType, Type<?> rightType, Type resultType) -
emitConvertArithmeticResult
-
emitPrimitiveBinaryOp
-
emitUnboxingBinaryOp
private void emitUnboxingBinaryOp(ExpressionType op, Type leftType, Type rightType, Type resultType) -
emitUnboxingBinaryArithmetic
private void emitUnboxingBinaryArithmetic(ExpressionType op, Type leftType, Type rightType, Type resultType) -
emitLiftedRelational
private void emitLiftedRelational(ExpressionType op, Type leftType, Type rightType, Type resultType) -
unboxRightBinaryOperand
-
unboxLeftBinaryOperand
-
emitLiftedBooleanAnd
-
emitLiftedBooleanOr
-
emitObjectBinaryOp
-
emitArithmeticBinaryOp
-
emitConstantExpression
-
emitConstant
-
emitDefaultValueExpression
-
emitGotoExpression
-
emitUnreachable
-
emitExpressionAndBranch
-
emitBranchNot
-
emitBranchNullCheck
-
emitBranchRelation
-
emitRelationalBranchOp
private void emitRelationalBranchOp(ExpressionType op, Type<?> operandType, boolean branch, Label label) -
emitBranchOp
-
emitBranchLogical
-
emitBranchAnd
-
emitBranchOr
-
emitBranchBlock
-
emitInvocationExpression
-
emitInlinedInvoke
-
emitLabelExpression
-
pushLabelBlock
-
tryPushLabelBlock
-
popLabelBlock
-
defineBlockLabels
-
ensureLabel
-
referenceLabel
-
defineLabel
-
emitLambdaExpression
-
emitDelegateConstruction
-
getUniqueMethodName
-
getUniqueLambdaName
-
emitLambdaBody
private void emitLambdaBody() -
emitLambdaBody
-
emitDelegateConstruction
-
emitClosureCreation
-
ensureConstructor
private void ensureConstructor() -
ensureClosure
private void ensureClosure() -
emitConstantArray
-
emitLoopExpression
-
emitMemberExpression
-
emitMemberGet
-
emitMethodCallExpression
-
emitMethodCallExpression
-
emitMethodCall
-
emitMethodCall
private void emitMethodCall(Expression target, MethodInfo method, IArgumentProvider expr, int flags) -
emitMethodCall
private void emitMethodCall(Expression target, MethodInfo method, MethodCallExpression expr, int flags) -
emitMethodCall
private void emitMethodCall(MethodInfo method, IArgumentProvider args, Type<?> objectType, int flags) -
emitArguments
-
emitArguments
-
emitNewExpression
-
emitNewArrayExpression
-
emitParameterExpression
-
emitRuntimeVariablesExpression
-
emitTypeBinaryExpression
-
emitUnaryExpression
-
emitUnary
-
emitUnaryOperator
-
emitUnaryMethod
-
emitConvertUnaryExpression
-
emitConvert
-
emitUnboxUnaryExpression
-
emitThrowUnaryExpression
-
emitThrow
-
emitTryExpression
-
emitCatchStart
-
checkTry
private void checkTry() -
emitSaveExceptionOrPop
-
emitSwitchExpression
-
tryEmitStringSwitch
-
tryEmitLookupSwitch
-
canOptimizeSwitchType
-