Split try-fault into two instructions, like try-catch
[hiphop-php.git] / hphp / compiler / option.h
blobd4a35db9cb2fd2a5a2a31362502112b5f591f424
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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_OPTION_H_
18 #define incl_HPHP_OPTION_H_
20 #include <map>
21 #include <set>
22 #include <vector>
23 #include "hphp/runtime/base/runtime-option.h"
24 #include "hphp/util/functional.h"
25 #include "hphp/util/string-bag.h"
27 namespace HPHP {
28 ///////////////////////////////////////////////////////////////////////////////
30 struct Hdf;
32 struct IniSettingMap;
34 struct Option {
35 /**
36 * Load options from different sources.
38 static void Load(const IniSettingMap& ini, Hdf &config);
39 static void Load(); // load default options
41 /**
42 * Directories to add to a package.
44 static std::string RootDirectory;
45 static std::set<std::string> PackageDirectories;
47 /**
48 * Files to add to a package.
50 static std::set<std::string> PackageFiles;
52 /**
53 * File path patterns for excluding files from a package scan of programs.
55 static std::set<std::string> PackageExcludeDirs;
56 static std::set<std::string> PackageExcludeFiles;
57 static std::set<std::string> PackageExcludePatterns;
58 static std::set<std::string> PackageExcludeStaticFiles;
59 static std::set<std::string> PackageExcludeStaticDirs;
60 static std::set<std::string> PackageExcludeStaticPatterns;
62 static bool IsFileExcluded(const std::string &file,
63 const std::set<std::string> &patterns);
64 static void FilterFiles(std::vector<std::string> &files,
65 const std::set<std::string> &patterns);
67 /**
68 * Directories in which files are parsed on-demand, when parse-on-demand
69 * is off.
71 static std::vector<std::string> ParseOnDemandDirs;
73 /**
74 * Whether to store PHP source files in static file cache.
76 static bool CachePHPFile;
78 /**
79 * Legal root directory expressions in an include expression. For example,
81 * include_once $PHP_ROOT . '/lib.php';
83 * Here, "$PHP_ROOT" is a legal include root. Stores what it resolves to.
85 * Option::IncludeRoots["$PHP_ROOT"] = "";
86 * Option::IncludeRoots["$LIB_ROOT"] = "lib";
88 static std::map<std::string, std::string> IncludeRoots;
89 static std::map<std::string, std::string> AutoloadRoots;
90 static std::vector<std::string> IncludeSearchPaths;
92 /**
93 * PHP include root expression to use when generating PHP trimmed code.
95 static std::string DefaultIncludeRoot;
97 /**
98 * PHP functions that can be assumed to always return a certain constant
99 * value.
101 static hphp_string_imap<std::string> ConstantFunctions;
104 * Optimization flags
106 static bool PreOptimization;
109 * Flags that only affect HHBBC right now. See hhbbc/hhbbc.h for
110 * description.
112 static bool HardConstProp;
115 * CodeGenerator options for PHP.
117 static bool GeneratePickledPHP;
118 static bool GenerateInlinedPHP;
119 static bool GenerateTrimmedPHP;
120 static bool ConvertSuperGlobals; // $GLOBALS['var'] => global $var
121 static std::string ProgramPrologue;
122 static std::string TrimmedPrologue;
123 static std::set<std::string> VolatileClasses;
124 static std::map<std::string,std::string, stdltistr> AutoloadClassMap;
125 static std::map<std::string,std::string, stdltistr> AutoloadFuncMap;
126 static std::map<std::string,std::string> AutoloadConstMap;
127 static std::string AutoloadRoot;
130 * CodeGenerator options for HHBC.
132 static bool GenerateTextHHBC;
133 static bool GenerateBinaryHHBC;
134 static std::string RepoCentralPath;
135 static bool RepoDebugInfo;
137 static std::vector<std::string> APCProfile;
140 * Names of hot and cold functions to be marked in sources.
142 static std::map<std::string, std::string> FunctionSections;
145 * A somewhat unique prefix for system identifiers.
147 static std::string IdPrefix;
148 static std::string LambdaPrefix;
149 static std::string Tab;
152 * Name resolution helpers.
154 static const char *UserFilePrefix;
157 * Turn it off for cleaner unit tests.
159 static bool KeepStatementsWithNoEffect;
162 * Whether or not name matches AUTOLOAD files. If not, returns empty. If
163 * yes, returns root directory for the file.
165 static std::string GetAutoloadRoot(const std::string &name);
168 * Turning a file name into an identifier. When id is false, preserve
169 * "/" in file paths.
171 static std::string MangleFilename(const std::string &name, bool id);
173 static std::string ProgramName;
175 static bool ParseTimeOpts;
176 static bool EnableHipHopExperimentalSyntax;
177 static bool EnableShortTags;
178 static bool EnableAspTags;
179 static int ParserThreadCount;
181 static int GetScannerType();
184 * "Volatile" means a class or a function can be declared dynamically.
186 static bool AllVolatile;
189 * Output options
191 static bool GenerateDocComments;
192 static bool DumpAst;
193 static bool WholeProgram;
194 static bool UseHHBBC; // see hhbbc/README
195 static bool RecordErrors;
197 private:
198 static StringBag OptionStrings;
200 static void LoadRootHdf(const IniSettingMap& ini, const Hdf &roots,
201 const std::string& name,
202 std::map<std::string, std::string> &map);
205 //////////////////////////////////////////////////////////////////////
208 * Hook called after Option is set up to propagate various options to
209 * HHBBC's option structure.
211 * This exists this way because we don't want to have libhhbbc depend
212 * on all of libhphp_analysis---the dependency goes the other way.
214 void initialize_hhbbc_options();
216 ///////////////////////////////////////////////////////////////////////////////
218 #endif // incl_HPHP_OPTION_H_