Beispiel #1
0
        /// <summary>
        /// Visit FuncBindAssignment
        /// </summary>
        /// <param name="funcBindAssignment">FuncBindAssignment to visit</param>
        public void VisitFuncBindAssignment(Node funcBindAssignment)
        {
            //Convert FuncBind in a FunctionDef node
            NodeGraphBuilder graphBuilder = new NodeGraphBuilder();

            //Create functionDef node
            Node functionDef = (Node)graphBuilder.DefineNode("FunctionDef");

            //Add identifier of function
            functionDef.Add(funcBindAssignment.ViewAllNodes().ElementAt(0));

            //Add formals
            functionDef.Add(funcBindAssignment.ViewAllNodes().ElementAt(1));

            //Create StatementList to store the single statement in
            Node statementList = (Node)graphBuilder.DefineNode("StatementList");

            statementList.Add(funcBindAssignment.ViewAllNodes().ElementAt(2));
            functionDef.Add(statementList);

            //Visit this functionDefinition
            VisitFunctionDef(functionDef);

            //Add function to SymbolTable
            Node identifier = funcBindAssignment.ViewAllNodes().ElementAt(0);

            SymbolTable.AddFunctionDefinition(identifier.AtomicValue.ToString(), functionDef);
        }
Beispiel #2
0
        /// <summary>
        /// Visit module and check declarations in module and dependency's
        /// </summary>
        /// <param name="module">Module to visit</param>
        public override void Visit(Module module)
        {
            //Get dependency for module
            List <Module> dependencyList = ModuleCache.Instance.RequestDependencies(module);

            //Store all functiondefinitions
            foreach (Module dependency in dependencyList)
            {
                foreach (FunctionDefinition functionDef in dependency.GetFunctionDefinitions())
                {
                    //Check if function is not already defined
                    if (SymbolTable.ContainsFunction(functionDef.GetIdentifier()))
                    {
                        ExceptionList.Add(new FunctionAlreadyDefined(functionDef.GetIdentifier()));
                    }
                    else
                    {
                        SymbolTable.AddFunctionDefinition(functionDef);
                    }
                }
            }

            //Check all definitions
            foreach (Module dependency in dependencyList)
            {
                //Check FunctionDefinitions
                foreach (FunctionDefinition function in dependency.GetFunctionDefinitions())
                {
                    function.AcceptVisitor(this);
                }

                //Check markups in sites
                foreach (Site site in dependency.GetSites())
                {
                    foreach (Mapping mapping in site.GetMappings())
                    {
                        mapping.AcceptVisitor(this);
                    }
                }
            }
        }