2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PACKAGE_H_
18 #define incl_HPHP_PACKAGE_H_
25 #include "hphp/util/file-cache.h"
26 #include "hphp/util/mutex.h"
27 #include "hphp/hhbbc/hhbbc.h"
30 ///////////////////////////////////////////////////////////////////////////////
32 struct AnalysisResult
;
33 using AnalysisResultPtr
= std::shared_ptr
<AnalysisResult
>;
36 * A package contains a list of directories and files that will be parsed
37 * and analyzed together. No files outside of a package will be considered
38 * in type inferences. One single AnalysisResult will be generated and it
39 * contains all classes, functions, variables, constants and their types.
40 * Therefore, a package is really toppest entry point for parsing.
43 explicit Package(const char *root
, bool bShortTags
= true);
45 void addAllFiles(bool force
); // add from Option::PackageDirectories/Files
47 void addSourceFile(const std::string
& fileName
, bool check
= false,
49 void addInputList(const std::string
& listFileName
);
50 void addStaticFile(const std::string
& fileName
);
51 void addDirectory(const std::string
&path
, bool force
);
52 void addHHJSDirectory(const std::string
&path
, bool force
);
53 void addStaticDirectory(const std::string
& path
);
54 void addSourceDirectory(const std::string
& path
, bool force
, bool js
= false);
56 bool parse(bool check
);
57 bool parseImpl(const std::string
* fileName
);
59 AnalysisResultPtr
getAnalysisResult() { return m_ar
;}
60 void resetAr() { m_ar
.reset(); }
61 int getFileCount() const { return m_filesToParse
.size();}
62 int getLineCount() const { return m_lineCount
;}
63 int getCharCount() const { return m_charCount
;}
65 void saveStatsToFile(const char *filename
, int totalSeconds
) const;
67 const std::string
& getRoot() const { return m_root
;}
68 std::shared_ptr
<FileCache
> getFileCache();
70 void cache_only() { m_cache_only
= true; }
73 std::set
<std::string
> m_filesToParse
;
78 AnalysisResultPtr m_ar
;
82 std::shared_ptr
<FileCache
> m_fileCache
;
83 std::map
<std::string
,bool> m_directories
;
84 std::map
<std::string
,bool> m_hhjsDirectories
;
85 std::set
<std::string
> m_staticDirectories
;
86 std::set
<std::string
> m_extraStaticFiles
;
87 std::map
<std::string
,std::string
> m_discoveredStaticFiles
;
88 HHBBC::UnitEmitterQueue m_ueq
;
89 std::atomic
<bool> m_stop_caching
{};
90 hphp_fast_set
<std::string
> m_locally_cached_bytecode
;
94 ///////////////////////////////////////////////////////////////////////////////
96 #endif // incl_HPHP_PACKAGE_H_