Class DefaultSemanticProvider
Default implementation of a provider of semantic information about expressions and reflection objects.
Implements
Namespace: System.Linq.Expressions
Assembly: Nuqleon.Linq.Expressions.Optimizers.dll
Syntax
public class DefaultSemanticProvider : Object, ISemanticProvider
Constructors
DefaultSemanticProvider()
Declaration
public DefaultSemanticProvider()
Methods
AllBitsOne(Expression)
Checks if the specified expression
represents a value where all bits are one (1).
Declaration
public virtual bool AllBitsOne(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
AllBitsZero(Expression)
Checks if the specified expression
represents a value where all bits are zero (0).
Declaration
public virtual bool AllBitsZero(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
AlwaysThrows(Expression)
Checks if the specified expression
represents an unconditional throw
of an exception with no other side-effects.
Declaration
public virtual bool AlwaysThrows(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetConstantValue(Expression)
Gets the constant value represented by the specified expression
.
Declaration
public virtual object GetConstantValue(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to get a constant value for. |
Returns
Type | Description |
---|---|
System.Object | The constant value represented by the specified |
HasConstantValue(Expression)
Checks if the specified expression
represents a constant value.
Declaration
public virtual bool HasConstantValue(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
If this method returns true
for a given expression, a subsequent call to
GetConstantValue(Expression) should be able to obtain the constant value that's
represented by the expression.
IsAlwaysNull(Expression)
Checks if the specified expression
represents a null reference.
Declaration
public virtual bool IsAlwaysNull(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsConst(ParameterInfo)
Checks if the specified parameter
uses the argument in a const
(readonly
)
fashion, i.e. it doesn't cause any mutation to the argument passed to it.
Declaration
public virtual bool IsConst(ParameterInfo parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.ParameterInfo | parameter | The parameter to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsFalse(Expression)
Checks if the specified expression
represents a false
value.
Declaration
public virtual bool IsFalse(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsIdentityFunction(Expression)
Checks if the specified expression
represents an identity function.
Declaration
public virtual bool IsIdentityFunction(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsImmutable(Type)
Checks if instances of the specified type
are immutable.
Declaration
public virtual bool IsImmutable(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsMaxValue(Expression)
Checks if the specified expression
represents a maximum value, such as System.Int32.MaxValue.
Declaration
public virtual bool IsMaxValue(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsMinValue(Expression)
Checks if the specified expression
represents a minimum value, such as System.Int32.MinValue.
Declaration
public virtual bool IsMinValue(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNeverNull(Expression)
Checks if the specified expression
is guaranteed to evaluate to a non-null value.
Declaration
public virtual bool IsNeverNull(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
Note that this method can return true
even if the specified expression
may
throw an exception.
IsOne(Expression)
Checks if the specified expression
represents a one (1) value.
Declaration
public virtual bool IsOne(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsPure(Expression)
Checks if the specified expression
does not have any side-effects for evaluation.
Declaration
public virtual bool IsPure(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
Any node for which this method returns true
is not allowed to throw a synchronous exception.
IsPure(MemberInfo)
Checks if the specified member
is pure and doesn't have any side-effects for
evaluation.
Declaration
public virtual bool IsPure(MemberInfo member)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MemberInfo | member | The member to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
Pure members can be evaluated at compile time if all operands passed to them are constant values that can be obtained at runtime. The member is allowed to throw an exception (provided this behavior is deterministic), causing the expression optimizer to either suppress optimizing the node or to replace the subexpression with a System.Linq.Expressions.ExpressionType.Throw node.
Note that members should not be reported as pure if their result is a mutable object. All evaluations of the optimized tree containing such a member would share the resulting object.
IsTrue(Expression)
Checks if the specified expression
represents a true
value.
Declaration
public virtual bool IsTrue(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsZero(Expression)
Checks if the specified expression
represents a zero (0) value.
Declaration
public virtual bool IsZero(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
NeverThrows(Expression)
Checks if the specified expression
can never throw.
Declaration
public virtual bool NeverThrows(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
NeverThrows(MemberInfo)
Checks if the specified member
can never throw.
Declaration
public virtual bool NeverThrows(MemberInfo member)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MemberInfo | member | The member to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|