2013-10-20 15:06:05 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2014-03-19 01:02:29 +01:00
|
|
|
* Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
|
2013-10-20 15:06:05 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-10-16 17:44:06 +02:00
|
|
|
#ifndef EXPRESSION_H
|
|
|
|
#define EXPRESSION_H
|
2013-10-20 15:06:05 +02:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "config/i2-config.hpp"
|
2014-09-09 14:49:21 +02:00
|
|
|
#include "base/debuginfo.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/array.hpp"
|
|
|
|
#include "base/dictionary.hpp"
|
2014-11-15 08:20:22 +01:00
|
|
|
#include "base/scriptfunction.hpp"
|
|
|
|
#include "base/configerror.hpp"
|
|
|
|
#include "base/convert.hpp"
|
2014-11-09 19:48:28 +01:00
|
|
|
#include <boost/foreach.hpp>
|
2014-11-15 08:20:22 +01:00
|
|
|
#include <map>
|
2013-10-20 15:06:05 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2014-08-12 15:31:47 +02:00
|
|
|
struct DebugHint
|
|
|
|
{
|
2014-11-17 10:34:11 +01:00
|
|
|
public:
|
|
|
|
DebugHint(const Dictionary::Ptr& hints = Dictionary::Ptr())
|
|
|
|
: m_Hints(hints)
|
|
|
|
{ }
|
2014-08-12 15:31:47 +02:00
|
|
|
|
|
|
|
inline void AddMessage(const String& message, const DebugInfo& di)
|
|
|
|
{
|
2014-11-17 10:34:11 +01:00
|
|
|
if (!m_Hints)
|
|
|
|
m_Hints = new Dictionary();
|
|
|
|
|
|
|
|
if (!m_Messages) {
|
|
|
|
m_Messages = new Array();
|
|
|
|
m_Hints->Set("messages", m_Messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
Array::Ptr amsg = new Array();
|
|
|
|
amsg->Add(message);
|
|
|
|
amsg->Add(di.Path);
|
|
|
|
amsg->Add(di.FirstLine);
|
|
|
|
amsg->Add(di.FirstColumn);
|
|
|
|
amsg->Add(di.LastLine);
|
|
|
|
amsg->Add(di.LastColumn);
|
|
|
|
m_Messages->Add(amsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DebugHint GetChild(const String& name)
|
|
|
|
{
|
|
|
|
if (!m_Hints)
|
|
|
|
m_Hints = new Dictionary();
|
|
|
|
|
|
|
|
if (!m_Children) {
|
|
|
|
m_Children = new Dictionary;
|
|
|
|
m_Hints->Set("properties", m_Children);
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr child = m_Children->Get(name);
|
|
|
|
|
|
|
|
if (!child) {
|
|
|
|
child = new Dictionary();
|
|
|
|
m_Children->Set(name, child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DebugHint(child);
|
2014-08-12 15:31:47 +02:00
|
|
|
}
|
|
|
|
|
2014-11-17 10:34:11 +01:00
|
|
|
Dictionary::Ptr ToDictionary(void) const
|
2014-08-12 15:31:47 +02:00
|
|
|
{
|
2014-11-17 10:34:11 +01:00
|
|
|
return m_Hints;
|
2014-08-12 15:31:47 +02:00
|
|
|
}
|
|
|
|
|
2014-11-17 10:34:11 +01:00
|
|
|
private:
|
|
|
|
Dictionary::Ptr m_Hints;
|
|
|
|
Array::Ptr m_Messages;
|
|
|
|
Dictionary::Ptr m_Children;
|
2014-08-12 15:31:47 +02:00
|
|
|
};
|
|
|
|
|
2014-11-04 15:19:33 +01:00
|
|
|
enum CombinedSetOp
|
|
|
|
{
|
|
|
|
OpSetLiteral,
|
|
|
|
OpSetAdd,
|
|
|
|
OpSetSubtract,
|
|
|
|
OpSetMultiply,
|
|
|
|
OpSetDivide
|
|
|
|
};
|
|
|
|
|
2014-11-15 08:20:22 +01:00
|
|
|
typedef std::map<String, String> DefinitionMap;
|
|
|
|
|
2013-10-20 15:06:05 +02:00
|
|
|
/**
|
|
|
|
* @ingroup config
|
|
|
|
*/
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API Expression
|
2013-10-20 15:06:05 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-11-09 19:48:28 +01:00
|
|
|
virtual ~Expression(void);
|
|
|
|
|
|
|
|
Value Evaluate(const Object::Ptr& context, DebugHint *dhint = NULL) const;
|
|
|
|
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const = 0;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fp) const = 0;
|
2014-11-09 19:48:28 +01:00
|
|
|
virtual const DebugInfo& GetDebugInfo(void) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
I2_CONFIG_API std::vector<Expression *> MakeIndexer(const String& index1);
|
|
|
|
|
|
|
|
class I2_CONFIG_API OwnedExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OwnedExpression(const boost::shared_ptr<Expression>& expression)
|
|
|
|
: m_Expression(expression)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
|
|
|
|
{
|
|
|
|
return m_Expression->DoEvaluate(context, dhint);
|
|
|
|
}
|
|
|
|
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fp) const
|
|
|
|
{
|
|
|
|
return m_Expression->GenerateCode(definitions, fp);
|
|
|
|
}
|
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
virtual const DebugInfo& GetDebugInfo(void) const
|
|
|
|
{
|
|
|
|
return m_Expression->GetDebugInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
boost::shared_ptr<Expression> m_Expression;
|
|
|
|
};
|
|
|
|
|
2014-11-15 08:20:22 +01:00
|
|
|
class I2_CONFIG_API NativeExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Value (*Callback)(const Object::Ptr& context);
|
|
|
|
|
|
|
|
NativeExpression(Callback callback)
|
|
|
|
: m_Callback(callback)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
|
|
|
|
{
|
|
|
|
return m_Callback(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fp) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Native expression does not support codegen.");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Callback m_Callback;
|
|
|
|
};
|
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API LiteralExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LiteralExpression(const Value& value = Value());
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fp) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Value m_Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline LiteralExpression *MakeLiteral(const Value& literal = Value())
|
|
|
|
{
|
|
|
|
return new LiteralExpression(literal);
|
|
|
|
}
|
|
|
|
|
|
|
|
class I2_CONFIG_API DebuggableExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
DebuggableExpression(const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: m_DebugInfo(debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual const DebugInfo& GetDebugInfo(void) const;
|
|
|
|
|
|
|
|
DebugInfo m_DebugInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API UnaryExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
UnaryExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Operand(operand)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~UnaryExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Expression *m_Operand;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API BinaryExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
BinaryExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Operand1(operand1), m_Operand2(operand2)
|
|
|
|
{ }
|
2014-03-22 10:29:45 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
~BinaryExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Operand1;
|
|
|
|
delete m_Operand2;
|
|
|
|
}
|
2013-10-20 15:06:05 +02:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
protected:
|
|
|
|
Expression *m_Operand1;
|
|
|
|
Expression *m_Operand2;
|
|
|
|
};
|
2013-10-20 15:06:05 +02:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
class I2_CONFIG_API VariableExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
VariableExpression(const String& variable, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Variable(variable)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
String m_Variable;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API NegateExpression : public UnaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
NegateExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: UnaryExpression(operand, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API LogicalNegateExpression : public UnaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
LogicalNegateExpression(Expression *operand, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: UnaryExpression(operand, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API AddExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
AddExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API SubtractExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
SubtractExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API MultiplyExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
MultiplyExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API DivideExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
DivideExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API BinaryAndExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
BinaryAndExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API BinaryOrExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
BinaryOrExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API ShiftLeftExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ShiftLeftExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API ShiftRightExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ShiftRightExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API EqualExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
EqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API NotEqualExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
NotEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API LessThanExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
LessThanExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API GreaterThanExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
GreaterThanExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API LessThanOrEqualExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
LessThanOrEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API GreaterThanOrEqualExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
GreaterThanOrEqualExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API InExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
InExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API NotInExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
NotInExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API LogicalAndExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
LogicalAndExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API LogicalOrExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
LogicalOrExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API FunctionCallExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
FunctionCallExpression(Expression *fname, const std::vector<Expression *>& args, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_FName(fname), m_Args(args)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~FunctionCallExpression(void)
|
|
|
|
{
|
|
|
|
delete m_FName;
|
|
|
|
|
|
|
|
BOOST_FOREACH(Expression *expr, m_Args)
|
|
|
|
delete expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
Expression *m_FName;
|
|
|
|
std::vector<Expression *> m_Args;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API ArrayExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ArrayExpression(const std::vector<Expression *>& expressions, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Expressions(expressions)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~ArrayExpression(void)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(Expression *expr, m_Expressions)
|
|
|
|
delete expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Expression *> m_Expressions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API DictExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
DictExpression(const std::vector<Expression *>& expressions, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Expressions(expressions), m_Inline(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~DictExpression(void)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(Expression *expr, m_Expressions)
|
|
|
|
delete expr;
|
|
|
|
}
|
2013-10-20 15:06:05 +02:00
|
|
|
|
2014-03-23 11:27:40 +01:00
|
|
|
void MakeInline(void);
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Expression *> m_Expressions;
|
|
|
|
bool m_Inline;
|
|
|
|
};
|
2014-03-23 11:27:40 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API SetExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
SetExpression(const std::vector<Expression *>& indexer, CombinedSetOp op, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Op(op), m_Indexer(indexer), m_Operand2(operand2)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~SetExpression(void)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(Expression *expr, m_Indexer)
|
|
|
|
delete expr;
|
|
|
|
|
|
|
|
delete m_Operand2;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-03-22 10:29:45 +01:00
|
|
|
|
2013-10-20 15:06:05 +02:00
|
|
|
private:
|
2014-11-09 19:48:28 +01:00
|
|
|
CombinedSetOp m_Op;
|
|
|
|
std::vector<Expression *> m_Indexer;
|
|
|
|
Expression *m_Operand2;
|
|
|
|
|
|
|
|
};
|
2014-11-15 08:20:22 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API IndexerExpression : public BinaryExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
IndexerExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: BinaryExpression(operand1, operand2, debugInfo)
|
|
|
|
{ }
|
2014-03-22 10:29:45 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
};
|
2014-11-15 08:20:22 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API ImportExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ImportExpression(Expression *type, Expression *name, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Type(type), m_Name(name)
|
|
|
|
{ }
|
2014-03-23 19:58:24 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
~ImportExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Type;
|
|
|
|
delete m_Name;
|
|
|
|
}
|
2014-03-30 15:04:53 +02:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-06 19:35:47 +01:00
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
private:
|
|
|
|
Expression *m_Type;
|
|
|
|
Expression *m_Name;
|
2013-10-20 15:06:05 +02:00
|
|
|
};
|
|
|
|
|
2014-11-15 08:20:22 +01:00
|
|
|
I2_CONFIG_API String CodeGenExpression(DefinitionMap& definitions, Expression *expression);
|
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API FunctionExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
FunctionExpression(const String& name, const std::vector<String>& args, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_Expression(expression)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
String m_Name;
|
|
|
|
std::vector<String> m_Args;
|
|
|
|
boost::shared_ptr<Expression> m_Expression;
|
|
|
|
};
|
|
|
|
|
2014-11-20 06:53:57 +01:00
|
|
|
class I2_CONFIG_API SlotExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SlotExpression(const String& signal, Expression *slot, const DebugInfo& debugInfo = DebugInfo())
|
|
|
|
: DebuggableExpression(debugInfo), m_Signal(signal), m_Slot(slot)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-20 06:53:57 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
String m_Signal;
|
|
|
|
Expression *m_Slot;
|
|
|
|
};
|
|
|
|
|
2014-11-09 19:48:28 +01:00
|
|
|
class I2_CONFIG_API ApplyExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ApplyExpression(const String& type, const String& target, Expression *name,
|
|
|
|
Expression *filter, const String& fkvar, const String& fvvar,
|
2014-11-13 23:25:31 +01:00
|
|
|
Expression *fterm, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Type(type), m_Target(target),
|
|
|
|
m_Name(name), m_Filter(filter), m_FKVar(fkvar), m_FVVar(fvvar),
|
|
|
|
m_FTerm(fterm), m_Expression(expression)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~ApplyExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
String m_Type;
|
|
|
|
String m_Target;
|
|
|
|
Expression *m_Name;
|
|
|
|
boost::shared_ptr<Expression> m_Filter;
|
|
|
|
String m_FKVar;
|
|
|
|
String m_FVVar;
|
|
|
|
boost::shared_ptr<Expression> m_FTerm;
|
|
|
|
boost::shared_ptr<Expression> m_Expression;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API ObjectExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter, const String& zone, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type), m_Name(name), m_Filter(filter), m_Zone(zone), m_Expression(expression)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~ObjectExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_Abstract;
|
|
|
|
String m_Type;
|
|
|
|
Expression *m_Name;
|
|
|
|
boost::shared_ptr<Expression> m_Filter;
|
|
|
|
String m_Zone;
|
|
|
|
boost::shared_ptr<Expression> m_Expression;
|
|
|
|
};
|
|
|
|
|
|
|
|
class I2_CONFIG_API ForExpression : public DebuggableExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 23:25:31 +01:00
|
|
|
ForExpression(const String& fkvar, const String& fvvar, Expression *value, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
2014-11-09 19:48:28 +01:00
|
|
|
: DebuggableExpression(debugInfo), m_FKVar(fkvar), m_FVVar(fvvar), m_Value(value), m_Expression(expression)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~ForExpression(void)
|
|
|
|
{
|
|
|
|
delete m_Value;
|
|
|
|
delete m_Expression;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Value DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const;
|
2014-11-15 08:20:22 +01:00
|
|
|
virtual void GenerateCode(DefinitionMap& definitions, std::ostream& fpg) const;
|
2014-11-09 19:48:28 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
String m_FKVar;
|
|
|
|
String m_FVVar;
|
|
|
|
Expression *m_Value;
|
|
|
|
Expression *m_Expression;
|
|
|
|
};
|
2014-11-04 15:19:33 +01:00
|
|
|
|
2013-10-20 15:06:05 +02:00
|
|
|
}
|
|
|
|
|
2014-10-16 17:44:06 +02:00
|
|
|
#endif /* EXPRESSION_H */
|