本文整理汇总了C#中Boo.Lang.Compiler.Ast.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsLogicalCondition
public static bool IsLogicalCondition(Expression node)
{
Node condition = node;
while (IsLogicalExpression(condition.ParentNode))
condition = condition.ParentNode;
return IsConditionOfConditionalStatement(condition);
}
示例2: ComparisonFor
public static Expression ComparisonFor(Expression local, IEnumerable<Expression> expressions)
{
BinaryExpression expression;
IEnumerator<Expression> enumerator = expressions.GetEnumerator();
if (!enumerator.MoveNext())
{
throw new AssertionFailedException("e.MoveNext()");
}
BinaryExpression expression1 = expression = new BinaryExpression(LexicalInfo.Empty);
expression.set_Operator(11);
expression.set_Left(Expression.Lift(local));
expression.set_Right(Expression.Lift(enumerator.Current));
Expression expression2 = expression;
while (enumerator.MoveNext())
{
BinaryExpression expression3;
BinaryExpression expression4;
BinaryExpression expression11 = expression4 = new BinaryExpression(LexicalInfo.Empty);
expression4.set_Operator(0x1c);
expression4.set_Left(Expression.Lift(expression2));
BinaryExpression expression12 = expression3 = new BinaryExpression(LexicalInfo.Empty);
expression3.set_Operator(11);
expression3.set_Left(Expression.Lift(local));
expression3.set_Right(Expression.Lift(enumerator.Current));
expression4.set_Right(expression3);
expression2 = expression4;
}
return expression2;
}
示例3: Slice
public Slice(LexicalInfo lexicalInfo, Expression begin, Expression end, Expression step)
: base(lexicalInfo)
{
this.Begin = begin;
this.End = end;
this.Step = step;
}
示例4: ExplicitBooleanContext
private Expression ExplicitBooleanContext(Expression expression)
{
var type = GetExpressionType(expression);
if (type == TypeSystemServices.BoolType)
{
return expression;
}
// happening
//Trace.Assert(!TypeSystemServices.IsError(expression), "shouldn't have error boolean expression.");
if (TypeSystemServices.IsNumber(type) || type.IsEnum)
{
return CodeBuilder.CreateBoundBinaryExpression(
TypeSystemServices.BoolType,
BinaryOperatorType.Equality,
expression,
CodeBuilder.CreateIntegerLiteral(0));
}
else if (TypeSystemServices.IsReferenceType(type))
{
return CodeBuilder.CreateBoundBinaryExpression(
TypeSystemServices.BoolType,
BinaryOperatorType.Equality,
expression,
CodeBuilder.CreateNullLiteral());
}
return expression;
}
示例5: BinaryExpression
public BinaryExpression(LexicalInfo lexicalInfoProvider, BinaryOperatorType operator_, Expression left, Expression right)
: base(lexicalInfoProvider)
{
this.Operator = operator_;
this.Left = left;
this.Right = right;
}
示例6: PropagateChanges
public override void PropagateChanges(MethodInvocationExpression eval, List chain)
{
ExpressionCollection expressions = new ExpressionCollection();
foreach (object local1 in chain.Reversed)
{
if (!(local1 is ProcessAssignmentsToSpecialMembers.ChainItem))
{
}
ProcessAssignmentsToSpecialMembers.ChainItem item = (ProcessAssignmentsToSpecialMembers.ChainItem) RuntimeServices.Coerce(local1, typeof(ProcessAssignmentsToSpecialMembers.ChainItem));
if (item.Container is MethodInvocationExpression)
{
break;
}
if (item.Container is SlicingExpression)
{
SlicingExpression expression = item.Container;
Expression[] expressionArray1 = new Expression[] { expression.get_Target().CloneNode(), expression.get_Indices().get_Item(0).get_Begin().CloneNode(), this.get_CodeBuilder().CreateReference(item.Local) };
expressions.Add(this.CreateConstructorInvocation(this._sliceValueTypeChangeConstructor, expressionArray1));
break;
}
MemberReferenceExpression container = item.Container;
Expression[] args = new Expression[] { container.get_Target().CloneNode(), this.get_CodeBuilder().CreateStringLiteral(container.get_Name()), this.get_CodeBuilder().CreateReference(item.Local) };
expressions.Add(this.CreateConstructorInvocation(this._valueTypeChangeConstructor, args));
}
MethodInvocationExpression expression3 = this.get_CodeBuilder().CreateMethodInvocation(this._propagateChanges);
IArrayType type = this._valueTypeChangeType.MakeArrayType(1);
expression3.get_Arguments().Add(this.get_CodeBuilder().CreateArray(type, expressions));
eval.get_Arguments().Add(expression3);
}
示例7: IfStatement
public IfStatement(LexicalInfo token, Expression condition, Block trueBlock, Block falseBlock)
: base(token)
{
this.Condition = condition;
this.TrueBlock = trueBlock;
this.FalseBlock = falseBlock;
}
示例8: Reify
public Expression Reify(Expression node)
{
if (ShouldReify())
{
RunExpansionIterations();
}
return node;
}
示例9: IsTryGetParameterInvocation
private static bool IsTryGetParameterInvocation(Expression condition)
{
var expression = condition as ReferenceExpression;
if (expression == null)
return false;
return expression.Name.StartsWith("?");
}
示例10: CreateMethodInvocationExpression
public static MethodInvocationExpression CreateMethodInvocationExpression(LexicalInfo li, Expression target, Expression arg)
{
MethodInvocationExpression mie = new MethodInvocationExpression(li);
mie.Target = (Expression)target.Clone();
mie.Arguments.Add((Expression)arg.Clone());
mie.IsSynthetic = true;
return mie;
}
示例11: FixCondition
private Expression FixCondition(Expression condition)
{
if (IsTryGetParameterInvocation(condition) == false)
return condition;
var isNull =
new MemberReferenceExpression(condition, "_IsIgnoreNullReferencingNotNullObject_");
return isNull;
}
示例12: IsSpecialMemberTarget
protected override bool IsSpecialMemberTarget(Expression container)
{
if (container.NodeType == NodeType.UnaryExpression)
{
UnaryExpression ue = container as UnaryExpression;
if (ue.Operator == UnaryOperatorType.Indirection)
return false; //indirected value type, no need to process it specially
}
return null != container.ExpressionType && container.ExpressionType.IsValueType;
}
示例13: when
public static Expression when(Expression expression)
{
BlockExpression right = new BlockExpression();
right.Body.Add(new ReturnStatement(expression));
return new BinaryExpression(
BinaryOperatorType.Assign,
new ReferenceExpression("condition"),
right
);
}
示例14: IsTryGetParameterInvocation
private static bool IsTryGetParameterInvocation(Expression condition)
{
var mie = condition as MethodInvocationExpression;
if (mie == null)
return false;
var expression = mie.Target as ReferenceExpression;
if (expression == null)
return false;
return expression.Name == "TryGetParameter";
}
示例15: when
public static Expression when(Expression expression, Expression action)
{
BlockExpression condition = new BlockExpression();
condition.Body.Add(new ReturnStatement(expression));
return new MethodInvocationExpression(
new ReferenceExpression("When"),
condition,
action
);
}