本文整理汇总了C#中Microsoft.Scripting.Actions.ActionBinder.ConvertExpression方法的典型用法代码示例。如果您正苦于以下问题:C# ActionBinder.ConvertExpression方法的具体用法?C# ActionBinder.ConvertExpression怎么用?C# ActionBinder.ConvertExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Actions.ActionBinder
的用法示例。
在下文中一共展示了ActionBinder.ConvertExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeReturn
public Expression MakeReturn(ActionBinder binder, Expression expr) {
// we create a temporary here so that ConvertExpression doesn't need to (because it has no way to declare locals).
if (expr.Type != typeof(void)) {
ParameterExpression variable = GetTemporary(expr.Type, "$retVal");
Expression conv = binder.ConvertExpression(variable, ReturnType, ConversionResultKind.ExplicitCast, Context);
if (conv == variable) return MakeReturn(expr);
return MakeReturn(Ast.Block(Ast.Assign(variable, expr), conv));
}
return MakeReturn(binder.ConvertExpression(expr, ReturnType, ConversionResultKind.ExplicitCast, Context));
}
示例2: MakeReturn
public Statement MakeReturn(ActionBinder binder, Expression expr) {
// we create a temporary here so that ConvertExpression doesn't need to (because it has no way to declare locals).
if (expr.Type != typeof(void)) {
Variable variable = GetTemporary(expr.Type, "$retVal");
Expression read = Ast.ReadDefined(variable);
Expression conv = binder.ConvertExpression(read, ReturnType);
if (conv == read) return Ast.Return(expr);
return Ast.Return(Ast.Comma(Ast.Assign(variable, expr), conv));
}
return Ast.Return(binder.ConvertExpression(expr, ReturnType));
}