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 +----------------------------------------------------------------------+
24 #include <folly/Optional.h>
26 #include "hphp/util/file-cache.h"
27 #include "hphp/util/mutex.h"
28 #include "hphp/hhbbc/hhbbc.h"
31 ///////////////////////////////////////////////////////////////////////////////
33 struct AnalysisResult
;
34 using AnalysisResultPtr
= std::shared_ptr
<AnalysisResult
>;
37 * A package contains a list of directories and files that will be parsed
38 * and analyzed together. No files outside of a package will be considered
39 * in type inferences. One single AnalysisResult will be generated and it
40 * contains all classes, functions, variables, constants and their types.
41 * Therefore, a package is really toppest entry point for parsing.
44 explicit Package(const char *root
, bool bShortTags
= true);
46 void addAllFiles(bool force
); // add from Option::PackageDirectories/Files
48 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 addStaticDirectory(const std::string
& path
);
53 void addSourceDirectory(const std::string
& path
, bool force
);
55 bool parse(bool check
, std::thread
& unit_emitter_thread
);
56 bool parseImpl(const std::string
* fileName
);
58 AnalysisResultPtr
getAnalysisResult() { return m_ar
;}
59 void resetAr() { m_ar
.reset(); }
60 int getFileCount() const { return m_filesToParse
.size();}
61 int getLineCount() const { return m_lineCount
;}
62 int getCharCount() const { return m_charCount
;}
64 void saveStatsToFile(const char *filename
, int totalSeconds
) const;
66 const std::string
& getRoot() const { return m_root
;}
67 std::shared_ptr
<FileCache
> getFileCache();
69 void addUnitEmitter(std::unique_ptr
<UnitEmitter
> ue
);
72 std::unique_ptr
<UnitEmitter
> createSymlinkWrapper(
73 const std::string
& full_path
, const std::string
& file_name
,
74 std::unique_ptr
<UnitEmitter
> org_ue
);
77 std::set
<std::string
> m_filesToParse
;
82 AnalysisResultPtr m_ar
;
86 std::shared_ptr
<FileCache
> m_fileCache
;
87 std::map
<std::string
,bool> m_directories
;
88 std::set
<std::string
> m_staticDirectories
;
89 std::set
<std::string
> m_extraStaticFiles
;
90 std::map
<std::string
,std::string
> m_discoveredStaticFiles
;
91 folly::Optional
<HHBBC::UnitEmitterQueue
> m_ueq
;
92 hphp_fast_set
<std::string
> m_locally_cached_bytecode
;
95 ///////////////////////////////////////////////////////////////////////////////