GetFunctionCallBinder() static private method

static private GetFunctionCallBinder ( string name, int argsCount, bool isStatic = true ) : System.Runtime.CompilerServices.CallSiteBinder
name string
argsCount int
isStatic bool
return System.Runtime.CompilerServices.CallSiteBinder
Ejemplo n.º 1
0
        private static CallSiteBinder GetFunctionCallBinder(IList <ParseNode> nodes, int argCount, bool isStatic)
        {
            var funcText = nodes[0].Token.Text;

            Debug.Assert(funcText.Length >= 2 && funcText.EndsWith("("));
            var funcName = funcText.Substring(0, funcText.Length - 1);

            if (isStatic)
            {
                funcName = funcName.ToUpperInvariant();
            }
            return(DLRUtil.GetFunctionCallBinder(funcName, argCount, isStatic));
        }
Ejemplo n.º 2
0
 private static Expression GetPowerAST(IList <ParseNode> nodes, int start, Expression context)
 {
     //Have to rewrite power expressions to Math.Pow function calls because C# runtime does not support the ^ operator like VB
     //a^b^c is rewritten as Math.Pow(Math.Pow(a, b), c) and calculated as (a^b)^c
     Debug.Assert(nodes.Count >= 3 && nodes.Count % 2 == 1);
     return(start == 0
                ? nodes[start].GetAST(context)
                : Expression.Dynamic(DLRUtil.GetFunctionCallBinder("Pow", 2),
                                     typeof(object),
                                     Expression.Constant(typeof(Math)),
                                     GetPowerAST(nodes, start - 2, context),
                                     nodes[start].GetAST(context)));
 }