Ejemplo n.º 1
0
        public override void Visit(FunctionInvocationSyntax pNode)
        {
            var md = MetadataCache.FindBestOverload(pNode, out bool exact);

            for (int i = 0; i < md.Parameters.Length; i++)
            {
                if (pNode.Arguments[i].Type == SmallType.Undefined)
                {
                    Compiler.ReportError(CompilerErrorType.UndefinedType, pNode.Arguments[i]);
                }
                else
                {
                    if (!md.Parameters[i].Type.IsAssignableFrom(pNode.Arguments[i].Type))
                    {
                        Compiler.ReportError(CompilerErrorType.TypeMismatch, pNode.Arguments[i], md.Parameters[i].Type.ToString(), pNode.Arguments[i].Type.ToString());
                    }
                }
            }

            if (!exact) //All functions should be able to be bound exactly at this point
            {
                Compiler.ReportError(CompilerErrorType.NoMethodOverload, pNode, pNode.Value, pNode.Arguments.Count.ToString());
            }

            base.Visit(pNode);
        }
Ejemplo n.º 2
0
        public override void Visit(FunctionInvocationSyntax pNode)
        {
            var d = MetadataCache.FindBestOverload(pNode, out bool e);

            if (d != null)
            {
                pNode.SetType(d.GetReturnType());
            }
            base.Visit(pNode);
        }
Ejemplo n.º 3
0
        public override SyntaxNode Visit(FunctionInvocationSyntax pNode)
        {
            var o = GetValue <MemberAccessContext>("MemberContext", null);

            if (o != null)
            {
                pNode.Namespace = o.Namespace;
                o.Namespace     = "";
                if (o.Member != null)
                {
                    pNode.InstanceType = o.Member.Type.ToSystemType();
                }
            }


            if (!MetadataCache.MethodExists(pNode.Namespace, pNode.Value))
            {
                Compiler.ReportError(CompilerErrorType.MethodNotDefined, pNode, pNode.Value, pNode.Namespace);
            }
            else
            {
                var md = MetadataCache.FindBestOverload(pNode, out bool e);
                if (md.ExternMethod != null && md.ExternMethod.IsPrivate)
                {
                    Compiler.ReportError(CompilerErrorType.MethodNotExported, pNode, pNode.Value);
                }

                if (md.Parameters.Length != pNode.Arguments.Count)
                {
                    Compiler.ReportError(CompilerErrorType.NoMethodOverload, pNode, pNode.Value, pNode.Arguments.Count.ToString());
                }

                if (o != null && md.ReturnTypes.Length > 0)
                {
                    o.Member = LocalDefinition.Create(pNode, "__" + pNode.Value + "__", md.GetReturnType());
                }
            }

            List <ArgumentExpressionSyntax> arguments = new List <ArgumentExpressionSyntax>();

            foreach (var a in pNode.Arguments)
            {
                using (new ContextValue(this, "MemberContext", new MemberAccessContext()))
                {
                    arguments.Add(a.Accept <ArgumentExpressionSyntax>(this));
                }
            }
            return(SyntaxFactory.FunctionInvocation(pNode.Value, arguments).WithAttributes(pNode));
        }
Ejemplo n.º 4
0
        public override void Visit(FunctionInvocationSyntax pNode)
        {
            var def = MetadataCache.FindBestOverload(pNode, out bool e);

            for (int i = 0; i < pNode.Arguments.Count; i++)
            {
                pNode.Arguments[i].IsRef = def.Parameters[i].IsRef;
                if (pNode.Arguments[i].Value.GetType() == typeof(IdentifierSyntax))
                {
                    var id = (IdentifierSyntax)pNode.Arguments[i].Value;
                    if (id.Local.IsAddress && !pNode.Arguments[i].IsRef)
                    {
                        pNode.Arguments[i].CreateCopy = true;
                    }
                }
                pNode.Arguments[i].Accept(this);
            }
        }