mirror of https://github.com/Icinga/icinga2.git
parent
dcaad50221
commit
77806b9de7
|
@ -17,11 +17,12 @@
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef VMFRAME_H
|
#ifndef SCRIPTFRAME_H
|
||||||
#define VMFRAME_H
|
#define SCRIPTFRAME_H
|
||||||
|
|
||||||
#include "config/i2-config.hpp"
|
#include "config/i2-config.hpp"
|
||||||
#include "base/dictionary.hpp"
|
#include "base/dictionary.hpp"
|
||||||
|
#include "base/scriptglobal.hpp"
|
||||||
#include <boost/thread/tss.hpp>
|
#include <boost/thread/tss.hpp>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -34,7 +35,7 @@ struct I2_BASE_API ScriptFrame
|
||||||
ScriptFrame *NextFrame;
|
ScriptFrame *NextFrame;
|
||||||
|
|
||||||
ScriptFrame(void)
|
ScriptFrame(void)
|
||||||
: Locals(new Dictionary()), Self(Locals)
|
: Locals(new Dictionary()), Self(ScriptGlobal::GetGlobals())
|
||||||
{
|
{
|
||||||
NextFrame = GetCurrentFrame();
|
NextFrame = GetCurrentFrame();
|
||||||
SetCurrentFrame(this);
|
SetCurrentFrame(this);
|
||||||
|
|
|
@ -162,10 +162,9 @@ library return T_LIBRARY;
|
||||||
null return T_NULL;
|
null return T_NULL;
|
||||||
true { yylval->boolean = 1; return T_BOOLEAN; }
|
true { yylval->boolean = 1; return T_BOOLEAN; }
|
||||||
false { yylval->boolean = 0; return T_BOOLEAN; }
|
false { yylval->boolean = 0; return T_BOOLEAN; }
|
||||||
const return T_GLOBAL;
|
const return T_CONST;
|
||||||
local return T_LOCAL;
|
var return T_VAR;
|
||||||
this return T_THIS;
|
this return T_THIS;
|
||||||
global return T_GLOBAL;
|
|
||||||
use return T_USE;
|
use return T_USE;
|
||||||
apply return T_APPLY;
|
apply return T_APPLY;
|
||||||
to return T_TO;
|
to return T_TO;
|
||||||
|
|
|
@ -141,8 +141,8 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
||||||
%token T_LESS_THAN "< (T_LESS_THAN)"
|
%token T_LESS_THAN "< (T_LESS_THAN)"
|
||||||
%token T_GREATER_THAN "> (T_GREATER_THAN)"
|
%token T_GREATER_THAN "> (T_GREATER_THAN)"
|
||||||
|
|
||||||
%token T_LOCAL "local (T_LOCAL)"
|
%token T_VAR "var (T_VAR)"
|
||||||
%token T_GLOBAL "global (T_GLOBAL)"
|
%token T_CONST "const (T_CONST)"
|
||||||
%token T_USE "use (T_USE)"
|
%token T_USE "use (T_USE)"
|
||||||
%token <type> T_TYPE_DICTIONARY "dictionary (T_TYPE_DICTIONARY)"
|
%token <type> T_TYPE_DICTIONARY "dictionary (T_TYPE_DICTIONARY)"
|
||||||
%token <type> T_TYPE_ARRAY "array (T_TYPE_ARRAY)"
|
%token <type> T_TYPE_ARRAY "array (T_TYPE_ARRAY)"
|
||||||
|
@ -197,7 +197,6 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
||||||
%type <cvlist> use_specifier_items
|
%type <cvlist> use_specifier_items
|
||||||
%type <cvitem> use_specifier_item
|
%type <cvitem> use_specifier_item
|
||||||
%type <num> object_declaration
|
%type <num> object_declaration
|
||||||
%type <scope> scope_specifier
|
|
||||||
|
|
||||||
%right T_FOLLOWS
|
%right T_FOLLOWS
|
||||||
%right T_INCLUDE T_INCLUDE_RECURSIVE T_OBJECT T_TEMPLATE T_APPLY T_IMPORT T_ASSIGN T_IGNORE T_WHERE
|
%right T_INCLUDE T_INCLUDE_RECURSIVE T_OBJECT T_TEMPLATE T_APPLY T_IMPORT T_ASSIGN T_IGNORE T_WHERE
|
||||||
|
@ -219,7 +218,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
||||||
%left UNARY_MINUS
|
%left UNARY_MINUS
|
||||||
%right '!' '~'
|
%right '!' '~'
|
||||||
%left '.' '(' '['
|
%left '.' '(' '['
|
||||||
%left T_LOCAL T_GLOBAL T_THIS
|
%left T_VAR T_THIS
|
||||||
%right ';' ','
|
%right ';' ','
|
||||||
%right T_NEWLINE
|
%right T_NEWLINE
|
||||||
%{
|
%{
|
||||||
|
@ -534,20 +533,6 @@ combined_set_op: T_SET
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
scope_specifier: T_LOCAL
|
|
||||||
{
|
|
||||||
$$ = ScopeLocal;
|
|
||||||
}
|
|
||||||
| T_GLOBAL
|
|
||||||
{
|
|
||||||
$$ = ScopeGlobal;
|
|
||||||
}
|
|
||||||
| T_THIS
|
|
||||||
{
|
|
||||||
$$ = ScopeThis;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
lterm: type
|
lterm: type
|
||||||
{
|
{
|
||||||
$$ = MakeLiteral(); // ASTify this
|
$$ = MakeLiteral(); // ASTify this
|
||||||
|
@ -558,8 +543,7 @@ lterm: type
|
||||||
}
|
}
|
||||||
| rterm combined_set_op rterm
|
| rterm combined_set_op rterm
|
||||||
{
|
{
|
||||||
Expression *expr = $1;
|
$$ = new SetExpression($1, $2, $3, DebugInfoRange(@1, @3));
|
||||||
$$ = new SetExpression(expr, $2, $3, DebugInfoRange(@1, @3));
|
|
||||||
}
|
}
|
||||||
| T_INCLUDE T_STRING
|
| T_INCLUDE T_STRING
|
||||||
{
|
{
|
||||||
|
@ -652,16 +636,10 @@ lterm: type
|
||||||
$$ = new SetExpression(MakeIndexer(ScopeCurrent, $2), OpSetLiteral, fexpr, DebugInfoRange(@1, @7));
|
$$ = new SetExpression(MakeIndexer(ScopeCurrent, $2), OpSetLiteral, fexpr, DebugInfoRange(@1, @7));
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
| scope_specifier T_FUNCTION identifier '(' identifier_items ')' use_specifier rterm_scope
|
| T_CONST T_IDENTIFIER T_SET rterm
|
||||||
{
|
{
|
||||||
DictExpression *aexpr = dynamic_cast<DictExpression *>($8);
|
$$ = new SetExpression(MakeIndexer(ScopeGlobal, $2), OpSetLiteral, $4);
|
||||||
aexpr->MakeInline();
|
free($2);
|
||||||
|
|
||||||
FunctionExpression *fexpr = new FunctionExpression(*$5, $7, aexpr, DebugInfoRange(@1, @8));
|
|
||||||
delete $5;
|
|
||||||
|
|
||||||
$$ = new SetExpression(MakeIndexer($1, $3), OpSetLiteral, fexpr, DebugInfoRange(@1, @8));
|
|
||||||
free($3);
|
|
||||||
}
|
}
|
||||||
| rterm
|
| rterm
|
||||||
{
|
{
|
||||||
|
@ -770,15 +748,21 @@ rterm: T_STRING
|
||||||
{
|
{
|
||||||
$$ = new SubtractExpression(MakeLiteral(0), $2, DebugInfoRange(@1, @2));
|
$$ = new SubtractExpression(MakeLiteral(0), $2, DebugInfoRange(@1, @2));
|
||||||
}
|
}
|
||||||
| scope_specifier
|
| T_THIS
|
||||||
{
|
{
|
||||||
$$ = new GetScopeExpression($1);
|
$$ = new GetScopeExpression(ScopeThis);
|
||||||
}
|
}
|
||||||
| scope_specifier T_IDENTIFIER
|
| T_VAR rterm
|
||||||
{
|
{
|
||||||
Expression *scope = new GetScopeExpression($1);
|
Expression *expr = $2;
|
||||||
$$ = new IndexerExpression(scope, MakeLiteral($2), DebugInfoRange(@1, @2));
|
BindToScope(expr, ScopeLocal);
|
||||||
free($2);
|
$$ = new SetExpression(expr, OpSetLiteral, MakeLiteral(), DebugInfoRange(@1, @2));
|
||||||
|
}
|
||||||
|
| T_VAR rterm combined_set_op rterm
|
||||||
|
{
|
||||||
|
Expression *expr = $2;
|
||||||
|
BindToScope(expr, ScopeLocal);
|
||||||
|
$$ = new SetExpression(expr, $3, $4, DebugInfoRange(@1, @4));
|
||||||
}
|
}
|
||||||
| rterm_array
|
| rterm_array
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue