Ejemplo n.º 1
0
            /// <summary>
            /// Execute
            /// </summary>
            /// <param name="setting">Translation Unit Parse Setting</param>
            /// <returns>Translation Unit Map</returns>
            public TranslationUnitMap Execute(TranslationUnitParseSetting setting)
            {
                this.Setting = setting;

                var display_diag = setting.DisplayDiag;

                var src_path_list = setting.Sources;

                var command_line_args = setting.CommandLineArgs.ToArray();

                var options = setting.ParseOptions;

                using (var index = Clang.CreateIndex(false, display_diag))
                {
                    foreach (var src_path in src_path_list)
                    {
                        if (File.Exists(src_path))
                        {
                            using (var tu = index.ParseTranslationUnit(src_path, command_line_args, new ClangUnsavedFile[0], options))
                            {
                                this.ExecuteCore(index, tu);
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException($"Source File Not Found :{src_path}");
                        }
                    }
                }

                return(this.TranslationUnitMap);
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Parse Translation Units
        /// </summary>
        /// <param name="setting">Translation Unit Parse Setting</param>
        /// <returns>Translation Unit Map</returns>
        public static TranslationUnitMap Parse(TranslationUnitParseSetting setting)
        {
            var impl = new TranslationUnitsParserImpl();

            var map = impl.Execute(setting);

            return(map);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Execute Behavior Relations Analysis Process
        /// </summary>
        public static void Execute()
        {
            var setting = new TranslationUnitParseSetting()
            {
                Sources = new List <string>()
                {
                    "./Code2/src/main.cpp",
                    "./Code2/src/TestClass.cpp",
                },
                CommandLineArgs = new List <string>()
                {
                    "-I./Code2/inc",
                },
                ParseOptions = TranslationUnitFlags.None,
                DisplayDiag  = true,
                DumpAST      = true,
            };

            var map = TranslationUnitsParser.Parse(setting);

            InvokationTreeDumper.Dump(map);

            CrossReferencesDumper.Dump(map);
        }