1 Star 0 Fork 153

klooer/sig_arkcompiler_ets_frontend

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
options.h 3.69 KB
一键复制 编辑 原始数据 按行查看 历史
ivagin 提交于 2023-03-09 15:17 +08:00 . [ets] Supported arktsconfig.json as es2panda input
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ES2PANDA_AOT_OPTIONS_H
#define ES2PANDA_AOT_OPTIONS_H
#include "libpandabase/os/file.h"
#include "plugins/ecmascript/es2panda/es2panda.h"
#include <exception>
#include <fstream>
#include <iostream>
namespace panda {
class PandArgParser;
class PandaArg;
} // namespace panda
namespace panda::es2panda::aot {
enum class OptionFlags : uint32_t {
DEFAULT = 0U,
PARSE_ONLY = 1U << 0U,
PARSE_MODULE = 1U << 1U,
SIZE_STAT = 1U << 2U,
};
inline std::underlying_type_t<OptionFlags> operator&(OptionFlags a, OptionFlags b)
{
using Utype = std::underlying_type_t<OptionFlags>;
/* NOLINTNEXTLINE(hicpp-signed-bitwise) */
return static_cast<Utype>(static_cast<Utype>(a) & static_cast<Utype>(b));
}
inline OptionFlags &operator|=(OptionFlags &a, OptionFlags b)
{
using Utype = std::underlying_type_t<OptionFlags>;
/* NOLINTNEXTLINE(hicpp-signed-bitwise) */
return a = static_cast<OptionFlags>(static_cast<Utype>(a) | static_cast<Utype>(b));
}
template <class T>
T BaseName(T const &path)
{
return path.substr(path.find_last_of(panda::os::file::File::GetPathDelim()) + 1);
}
class Options {
public:
Options();
NO_COPY_SEMANTIC(Options);
NO_MOVE_SEMANTIC(Options);
~Options();
bool Parse(int argc, const char **argv);
es2panda::ScriptExtension Extension() const
{
return extension_;
}
const es2panda::CompilerOptions &CompilerOptions() const
{
return compiler_options_;
}
const std::string &ParserInput() const
{
return parser_input_;
}
const std::string &CompilerOutput() const
{
return compiler_output_;
}
void SetCompilerOutput(const std::string &compiler_output)
{
compiler_output_ = compiler_output;
}
const std::string &LogLevel() const
{
return log_level_;
}
const std::string &SourceFile() const
{
return source_file_;
}
const std::string &ErrorMsg() const
{
return error_msg_;
}
int OptLevel() const
{
return opt_level_;
}
int ThreadCount() const
{
return thread_count_;
}
bool ParseModule() const
{
return (options_ & OptionFlags::PARSE_MODULE) != 0;
}
bool ParseOnly() const
{
return (options_ & OptionFlags::PARSE_ONLY) != 0;
}
bool SizeStat() const
{
return (options_ & OptionFlags::SIZE_STAT) != 0;
}
bool IsDynamic() const
{
return extension_ != es2panda::ScriptExtension::ETS;
}
bool ListFiles() const
{
return list_files_;
}
private:
es2panda::ScriptExtension extension_ {es2panda::ScriptExtension::JS};
es2panda::CompilerOptions compiler_options_ {};
OptionFlags options_ {OptionFlags::DEFAULT};
panda::PandArgParser *argparser_;
std::string parser_input_;
std::string compiler_output_;
std::string log_level_;
std::string result_;
std::string source_file_;
std::string error_msg_;
int opt_level_ {0};
int thread_count_ {0};
bool list_files_ {false};
};
} // namespace panda::es2panda::aot
#endif // AOT_OPTIONS_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/klooer/sig_arkcompiler_ets_frontend.git
git@gitee.com:klooer/sig_arkcompiler_ets_frontend.git
klooer
sig_arkcompiler_ets_frontend
sig_arkcompiler_ets_frontend
master

搜索帮助