예제 #1
0
        public StaDynSourceFileAST completeDecorateAndUpdate(string fileName, bool clearTypeTable)
        {
            StaDynSourceFileAST file = ProjectFileAST.Instance.getAstFile(fileName);

            try {
                this.completeDecorateAST(file);
            } catch (Exception e) {
                ErrorManager.Instance.NotifyError(new ParserError(new Location(fileName, 0, 0), e.Message));
            }

            //replace AST
            ProjectFileAST.Instance.addOrReplaceAst(file);

            return(file);

            //try
            //{
            //    this.VisitorSSA(fileName);
            //    this.VisitorTypeLoad(fileName, clearTypeTable);
            //    this.VisitorTypeDefinition(fileName);
            //    this.VisitorSymbolIdentification(fileName);
            //    this.VisitorTypeInference(fileName);
            //}
            //catch (Exception e)
            //{
            //    ErrorManager.Instance.NotifyError(new ParserError(new Location(fileName, 0, 0), e.Message));
            //}

            //return ProjectFileAST.Instance.getAstFile(fileName);
        }
예제 #2
0
        /// <summary>
        /// Add the new StaDynSourceFile if the fileName doesnt exist or replace the existing AST is already exits
        /// </summary>
        /// <param name="newAst">new StaDynSourceFileAst</param>
        public void addOrReplaceAst(StaDynSourceFileAST newAst)
        {
            int index = this.getIndexOfFile(newAst.FileName);

            if (index < 0)
            {
                this.addSourceFile(newAst);
            }
            else
            {
                this.FilesAST[index].Ast = newAst.Ast;
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a new StaDynSourceFileAST to the list
        /// </summary>
        /// <param name="newAST"></param>
        /// <returns>False if the AST exits already</returns>
        public bool addSourceFile(StaDynSourceFileAST newAST)
        {
            //fasle if already exists

            if (this.getIndexOfFile(newAST.FileName) != -1)
            {
                return(false);
            }

            this.FilesAST.Add(newAST);

            return(true);
        }
예제 #4
0
        public void VisitorTypeDefinition(string fileName)
        {
            StaDynSourceFileAST file = ProjectFileAST.Instance.getAstFile(fileName);

            if (file.Ast == null)
            {
                return;
            }

            file.Ast.Accept(new VisitorTypeDefinition(), null);

            //replace AST
            ProjectFileAST.Instance.addOrReplaceAst(file);
        }
예제 #5
0
        public StaDynSourceFileAST completeDecorateAndUpdate(StaDynSourceFileAST file)
        {
            //StaDynSourceFileAST file = ProjectFileAST.Instance.getAstFile(fileName);

            try {
                file = this.completeDecorateAST(file);
            } catch (Exception e) {
                ErrorManager.Instance.NotifyError(new ParserError(new Location(file.FileName, 0, 0), e.Message));
            }

            //replace AST
            ProjectFileAST.Instance.addOrReplaceAst(file);

            return(file);
        }
예제 #6
0
        public void VisitorTypeLoad(string fileName, bool clearTypeTable)
        {
            StaDynSourceFileAST file = ProjectFileAST.Instance.getAstFile(fileName);

            if (file.Ast == null)
            {
                return;
            }

            if (clearTypeTable)
            {
                TypeTable.Instance.Clear();
            }

            file.Ast.Accept(new VisitorTypeLoad(), null);

            //replace AST
            ProjectFileAST.Instance.addOrReplaceAst(file);
        }
예제 #7
0
        public StaDynSourceFileAST completeDecorateAST(StaDynSourceFileAST file)
        {
            try {
                if (file.Ast == null)
                {
                    return(file);
                }

                //TypeTable.Instance.Clear();

                file.Ast.Accept(new VisitorSSA(), null);

                file.Ast.Accept(new VisitorTypeLoad(), null);

                file.Ast.Accept(new VisitorTypeDefinition(), null);

                string directory = Path.GetDirectoryName(file.FileName);

                //req.FileName.Remove(req.FileName.Length - ast.Location.FileName.Length);

                IDictionary <string, string> name = new Dictionary <string, string>();

                name.Add(file.Ast.Location.FileName, directory);

                VisitorSymbolIdentification vsi = new VisitorSymbolIdentification(name);

                file.Ast.Accept(vsi, null);

                file.Ast.Accept(new VisitorTypeInference(), null);
            } catch (Exception e) {
                ErrorManager.Instance.NotifyError(new ParserError(new Location(file.FileName, 0, 0), e.Message));
            }

            //Update refernces
            //ProjectFileAST.Instance.addOrReplaceAst(file);

            return(file);
        }
예제 #8
0
        public void VisitorSymbolIdentification(string fileName)
        {
            StaDynSourceFileAST file = ProjectFileAST.Instance.getAstFile(fileName);

            if (file.Ast == null)
            {
                return;
            }

            string directory = Path.GetDirectoryName(fileName);

            //req.FileName.Remove(req.FileName.Length - ast.Location.FileName.Length);

            IDictionary <string, string> name = new Dictionary <string, string>();

            name.Add(file.Ast.Location.FileName, directory);

            VisitorSymbolIdentification vsi = new VisitorSymbolIdentification(name);

            file.Ast.Accept(vsi, null);

            //replace AST
            ProjectFileAST.Instance.addOrReplaceAst(file);
        }