mirror of https://github.com/Icinga/icinga2.git
Merge pull request #5868 from Icinga/feature/expression-ptr
Use std::unique_ptr for Expression objects
This commit is contained in:
commit
5b44bfb125
|
@ -176,20 +176,16 @@ static int Main(void)
|
|||
String initconfig = Application::GetSysconfDir() + "/icinga2/init.conf";
|
||||
|
||||
if (Utility::PathExists(initconfig)) {
|
||||
Expression *expression;
|
||||
std::unique_ptr<Expression> expression;
|
||||
try {
|
||||
expression = ConfigCompiler::CompileFile(initconfig);
|
||||
|
||||
ScriptFrame frame;
|
||||
expression->Evaluate(frame);
|
||||
} catch (const std::exception& ex) {
|
||||
delete expression;
|
||||
|
||||
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
delete expression;
|
||||
}
|
||||
|
||||
if (!autocomplete)
|
||||
|
|
|
@ -68,7 +68,7 @@ extern "C" void dbg_inspect_object(Object *obj)
|
|||
|
||||
extern "C" void dbg_eval(const char *text)
|
||||
{
|
||||
Expression *expr = nullptr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
|
||||
try {
|
||||
ScriptFrame frame;
|
||||
|
@ -78,13 +78,11 @@ extern "C" void dbg_eval(const char *text)
|
|||
} catch (const std::exception& ex) {
|
||||
std::cout << "Error: " << DiagnosticInformation(ex) << "\n";
|
||||
}
|
||||
|
||||
delete expr;
|
||||
}
|
||||
|
||||
extern "C" void dbg_eval_with_value(const Value& value, const char *text)
|
||||
{
|
||||
Expression *expr = nullptr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
|
||||
try {
|
||||
ScriptFrame frame;
|
||||
|
@ -96,13 +94,11 @@ extern "C" void dbg_eval_with_value(const Value& value, const char *text)
|
|||
} catch (const std::exception& ex) {
|
||||
std::cout << "Error: " << DiagnosticInformation(ex) << "\n";
|
||||
}
|
||||
|
||||
delete expr;
|
||||
}
|
||||
|
||||
extern "C" void dbg_eval_with_object(Object *object, const char *text)
|
||||
{
|
||||
Expression *expr = nullptr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
|
||||
try {
|
||||
ScriptFrame frame;
|
||||
|
@ -114,8 +110,6 @@ extern "C" void dbg_eval_with_object(Object *object, const char *text)
|
|||
} catch (const std::exception& ex) {
|
||||
std::cout << "Error: " << DiagnosticInformation(ex) << "\n";
|
||||
}
|
||||
|
||||
delete expr;
|
||||
}
|
||||
|
||||
void ConsoleCommand::BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di)
|
||||
|
@ -400,7 +394,7 @@ incomplete:
|
|||
|
||||
command += line;
|
||||
|
||||
Expression *expr = nullptr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
|
||||
try {
|
||||
lines[fileName] = command;
|
||||
|
@ -412,7 +406,7 @@ incomplete:
|
|||
|
||||
/* This relies on the fact that - for syntax errors - CompileText()
|
||||
* returns an AST where the top-level expression is a 'throw'. */
|
||||
if (!syntaxOnly || dynamic_cast<ThrowExpression *>(expr)) {
|
||||
if (!syntaxOnly || dynamic_cast<ThrowExpression *>(expr.get())) {
|
||||
if (syntaxOnly)
|
||||
std::cerr << " => " << command << std::endl;
|
||||
result = Serialize(expr->Evaluate(scriptFrame), 0);
|
||||
|
@ -502,8 +496,6 @@ incomplete:
|
|||
if (!commandOnce.IsEmpty())
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
delete expr;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -51,9 +51,9 @@ static void IncludeZoneDirRecursive(const String& path, const String& package, b
|
|||
/* register this zone path for cluster config sync */
|
||||
ConfigCompiler::RegisterZoneDir("_etc", path, zoneName);
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
std::vector<std::unique_ptr<Expression> > expressions;
|
||||
Utility::GlobRecursive(path, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zoneName, package), GlobFile);
|
||||
DictExpression expr(expressions);
|
||||
DictExpression expr(std::move(expressions));
|
||||
if (!ExecuteExpression(&expr))
|
||||
success = false;
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ static void IncludeNonLocalZone(const String& zonePath, const String& package, b
|
|||
return;
|
||||
}
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
std::vector<std::unique_ptr<Expression> > expressions;
|
||||
Utility::GlobRecursive(zonePath, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zoneName, package), GlobFile);
|
||||
DictExpression expr(expressions);
|
||||
DictExpression expr(std::move(expressions));
|
||||
if (!ExecuteExpression(&expr))
|
||||
success = false;
|
||||
}
|
||||
|
@ -88,13 +88,11 @@ static void IncludePackage(const String& packagePath, bool& success)
|
|||
String packageName = Utility::BaseName(packagePath);
|
||||
|
||||
if (Utility::PathExists(packagePath + "/include.conf")) {
|
||||
Expression *expr = ConfigCompiler::CompileFile(packagePath + "/include.conf",
|
||||
std::unique_ptr<Expression> expr = ConfigCompiler::CompileFile(packagePath + "/include.conf",
|
||||
String(), packageName);
|
||||
|
||||
if (!ExecuteExpression(expr))
|
||||
if (!ExecuteExpression(&*expr))
|
||||
success = false;
|
||||
|
||||
delete expr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,9 +105,8 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
|
|||
if (!configs.empty()) {
|
||||
for (const String& configPath : configs) {
|
||||
try {
|
||||
Expression *expression = ConfigCompiler::CompileFile(configPath, String(), "_etc");
|
||||
success = ExecuteExpression(expression);
|
||||
delete expression;
|
||||
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(configPath, String(), "_etc");
|
||||
success = ExecuteExpression(&*expression);
|
||||
if (!success)
|
||||
return false;
|
||||
} catch (const std::exception& ex) {
|
||||
|
|
|
@ -68,7 +68,7 @@ using namespace icinga;
|
|||
template<typename T>
|
||||
static void MakeRBinaryOp(Expression** result, Expression *left, Expression *right, const DebugInfo& diLeft, const DebugInfo& diRight)
|
||||
{
|
||||
*result = new T(left, right, DebugInfoRange(diLeft, diRight));
|
||||
*result = new T(std::unique_ptr<Expression>(left), std::unique_ptr<Expression>(right), DebugInfoRange(diLeft, diRight));
|
||||
}
|
||||
|
||||
%}
|
||||
|
@ -80,7 +80,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
|||
%error-verbose
|
||||
%glr-parser
|
||||
|
||||
%parse-param { std::vector<std::pair<Expression *, EItemInfo> > *llist }
|
||||
%parse-param { std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> > *llist }
|
||||
%parse-param { ConfigCompiler *context }
|
||||
%lex-param { void *scanner }
|
||||
|
||||
|
@ -92,12 +92,12 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
|||
icinga::DictExpression *dexpr;
|
||||
CombinedSetOp csop;
|
||||
std::vector<String> *slist;
|
||||
std::vector<std::pair<Expression *, EItemInfo> > *llist;
|
||||
std::vector<Expression *> *elist;
|
||||
std::vector<std::pair<Expression *, Expression *> > *ebranchlist;
|
||||
std::pair<Expression *, Expression *> *ebranch;
|
||||
std::pair<String, Expression *> *cvitem;
|
||||
std::map<String, Expression *> *cvlist;
|
||||
std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> > *llist;
|
||||
std::vector<std::unique_ptr<Expression> > *elist;
|
||||
std::vector<std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> > > *ebranchlist;
|
||||
std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> > *ebranch;
|
||||
std::pair<String, std::unique_ptr<Expression> > *cvitem;
|
||||
std::map<String, std::unique_ptr<Expression> > *cvlist;
|
||||
icinga::ScopeSpecifier scope;
|
||||
}
|
||||
|
||||
|
@ -238,13 +238,13 @@ int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
|
|||
|
||||
extern int yydebug;
|
||||
|
||||
void yyerror(const YYLTYPE *locp, std::vector<std::pair<Expression *, EItemInfo> > *, ConfigCompiler *context, const char *err)
|
||||
void yyerror(const YYLTYPE *locp, std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> > *, ConfigCompiler *context, const char *err)
|
||||
{
|
||||
bool incomplete = context && context->m_Eof && (context->m_OpenBraces > 0);
|
||||
BOOST_THROW_EXCEPTION(ScriptError(err, *locp, incomplete));
|
||||
}
|
||||
|
||||
int yyparse(std::vector<std::pair<Expression *, EItemInfo> > *llist, ConfigCompiler *context);
|
||||
int yyparse(std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> > *llist, ConfigCompiler *context);
|
||||
|
||||
static void BeginFlowControlBlock(ConfigCompiler *compiler, int allowedTypes, bool inherit)
|
||||
{
|
||||
|
@ -267,9 +267,9 @@ static void UseFlowControl(ConfigCompiler *compiler, FlowControlType type, const
|
|||
BOOST_THROW_EXCEPTION(ScriptError("Invalid flow control statement.", location));
|
||||
}
|
||||
|
||||
Expression *ConfigCompiler::Compile(void)
|
||||
std::unique_ptr<Expression> ConfigCompiler::Compile(void)
|
||||
{
|
||||
std::vector<std::pair<Expression *, EItemInfo> > llist;
|
||||
std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> > llist;
|
||||
|
||||
//yydebug = 1;
|
||||
|
||||
|
@ -282,19 +282,19 @@ Expression *ConfigCompiler::Compile(void)
|
|||
EndFlowControlBlock(this);
|
||||
m_IgnoreNewlines.pop();
|
||||
|
||||
std::vector<Expression *> dlist;
|
||||
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
|
||||
for (const auto& litem : llist) {
|
||||
std::vector<std::unique_ptr<Expression> > dlist;
|
||||
decltype(llist.size()) num = 0;
|
||||
for (auto& litem : llist) {
|
||||
if (!litem.second.SideEffect && num != llist.size() - 1) {
|
||||
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
|
||||
}
|
||||
dlist.push_back(litem.first);
|
||||
dlist.push_back(std::move(litem.first));
|
||||
num++;
|
||||
}
|
||||
|
||||
DictExpression *expr = new DictExpression(dlist);
|
||||
std::unique_ptr<DictExpression> expr{new DictExpression(std::move(dlist))};
|
||||
expr->MakeInline();
|
||||
return expr;
|
||||
return std::move(expr);
|
||||
}
|
||||
|
||||
#define scanner (context->GetScanner())
|
||||
|
@ -318,7 +318,7 @@ statements: newlines lterm_items
|
|||
|
||||
lterm_items: /* empty */
|
||||
{
|
||||
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
|
||||
}
|
||||
| lterm_items_inner
|
||||
| lterm_items_inner sep
|
||||
|
@ -326,26 +326,26 @@ lterm_items: /* empty */
|
|||
|
||||
lterm_items_inner: lterm %dprec 2
|
||||
{
|
||||
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
|
||||
EItemInfo info = { true, @1 };
|
||||
$$->emplace_back($1, info);
|
||||
$$->emplace_back(std::unique_ptr<Expression>($1), info);
|
||||
}
|
||||
| rterm_no_side_effect
|
||||
{
|
||||
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
|
||||
EItemInfo info = { false, @1 };
|
||||
$$->emplace_back($1, info);
|
||||
$$->emplace_back(std::unique_ptr<Expression>($1), info);
|
||||
}
|
||||
| lterm_items_inner sep lterm %dprec 1
|
||||
{
|
||||
if ($1)
|
||||
$$ = $1;
|
||||
else
|
||||
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
|
||||
|
||||
if ($3) {
|
||||
EItemInfo info = { true, @3 };
|
||||
$$->emplace_back($3, info);
|
||||
$$->emplace_back(std::unique_ptr<Expression>($3), info);
|
||||
}
|
||||
}
|
||||
| lterm_items_inner sep rterm_no_side_effect %dprec 1
|
||||
|
@ -353,11 +353,11 @@ lterm_items_inner: lterm %dprec 2
|
|||
if ($1)
|
||||
$$ = $1;
|
||||
else
|
||||
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, EItemInfo> >();
|
||||
|
||||
if ($3) {
|
||||
EItemInfo info = { false, @3 };
|
||||
$$->emplace_back($3, info);
|
||||
$$->emplace_back(std::unique_ptr<Expression>($3), info);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
@ -396,26 +396,28 @@ object:
|
|||
bool seen_ignore = context->m_SeenIgnore.top();
|
||||
context->m_SeenIgnore.pop();
|
||||
|
||||
Expression *ignore = context->m_Ignore.top();
|
||||
std::unique_ptr<Expression> ignore{std::move(context->m_Ignore.top())};
|
||||
context->m_Ignore.pop();
|
||||
|
||||
Expression *assign = context->m_Assign.top();
|
||||
std::unique_ptr<Expression> assign{std::move(context->m_Assign.top())};
|
||||
context->m_Assign.pop();
|
||||
|
||||
Expression *filter = NULL;
|
||||
std::unique_ptr<Expression> filter;
|
||||
|
||||
if (seen_assign) {
|
||||
if (ignore) {
|
||||
Expression *rex = new LogicalNegateExpression(ignore, DebugInfoRange(@2, @5));
|
||||
std::unique_ptr<Expression> rex{new LogicalNegateExpression(std::move(ignore), DebugInfoRange(@2, @5))};
|
||||
|
||||
filter = new LogicalAndExpression(assign, rex, DebugInfoRange(@2, @5));
|
||||
filter.reset(new LogicalAndExpression(std::move(assign), std::move(rex), DebugInfoRange(@2, @5)));
|
||||
} else
|
||||
filter = assign;
|
||||
filter.swap(assign);
|
||||
} else if (seen_ignore) {
|
||||
BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore where' cannot be used without 'assign where'", DebugInfoRange(@2, @4)));
|
||||
}
|
||||
|
||||
$$ = new ObjectExpression(abstract, $3, $4, filter, context->GetZone(), context->GetPackage(), $5, $6, $7, $9, DebugInfoRange(@2, @7));
|
||||
$$ = new ObjectExpression(abstract, std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($4),
|
||||
std::move(filter), context->GetZone(), context->GetPackage(), std::move(*$5), $6, $7, std::unique_ptr<Expression>($9), DebugInfoRange(@2, @7));
|
||||
delete $5;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -468,15 +470,15 @@ combined_set_op: T_SET
|
|||
|
||||
lterm: T_LIBRARY rterm
|
||||
{
|
||||
$$ = new LibraryExpression($2, @$);
|
||||
$$ = new LibraryExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| rterm combined_set_op rterm
|
||||
{
|
||||
$$ = new SetExpression($1, $2, $3, @$);
|
||||
$$ = new SetExpression(std::unique_ptr<Expression>($1), $2, std::unique_ptr<Expression>($3), @$);
|
||||
}
|
||||
| T_INCLUDE rterm
|
||||
{
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), $2, NULL, NULL, IncludeRegular, false, context->GetZone(), context->GetPackage(), @$);
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), std::unique_ptr<Expression>($2), NULL, NULL, IncludeRegular, false, context->GetZone(), context->GetPackage(), @$);
|
||||
}
|
||||
| T_INCLUDE T_STRING_ANGLE
|
||||
{
|
||||
|
@ -485,23 +487,23 @@ lterm: T_LIBRARY rterm
|
|||
}
|
||||
| T_INCLUDE_RECURSIVE rterm
|
||||
{
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), $2, MakeLiteral("*.conf"), NULL, IncludeRecursive, false, context->GetZone(), context->GetPackage(), @$);
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), std::unique_ptr<Expression>($2), MakeLiteral("*.conf"), NULL, IncludeRecursive, false, context->GetZone(), context->GetPackage(), @$);
|
||||
}
|
||||
| T_INCLUDE_RECURSIVE rterm ',' rterm
|
||||
{
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), $2, $4, NULL, IncludeRecursive, false, context->GetZone(), context->GetPackage(), @$);
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), std::unique_ptr<Expression>($2), std::unique_ptr<Expression>($4), NULL, IncludeRecursive, false, context->GetZone(), context->GetPackage(), @$);
|
||||
}
|
||||
| T_INCLUDE_ZONES rterm ',' rterm
|
||||
{
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), $4, MakeLiteral("*.conf"), $2, IncludeZones, false, context->GetZone(), context->GetPackage(), @$);
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), std::unique_ptr<Expression>($4), MakeLiteral("*.conf"), std::unique_ptr<Expression>($2), IncludeZones, false, context->GetZone(), context->GetPackage(), @$);
|
||||
}
|
||||
| T_INCLUDE_ZONES rterm ',' rterm ',' rterm
|
||||
{
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), $4, $6, $2, IncludeZones, false, context->GetZone(), context->GetPackage(), @$);
|
||||
$$ = new IncludeExpression(Utility::DirName(context->GetPath()), std::unique_ptr<Expression>($4), std::unique_ptr<Expression>($6), std::unique_ptr<Expression>($2), IncludeZones, false, context->GetZone(), context->GetPackage(), @$);
|
||||
}
|
||||
| T_IMPORT rterm
|
||||
{
|
||||
$$ = new ImportExpression($2, @$);
|
||||
$$ = new ImportExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| T_ASSIGN T_WHERE
|
||||
{
|
||||
|
@ -517,11 +519,11 @@ lterm: T_LIBRARY rterm
|
|||
context->m_SeenAssign.top() = true;
|
||||
|
||||
if (context->m_Assign.top())
|
||||
context->m_Assign.top() = new LogicalOrExpression(context->m_Assign.top(), $4, @$);
|
||||
context->m_Assign.top() = new LogicalOrExpression(std::unique_ptr<Expression>(context->m_Assign.top()), std::unique_ptr<Expression>($4), @$);
|
||||
else
|
||||
context->m_Assign.top() = $4;
|
||||
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| T_ASSIGN T_WHERE rterm %dprec 1
|
||||
{
|
||||
|
@ -533,11 +535,11 @@ lterm: T_LIBRARY rterm
|
|||
context->m_SeenAssign.top() = true;
|
||||
|
||||
if (context->m_Assign.top())
|
||||
context->m_Assign.top() = new LogicalOrExpression(context->m_Assign.top(), $3, @$);
|
||||
context->m_Assign.top() = new LogicalOrExpression(std::unique_ptr<Expression>(context->m_Assign.top()), std::unique_ptr<Expression>($3), @$);
|
||||
else
|
||||
context->m_Assign.top() = $3;
|
||||
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| T_IGNORE T_WHERE
|
||||
{
|
||||
|
@ -553,11 +555,11 @@ lterm: T_LIBRARY rterm
|
|||
context->m_SeenIgnore.top() = true;
|
||||
|
||||
if (context->m_Ignore.top())
|
||||
context->m_Ignore.top() = new LogicalOrExpression(context->m_Ignore.top(), $4, @$);
|
||||
context->m_Ignore.top() = new LogicalOrExpression(std::unique_ptr<Expression>(context->m_Ignore.top()), std::unique_ptr<Expression>($4), @$);
|
||||
else
|
||||
context->m_Ignore.top() = $4;
|
||||
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| T_IGNORE T_WHERE rterm %dprec 1
|
||||
{
|
||||
|
@ -569,16 +571,16 @@ lterm: T_LIBRARY rterm
|
|||
context->m_SeenIgnore.top() = true;
|
||||
|
||||
if (context->m_Ignore.top())
|
||||
context->m_Ignore.top() = new LogicalOrExpression(context->m_Ignore.top(), $3, @$);
|
||||
context->m_Ignore.top() = new LogicalOrExpression(std::unique_ptr<Expression>(context->m_Ignore.top()), std::unique_ptr<Expression>($3), @$);
|
||||
else
|
||||
context->m_Ignore.top() = $3;
|
||||
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| T_RETURN optional_rterm
|
||||
{
|
||||
UseFlowControl(context, FlowControlReturn, @$);
|
||||
$$ = new ReturnExpression($2, @$);
|
||||
$$ = new ReturnExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| T_BREAK
|
||||
{
|
||||
|
@ -596,7 +598,7 @@ lterm: T_LIBRARY rterm
|
|||
}
|
||||
| T_USING rterm
|
||||
{
|
||||
$$ = new UsingExpression($2, @$);
|
||||
$$ = new UsingExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| apply
|
||||
| object
|
||||
|
@ -608,7 +610,7 @@ lterm: T_LIBRARY rterm
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
$$ = new ForExpression(*$3, *$5, $7, $10, @$);
|
||||
$$ = new ForExpression(*$3, *$5, std::unique_ptr<Expression>($7), std::unique_ptr<Expression>($10), @$);
|
||||
delete $3;
|
||||
delete $5;
|
||||
}
|
||||
|
@ -620,7 +622,7 @@ lterm: T_LIBRARY rterm
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
$$ = new ForExpression(*$3, "", $5, $8, @$);
|
||||
$$ = new ForExpression(*$3, "", std::unique_ptr<Expression>($5), std::unique_ptr<Expression>($8), @$);
|
||||
delete $3;
|
||||
}
|
||||
| T_FUNCTION identifier '(' identifier_items ')' use_specifier
|
||||
|
@ -631,28 +633,29 @@ lterm: T_LIBRARY rterm
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
FunctionExpression *fexpr = new FunctionExpression(*$2, *$4, $6, $8, @$);
|
||||
std::unique_ptr<FunctionExpression> fexpr{new FunctionExpression(*$2, *$4, std::move(*$6), std::unique_ptr<Expression>($8), @$)};
|
||||
delete $4;
|
||||
delete $6;
|
||||
|
||||
$$ = new SetExpression(MakeIndexer(ScopeThis, *$2), OpSetLiteral, fexpr, @$);
|
||||
$$ = new SetExpression(MakeIndexer(ScopeThis, *$2), OpSetLiteral, std::move(fexpr), @$);
|
||||
delete $2;
|
||||
}
|
||||
| T_CONST T_IDENTIFIER T_SET rterm
|
||||
{
|
||||
$$ = new SetExpression(MakeIndexer(ScopeGlobal, *$2), OpSetLiteral, $4);
|
||||
$$ = new SetExpression(MakeIndexer(ScopeGlobal, *$2), OpSetLiteral, std::unique_ptr<Expression>($4));
|
||||
delete $2;
|
||||
}
|
||||
| T_VAR rterm
|
||||
{
|
||||
Expression *expr = $2;
|
||||
std::unique_ptr<Expression> expr{$2};
|
||||
BindToScope(expr, ScopeLocal);
|
||||
$$ = new SetExpression(expr, OpSetLiteral, MakeLiteral(), @$);
|
||||
$$ = new SetExpression(std::move(expr), OpSetLiteral, MakeLiteral(), @$);
|
||||
}
|
||||
| T_VAR rterm combined_set_op rterm
|
||||
{
|
||||
Expression *expr = $2;
|
||||
std::unique_ptr<Expression> expr{$2};
|
||||
BindToScope(expr, ScopeLocal);
|
||||
$$ = new SetExpression(expr, $3, $4, @$);
|
||||
$$ = new SetExpression(std::move(expr), $3, std::unique_ptr<Expression>($4), @$);
|
||||
}
|
||||
| T_WHILE '(' rterm ')'
|
||||
{
|
||||
|
@ -662,22 +665,22 @@ lterm: T_LIBRARY rterm
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
$$ = new WhileExpression($3, $6, @$);
|
||||
$$ = new WhileExpression(std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($6), @$);
|
||||
}
|
||||
| T_THROW rterm
|
||||
{
|
||||
$$ = new ThrowExpression($2, false, @$);
|
||||
$$ = new ThrowExpression(std::unique_ptr<Expression>($2), false, @$);
|
||||
}
|
||||
| T_TRY rterm_scope T_EXCEPT rterm_scope
|
||||
{
|
||||
$$ = new TryExceptExpression($2, $4, @$);
|
||||
$$ = new TryExceptExpression(std::unique_ptr<Expression>($2), std::unique_ptr<Expression>($4), @$);
|
||||
}
|
||||
| rterm_side_effect
|
||||
;
|
||||
|
||||
rterm_items: /* empty */
|
||||
{
|
||||
$$ = new std::vector<Expression *>();
|
||||
$$ = new std::vector<std::unique_ptr<Expression> >();
|
||||
}
|
||||
| rterm_items_inner
|
||||
| rterm_items_inner ','
|
||||
|
@ -687,13 +690,13 @@ rterm_items: /* empty */
|
|||
|
||||
rterm_items_inner: rterm
|
||||
{
|
||||
$$ = new std::vector<Expression *>();
|
||||
$$->push_back($1);
|
||||
$$ = new std::vector<std::unique_ptr<Expression> >();
|
||||
$$->emplace_back($1);
|
||||
}
|
||||
| rterm_items_inner arraysep rterm
|
||||
{
|
||||
$$ = $1;
|
||||
$$->push_back($3);
|
||||
$$->emplace_back($3);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -704,7 +707,7 @@ rterm_array: '['
|
|||
newlines rterm_items ']'
|
||||
{
|
||||
context->m_OpenBraces--;
|
||||
$$ = new ArrayExpression(*$4, @$);
|
||||
$$ = new ArrayExpression(std::move(*$4), @$);
|
||||
delete $4;
|
||||
}
|
||||
| '['
|
||||
|
@ -714,7 +717,7 @@ rterm_array: '['
|
|||
rterm_items ']'
|
||||
{
|
||||
context->m_OpenBraces--;
|
||||
$$ = new ArrayExpression(*$3, @$);
|
||||
$$ = new ArrayExpression(std::move(*$3), @$);
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
@ -730,17 +733,14 @@ rterm_dict: '{'
|
|||
EndFlowControlBlock(context);
|
||||
context->m_OpenBraces--;
|
||||
context->m_IgnoreNewlines.pop();
|
||||
std::vector<Expression *> dlist;
|
||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||
int num = 0;
|
||||
for (const EListItem& litem : *$3) {
|
||||
std::vector<std::unique_ptr<Expression> > dlist;
|
||||
for (auto& litem : *$3) {
|
||||
if (!litem.second.SideEffect)
|
||||
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
|
||||
dlist.push_back(litem.first);
|
||||
num++;
|
||||
dlist.push_back(std::move(litem.first));
|
||||
}
|
||||
delete $3;
|
||||
$$ = new DictExpression(dlist, @$);
|
||||
$$ = new DictExpression(std::move(dlist), @$);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -753,17 +753,14 @@ rterm_scope_require_side_effect: '{'
|
|||
{
|
||||
context->m_OpenBraces--;
|
||||
context->m_IgnoreNewlines.pop();
|
||||
std::vector<Expression *> dlist;
|
||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||
int num = 0;
|
||||
for (const EListItem& litem : *$3) {
|
||||
std::vector<std::unique_ptr<Expression> > dlist;
|
||||
for (auto& litem : *$3) {
|
||||
if (!litem.second.SideEffect)
|
||||
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
|
||||
dlist.push_back(litem.first);
|
||||
num++;
|
||||
dlist.push_back(std::move(litem.first));
|
||||
}
|
||||
delete $3;
|
||||
$$ = new DictExpression(dlist, @$);
|
||||
$$ = new DictExpression(std::move(dlist), @$);
|
||||
$$->MakeInline();
|
||||
}
|
||||
;
|
||||
|
@ -777,101 +774,102 @@ rterm_scope: '{'
|
|||
{
|
||||
context->m_OpenBraces--;
|
||||
context->m_IgnoreNewlines.pop();
|
||||
std::vector<Expression *> dlist;
|
||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
|
||||
for (const EListItem& litem : *$3) {
|
||||
std::vector<std::unique_ptr<Expression> > dlist;
|
||||
decltype($3->size()) num = 0;
|
||||
for (auto& litem : *$3) {
|
||||
if (!litem.second.SideEffect && num != $3->size() - 1)
|
||||
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
|
||||
dlist.push_back(litem.first);
|
||||
dlist.push_back(std::move(litem.first));
|
||||
num++;
|
||||
}
|
||||
delete $3;
|
||||
$$ = new DictExpression(dlist, @$);
|
||||
$$ = new DictExpression(std::move(dlist), @$);
|
||||
$$->MakeInline();
|
||||
}
|
||||
;
|
||||
|
||||
else_if_branch: T_ELSE T_IF '(' rterm ')' rterm_scope
|
||||
{
|
||||
$$ = new std::pair<Expression *, Expression *>($4, $6);
|
||||
$$ = new std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> >(std::unique_ptr<Expression>($4), std::unique_ptr<Expression>($6));
|
||||
}
|
||||
;
|
||||
|
||||
else_if_branches: /* empty */
|
||||
{
|
||||
$$ = new std::vector<std::pair<Expression *, Expression *> >();
|
||||
$$ = new std::vector<std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> > >();
|
||||
}
|
||||
| else_if_branches else_if_branch
|
||||
{
|
||||
$$ = $1;
|
||||
$$->push_back(*$2);
|
||||
$$->push_back(std::move(*$2));
|
||||
delete $2;
|
||||
}
|
||||
;
|
||||
|
||||
rterm_side_effect: rterm '(' rterm_items ')'
|
||||
{
|
||||
$$ = new FunctionCallExpression($1, *$3, @$);
|
||||
$$ = new FunctionCallExpression(std::unique_ptr<Expression>($1), std::move(*$3), @$);
|
||||
delete $3;
|
||||
}
|
||||
| T_IF '(' rterm ')' rterm_scope else_if_branches
|
||||
{
|
||||
std::vector<std::pair<Expression *, Expression *> > ebranches = *$6;
|
||||
std::vector<std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> > > ebranches;
|
||||
$6->swap(ebranches);
|
||||
delete $6;
|
||||
|
||||
Expression *afalse = NULL;
|
||||
std::unique_ptr<Expression> afalse;
|
||||
|
||||
for (int i = ebranches.size() - 1; i >= 0; i--) {
|
||||
const std::pair<Expression *, Expression *>& ebranch = ebranches[i];
|
||||
afalse = new ConditionalExpression(ebranch.first, ebranch.second, afalse, @6);
|
||||
auto& ebranch = ebranches[i];
|
||||
afalse.reset(new ConditionalExpression(std::move(ebranch.first), std::move(ebranch.second), std::move(afalse), @6));
|
||||
}
|
||||
|
||||
$$ = new ConditionalExpression($3, $5, afalse, @$);
|
||||
$$ = new ConditionalExpression(std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($5), std::move(afalse), @$);
|
||||
}
|
||||
| T_IF '(' rterm ')' rterm_scope else_if_branches T_ELSE rterm_scope
|
||||
{
|
||||
std::vector<std::pair<Expression *, Expression *> > ebranches = *$6;
|
||||
std::vector<std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression> > > ebranches;
|
||||
$6->swap(ebranches);
|
||||
delete $6;
|
||||
|
||||
$8->MakeInline();
|
||||
|
||||
Expression *afalse = $8;
|
||||
std::unique_ptr<Expression> afalse{$8};
|
||||
|
||||
for (int i = ebranches.size() - 1; i >= 0; i--) {
|
||||
const std::pair<Expression *, Expression *>& ebranch = ebranches[i];
|
||||
afalse = new ConditionalExpression(ebranch.first, ebranch.second, afalse, @6);
|
||||
auto& ebranch = ebranches[i];
|
||||
afalse.reset(new ConditionalExpression(std::move(ebranch.first), std::move(ebranch.second), std::move(afalse), @6));
|
||||
}
|
||||
|
||||
$$ = new ConditionalExpression($3, $5, afalse, @$);
|
||||
$$ = new ConditionalExpression(std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($5), std::move(afalse), @$);
|
||||
}
|
||||
;
|
||||
|
||||
rterm_no_side_effect_no_dict: T_STRING
|
||||
{
|
||||
$$ = MakeLiteral(*$1);
|
||||
$$ = MakeLiteralRaw(*$1);
|
||||
delete $1;
|
||||
}
|
||||
| T_NUMBER
|
||||
{
|
||||
$$ = MakeLiteral($1);
|
||||
$$ = MakeLiteralRaw($1);
|
||||
}
|
||||
| T_BOOLEAN
|
||||
{
|
||||
$$ = MakeLiteral($1);
|
||||
$$ = MakeLiteralRaw($1);
|
||||
}
|
||||
| T_NULL
|
||||
{
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| rterm '.' T_IDENTIFIER %dprec 2
|
||||
{
|
||||
$$ = new IndexerExpression($1, MakeLiteral(*$3), @$);
|
||||
$$ = new IndexerExpression(std::unique_ptr<Expression>($1), MakeLiteral(*$3), @$);
|
||||
delete $3;
|
||||
}
|
||||
| rterm '[' rterm ']'
|
||||
{
|
||||
$$ = new IndexerExpression($1, $3, @$);
|
||||
$$ = new IndexerExpression(std::unique_ptr<Expression>($1), std::unique_ptr<Expression>($3), @$);
|
||||
}
|
||||
| T_IDENTIFIER
|
||||
{
|
||||
|
@ -880,11 +878,11 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
}
|
||||
| '!' rterm
|
||||
{
|
||||
$$ = new LogicalNegateExpression($2, @$);
|
||||
$$ = new LogicalNegateExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| '~' rterm
|
||||
{
|
||||
$$ = new NegateExpression($2, @$);
|
||||
$$ = new NegateExpression(std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| T_PLUS rterm %prec UNARY_PLUS
|
||||
{
|
||||
|
@ -892,7 +890,7 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
}
|
||||
| T_MINUS rterm %prec UNARY_MINUS
|
||||
{
|
||||
$$ = new SubtractExpression(MakeLiteral(0), $2, @$);
|
||||
$$ = new SubtractExpression(MakeLiteral(0), std::unique_ptr<Expression>($2), @$);
|
||||
}
|
||||
| T_THIS
|
||||
{
|
||||
|
@ -908,11 +906,11 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
}
|
||||
| T_CURRENT_FILENAME
|
||||
{
|
||||
$$ = MakeLiteral(@$.Path);
|
||||
$$ = MakeLiteralRaw(@$.Path);
|
||||
}
|
||||
| T_CURRENT_LINE
|
||||
{
|
||||
$$ = MakeLiteral(@$.FirstLine);
|
||||
$$ = MakeLiteralRaw(@$.FirstLine);
|
||||
}
|
||||
| identifier T_FOLLOWS
|
||||
{
|
||||
|
@ -926,7 +924,7 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
args.push_back(*$1);
|
||||
delete $1;
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", args, new std::map<String, Expression *>(), $4, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", args, {}, std::unique_ptr<Expression>($4), @$);
|
||||
}
|
||||
| identifier T_FOLLOWS rterm %dprec 1
|
||||
{
|
||||
|
@ -936,7 +934,7 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
args.push_back(*$1);
|
||||
delete $1;
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", args, new std::map<String, Expression *>(), $3, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", args, {}, std::unique_ptr<Expression>($3), @$);
|
||||
}
|
||||
| '(' identifier_items ')' T_FOLLOWS
|
||||
{
|
||||
|
@ -946,14 +944,14 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", *$2, new std::map<String, Expression *>(), $6, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", *$2, {}, std::unique_ptr<Expression>($6), @$);
|
||||
delete $2;
|
||||
}
|
||||
| '(' identifier_items ')' T_FOLLOWS rterm %dprec 1
|
||||
{
|
||||
ASSERT(!dynamic_cast<DictExpression *>($5));
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", *$2, new std::map<String, Expression *>(), $5, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", *$2, {}, std::unique_ptr<Expression>($5), @$);
|
||||
delete $2;
|
||||
}
|
||||
| rterm_array
|
||||
|
@ -994,8 +992,9 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", *$3, $5, $7, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", *$3, std::move(*$5), std::unique_ptr<Expression>($7), @$);
|
||||
delete $3;
|
||||
delete $5;
|
||||
}
|
||||
| T_NULLARY_LAMBDA_BEGIN
|
||||
{
|
||||
|
@ -1005,20 +1004,19 @@ rterm_no_side_effect_no_dict: T_STRING
|
|||
{
|
||||
EndFlowControlBlock(context);
|
||||
|
||||
std::vector<Expression *> dlist;
|
||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||
std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
|
||||
for (const EListItem& litem : *$3) {
|
||||
std::vector<std::unique_ptr<Expression> > dlist;
|
||||
decltype(dlist.size()) num = 0;
|
||||
for (auto& litem : *$3) {
|
||||
if (!litem.second.SideEffect && num != $3->size() - 1)
|
||||
yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
|
||||
dlist.push_back(litem.first);
|
||||
dlist.push_back(std::move(litem.first));
|
||||
num++;
|
||||
}
|
||||
delete $3;
|
||||
DictExpression *aexpr = new DictExpression(dlist, @$);
|
||||
std::unique_ptr<DictExpression> aexpr{new DictExpression(std::move(dlist), @$)};
|
||||
aexpr->MakeInline();
|
||||
|
||||
$$ = new FunctionExpression("<anonymous>", std::vector<String>(), NULL, aexpr, @$);
|
||||
$$ = new FunctionExpression("<anonymous>", {}, {}, std::move(aexpr), @$);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1026,9 +1024,9 @@ rterm_no_side_effect:
|
|||
rterm_no_side_effect_no_dict %dprec 1
|
||||
| rterm_dict %dprec 2
|
||||
{
|
||||
Expression *expr = $1;
|
||||
std::unique_ptr<Expression> expr{$1};
|
||||
BindToScope(expr, ScopeThis);
|
||||
$$ = expr;
|
||||
$$ = expr.release();
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1069,7 +1067,7 @@ ignore_specifier: /* empty */
|
|||
|
||||
use_specifier: /* empty */
|
||||
{
|
||||
$$ = NULL;
|
||||
$$ = new std::map<String, std::unique_ptr<Expression> >();
|
||||
}
|
||||
| T_USE '(' use_specifier_items ')'
|
||||
{
|
||||
|
@ -1079,26 +1077,26 @@ use_specifier: /* empty */
|
|||
|
||||
use_specifier_items: use_specifier_item
|
||||
{
|
||||
$$ = new std::map<String, Expression *>();
|
||||
$$->insert(*$1);
|
||||
$$ = new std::map<String, std::unique_ptr<Expression> >();
|
||||
$$->insert(std::move(*$1));
|
||||
delete $1;
|
||||
}
|
||||
| use_specifier_items ',' use_specifier_item
|
||||
{
|
||||
$$ = $1;
|
||||
$$->insert(*$3);
|
||||
$$->insert(std::move(*$3));
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
use_specifier_item: identifier
|
||||
{
|
||||
$$ = new std::pair<String, Expression *>(*$1, new VariableExpression(*$1, @1));
|
||||
$$ = new std::pair<String, std::unique_ptr<Expression> >(*$1, std::unique_ptr<Expression>(new VariableExpression(*$1, @1)));
|
||||
delete $1;
|
||||
}
|
||||
| identifier T_SET rterm
|
||||
{
|
||||
$$ = new std::pair<String, Expression *>(*$1, $3);
|
||||
$$ = new std::pair<String, std::unique_ptr<Expression> >(*$1, std::unique_ptr<Expression>($3));
|
||||
delete $1;
|
||||
}
|
||||
;
|
||||
|
@ -1127,7 +1125,7 @@ apply_for_specifier: /* empty */
|
|||
|
||||
optional_rterm: /* empty */
|
||||
{
|
||||
$$ = MakeLiteral();
|
||||
$$ = MakeLiteralRaw();
|
||||
}
|
||||
| rterm
|
||||
;
|
||||
|
@ -1189,26 +1187,26 @@ apply:
|
|||
if (!seen_assign && !context->m_FTerm.top())
|
||||
BOOST_THROW_EXCEPTION(ScriptError("'apply' is missing 'assign'/'for'", DebugInfoRange(@2, @3)));
|
||||
|
||||
Expression *ignore = context->m_Ignore.top();
|
||||
std::unique_ptr<Expression> ignore{context->m_Ignore.top()};
|
||||
context->m_Ignore.pop();
|
||||
|
||||
Expression *assign;
|
||||
std::unique_ptr<Expression> assign;
|
||||
|
||||
if (!seen_assign)
|
||||
assign = MakeLiteral(true);
|
||||
else
|
||||
assign = context->m_Assign.top();
|
||||
assign.reset(context->m_Assign.top());
|
||||
|
||||
context->m_Assign.pop();
|
||||
|
||||
Expression *filter;
|
||||
std::unique_ptr<Expression> filter;
|
||||
|
||||
if (ignore) {
|
||||
Expression *rex = new LogicalNegateExpression(ignore, DebugInfoRange(@2, @5));
|
||||
std::unique_ptr<Expression>rex{new LogicalNegateExpression(std::move(ignore), DebugInfoRange(@2, @5))};
|
||||
|
||||
filter = new LogicalAndExpression(assign, rex, DebugInfoRange(@2, @5));
|
||||
filter.reset(new LogicalAndExpression(std::move(assign), std::move(rex), DebugInfoRange(@2, @5)));
|
||||
} else
|
||||
filter = assign;
|
||||
filter.swap(assign);
|
||||
|
||||
String fkvar = context->m_FKVar.top();
|
||||
context->m_FKVar.pop();
|
||||
|
@ -1216,10 +1214,11 @@ apply:
|
|||
String fvvar = context->m_FVVar.top();
|
||||
context->m_FVVar.pop();
|
||||
|
||||
Expression *fterm = context->m_FTerm.top();
|
||||
std::unique_ptr<Expression> fterm{context->m_FTerm.top()};
|
||||
context->m_FTerm.pop();
|
||||
|
||||
$$ = new ApplyExpression(type, target, $4, filter, context->GetPackage(), fkvar, fvvar, fterm, $7, $8, $10, DebugInfoRange(@2, @8));
|
||||
$$ = new ApplyExpression(type, target, std::unique_ptr<Expression>($4), std::move(filter), context->GetPackage(), fkvar, fvvar, std::move(fterm), std::move(*$7), $8, std::unique_ptr<Expression>($10), DebugInfoRange(@2, @8));
|
||||
delete $7;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -109,12 +109,11 @@ String ConfigCompiler::GetPackage(void) const
|
|||
return m_Package;
|
||||
}
|
||||
|
||||
void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
|
||||
void ConfigCompiler::CollectIncludes(std::vector<std::unique_ptr<Expression> >& expressions,
|
||||
const String& file, const String& zone, const String& package)
|
||||
{
|
||||
try {
|
||||
Expression *expr = CompileFile(file, zone, package);
|
||||
expressions.push_back(expr);
|
||||
expressions.emplace_back(CompileFile(file, zone, package));
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "ConfigCompiler")
|
||||
<< "Cannot compile file '"
|
||||
|
@ -130,7 +129,7 @@ void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
|
|||
* @param search Whether to search global include dirs.
|
||||
* @param debuginfo Debug information.
|
||||
*/
|
||||
Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const String& path,
|
||||
std::unique_ptr<Expression> ConfigCompiler::HandleInclude(const String& relativeBase, const String& path,
|
||||
bool search, const String& zone, const String& package, const DebugInfo& debuginfo)
|
||||
{
|
||||
String upath;
|
||||
|
@ -153,7 +152,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
std::vector<std::unique_ptr<Expression> > expressions;
|
||||
|
||||
if (!Utility::Glob(includePath, std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zone, package), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
|
||||
std::ostringstream msgbuf;
|
||||
|
@ -161,9 +160,9 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
|
|||
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debuginfo));
|
||||
}
|
||||
|
||||
DictExpression *expr = new DictExpression(expressions);
|
||||
std::unique_ptr<DictExpression> expr{new DictExpression(std::move(expressions))};
|
||||
expr->MakeInline();
|
||||
return expr;
|
||||
return std::move(expr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,7 +173,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
|
|||
* @param pattern The file pattern.
|
||||
* @param debuginfo Debug information.
|
||||
*/
|
||||
Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, const String& path,
|
||||
std::unique_ptr<Expression> ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, const String& path,
|
||||
const String& pattern, const String& zone, const String& package, const DebugInfo&)
|
||||
{
|
||||
String ppath;
|
||||
|
@ -184,15 +183,15 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, c
|
|||
else
|
||||
ppath = relativeBase + "/" + path;
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
std::vector<std::unique_ptr<Expression> > expressions;
|
||||
Utility::GlobRecursive(ppath, pattern, std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zone, package), GlobFile);
|
||||
|
||||
DictExpression *dict = new DictExpression(expressions);
|
||||
std::unique_ptr<DictExpression> dict{new DictExpression(std::move(expressions))};
|
||||
dict->MakeInline();
|
||||
return dict;
|
||||
return std::move(dict);
|
||||
}
|
||||
|
||||
void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String& tag, const String& path, const String& pattern, const String& package, std::vector<Expression *>& expressions)
|
||||
void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String& tag, const String& path, const String& pattern, const String& package, std::vector<std::unique_ptr<Expression> >& expressions)
|
||||
{
|
||||
String zoneName = Utility::BaseName(path);
|
||||
|
||||
|
@ -217,7 +216,7 @@ void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String&
|
|||
* @param pattern The file pattern.
|
||||
* @param debuginfo Debug information.
|
||||
*/
|
||||
Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const String& tag,
|
||||
std::unique_ptr<Expression> ConfigCompiler::HandleIncludeZones(const String& relativeBase, const String& tag,
|
||||
const String& path, const String& pattern, const String& package, const DebugInfo&)
|
||||
{
|
||||
String ppath;
|
||||
|
@ -230,9 +229,9 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const
|
|||
newRelativeBase = ".";
|
||||
}
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
std::vector<std::unique_ptr<Expression> > expressions;
|
||||
Utility::Glob(ppath + "/*", std::bind(&ConfigCompiler::HandleIncludeZone, newRelativeBase, tag, _1, pattern, package, std::ref(expressions)), GlobDirectory);
|
||||
return new DictExpression(expressions);
|
||||
return std::unique_ptr<Expression>(new DictExpression(std::move(expressions)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,7 +241,7 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const
|
|||
* @param stream The input stream.
|
||||
* @returns Configuration items.
|
||||
*/
|
||||
Expression *ConfigCompiler::CompileStream(const String& path,
|
||||
std::unique_ptr<Expression> ConfigCompiler::CompileStream(const String& path,
|
||||
std::istream *stream, const String& zone, const String& package)
|
||||
{
|
||||
CONTEXT("Compiling configuration stream with name '" + path + "'");
|
||||
|
@ -254,9 +253,9 @@ Expression *ConfigCompiler::CompileStream(const String& path,
|
|||
try {
|
||||
return ctx.Compile();
|
||||
} catch (const ScriptError& ex) {
|
||||
return new ThrowExpression(MakeLiteral(ex.what()), ex.IsIncompleteExpression(), ex.GetDebugInfo());
|
||||
return std::unique_ptr<Expression>(new ThrowExpression(MakeLiteral(ex.what()), ex.IsIncompleteExpression(), ex.GetDebugInfo()));
|
||||
} catch (const std::exception& ex) {
|
||||
return new ThrowExpression(MakeLiteral(DiagnosticInformation(ex)), false);
|
||||
return std::unique_ptr<Expression>(new ThrowExpression(MakeLiteral(DiagnosticInformation(ex)), false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,7 @@ Expression *ConfigCompiler::CompileStream(const String& path,
|
|||
* @param path The path.
|
||||
* @returns Configuration items.
|
||||
*/
|
||||
Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
|
||||
std::unique_ptr<Expression> ConfigCompiler::CompileFile(const String& path, const String& zone,
|
||||
const String& package)
|
||||
{
|
||||
CONTEXT("Compiling configuration file '" + path + "'");
|
||||
|
@ -292,7 +291,7 @@ Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
|
|||
* @param text The text.
|
||||
* @returns Configuration items.
|
||||
*/
|
||||
Expression *ConfigCompiler::CompileText(const String& path, const String& text,
|
||||
std::unique_ptr<Expression> ConfigCompiler::CompileText(const String& path, const String& text,
|
||||
const String& zone, const String& package)
|
||||
{
|
||||
std::stringstream stream(text);
|
||||
|
|
|
@ -90,13 +90,13 @@ public:
|
|||
const String& zone = String(), const String& package = String());
|
||||
virtual ~ConfigCompiler(void);
|
||||
|
||||
Expression *Compile(void);
|
||||
std::unique_ptr<Expression> Compile(void);
|
||||
|
||||
static Expression *CompileStream(const String& path, std::istream *stream,
|
||||
static std::unique_ptr<Expression>CompileStream(const String& path, std::istream *stream,
|
||||
const String& zone = String(), const String& package = String());
|
||||
static Expression *CompileFile(const String& path, const String& zone = String(),
|
||||
static std::unique_ptr<Expression>CompileFile(const String& path, const String& zone = String(),
|
||||
const String& package = String());
|
||||
static Expression *CompileText(const String& path, const String& text,
|
||||
static std::unique_ptr<Expression>CompileText(const String& path, const String& text,
|
||||
const String& zone = String(), const String& package = String());
|
||||
|
||||
static void AddIncludeSearchDir(const String& dir);
|
||||
|
@ -109,14 +109,14 @@ public:
|
|||
void SetPackage(const String& package);
|
||||
String GetPackage(void) const;
|
||||
|
||||
static void CollectIncludes(std::vector<Expression *>& expressions,
|
||||
static void CollectIncludes(std::vector<std::unique_ptr<Expression> >& expressions,
|
||||
const String& file, const String& zone, const String& package);
|
||||
|
||||
static Expression *HandleInclude(const String& relativeBase, const String& path, bool search,
|
||||
static std::unique_ptr<Expression> HandleInclude(const String& relativeBase, const String& path, bool search,
|
||||
const String& zone, const String& package, const DebugInfo& debuginfo = DebugInfo());
|
||||
static Expression *HandleIncludeRecursive(const String& relativeBase, const String& path,
|
||||
static std::unique_ptr<Expression> HandleIncludeRecursive(const String& relativeBase, const String& path,
|
||||
const String& pattern, const String& zone, const String& package, const DebugInfo& debuginfo = DebugInfo());
|
||||
static Expression *HandleIncludeZones(const String& relativeBase, const String& tag,
|
||||
static std::unique_ptr<Expression> HandleIncludeZones(const String& relativeBase, const String& tag,
|
||||
const String& path, const String& pattern, const String& package, const DebugInfo& debuginfo = DebugInfo());
|
||||
|
||||
size_t ReadInput(char *buffer, size_t max_bytes);
|
||||
|
@ -144,7 +144,7 @@ private:
|
|||
void InitializeScanner(void);
|
||||
void DestroyScanner(void);
|
||||
|
||||
static void HandleIncludeZone(const String& relativeBase, const String& tag, const String& path, const String& pattern, const String& package, std::vector<Expression *>& expressions);
|
||||
static void HandleIncludeZone(const String& relativeBase, const String& tag, const String& path, const String& pattern, const String& package, std::vector<std::unique_ptr<Expression> >& expressions);
|
||||
|
||||
static bool IsAbsolutePath(const String& path);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
|
||||
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
|
||||
icinga::Expression *expression = icinga::ConfigCompiler::CompileText(name, fragment); \
|
||||
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
|
||||
VERIFY(expression); \
|
||||
try { \
|
||||
icinga::ScriptFrame frame; \
|
||||
|
@ -37,7 +37,6 @@
|
|||
std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \
|
||||
icinga::Application::Exit(1); \
|
||||
} \
|
||||
delete expression; \
|
||||
}, 5)
|
||||
|
||||
#endif /* CONFIGFRAGMENT_H */
|
||||
|
|
|
@ -580,7 +580,7 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
|
|||
if (withModAttrs) {
|
||||
/* restore modified attributes */
|
||||
if (Utility::PathExists(Application::GetModAttrPath())) {
|
||||
Expression *expression = ConfigCompiler::CompileFile(Application::GetModAttrPath());
|
||||
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Application::GetModAttrPath());
|
||||
|
||||
if (expression) {
|
||||
try {
|
||||
|
@ -590,8 +590,6 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
|
|||
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||
}
|
||||
}
|
||||
|
||||
delete expression;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void ConfigItemBuilder::SetPackage(const String& package)
|
|||
|
||||
void ConfigItemBuilder::AddExpression(Expression *expr)
|
||||
{
|
||||
m_Expressions.push_back(expr);
|
||||
m_Expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
void ConfigItemBuilder::SetFilter(const std::shared_ptr<Expression>& filter)
|
||||
|
@ -110,24 +110,20 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
|
|||
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
|
||||
}
|
||||
|
||||
std::vector<Expression *> exprs;
|
||||
std::vector<std::unique_ptr<Expression> > exprs;
|
||||
|
||||
Array::Ptr templateArray = new Array();
|
||||
templateArray->Add(m_Name);
|
||||
|
||||
exprs.push_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd,
|
||||
new LiteralExpression(templateArray), m_DebugInfo));
|
||||
|
||||
DictExpression *dexpr = new DictExpression(m_Expressions, m_DebugInfo);
|
||||
dexpr->MakeInline();
|
||||
exprs.push_back(dexpr);
|
||||
exprs.emplace_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd,
|
||||
std::unique_ptr<LiteralExpression>(new LiteralExpression(templateArray)), m_DebugInfo));
|
||||
|
||||
#ifdef I2_DEBUG
|
||||
if (!m_Abstract) {
|
||||
bool foundDefaultImport = false;
|
||||
|
||||
for (Expression *expr : m_Expressions) {
|
||||
if (dynamic_cast<ImportDefaultTemplatesExpression *>(expr)) {
|
||||
for (const std::unique_ptr<Expression>& expr : m_Expressions) {
|
||||
if (dynamic_cast<ImportDefaultTemplatesExpression *>(expr.get())) {
|
||||
foundDefaultImport = true;
|
||||
break;
|
||||
}
|
||||
|
@ -137,7 +133,11 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
|
|||
}
|
||||
#endif /* I2_DEBUG */
|
||||
|
||||
std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(exprs, m_DebugInfo);
|
||||
DictExpression *dexpr = new DictExpression(std::move(m_Expressions), m_DebugInfo);
|
||||
dexpr->MakeInline();
|
||||
exprs.emplace_back(dexpr);
|
||||
|
||||
std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(std::move(exprs), m_DebugInfo);
|
||||
exprl->MakeInline();
|
||||
|
||||
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
Type::Ptr m_Type; /**< The object type. */
|
||||
String m_Name; /**< The name. */
|
||||
bool m_Abstract; /**< Whether the item is abstract. */
|
||||
std::vector<Expression *> m_Expressions; /**< Expressions for this item. */
|
||||
std::vector<std::unique_ptr<Expression> > m_Expressions; /**< Expressions for this item. */
|
||||
std::shared_ptr<Expression> m_Filter; /**< Filter expression. */
|
||||
DebugInfo m_DebugInfo; /**< Debug information. */
|
||||
Dictionary::Ptr m_Scope; /**< variable scope. */
|
||||
|
|
|
@ -90,10 +90,10 @@ const DebugInfo& Expression::GetDebugInfo(void) const
|
|||
return debugInfo;
|
||||
}
|
||||
|
||||
Expression *icinga::MakeIndexer(ScopeSpecifier scopeSpec, const String& index)
|
||||
std::unique_ptr<Expression> icinga::MakeIndexer(ScopeSpecifier scopeSpec, const String& index)
|
||||
{
|
||||
Expression *scope = new GetScopeExpression(scopeSpec);
|
||||
return new IndexerExpression(scope, MakeLiteral(index));
|
||||
std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
|
||||
return std::unique_ptr<Expression>(new IndexerExpression(std::move(scope), MakeLiteral(index)));
|
||||
}
|
||||
|
||||
void DictExpression::MakeInline(void)
|
||||
|
@ -429,7 +429,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin
|
|||
if (vfunc.IsObjectType<Type>()) {
|
||||
std::vector<Value> arguments;
|
||||
arguments.reserve(m_Args.size());
|
||||
for (Expression *arg : m_Args) {
|
||||
for (const auto& arg : m_Args) {
|
||||
ExpressionResult argres = arg->Evaluate(frame);
|
||||
CHECK_RESULT(argres);
|
||||
|
||||
|
@ -449,7 +449,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin
|
|||
|
||||
std::vector<Value> arguments;
|
||||
arguments.reserve(m_Args.size());
|
||||
for (Expression *arg : m_Args) {
|
||||
for (const auto& arg : m_Args) {
|
||||
ExpressionResult argres = arg->Evaluate(frame);
|
||||
CHECK_RESULT(argres);
|
||||
|
||||
|
@ -464,7 +464,7 @@ ExpressionResult ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin
|
|||
Array::Ptr result = new Array();
|
||||
result->Reserve(m_Expressions.size());
|
||||
|
||||
for (Expression *aexpr : m_Expressions) {
|
||||
for (const auto& aexpr : m_Expressions) {
|
||||
ExpressionResult element = aexpr->Evaluate(frame);
|
||||
CHECK_RESULT(element);
|
||||
|
||||
|
@ -486,7 +486,7 @@ ExpressionResult DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint
|
|||
Value result;
|
||||
|
||||
try {
|
||||
for (Expression *aexpr : m_Expressions) {
|
||||
for (const auto& aexpr : m_Expressions) {
|
||||
ExpressionResult element = aexpr->Evaluate(frame, m_Inline ? dhint : nullptr);
|
||||
CHECK_RESULT(element);
|
||||
result = element.GetValue();
|
||||
|
@ -683,18 +683,18 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
|
|||
return true;
|
||||
}
|
||||
|
||||
void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec)
|
||||
void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec)
|
||||
{
|
||||
DictExpression *dexpr = dynamic_cast<DictExpression *>(expr);
|
||||
DictExpression *dexpr = dynamic_cast<DictExpression *>(expr.get());
|
||||
|
||||
if (dexpr) {
|
||||
for (Expression *& expr : dexpr->m_Expressions)
|
||||
for (auto& expr : dexpr->m_Expressions)
|
||||
BindToScope(expr, scopeSpec);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SetExpression *aexpr = dynamic_cast<SetExpression *>(expr);
|
||||
SetExpression *aexpr = dynamic_cast<SetExpression *>(expr.get());
|
||||
|
||||
if (aexpr) {
|
||||
BindToScope(aexpr->m_Operand1, scopeSpec);
|
||||
|
@ -702,27 +702,25 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec)
|
|||
return;
|
||||
}
|
||||
|
||||
IndexerExpression *iexpr = dynamic_cast<IndexerExpression *>(expr);
|
||||
IndexerExpression *iexpr = dynamic_cast<IndexerExpression *>(expr.get());
|
||||
|
||||
if (iexpr) {
|
||||
BindToScope(iexpr->m_Operand1, scopeSpec);
|
||||
return;
|
||||
}
|
||||
|
||||
LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr);
|
||||
LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr.get());
|
||||
|
||||
if (lexpr && lexpr->GetValue().IsString()) {
|
||||
Expression *scope = new GetScopeExpression(scopeSpec);
|
||||
expr = new IndexerExpression(scope, lexpr, lexpr->GetDebugInfo());
|
||||
std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
|
||||
expr.reset(new IndexerExpression(std::move(scope), std::move(expr), lexpr->GetDebugInfo()));
|
||||
}
|
||||
|
||||
VariableExpression *vexpr = dynamic_cast<VariableExpression *>(expr);
|
||||
VariableExpression *vexpr = dynamic_cast<VariableExpression *>(expr.get());
|
||||
|
||||
if (vexpr) {
|
||||
Expression *scope = new GetScopeExpression(scopeSpec);
|
||||
Expression *new_expr = new IndexerExpression(scope, MakeLiteral(vexpr->GetVariable()), vexpr->GetDebugInfo());
|
||||
delete expr;
|
||||
expr = new_expr;
|
||||
std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
|
||||
expr.reset(new IndexerExpression(std::move(scope), MakeLiteral(vexpr->GetVariable()), vexpr->GetDebugInfo()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -852,7 +850,7 @@ ExpressionResult IncludeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dh
|
|||
if (frame.Sandboxed)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Includes are not allowed in sandbox mode.", m_DebugInfo));
|
||||
|
||||
Expression *expr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
String name, path, pattern;
|
||||
|
||||
switch (m_Type) {
|
||||
|
@ -910,12 +908,9 @@ ExpressionResult IncludeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dh
|
|||
try {
|
||||
res = expr->Evaluate(frame, dhint);
|
||||
} catch (const std::exception&) {
|
||||
delete expr;
|
||||
throw;
|
||||
}
|
||||
|
||||
delete expr;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
static void ScriptBreakpoint(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di);
|
||||
};
|
||||
|
||||
I2_CONFIG_API Expression *MakeIndexer(ScopeSpecifier scopeSpec, const String& index);
|
||||
I2_CONFIG_API std::unique_ptr<Expression> MakeIndexer(ScopeSpecifier scopeSpec, const String& index);
|
||||
|
||||
class I2_CONFIG_API OwnedExpression : public Expression
|
||||
{
|
||||
|
@ -252,11 +252,16 @@ private:
|
|||
Value m_Value;
|
||||
};
|
||||
|
||||
inline LiteralExpression *MakeLiteral(const Value& literal = Value())
|
||||
inline LiteralExpression *MakeLiteralRaw(const Value& literal = Value())
|
||||
{
|
||||
return new LiteralExpression(literal);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<LiteralExpression> MakeLiteral(const Value& literal = Value())
|
||||
{
|
||||
return std::unique_ptr<LiteralExpression>(MakeLiteralRaw(literal));
|
||||
}
|
||||
|
||||
class I2_CONFIG_API DebuggableExpression : public Expression
|
||||
{
|
||||
public:
|
||||
|
@ -273,35 +278,24 @@ protected:
|
|||
class I2_CONFIG_API UnaryExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
UnaryExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Operand(operand)
|
||||
UnaryExpression(std::unique_ptr<Expression> operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Operand(std::move(operand))
|
||||
{ }
|
||||
|
||||
~UnaryExpression(void)
|
||||
{
|
||||
delete m_Operand;
|
||||
}
|
||||
|
||||
protected:
|
||||
Expression *m_Operand;
|
||||
std::unique_ptr<Expression> m_Operand;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API BinaryExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
BinaryExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Operand1(operand1), m_Operand2(operand2)
|
||||
BinaryExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Operand1(std::move(operand1)), m_Operand2(std::move(operand2))
|
||||
{ }
|
||||
|
||||
~BinaryExpression(void)
|
||||
{
|
||||
delete m_Operand1;
|
||||
delete m_Operand2;
|
||||
}
|
||||
|
||||
protected:
|
||||
Expression *m_Operand1;
|
||||
Expression *m_Operand2;
|
||||
std::unique_ptr<Expression> m_Operand1;
|
||||
std::unique_ptr<Expression> m_Operand2;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API VariableExpression : public DebuggableExpression
|
||||
|
@ -323,14 +317,14 @@ protected:
|
|||
private:
|
||||
String m_Variable;
|
||||
|
||||
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
|
||||
friend I2_CONFIG_API void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
};
|
||||
|
||||
class I2_CONFIG_API NegateExpression : public UnaryExpression
|
||||
{
|
||||
public:
|
||||
NegateExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(operand, debugInfo)
|
||||
NegateExpression(std::unique_ptr<Expression> operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(std::move(operand), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -340,8 +334,8 @@ protected:
|
|||
class I2_CONFIG_API LogicalNegateExpression : public UnaryExpression
|
||||
{
|
||||
public:
|
||||
LogicalNegateExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(operand, debugInfo)
|
||||
LogicalNegateExpression(std::unique_ptr<Expression> operand, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(std::move(operand), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -351,8 +345,8 @@ protected:
|
|||
class I2_CONFIG_API AddExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
AddExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
AddExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -362,8 +356,8 @@ protected:
|
|||
class I2_CONFIG_API SubtractExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
SubtractExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
SubtractExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -373,8 +367,8 @@ protected:
|
|||
class I2_CONFIG_API MultiplyExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
MultiplyExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
MultiplyExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -384,8 +378,8 @@ protected:
|
|||
class I2_CONFIG_API DivideExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
DivideExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
DivideExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -395,8 +389,8 @@ protected:
|
|||
class I2_CONFIG_API ModuloExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
ModuloExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
ModuloExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -406,8 +400,8 @@ protected:
|
|||
class I2_CONFIG_API XorExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
XorExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
XorExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -417,8 +411,8 @@ protected:
|
|||
class I2_CONFIG_API BinaryAndExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
BinaryAndExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
BinaryAndExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -428,8 +422,8 @@ protected:
|
|||
class I2_CONFIG_API BinaryOrExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
BinaryOrExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
BinaryOrExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -439,8 +433,8 @@ protected:
|
|||
class I2_CONFIG_API ShiftLeftExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
ShiftLeftExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
ShiftLeftExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -450,8 +444,8 @@ protected:
|
|||
class I2_CONFIG_API ShiftRightExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
ShiftRightExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
ShiftRightExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -461,8 +455,8 @@ protected:
|
|||
class I2_CONFIG_API EqualExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
EqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
EqualExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -472,8 +466,8 @@ protected:
|
|||
class I2_CONFIG_API NotEqualExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
NotEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
NotEqualExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -483,8 +477,8 @@ protected:
|
|||
class I2_CONFIG_API LessThanExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
LessThanExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
LessThanExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -494,8 +488,8 @@ protected:
|
|||
class I2_CONFIG_API GreaterThanExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
GreaterThanExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
GreaterThanExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -505,8 +499,8 @@ protected:
|
|||
class I2_CONFIG_API LessThanOrEqualExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
LessThanOrEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
LessThanOrEqualExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -516,8 +510,8 @@ protected:
|
|||
class I2_CONFIG_API GreaterThanOrEqualExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
GreaterThanOrEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
GreaterThanOrEqualExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -527,8 +521,8 @@ protected:
|
|||
class I2_CONFIG_API InExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
InExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
InExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -538,8 +532,8 @@ protected:
|
|||
class I2_CONFIG_API NotInExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
NotInExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
NotInExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -549,8 +543,8 @@ protected:
|
|||
class I2_CONFIG_API LogicalAndExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
LogicalAndExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
LogicalAndExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -560,8 +554,8 @@ protected:
|
|||
class I2_CONFIG_API LogicalOrExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
LogicalOrExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
LogicalOrExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -571,76 +565,56 @@ protected:
|
|||
class I2_CONFIG_API FunctionCallExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
FunctionCallExpression(Expression *fname, const std::vector<Expression *>& args, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_FName(fname), m_Args(args)
|
||||
FunctionCallExpression(std::unique_ptr<Expression> fname, std::vector<std::unique_ptr<Expression> >&& args, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_FName(std::move(fname)), m_Args(std::move(args))
|
||||
{ }
|
||||
|
||||
~FunctionCallExpression(void)
|
||||
{
|
||||
delete m_FName;
|
||||
|
||||
for (Expression *expr : m_Args)
|
||||
delete expr;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
public:
|
||||
Expression *m_FName;
|
||||
std::vector<Expression *> m_Args;
|
||||
std::unique_ptr<Expression> m_FName;
|
||||
std::vector<std::unique_ptr<Expression> > m_Args;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ArrayExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ArrayExpression(const std::vector<Expression *>& expressions, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Expressions(expressions)
|
||||
ArrayExpression(std::vector<std::unique_ptr<Expression > >&& expressions, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Expressions(std::move(expressions))
|
||||
{ }
|
||||
|
||||
~ArrayExpression(void)
|
||||
{
|
||||
for (Expression *expr : m_Expressions)
|
||||
delete expr;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
std::vector<Expression *> m_Expressions;
|
||||
std::vector<std::unique_ptr<Expression> > m_Expressions;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API DictExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
DictExpression(const std::vector<Expression *>& expressions = std::vector<Expression *>(), const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Expressions(expressions), m_Inline(false)
|
||||
DictExpression(std::vector<std::unique_ptr<Expression> >&& expressions = {}, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Expressions(std::move(expressions)), m_Inline(false)
|
||||
{ }
|
||||
|
||||
~DictExpression(void)
|
||||
{
|
||||
for (Expression *expr : m_Expressions)
|
||||
delete expr;
|
||||
}
|
||||
|
||||
void MakeInline(void);
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
std::vector<Expression *> m_Expressions;
|
||||
std::vector<std::unique_ptr<Expression> > m_Expressions;
|
||||
bool m_Inline;
|
||||
|
||||
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
|
||||
friend I2_CONFIG_API void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
};
|
||||
|
||||
class I2_CONFIG_API SetExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
SetExpression(Expression *operand1, CombinedSetOp op, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo), m_Op(op)
|
||||
SetExpression(std::unique_ptr<Expression> operand1, CombinedSetOp op, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo), m_Op(op)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -649,59 +623,46 @@ protected:
|
|||
private:
|
||||
CombinedSetOp m_Op;
|
||||
|
||||
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
|
||||
friend I2_CONFIG_API void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ConditionalExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ConditionalExpression(Expression *condition, Expression *true_branch, Expression *false_branch, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Condition(condition), m_TrueBranch(true_branch), m_FalseBranch(false_branch)
|
||||
ConditionalExpression(std::unique_ptr<Expression> condition, std::unique_ptr<Expression> true_branch, std::unique_ptr<Expression> false_branch, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Condition(std::move(condition)), m_TrueBranch(std::move(true_branch)), m_FalseBranch(std::move(false_branch))
|
||||
{ }
|
||||
|
||||
~ConditionalExpression(void)
|
||||
{
|
||||
delete m_Condition;
|
||||
delete m_TrueBranch;
|
||||
delete m_FalseBranch;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_Condition;
|
||||
Expression *m_TrueBranch;
|
||||
Expression *m_FalseBranch;
|
||||
std::unique_ptr<Expression> m_Condition;
|
||||
std::unique_ptr<Expression> m_TrueBranch;
|
||||
std::unique_ptr<Expression> m_FalseBranch;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API WhileExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
WhileExpression(Expression *condition, Expression *loop_body, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Condition(condition), m_LoopBody(loop_body)
|
||||
WhileExpression(std::unique_ptr<Expression> condition, std::unique_ptr<Expression> loop_body, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Condition(std::move(condition)), m_LoopBody(std::move(loop_body))
|
||||
{ }
|
||||
|
||||
~WhileExpression(void)
|
||||
{
|
||||
delete m_Condition;
|
||||
delete m_LoopBody;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_Condition;
|
||||
Expression *m_LoopBody;
|
||||
std::unique_ptr<Expression> m_Condition;
|
||||
std::unique_ptr<Expression> m_LoopBody;
|
||||
};
|
||||
|
||||
|
||||
class I2_CONFIG_API ReturnExpression : public UnaryExpression
|
||||
{
|
||||
public:
|
||||
ReturnExpression(Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(expression, debugInfo)
|
||||
ReturnExpression(std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(std::move(expression), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -747,56 +708,46 @@ private:
|
|||
class I2_CONFIG_API IndexerExpression : public BinaryExpression
|
||||
{
|
||||
public:
|
||||
IndexerExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(operand1, operand2, debugInfo)
|
||||
IndexerExpression(std::unique_ptr<Expression> operand1, std::unique_ptr<Expression> operand2, const DebugInfo& debugInfo = DebugInfo())
|
||||
: BinaryExpression(std::move(operand1), std::move(operand2), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
virtual bool GetReference(ScriptFrame& frame, bool init_dict, Value *parent, String *index, DebugHint **dhint) const override;
|
||||
|
||||
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
|
||||
friend I2_CONFIG_API void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
};
|
||||
|
||||
I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
|
||||
I2_CONFIG_API void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
|
||||
|
||||
class I2_CONFIG_API ThrowExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ThrowExpression(Expression *message, bool incompleteExpr, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Message(message), m_IncompleteExpr(incompleteExpr)
|
||||
ThrowExpression(std::unique_ptr<Expression> message, bool incompleteExpr, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Message(std::move(message)), m_IncompleteExpr(incompleteExpr)
|
||||
{ }
|
||||
|
||||
~ThrowExpression(void)
|
||||
{
|
||||
delete m_Message;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_Message;
|
||||
std::unique_ptr<Expression> m_Message;
|
||||
bool m_IncompleteExpr;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ImportExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ImportExpression(Expression *name, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(name)
|
||||
ImportExpression(std::unique_ptr<Expression> name, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(std::move(name))
|
||||
{ }
|
||||
|
||||
~ImportExpression(void)
|
||||
{
|
||||
delete m_Name;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_Name;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ImportDefaultTemplatesExpression : public DebuggableExpression
|
||||
|
@ -814,145 +765,99 @@ class I2_CONFIG_API FunctionExpression : public DebuggableExpression
|
|||
{
|
||||
public:
|
||||
FunctionExpression(const String& name, const std::vector<String>& args,
|
||||
std::map<String, Expression *> *closedVars, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_ClosedVars(closedVars), m_Expression(expression)
|
||||
std::map<String, std::unique_ptr<Expression> >&& closedVars, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
|
||||
{ }
|
||||
|
||||
~FunctionExpression(void)
|
||||
{
|
||||
if (m_ClosedVars) {
|
||||
typedef std::pair<String, Expression *> kv_pair;
|
||||
for (const kv_pair& kv : *m_ClosedVars) {
|
||||
delete kv.second;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_ClosedVars;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
String m_Name;
|
||||
std::vector<String> m_Args;
|
||||
std::map<String, Expression *> *m_ClosedVars;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ApplyExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ApplyExpression(const String& type, const String& target, Expression *name,
|
||||
Expression *filter, const String& package, const String& fkvar, const String& fvvar,
|
||||
Expression *fterm, std::map<String, Expression *> *closedVars, bool ignoreOnError,
|
||||
Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
ApplyExpression(const String& type, const String& target, std::unique_ptr<Expression> name,
|
||||
std::unique_ptr<Expression> filter, const String& package, const String& fkvar, const String& fvvar,
|
||||
std::unique_ptr<Expression> fterm, std::map<String, std::unique_ptr<Expression> >&& closedVars, bool ignoreOnError,
|
||||
std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Type(type), m_Target(target),
|
||||
m_Name(name), m_Filter(filter), m_Package(package), m_FKVar(fkvar), m_FVVar(fvvar),
|
||||
m_FTerm(fterm), m_IgnoreOnError(ignoreOnError), m_ClosedVars(closedVars),
|
||||
m_Expression(expression)
|
||||
m_Name(std::move(name)), m_Filter(std::move(filter)), m_Package(package), m_FKVar(fkvar), m_FVVar(fvvar),
|
||||
m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
|
||||
m_Expression(std::move(expression))
|
||||
{ }
|
||||
|
||||
~ApplyExpression(void)
|
||||
{
|
||||
delete m_Name;
|
||||
|
||||
if (m_ClosedVars) {
|
||||
typedef std::pair<String, Expression *> kv_pair;
|
||||
for (const kv_pair& kv : *m_ClosedVars) {
|
||||
delete kv.second;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_ClosedVars;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
String m_Type;
|
||||
String m_Target;
|
||||
Expression *m_Name;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
String m_Package;
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
std::shared_ptr<Expression> m_FTerm;
|
||||
bool m_IgnoreOnError;
|
||||
std::map<String, Expression *> *m_ClosedVars;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ObjectExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ObjectExpression(bool abstract, Expression *type, Expression *name, Expression *filter,
|
||||
const String& zone, const String& package, std::map<String, Expression *> *closedVars,
|
||||
bool defaultTmpl, bool ignoreOnError, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type),
|
||||
m_Name(name), m_Filter(filter), m_Zone(zone), m_Package(package), m_DefaultTmpl(defaultTmpl),
|
||||
m_IgnoreOnError(ignoreOnError), m_ClosedVars(closedVars), m_Expression(expression)
|
||||
ObjectExpression(bool abstract, std::unique_ptr<Expression> type, std::unique_ptr<Expression> name, std::unique_ptr<Expression> filter,
|
||||
const String& zone, const String& package, std::map<String, std::unique_ptr<Expression> >&& closedVars,
|
||||
bool defaultTmpl, bool ignoreOnError, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(std::move(type)),
|
||||
m_Name(std::move(name)), m_Filter(std::move(filter)), m_Zone(zone), m_Package(package), m_DefaultTmpl(defaultTmpl),
|
||||
m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
|
||||
{ }
|
||||
|
||||
~ObjectExpression(void)
|
||||
{
|
||||
delete m_Name;
|
||||
|
||||
if (m_ClosedVars) {
|
||||
typedef std::pair<String, Expression *> kv_pair;
|
||||
for (const kv_pair& kv : *m_ClosedVars) {
|
||||
delete kv.second;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_ClosedVars;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
bool m_Abstract;
|
||||
Expression *m_Type;
|
||||
Expression *m_Name;
|
||||
std::unique_ptr<Expression> m_Type;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
std::shared_ptr<Expression> m_Filter;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
bool m_DefaultTmpl;
|
||||
bool m_IgnoreOnError;
|
||||
std::map<String, Expression *> *m_ClosedVars;
|
||||
std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
|
||||
std::shared_ptr<Expression> m_Expression;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API ForExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ForExpression(const String& fkvar, const String& fvvar, Expression *value, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_FKVar(fkvar), m_FVVar(fvvar), m_Value(value), m_Expression(expression)
|
||||
ForExpression(const String& fkvar, const String& fvvar, std::unique_ptr<Expression> value, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_FKVar(fkvar), m_FVVar(fvvar), m_Value(std::move(value)), m_Expression(std::move(expression))
|
||||
{ }
|
||||
|
||||
~ForExpression(void)
|
||||
{
|
||||
delete m_Value;
|
||||
delete m_Expression;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
Expression *m_Value;
|
||||
Expression *m_Expression;
|
||||
std::unique_ptr<Expression> m_Value;
|
||||
std::unique_ptr<Expression> m_Expression;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API LibraryExpression : public UnaryExpression
|
||||
{
|
||||
public:
|
||||
LibraryExpression(Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(expression, debugInfo)
|
||||
LibraryExpression(std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(std::move(expression), debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
|
@ -969,27 +874,20 @@ enum IncludeType
|
|||
class I2_CONFIG_API IncludeExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
IncludeExpression(const String& relativeBase, Expression *path, Expression *pattern, Expression *name,
|
||||
IncludeExpression(const String& relativeBase, std::unique_ptr<Expression> path, std::unique_ptr<Expression> pattern, std::unique_ptr<Expression> name,
|
||||
IncludeType type, bool searchIncludes, const String& zone, const String& package, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_RelativeBase(relativeBase), m_Path(path), m_Pattern(pattern),
|
||||
m_Name(name), m_Type(type), m_SearchIncludes(searchIncludes), m_Zone(zone), m_Package(package)
|
||||
: DebuggableExpression(debugInfo), m_RelativeBase(relativeBase), m_Path(std::move(path)), m_Pattern(std::move(pattern)),
|
||||
m_Name(std::move(name)), m_Type(type), m_SearchIncludes(searchIncludes), m_Zone(zone), m_Package(package)
|
||||
{ }
|
||||
|
||||
~IncludeExpression(void)
|
||||
{
|
||||
delete m_Path;
|
||||
delete m_Pattern;
|
||||
delete m_Name;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
String m_RelativeBase;
|
||||
Expression *m_Path;
|
||||
Expression *m_Pattern;
|
||||
Expression *m_Name;
|
||||
std::unique_ptr<Expression> m_Path;
|
||||
std::unique_ptr<Expression> m_Pattern;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
IncludeType m_Type;
|
||||
bool m_SearchIncludes;
|
||||
String m_Zone;
|
||||
|
@ -1010,41 +908,30 @@ protected:
|
|||
class I2_CONFIG_API UsingExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
UsingExpression(Expression *name, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(name)
|
||||
UsingExpression(std::unique_ptr<Expression> name, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Name(std::move(name))
|
||||
{ }
|
||||
|
||||
~UsingExpression(void)
|
||||
{
|
||||
delete m_Name;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_Name;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API TryExceptExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
TryExceptExpression(Expression *tryBody, Expression *exceptBody, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_TryBody(tryBody), m_ExceptBody(exceptBody)
|
||||
TryExceptExpression(std::unique_ptr<Expression> tryBody, std::unique_ptr<Expression> exceptBody, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_TryBody(std::move(tryBody)), m_ExceptBody(std::move(exceptBody))
|
||||
{ }
|
||||
|
||||
~TryExceptExpression(void)
|
||||
{
|
||||
delete m_TryBody;
|
||||
delete m_ExceptBody;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
|
||||
private:
|
||||
Expression *m_TryBody;
|
||||
Expression *m_ExceptBody;
|
||||
std::unique_ptr<Expression> m_TryBody;
|
||||
std::unique_ptr<Expression> m_ExceptBody;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
}
|
||||
|
||||
static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& argNames,
|
||||
std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression)
|
||||
const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression)
|
||||
{
|
||||
auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
|
||||
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const std::shared_ptr<Expression>& filter,
|
||||
const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
|
||||
const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
|
||||
bool ignoreOnError, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
}
|
||||
|
||||
static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter,
|
||||
const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
|
||||
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
return Empty;
|
||||
}
|
||||
|
||||
static inline ExpressionResult For(ScriptFrame& frame, const String& fkvar, const String& fvvar, const Value& value, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
static inline ExpressionResult For(ScriptFrame& frame, const String& fkvar, const String& fvvar, const Value& value, const std::unique_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
if (value.IsObjectType<Array>()) {
|
||||
if (!fvvar.IsEmpty())
|
||||
|
@ -251,15 +251,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, std::map<String, Expression *> *closedVars)
|
||||
static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, const std::map<String, std::unique_ptr<Expression> >& closedVars)
|
||||
{
|
||||
Dictionary::Ptr locals;
|
||||
|
||||
if (closedVars) {
|
||||
if (!closedVars.empty()) {
|
||||
locals = new Dictionary();
|
||||
|
||||
typedef std::pair<String, Expression *> ClosedVar;
|
||||
for (const ClosedVar& cvar : *closedVars) {
|
||||
for (const auto& cvar : closedVars) {
|
||||
locals->Set(cvar.first, cvar.second->Evaluate(frame));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,15 +124,14 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
fp << config;
|
||||
fp.close();
|
||||
|
||||
Expression *expr = ConfigCompiler::CompileFile(path, String(), "_api");
|
||||
std::unique_ptr<Expression> expr = ConfigCompiler::CompileFile(path, String(), "_api");
|
||||
|
||||
try {
|
||||
ActivationScope ascope;
|
||||
|
||||
ScriptFrame frame;
|
||||
expr->Evaluate(frame);
|
||||
delete expr;
|
||||
expr = nullptr;
|
||||
expr.reset();
|
||||
|
||||
WorkQueue upq;
|
||||
std::vector<ConfigItem::Ptr> newItems;
|
||||
|
@ -156,8 +155,6 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
|
||||
ApiListener::UpdateObjectAuthority();
|
||||
} catch (const std::exception& ex) {
|
||||
delete expr;
|
||||
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
|
|
|
@ -123,7 +123,7 @@ bool ConsoleHandler::ExecuteScriptHelper(HttpRequest& request, HttpResponse& res
|
|||
|
||||
Array::Ptr results = new Array();
|
||||
Dictionary::Ptr resultInfo = new Dictionary();
|
||||
Expression *expr = nullptr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
Value exprResult;
|
||||
|
||||
try {
|
||||
|
@ -160,11 +160,7 @@ bool ConsoleHandler::ExecuteScriptHelper(HttpRequest& request, HttpResponse& res
|
|||
debugInfo->Set("last_line", di.LastLine);
|
||||
debugInfo->Set("last_column", di.LastColumn);
|
||||
resultInfo->Set("debug_info", debugInfo);
|
||||
} catch (...) {
|
||||
delete expr;
|
||||
throw;
|
||||
}
|
||||
delete expr;
|
||||
|
||||
results->Add(resultInfo);
|
||||
|
||||
|
@ -301,13 +297,12 @@ std::vector<String> ConsoleHandler::GetAutocompletionSuggestions(const String& w
|
|||
Value value;
|
||||
|
||||
try {
|
||||
Expression *expr = ConfigCompiler::CompileText("temp", pword);
|
||||
std::unique_ptr<Expression> expr = ConfigCompiler::CompileText("temp", pword);
|
||||
|
||||
if (expr)
|
||||
value = expr->Evaluate(frame);
|
||||
|
||||
AddSuggestions(matches, word, pword, true, value);
|
||||
|
||||
} catch (...) { /* Ignore the exception */ }
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,9 @@
|
|||
using namespace icinga;
|
||||
|
||||
EventQueue::EventQueue(const String& name)
|
||||
: m_Name(name), m_Filter(nullptr)
|
||||
: m_Name(name)
|
||||
{ }
|
||||
|
||||
EventQueue::~EventQueue(void)
|
||||
{
|
||||
delete m_Filter;
|
||||
}
|
||||
|
||||
bool EventQueue::CanProcessEvent(const String& type) const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
@ -46,7 +41,7 @@ void EventQueue::ProcessEvent(const Dictionary::Ptr& event)
|
|||
frame.Sandboxed = true;
|
||||
|
||||
try {
|
||||
if (!FilterUtility::EvaluateFilter(frame, m_Filter, event, "event"))
|
||||
if (!FilterUtility::EvaluateFilter(frame, &*m_Filter, event, "event"))
|
||||
return;
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "EventQueue")
|
||||
|
@ -93,11 +88,10 @@ void EventQueue::SetTypes(const std::set<String>& types)
|
|||
m_Types = types;
|
||||
}
|
||||
|
||||
void EventQueue::SetFilter(Expression *filter)
|
||||
void EventQueue::SetFilter(std::unique_ptr<Expression> filter)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
delete m_Filter;
|
||||
m_Filter = filter;
|
||||
m_Filter.swap(filter);
|
||||
}
|
||||
|
||||
Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
DECLARE_PTR_TYPEDEFS(EventQueue);
|
||||
|
||||
EventQueue(const String& name);
|
||||
~EventQueue(void);
|
||||
|
||||
bool CanProcessEvent(const String& type) const;
|
||||
void ProcessEvent(const Dictionary::Ptr& event);
|
||||
|
@ -46,7 +45,7 @@ public:
|
|||
void RemoveClient(void *client);
|
||||
|
||||
void SetTypes(const std::set<String>& types);
|
||||
void SetFilter(Expression *filter);
|
||||
void SetFilter(std::unique_ptr<Expression> filter);
|
||||
|
||||
Dictionary::Ptr WaitForEvent(void *client, double timeout = 5);
|
||||
|
||||
|
@ -64,7 +63,7 @@ private:
|
|||
boost::condition_variable m_CV;
|
||||
|
||||
std::set<String> m_Types;
|
||||
Expression *m_Filter;
|
||||
std::unique_ptr<Expression> m_Filter;
|
||||
|
||||
std::map<void *, std::deque<Dictionary::Ptr> > m_Events;
|
||||
};
|
||||
|
|
|
@ -66,7 +66,7 @@ bool EventsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request
|
|||
|
||||
String filter = HttpUtility::GetLastParameter(params, "filter");
|
||||
|
||||
Expression *ufilter = nullptr;
|
||||
std::unique_ptr<Expression> ufilter;
|
||||
|
||||
if (!filter.IsEmpty())
|
||||
ufilter = ConfigCompiler::CompileText("<API query>", filter);
|
||||
|
@ -80,7 +80,7 @@ bool EventsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request
|
|||
}
|
||||
|
||||
queue->SetTypes(types->ToSet<String>());
|
||||
queue->SetFilter(ufilter);
|
||||
queue->SetFilter(std::move(ufilter));
|
||||
|
||||
queue->AddClient(&request);
|
||||
|
||||
|
|
|
@ -162,14 +162,15 @@ void FilterUtility::CheckPermission(const ApiUser::Ptr& user, const String& perm
|
|||
foundPermission = true;
|
||||
|
||||
if (filter && permissionFilter) {
|
||||
std::vector<Expression *> args;
|
||||
args.push_back(new GetScopeExpression(ScopeLocal));
|
||||
FunctionCallExpression *fexpr = new FunctionCallExpression(new IndexerExpression(MakeLiteral(filter), MakeLiteral("call")), args);
|
||||
std::vector<std::unique_ptr<Expression> > args;
|
||||
args.emplace_back(new GetScopeExpression(ScopeLocal));
|
||||
std::unique_ptr<Expression> indexer{new IndexerExpression(std::unique_ptr<Expression>(MakeLiteral(filter)), std::unique_ptr<Expression>(MakeLiteral("call")))};
|
||||
FunctionCallExpression *fexpr = new FunctionCallExpression(std::move(indexer), std::move(args));
|
||||
|
||||
if (!*permissionFilter)
|
||||
*permissionFilter = fexpr;
|
||||
else
|
||||
*permissionFilter = new LogicalOrExpression(*permissionFilter, fexpr);
|
||||
*permissionFilter = new LogicalOrExpression(std::unique_ptr<Expression>(*permissionFilter), std::unique_ptr<Expression>(fexpr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +251,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
|||
frame.Sandboxed = true;
|
||||
Dictionary::Ptr uvars = new Dictionary();
|
||||
|
||||
Expression *ufilter = nullptr;
|
||||
std::unique_ptr<Expression> ufilter;
|
||||
|
||||
if (query->Contains("filter")) {
|
||||
String filter = HttpUtility::GetLastParameter(query, "filter");
|
||||
|
@ -267,16 +268,9 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
|||
|
||||
frame.Self = uvars;
|
||||
|
||||
try {
|
||||
provider->FindTargets(type, std::bind(&FilteredAddTarget,
|
||||
std::ref(permissionFrame), permissionFilter,
|
||||
std::ref(frame), ufilter, std::ref(result), variableName, _1));
|
||||
} catch (const std::exception&) {
|
||||
delete ufilter;
|
||||
throw;
|
||||
}
|
||||
|
||||
delete ufilter;
|
||||
provider->FindTargets(type, std::bind(&FilteredAddTarget,
|
||||
std::ref(permissionFrame), permissionFilter,
|
||||
std::ref(frame), &*ufilter, std::ref(result), variableName, _1));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -28,308 +28,236 @@ BOOST_AUTO_TEST_SUITE(config_ops)
|
|||
BOOST_AUTO_TEST_CASE(simple)
|
||||
{
|
||||
ScriptFrame frame;
|
||||
Expression *expr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
Dictionary::Ptr dict;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == Empty);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\n3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "{ 3\n\n5 }");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "1 + 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 4);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 - 1");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 2);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "5m * 10");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3000);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "5m / 5");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 60);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "7 & 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "2 | 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "true && false");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "true || false");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 < 5");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 > 5");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 <= 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 >= 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "2 + 3 * 4");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 14);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(2 + 3) * 4");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 20);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "2 * - 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == -6);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "-(2 + 3)");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == -5);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "- 2 * 2 - 2 * 3 - 4 * - 5");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 10);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "!0 == true");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "~0");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == (double)~(long)0);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "4 << 8");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 1024);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "1024 >> 4");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 64);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "2 << 3 << 4");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 256);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "256 >> 4 >> 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 2);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"hello\" == \"hello\"");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"hello\" != \"hello\"");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in [ \"foo\", \"bar\" ]");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in [ \"bar\", \"baz\" ]");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in null");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in \"bar\"");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in [ \"bar\", \"baz\" ]");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in [ \"foo\", \"bar\" ]");
|
||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in null");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in \"bar\"");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "{ a += 3 }");
|
||||
dict = expr->Evaluate(frame).GetValue();
|
||||
delete expr;
|
||||
BOOST_CHECK(dict->GetLength() == 1);
|
||||
BOOST_CHECK(dict->Get("a") == 3);
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "test");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "null + 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 + null");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"test\" + 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "test3");
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"\\\"te\\\\st\"");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "\"te\\st");
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"\\'test\"");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "({ a = 3\nb = 3 })");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue().IsObjectType<Dictionary>());
|
||||
delete expr;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(advanced)
|
||||
{
|
||||
ScriptFrame frame;
|
||||
Expression *expr;
|
||||
std::unique_ptr<Expression> expr;
|
||||
Function::Ptr func;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "regex(\"^Hello\", \"Hello World\")");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "__boost_test()");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
Object::Ptr self = new Object();
|
||||
ScriptFrame frame2(self);
|
||||
expr = ConfigCompiler::CompileText("<test>", "this");
|
||||
BOOST_CHECK(expr->Evaluate(frame2).GetValue() == Value(self));
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "var v = 7; v");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "{ a = 3 }.a");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "[ 2, 3 ][1]");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "var v = { a = 3}; v.a");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "a = 3 b = 3");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "function() { 3 }()");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "function() { return 3, 5 }()");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "typeof([]) == Array");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "typeof({}) == Dictionary");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "typeof(3) == Number");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "typeof(\"test\") == String");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 | 8) == 15");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 ^ 8) == 15");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 & 15) == 7");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "7 in [7] == true");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "7 !in [7] == false");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 | 8) > 14");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 ^ 8) > 14");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "(7 & 15) > 6");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"a\" = 3");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 = 3");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "var e; e");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue().IsEmpty());
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "var e = 3; e");
|
||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "Array.x");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "{{ 3 }}");
|
||||
func = expr->Evaluate(frame).GetValue();
|
||||
BOOST_CHECK(func->Invoke() == 3);
|
||||
delete expr;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -58,7 +58,7 @@ apply Service "livestatus" {
|
|||
}
|
||||
)CONFIG";
|
||||
|
||||
Expression *expr = ConfigCompiler::CompileText("<livestatus>", config);
|
||||
std::unique_ptr<Expression> expr = ConfigCompiler::CompileText("<livestatus>", config);
|
||||
expr->Evaluate(*ScriptFrame::GetCurrentFrame());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue