예제 #1
0
        public static void OnNode(FunctionDeclaration functionDeclaration)
        {
            var header = functionDeclaration?.CodeElement as FunctionDeclarationHeader;

            if (header == null)
            {
                return;                 //not my job
            }
            var filesection = functionDeclaration.Get <FileSection>("file");

            if (filesection != null) // TCRFUN_DECLARATION_NO_FILE_SECTION
            {
                DiagnosticUtils.AddError(filesection,
                                         "Illegal FILE SECTION in function \"" + header.Name + "\" declaration");
            }

            CheckNoGlobalOrExternal(functionDeclaration.Get <DataDivision>("data-division"));
            CheckNoLinkageItemIsAParameter(functionDeclaration.Get <LinkageSection>("linkage"), header.Profile);

            CheckParameters(header.Profile, functionDeclaration);
            CheckNoPerform(functionDeclaration.SymbolTable.EnclosingScope, functionDeclaration);

            var headerNameURI = new URI(header.Name);
            var functions     = functionDeclaration.SymbolTable.GetFunction(headerNameURI, functionDeclaration.Profile);

            if (functions.Count > 1)
            {
                DiagnosticUtils.AddError(functionDeclaration,
                                         "A function \"" + headerNameURI.Head + "\" with the same profile already exists in namespace \"" +
                                         headerNameURI.Tail + "\".");
            }
        }