internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { object val = _defaultValue; if (val is Missing) { val = CompilerHelpers.GetMissingValue(_argumentType); } #if FULL if (_argumentType.IsByRef) { Variable tmp = context.GetTemporary(_argumentType.GetElementType(), "optRef"); return(Ast.Comma( Ast.Assign( tmp, Ast.Convert(Ast.Constant(val), tmp.Type) ), Ast.Read(tmp) )); } #endif return(context.ConvertExpression(Ast.Constant(val), _argumentType)); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_tmp == null) { _tmp = context.GetTemporary(Type, "outParam"); } #endif return Ast.Comma(Ast.Assign(_tmp, base.ToExpression(context, parameters)), Ast.Read(_tmp)); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_tmp == null) { _tmp = context.GetTemporary(Type, "outParam"); } #endif return(Ast.Comma(Ast.Assign(_tmp, base.ToExpression(context, parameters)), Ast.Read(_tmp))); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_isRef) { if (_tmp == null) { _tmp = context.GetTemporary(_parameterType, "outParam"); } return Ast.Read(_tmp); } #endif return GetDefaultValue(); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_isRef) { if (_tmp == null) { _tmp = context.GetTemporary(_parameterType, "outParam"); } return(Ast.Read(_tmp)); } #endif return(GetDefaultValue()); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_tmp == null) { _tmp = context.GetTemporary(_elementType, "outParam"); } #endif // Ideally we'd pass in Ast.ReadField(parameters[Index], "Value") but due to // a bug in partial trust we can't access the generic field. // arg is boxType ? &_tmp : throw new ArgumentTypeException() // IncorrectBoxType throws the exception to avoid stack imbalance issues. return(Ast.Condition( Ast.TypeIs(parameters[Index], BoxType), Ast.Comma( Ast.Assign( _tmp, Ast.Call( typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(_elementType), Ast.ConvertHelper(parameters[Index], typeof(StrongBox <>).MakeGenericType(_elementType)) ) ), Ast.Read(_tmp) ), // Condition requires types of both expressions to be identical. // Putting the cast here is a temporary workaround until the // emit address and reference argument passing is finished. Ast.Convert( Ast.Call( typeof(BinderOps).GetMethod("IncorrectBoxType"), Ast.Constant(BoxType), Ast.ConvertHelper(parameters[Index], typeof(object)) ), _elementType ) )); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { #if FULL if (_tmp == null) { _tmp = context.GetTemporary(_elementType, "outParam"); } #endif // Ideally we'd pass in Ast.ReadField(parameters[Index], "Value") but due to // a bug in partial trust we can't access the generic field. // arg is boxType ? &_tmp : throw new ArgumentTypeException() // IncorrectBoxType throws the exception to avoid stack imbalance issues. return Ast.Condition( Ast.TypeIs(parameters[Index], BoxType), Ast.Comma( Ast.Assign( _tmp, Ast.Call( typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(_elementType), Ast.ConvertHelper(parameters[Index], typeof(StrongBox<>).MakeGenericType(_elementType)) ) ), Ast.Read(_tmp) ), // Condition requires types of both expressions to be identical. // Putting the cast here is a temporary workaround until the // emit address and reference argument passing is finished. Ast.Convert( Ast.Call( typeof(BinderOps).GetMethod("IncorrectBoxType"), Ast.Constant(BoxType), Ast.ConvertHelper(parameters[Index], typeof(object)) ), _elementType ) ); }
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) { object val = _defaultValue; if(val is Missing) { val = CompilerHelpers.GetMissingValue(_argumentType); } #if FULL if (_argumentType.IsByRef) { Variable tmp = context.GetTemporary(_argumentType.GetElementType(), "optRef"); return Ast.Comma( Ast.Assign( tmp, Ast.Convert(Ast.Constant(val), tmp.Type) ), Ast.Read(tmp) ); } #endif return context.ConvertExpression(Ast.Constant(val), _argumentType); }