本文整理汇总了C#中IExpr.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# IExpr.Equals方法的具体用法?C# IExpr.Equals怎么用?C# IExpr.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpr
的用法示例。
在下文中一共展示了IExpr.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Substitute
/// <summary>
/// Yield an expression that is 'inexpr' with 'var' replaced by 'subst'.
/// </summary>
/// <param name="subst">The expression to substitute.</param>
/// <param name="var">The variable to substitute for.</param>
/// <param name="inexpr">The expression to substitute into.</param>
public static IExpr/*!*/ Substitute(IExpr/*!*/ subst, IVariable/*!*/ var, IExpr/*!*/ inexpr){
Contract.Requires(inexpr != null);
Contract.Requires(var != null);
Contract.Requires(subst != null);
Contract.Ensures(Contract.Result<IExpr>() != null);
IExpr result = null;
if (inexpr is IVariable)
{
result = inexpr.Equals(var) ? subst : inexpr;
}
else if (inexpr is IFunApp)
{
IFunApp/*!*/ funapp = (IFunApp/*!*/)cce.NonNull(inexpr);
IList newargs = null;
var x = new System.Collections.Generic.List<IExpr>();
foreach (IExpr arg in funapp.Arguments){
x.Add(Substitute(subst,var, arg));
}
newargs = new ArrayList(x);
//newargs = new ArrayList{ IExpr/*!*/ arg in funapp.Arguments; Substitute(subst, var, arg) };
result = funapp.CloneWithArguments(newargs);
}
else if (inexpr is IFunction)
{
IFunction/*!*/ fun = (IFunction/*!*/)cce.NonNull(inexpr);
if (fun.Param.Equals(var))
result = fun;
else
result = fun.CloneWithBody(Substitute(subst, var, fun.Body));
}
else if (inexpr is IUnknown)
{
result = inexpr;
}
else
{
{Contract.Assert(false);throw new cce.UnreachableException();}
}
return result;
}