示例#1
0
 protected virtual T VisitFunctionCall(FunctionCallNode node)
 {
     Visit(node.FunctionReferenceNode);
     Visit(node.ArgumentNodes);
     return(DefaultResult);
 }
示例#2
0
        protected override void VisitFunctionCall(FunctionCallNode node)
        {
            if (node.FunctionReferenceNode.Symbol != null)
            {
                FunctionDefinitionNode functionDefinitionNode;
                ASTNode declarationNode = node.FunctionReferenceNode.Symbol.Node;
                if (declarationNode is FunctionDefinitionNode)
                {
                    functionDefinitionNode = (FunctionDefinitionNode)node.FunctionReferenceNode.Symbol.Node;
                }
                else
                {
                    node.Annotations.Add(new SymbolIsNotAFunctionError(node.FunctionReferenceNode.Name, declarationNode.Location));
                    return;
                }

                Symbol symbol = functionDefinitionNode.Symbol;

                if (symbol != null)
                {
                    node.BuiltinType = symbol.BuiltinType;
                    if (symbol is NestableSymbol nestableSymbol)
                    {
                        node.ComplexType = nestableSymbol.ComplexType;
                    }
                }

                string identifier = functionDefinitionNode.NameNode.Value;

                List <ParameterDeclarationNode> parameterNodes = functionDefinitionNode.ParameterNodes;
                List <ExpressionNode>           argumentNodes  = node.ArgumentNodes;

                int parametersCount = parameterNodes.Count;
                int argumentsCount  = argumentNodes.Count;

                if (parametersCount != argumentsCount)
                {
                    node.Annotations.Add(new ArgumentsCountDoesNotMatchError(identifier, parametersCount, argumentsCount, functionDefinitionNode.NameNode.Location));
                }

                int iterationsCount = Math.Min(parametersCount, argumentsCount);
                for (int i = 0; i < iterationsCount; i++)
                {
                    ParameterDeclarationNode parameterNode = parameterNodes[i];
                    SymbolTypePair           parameterType = GetSymbolTypePairFromSymbol(parameterNode.Symbol);
                    ExpressionNode           argumentNode  = argumentNodes[i];

                    /*
                     * if (parameterType.BuiltinType == SymbolType.Float)
                     * {
                     *  _isInsideFloatExpression = true;
                     * }
                     */

                    _currentExpressionTypes.Push(parameterType);
                    Visit(argumentNode);
                    _currentExpressionTypes.Pop();


                    //_isInsideFloatExpression = false;

                    SymbolTypePair argumentType = GetSymbolTypePairFromExpressionNode(argumentNode);

                    //Console.Write("x");
                }
            }
        }
 protected virtual void VisitFunctionCall(FunctionCallNode node)
 {
     Visit(node.FunctionReferenceNode);
     Visit(node.ArgumentNodes);
 }