Ejemplo n.º 1
0
 public virtual void Visit(FunctionInvocationSyntax pNode)
 {
     foreach (var a in pNode.Arguments)
     {
         a.Accept(this);
     }
 }
Ejemplo n.º 2
0
        public virtual SyntaxNode Visit(FunctionInvocationSyntax pNode)
        {
            List <ArgumentExpressionSyntax> arguments = new List <ArgumentExpressionSyntax>();

            foreach (var a in pNode.Arguments)
            {
                arguments.Add(a.Accept <ArgumentExpressionSyntax>(this));
            }
            return(SyntaxFactory.FunctionInvocation(pNode.Value, arguments).WithAttributes(pNode));
        }
Ejemplo n.º 3
0
        public static MethodDefinition FindBestOverload(Syntax.FunctionInvocationSyntax pFunc, out bool pExact)
        {
            List <MethodDefinition> methods = null;

            if (string.IsNullOrEmpty(pFunc.Namespace))
            {
                methods = new List <MethodDefinition>();
                if (_methods.ContainsKey(pFunc.Value))
                {
                    methods.AddRange(_methods[pFunc.Value]);
                }
                if (_importedMethods.ContainsKey("") && _importedMethods[""].ContainsKey(pFunc.Value))
                {
                    methods.AddRange(_importedMethods[""][pFunc.Value]);
                }
            }
            else
            {
                methods = _importedMethods[pFunc.Namespace][pFunc.Value];
            }

            SmallType[] parameters = new SmallType[pFunc.Arguments.Count];
            for (int i = 0; i < pFunc.Arguments.Count; i++)
            {
                parameters[i] = pFunc.Arguments[i].Type;
            }

            pExact = false;
            MethodDefinition method = null;

            foreach (var md in methods)
            {
                if (method == null)
                {
                    method = md;
                }

                if (md.Parameters.Length == parameters.Length)
                {
                    pExact = true;
                    method = md;
                    for (int i = 0; i < md.Parameters.Length; i++)
                    {
                        pExact = CompareParameter(parameters[i], md.Parameters[i].Type, pFunc.TypeParameters);
                        if (!pExact)
                        {
                            break;
                        }
                    }
                }
            }

            return(method);
        }
Ejemplo n.º 4
0
        public static MethodDefinition GetMethod(Syntax.FunctionInvocationSyntax pFunc)
        {
            List <MethodDefinition> methods = null;

            if (string.IsNullOrEmpty(pFunc.Namespace))
            {
                methods = new List <MethodDefinition>();
                if (_methods.ContainsKey(pFunc.Value))
                {
                    methods.AddRange(_methods[pFunc.Value]);
                }
                if (_importedMethods.ContainsKey("") && _importedMethods[""].ContainsKey(pFunc.Value))
                {
                    methods.AddRange(_importedMethods[""][pFunc.Value]);
                }
            }
            else
            {
                methods = _importedMethods[pFunc.Namespace][pFunc.Value];
            }

            SmallType[] parameters = new SmallType[pFunc.Arguments.Count];
            for (int i = 0; i < pFunc.Arguments.Count; i++)
            {
                parameters[i] = pFunc.Arguments[i].Type;
            }

            foreach (var md in methods)
            {
                if (md.Parameters.Length == parameters.Length)
                {
                    bool found = true;
                    for (int i = 0; i < md.Parameters.Length; i++)
                    {
                        found = CompareParameter(parameters[i], md.Parameters[i].Type, pFunc.TypeParameters);
                        if (!found)
                        {
                            break;
                        }
                    }

                    if (found)
                    {
                        return(md);
                    }
                }
            }

            throw new Exception("Unable to find matching function");
        }