xronos /Microsoft.Scripting/Actions/Calls/ParameterBinder.cs

Language C# Lines 82
MD5 Hash e761e8f03635b737ad5d99feca194f08 Estimated Cost $1,163 (why?)
Repository https://bitbucket.org/stefanrusek/xronos View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

#if CODEPLEX_40
using System;
#else
using System; using Microsoft;
#endif
using System.Collections.Generic;
#if CODEPLEX_40
using System.Dynamic;
using System.Linq.Expressions;
#else
using Microsoft.Scripting;
using Microsoft.Linq.Expressions;
#endif
using System.Reflection;
using Microsoft.Scripting.Utils;

namespace Microsoft.Scripting.Actions.Calls {
    /// <summary>
    /// Helper class for emitting calls via the MethodBinder.
    /// </summary>
    public class ParameterBinder {
        private readonly ActionBinder _actionBinder;
        private List<ParameterExpression> _temps;

        public ParameterBinder(ActionBinder actionBinder) {
            Assert.NotNull(actionBinder);

            _actionBinder = actionBinder;
        }

        public ActionBinder Binder {
            get { return _actionBinder; }
        }

        internal List<ParameterExpression> Temps {
            get { return _temps; }
        }

        internal ParameterExpression GetTemporary(Type type, string name) {
            Assert.NotNull(type);

            if (_temps == null) {
                _temps = new List<ParameterExpression>();
            }

            ParameterExpression res = Expression.Variable(type, name);
            _temps.Add(res);
            return res;
        }

        public virtual Expression ConvertExpression(Expression expr, ParameterInfo info, Type toType) {
            Assert.NotNull(expr, toType);

            return _actionBinder.ConvertExpression(expr, toType, ConversionResultKind.ExplicitCast, null);
        }

        public virtual Func<object[], object> ConvertObject(int index, DynamicMetaObject knownType, ParameterInfo info, Type toType) {
            throw new NotImplementedException();
        }

        public virtual Expression GetDynamicConversion(Expression value, Type type) {
            return Expression.Dynamic(OldConvertToAction.Make(_actionBinder, type), type, value);
        }
    }

}
Back to Top