#ifndef COMPILER_H
#define COMPILER_H
#include "ue2common.h"
#include "database.h"
#include "compiler/expression_info.h"
#include "parser/Component.h"
#include "util/noncopyable.h"
#include "util/ue2string.h"
#include <memory>
struct hs_database;
struct hs_expr_ext;
namespace ue2 {
struct CompileContext;
struct Grey;
struct target_t;
class NG;
class NGHolder;
class ReportManager;
class ParsedExpression : noncopyable {
public:
ParsedExpression(unsigned index, const char *expression, unsigned flags,
ReportID report, const hs_expr_ext *ext = nullptr);
ExpressionInfo expr;
std::unique_ptr<Component> component;
};
class ParsedLitExpression : noncopyable {
public:
ParsedLitExpression(unsigned index, const char *expression,
size_t expLength, unsigned flags, ReportID report);
void parseLiteral(const char *expression, size_t len, bool nocase);
ExpressionInfo expr;
ue2_literal lit;
};
struct BuiltExpression {
ExpressionInfo expr;
std::unique_ptr<NGHolder> g;
};
void addExpression(NG &ng, unsigned index, const char *expression,
unsigned flags, const hs_expr_ext *ext, ReportID report);
void addLitExpression(NG &ng, unsigned index, const char *expression,
unsigned flags, const hs_expr_ext *ext, ReportID id,
size_t expLength);
struct hs_database *build(NG &ng, unsigned int *length, u8 pureFlag);
BuiltExpression buildGraph(ReportManager &rm, const CompileContext &cc,
const ParsedExpression &expr);
platform_t target_to_platform(const target_t &target_info);
#if defined(DUMP_SUPPORT) || defined(DEBUG)
void dumpExpression(const ParsedExpression &expr, const char *stage,
const Grey &grey);
#else
static really_inline
void dumpExpression(UNUSED const ParsedExpression &expr,
UNUSED const char *stage, UNUSED const Grey &grey) {
}
#endif
}
#endif