public ConvertExpression ( Expression expr, |
||
expr | Expression | |
toType | ||
kind | ConversionResultKind | |
resolverFactory | Microsoft.Scripting.Actions.Calls.OverloadResolverFactory | |
리턴 | Expression |
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))); }
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))); }
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)); }
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)); }