mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Expr: move all classes into zeek::detail
This commit is contained in:
parent
3fa4acc175
commit
cbdb8ee074
34 changed files with 314 additions and 248 deletions
|
@ -23,7 +23,7 @@ const char* attr_name(attr_tag t)
|
||||||
return attr_names[int(t)];
|
return attr_names[int(t)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Attr::Attr(attr_tag t, IntrusivePtr<Expr> e)
|
Attr::Attr(attr_tag t, IntrusivePtr<zeek::detail::Expr> e)
|
||||||
: expr(std::move(e))
|
: expr(std::move(e))
|
||||||
{
|
{
|
||||||
tag = t;
|
tag = t;
|
||||||
|
@ -90,7 +90,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const
|
||||||
d->Add("=");
|
d->Add("=");
|
||||||
d->SP();
|
d->SP();
|
||||||
|
|
||||||
if ( expr->Tag() == EXPR_NAME )
|
if ( expr->Tag() == zeek::detail::EXPR_NAME )
|
||||||
{
|
{
|
||||||
d->Add(":zeek:see:`");
|
d->Add(":zeek:see:`");
|
||||||
expr->Describe(d);
|
expr->Describe(d);
|
||||||
|
@ -104,7 +104,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const
|
||||||
d->Add("`");
|
d->Add("`");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( expr->Tag() == EXPR_CONST )
|
else if ( expr->Tag() == zeek::detail::EXPR_CONST )
|
||||||
{
|
{
|
||||||
ODesc dd;
|
ODesc dd;
|
||||||
dd.SetQuotes(true);
|
dd.SetQuotes(true);
|
||||||
|
|
12
src/Attr.h
12
src/Attr.h
|
@ -8,7 +8,7 @@
|
||||||
#include "BroList.h"
|
#include "BroList.h"
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
class Expr;
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
// Note that there are two kinds of attributes: the kind (here) which
|
// Note that there are two kinds of attributes: the kind (here) which
|
||||||
// modify expressions or supply metadata on types, and the kind that
|
// modify expressions or supply metadata on types, and the kind that
|
||||||
|
@ -40,19 +40,19 @@ class Attr final : public BroObj {
|
||||||
public:
|
public:
|
||||||
static inline const IntrusivePtr<Attr> nil;
|
static inline const IntrusivePtr<Attr> nil;
|
||||||
|
|
||||||
Attr(attr_tag t, IntrusivePtr<Expr> e);
|
Attr(attr_tag t, IntrusivePtr<zeek::detail::Expr> e);
|
||||||
explicit Attr(attr_tag t);
|
explicit Attr(attr_tag t);
|
||||||
~Attr() override;
|
~Attr() override;
|
||||||
|
|
||||||
attr_tag Tag() const { return tag; }
|
attr_tag Tag() const { return tag; }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetExpr().")]]
|
[[deprecated("Remove in v4.1. Use GetExpr().")]]
|
||||||
Expr* AttrExpr() const { return expr.get(); }
|
zeek::detail::Expr* AttrExpr() const { return expr.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<Expr>& GetExpr() const
|
const IntrusivePtr<zeek::detail::Expr>& GetExpr() const
|
||||||
{ return expr; }
|
{ return expr; }
|
||||||
|
|
||||||
void SetAttrExpr(IntrusivePtr<Expr> e);
|
void SetAttrExpr(IntrusivePtr<zeek::detail::Expr> e);
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
void DescribeReST(ODesc* d, bool shorten = false) const;
|
void DescribeReST(ODesc* d, bool shorten = false) const;
|
||||||
|
@ -75,7 +75,7 @@ protected:
|
||||||
void AddTag(ODesc* d) const;
|
void AddTag(ODesc* d) const;
|
||||||
|
|
||||||
attr_tag tag;
|
attr_tag tag;
|
||||||
IntrusivePtr<Expr> expr;
|
IntrusivePtr<zeek::detail::Expr> expr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Manages a collection of attributes.
|
// Manages a collection of attributes.
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
|
|
||||||
class Expr;
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
typedef PList<Expr> expr_list;
|
typedef PList<zeek::detail::Expr> expr_list;
|
||||||
|
|
||||||
class ID;
|
class ID;
|
||||||
typedef PList<ID> id_list;
|
typedef PList<ID> id_list;
|
||||||
|
|
|
@ -12,7 +12,7 @@ DbgWatch::DbgWatch(BroObj* var_to_watch)
|
||||||
reporter->InternalError("DbgWatch unimplemented");
|
reporter->InternalError("DbgWatch unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgWatch::DbgWatch(Expr* expr_to_watch)
|
DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch)
|
||||||
{
|
{
|
||||||
reporter->InternalError("DbgWatch unimplemented");
|
reporter->InternalError("DbgWatch unimplemented");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class BroObj;
|
class BroObj;
|
||||||
class Expr;
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
class DbgWatch {
|
class DbgWatch {
|
||||||
public:
|
public:
|
||||||
explicit DbgWatch(BroObj* var_to_watch);
|
explicit DbgWatch(BroObj* var_to_watch);
|
||||||
explicit DbgWatch(Expr* expr_to_watch);
|
explicit DbgWatch(zeek::detail::Expr* expr_to_watch);
|
||||||
~DbgWatch();
|
~DbgWatch();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BroObj* var;
|
BroObj* var;
|
||||||
Expr* expr;
|
zeek::detail::Expr* expr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -935,7 +935,7 @@ bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, Val* result, stmt_flo
|
||||||
|
|
||||||
// Evaluates the given expression in the context of the currently selected
|
// Evaluates the given expression in the context of the currently selected
|
||||||
// frame. Returns the resulting value, or nil if none (or there was an error).
|
// frame. Returns the resulting value, or nil if none (or there was an error).
|
||||||
Expr* g_curr_debug_expr = nullptr;
|
zeek::detail::Expr* g_curr_debug_expr = nullptr;
|
||||||
const char* g_curr_debug_error = nullptr;
|
const char* g_curr_debug_error = nullptr;
|
||||||
bool in_debug = false;
|
bool in_debug = false;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "broker/Data.h"
|
#include "broker/Data.h"
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
const char* expr_name(BroExprTag t)
|
const char* expr_name(BroExprTag t)
|
||||||
{
|
{
|
||||||
static const char* expr_names[int(NUM_EXPRS)] = {
|
static const char* expr_names[int(NUM_EXPRS)] = {
|
||||||
|
@ -5055,3 +5057,5 @@ bool expr_greater(const Expr* e1, const Expr* e2)
|
||||||
{
|
{
|
||||||
return e1->Tag() > e2->Tag();
|
return e1->Tag() > e2->Tag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
67
src/Expr.h
67
src/Expr.h
|
@ -17,6 +17,13 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "ZeekArgs.h"
|
#include "ZeekArgs.h"
|
||||||
|
|
||||||
|
template <class T> class IntrusivePtr;
|
||||||
|
class Frame;
|
||||||
|
class Scope;
|
||||||
|
struct function_ingredients;
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
enum BroExprTag : int {
|
enum BroExprTag : int {
|
||||||
EXPR_ANY = -1,
|
EXPR_ANY = -1,
|
||||||
EXPR_NAME, EXPR_CONST,
|
EXPR_NAME, EXPR_CONST,
|
||||||
|
@ -58,19 +65,13 @@ enum BroExprTag : int {
|
||||||
|
|
||||||
extern const char* expr_name(BroExprTag t);
|
extern const char* expr_name(BroExprTag t);
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
|
||||||
class Frame;
|
|
||||||
class Scope;
|
|
||||||
class ListExpr;
|
class ListExpr;
|
||||||
class NameExpr;
|
class NameExpr;
|
||||||
class IndexExpr;
|
class IndexExpr;
|
||||||
class AssignExpr;
|
class AssignExpr;
|
||||||
class CallExpr;
|
class CallExpr;
|
||||||
class EventExpr;
|
class EventExpr;
|
||||||
|
class Stmt;
|
||||||
struct function_ingredients;
|
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
|
||||||
|
|
||||||
class Expr : public BroObj {
|
class Expr : public BroObj {
|
||||||
public:
|
public:
|
||||||
|
@ -953,3 +954,55 @@ extern bool expr_greater(const Expr* e1, const Expr* e2);
|
||||||
// True if the given Expr* has a vector type
|
// True if the given Expr* has a vector type
|
||||||
inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; }
|
inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; }
|
||||||
inline bool is_vector(const IntrusivePtr<Expr>& e) { return is_vector(e.get()); }
|
inline bool is_vector(const IntrusivePtr<Expr>& e) { return is_vector(e.get()); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using Expr [[deprecated("Remove in v4.1. Use zeek::detail::Expr instead.")]] = zeek::detail::Expr;
|
||||||
|
using NameExpr [[deprecated("Remove in v4.1. Use zeek::detail::NameExpr instead.")]] = zeek::detail::NameExpr;
|
||||||
|
using ConstExpr [[deprecated("Remove in v4.1. Use zeek::detail::ConstExpr instead.")]] = zeek::detail::ConstExpr;
|
||||||
|
using UnaryExpr [[deprecated("Remove in v4.1. Use zeek::detail::UnaryExpr instead.")]] = zeek::detail::UnaryExpr;
|
||||||
|
using BinaryExpr [[deprecated("Remove in v4.1. Use zeek::detail::BinaryExpr instead.")]] = zeek::detail::BinaryExpr;
|
||||||
|
using CloneExpr [[deprecated("Remove in v4.1. Use zeek::detail::CloneExpr instead.")]] = zeek::detail::CloneExpr;
|
||||||
|
using IncrExpr [[deprecated("Remove in v4.1. Use zeek::detail::IncrExpr instead.")]] = zeek::detail::IncrExpr;
|
||||||
|
using ComplementExpr [[deprecated("Remove in v4.1. Use zeek::detail::ComplementExpr instead.")]] = zeek::detail::ComplementExpr;
|
||||||
|
using NotExpr [[deprecated("Remove in v4.1. Use zeek::detail::NotExpr instead.")]] = zeek::detail::NotExpr;
|
||||||
|
using PosExpr [[deprecated("Remove in v4.1. Use zeek::detail::PosExpr instead.")]] = zeek::detail::PosExpr;
|
||||||
|
using NegExpr [[deprecated("Remove in v4.1. Use zeek::detail::NegExpr instead.")]] = zeek::detail::NegExpr;
|
||||||
|
using SizeExpr [[deprecated("Remove in v4.1. Use zeek::detail::SizeExpr instead.")]] = zeek::detail::SizeExpr;
|
||||||
|
using AddExpr [[deprecated("Remove in v4.1. Use zeek::detail::AddExpr instead.")]] = zeek::detail::AddExpr;
|
||||||
|
using AddToExpr [[deprecated("Remove in v4.1. Use zeek::detail::AddToExpr instead.")]] = zeek::detail::AddToExpr;
|
||||||
|
using RemoveFromExpr [[deprecated("Remove in v4.1. Use zeek::detail::RemoveFromExpr instead.")]] = zeek::detail::RemoveFromExpr;
|
||||||
|
using SubExpr [[deprecated("Remove in v4.1. Use zeek::detail::SubExpr instead.")]] = zeek::detail::SubExpr;
|
||||||
|
using TimesExpr [[deprecated("Remove in v4.1. Use zeek::detail::TimesExpr instead.")]] = zeek::detail::TimesExpr;
|
||||||
|
using DivideExpr [[deprecated("Remove in v4.1. Use zeek::detail::DivideExpr instead.")]] = zeek::detail::DivideExpr;
|
||||||
|
using ModExpr [[deprecated("Remove in v4.1. Use zeek::detail::ModExpr instead.")]] = zeek::detail::ModExpr;
|
||||||
|
using BoolExpr [[deprecated("Remove in v4.1. Use zeek::detail::BoolExpr instead.")]] = zeek::detail::BoolExpr;
|
||||||
|
using BitExpr [[deprecated("Remove in v4.1. Use zeek::detail::BitExpr instead.")]] = zeek::detail::BitExpr;
|
||||||
|
using EqExpr [[deprecated("Remove in v4.1. Use zeek::detail::EqExpr instead.")]] = zeek::detail::EqExpr;
|
||||||
|
using RelExpr [[deprecated("Remove in v4.1. Use zeek::detail::RelExpr instead.")]] = zeek::detail::RelExpr;
|
||||||
|
using CondExpr [[deprecated("Remove in v4.1. Use zeek::detail::CondExpr instead.")]] = zeek::detail::CondExpr;
|
||||||
|
using RefExpr [[deprecated("Remove in v4.1. Use zeek::detail::RefExpr instead.")]] = zeek::detail::RefExpr;
|
||||||
|
using AssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::AssignExpr instead.")]] = zeek::detail::AssignExpr;
|
||||||
|
using IndexSliceAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::IndexSliceAssignExpr instead.")]] = zeek::detail::IndexSliceAssignExpr;
|
||||||
|
using IndexExpr [[deprecated("Remove in v4.1. Use zeek::detail::IndexExpr instead.")]] = zeek::detail::IndexExpr;
|
||||||
|
using FieldExpr [[deprecated("Remove in v4.1. Use zeek::detail::FieldExpr instead.")]] = zeek::detail::FieldExpr;
|
||||||
|
using HasFieldExpr [[deprecated("Remove in v4.1. Use zeek::detail::HasFieldExpr instead.")]] = zeek::detail::HasFieldExpr;
|
||||||
|
using RecordConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordConstructorExpr instead.")]] = zeek::detail::RecordConstructorExpr;
|
||||||
|
using TableConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::TableConstructorExpr instead.")]] = zeek::detail::TableConstructorExpr;
|
||||||
|
using SetConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::SetConstructorExpr instead.")]] = zeek::detail::SetConstructorExpr;
|
||||||
|
using VectorConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::VectorConstructorExpr instead.")]] = zeek::detail::VectorConstructorExpr;
|
||||||
|
using FieldAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::FieldAssignExpr instead.")]] = zeek::detail::FieldAssignExpr;
|
||||||
|
using ArithCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::ArithCoerceExpr instead.")]] = zeek::detail::ArithCoerceExpr;
|
||||||
|
using RecordCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordCoerceExpr instead.")]] = zeek::detail::RecordCoerceExpr;
|
||||||
|
using TableCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::TableCoerceExpr instead.")]] = zeek::detail::TableCoerceExpr;
|
||||||
|
using VectorCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::VectorCoerceExpr instead.")]] = zeek::detail::VectorCoerceExpr;
|
||||||
|
using ScheduleTimer [[deprecated("Remove in v4.1. Use zeek::detail::ScheduleTimer instead.")]] = zeek::detail::ScheduleTimer;
|
||||||
|
using ScheduleExpr [[deprecated("Remove in v4.1. Use zeek::detail::ScheduleExpr instead.")]] = zeek::detail::ScheduleExpr;
|
||||||
|
using InExpr [[deprecated("Remove in v4.1. Use zeek::detail::InExpr instead.")]] = zeek::detail::InExpr;
|
||||||
|
using CallExpr [[deprecated("Remove in v4.1. Use zeek::detail::CallExpr instead.")]] = zeek::detail::CallExpr;
|
||||||
|
using LambdaExpr [[deprecated("Remove in v4.1. Use zeek::detail::LambdaExpr instead.")]] = zeek::detail::LambdaExpr;
|
||||||
|
using EventExpr [[deprecated("Remove in v4.1. Use zeek::detail::EventExpr instead.")]] = zeek::detail::EventExpr;
|
||||||
|
using ListExpr [[deprecated("Remove in v4.1. Use zeek::detail::ListExpr instead.")]] = zeek::detail::ListExpr;
|
||||||
|
using RecordAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordAssignExpr instead.")]] = zeek::detail::RecordAssignExpr;
|
||||||
|
using CastExpr [[deprecated("Remove in v4.1. Use zeek::detail::CastExpr instead.")]] = zeek::detail::CastExpr;
|
||||||
|
using IsExpr [[deprecated("Remove in v4.1. Use zeek::detail::IsExpr instead.")]] = zeek::detail::IsExpr;
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
#include <broker/expected.hh>
|
#include <broker/expected.hh>
|
||||||
|
|
||||||
namespace trigger { class Trigger; }
|
namespace trigger { class Trigger; }
|
||||||
class CallExpr;
|
|
||||||
class BroFunc;
|
class BroFunc;
|
||||||
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
|
||||||
class Frame : public BroObj {
|
class Frame : public BroObj {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -219,9 +220,9 @@ public:
|
||||||
void ClearTrigger();
|
void ClearTrigger();
|
||||||
trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
||||||
|
|
||||||
void SetCall(const CallExpr* arg_call) { call = arg_call; }
|
void SetCall(const zeek::detail::CallExpr* arg_call) { call = arg_call; }
|
||||||
void ClearCall() { call = nullptr; }
|
void ClearCall() { call = nullptr; }
|
||||||
const CallExpr* GetCall() const { return call; }
|
const zeek::detail::CallExpr* GetCall() const { return call; }
|
||||||
|
|
||||||
void SetDelayed() { delayed = true; }
|
void SetDelayed() { delayed = true; }
|
||||||
bool HasDelayed() const { return delayed; }
|
bool HasDelayed() const { return delayed; }
|
||||||
|
@ -322,7 +323,7 @@ private:
|
||||||
zeek::detail::Stmt* next_stmt;
|
zeek::detail::Stmt* next_stmt;
|
||||||
|
|
||||||
IntrusivePtr<trigger::Trigger> trigger;
|
IntrusivePtr<trigger::Trigger> trigger;
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
|
|
||||||
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;
|
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;
|
||||||
};
|
};
|
||||||
|
|
10
src/Func.cc
10
src/Func.cc
|
@ -343,7 +343,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
}
|
}
|
||||||
|
|
||||||
g_frame_stack.push_back(f.get()); // used for backtracing
|
g_frame_stack.push_back(f.get()); // used for backtracing
|
||||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||||
|
|
||||||
if ( g_trace_state.DoTrace() )
|
if ( g_trace_state.DoTrace() )
|
||||||
|
@ -641,7 +641,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
g_trace_state.LogTrace("\tBuiltin Function called: %s\n", d.Description());
|
g_trace_state.LogTrace("\tBuiltin Function called: %s\n", d.Description());
|
||||||
}
|
}
|
||||||
|
|
||||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||||
auto result = std::move(func(parent, args).rval);
|
auto result = std::move(func(parent, args).rval);
|
||||||
call_stack.pop_back();
|
call_stack.pop_back();
|
||||||
|
@ -675,7 +675,7 @@ void builtin_error(const char* msg, IntrusivePtr<Val> arg)
|
||||||
|
|
||||||
void builtin_error(const char* msg, BroObj* arg)
|
void builtin_error(const char* msg, BroObj* arg)
|
||||||
{
|
{
|
||||||
auto emit = [=](const CallExpr* ce)
|
auto emit = [=](const zeek::detail::CallExpr* ce)
|
||||||
{
|
{
|
||||||
if ( ce )
|
if ( ce )
|
||||||
ce->Error(msg, arg);
|
ce->Error(msg, arg);
|
||||||
|
@ -789,7 +789,7 @@ void init_builtin_funcs_subdirs()
|
||||||
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
|
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call)
|
||||||
{
|
{
|
||||||
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
|
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
|
||||||
return true;
|
return true;
|
||||||
|
@ -802,7 +802,7 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Expr* fmt_str_arg = args[0];
|
const zeek::detail::Expr* fmt_str_arg = args[0];
|
||||||
if ( fmt_str_arg->GetType()->Tag() != TYPE_STRING )
|
if ( fmt_str_arg->GetType()->Tag() != TYPE_STRING )
|
||||||
{
|
{
|
||||||
call->Error("first argument to fmt() needs to be a format string");
|
call->Error("first argument to fmt() needs to be a format string");
|
||||||
|
|
|
@ -20,14 +20,13 @@
|
||||||
#include "ZeekArgs.h"
|
#include "ZeekArgs.h"
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
class ListExpr;
|
|
||||||
class FuncType;
|
class FuncType;
|
||||||
class Frame;
|
class Frame;
|
||||||
class ID;
|
class ID;
|
||||||
class CallExpr;
|
|
||||||
class Scope;
|
class Scope;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
|
||||||
class Func : public BroObj {
|
class Func : public BroObj {
|
||||||
public:
|
public:
|
||||||
|
@ -254,10 +253,10 @@ extern void builtin_error(const char* msg, BroObj* arg);
|
||||||
extern void init_builtin_funcs();
|
extern void init_builtin_funcs();
|
||||||
extern void init_builtin_funcs_subdirs();
|
extern void init_builtin_funcs_subdirs();
|
||||||
|
|
||||||
extern bool check_built_in_call(BuiltinFunc* f, CallExpr* call);
|
extern bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call);
|
||||||
|
|
||||||
struct CallInfo {
|
struct CallInfo {
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
const Func* func;
|
const Func* func;
|
||||||
const zeek::Args& args;
|
const zeek::Args& args;
|
||||||
};
|
};
|
||||||
|
|
14
src/ID.cc
14
src/ID.cc
|
@ -205,7 +205,7 @@ void ID::SetVal(IntrusivePtr<Val> v, init_class c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::SetVal(IntrusivePtr<Expr> ev, init_class c)
|
void ID::SetVal(IntrusivePtr<zeek::detail::Expr> ev, init_class c)
|
||||||
{
|
{
|
||||||
const auto& a = attrs->Find(c == INIT_EXTRA ? ATTR_ADD_FUNC : ATTR_DEL_FUNC);
|
const auto& a = attrs->Find(c == INIT_EXTRA ? ATTR_ADD_FUNC : ATTR_DEL_FUNC);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ bool ID::IsDeprecated() const
|
||||||
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
void ID::MakeDeprecated(IntrusivePtr<zeek::detail::Expr> deprecation)
|
||||||
{
|
{
|
||||||
if ( IsDeprecated() )
|
if ( IsDeprecated() )
|
||||||
return;
|
return;
|
||||||
|
@ -292,7 +292,7 @@ std::string ID::GetDeprecationWarning() const
|
||||||
|
|
||||||
if ( depr_attr )
|
if ( depr_attr )
|
||||||
{
|
{
|
||||||
auto expr = static_cast<ConstExpr*>(depr_attr->GetExpr().get());
|
auto expr = static_cast<zeek::detail::ConstExpr*>(depr_attr->GetExpr().get());
|
||||||
if ( expr )
|
if ( expr )
|
||||||
{
|
{
|
||||||
StringVal* text = expr->Value()->AsStringVal();
|
StringVal* text = expr->Value()->AsStringVal();
|
||||||
|
@ -337,13 +337,13 @@ void ID::SetOption()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
void ID::EvalFunc(IntrusivePtr<zeek::detail::Expr> ef, IntrusivePtr<zeek::detail::Expr> ev)
|
||||||
{
|
{
|
||||||
auto arg1 = make_intrusive<ConstExpr>(val);
|
auto arg1 = make_intrusive<zeek::detail::ConstExpr>(val);
|
||||||
auto args = make_intrusive<ListExpr>();
|
auto args = make_intrusive<zeek::detail::ListExpr>();
|
||||||
args->Append(std::move(arg1));
|
args->Append(std::move(arg1));
|
||||||
args->Append(std::move(ev));
|
args->Append(std::move(ev));
|
||||||
auto ce = make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
auto ce = make_intrusive<zeek::detail::CallExpr>(std::move(ef), std::move(args));
|
||||||
SetVal(ce->Eval(nullptr));
|
SetVal(ce->Eval(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
src/ID.h
9
src/ID.h
|
@ -14,7 +14,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
class Expr;
|
|
||||||
class Func;
|
class Func;
|
||||||
class BroType;
|
class BroType;
|
||||||
class RecordType;
|
class RecordType;
|
||||||
|
@ -23,6 +22,8 @@ class VectorType;
|
||||||
class EnumType;
|
class EnumType;
|
||||||
class Attributes;
|
class Attributes;
|
||||||
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
typedef enum { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, } init_class;
|
typedef enum { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, } init_class;
|
||||||
typedef enum { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL } IDScope;
|
typedef enum { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL } IDScope;
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ public:
|
||||||
void SetVal(IntrusivePtr<Val> v);
|
void SetVal(IntrusivePtr<Val> v);
|
||||||
|
|
||||||
void SetVal(IntrusivePtr<Val> v, init_class c);
|
void SetVal(IntrusivePtr<Val> v, init_class c);
|
||||||
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
void SetVal(IntrusivePtr<zeek::detail::Expr> ev, init_class c);
|
||||||
|
|
||||||
bool HasVal() const { return val != nullptr; }
|
bool HasVal() const { return val != nullptr; }
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ public:
|
||||||
|
|
||||||
bool IsDeprecated() const;
|
bool IsDeprecated() const;
|
||||||
|
|
||||||
void MakeDeprecated(IntrusivePtr<Expr> deprecation);
|
void MakeDeprecated(IntrusivePtr<zeek::detail::Expr> deprecation);
|
||||||
|
|
||||||
std::string GetDeprecationWarning() const;
|
std::string GetDeprecationWarning() const;
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public:
|
||||||
std::vector<Func*> GetOptionHandlers() const;
|
std::vector<Func*> GetOptionHandlers() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev);
|
void EvalFunc(IntrusivePtr<zeek::detail::Expr> ef, IntrusivePtr<zeek::detail::Expr> ev);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpdateValID();
|
void UpdateValID();
|
||||||
|
|
|
@ -143,7 +143,7 @@ void Reporter::FatalErrorWithCore(const char* fmt, ...)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reporter::ExprRuntimeError(const Expr* expr, const char* fmt, ...)
|
void Reporter::ExprRuntimeError(const zeek::detail::Expr* expr, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
++errors;
|
++errors;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPAddr;
|
class IPAddr;
|
||||||
class Expr;
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
#define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess.
|
#define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess.
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public:
|
||||||
|
|
||||||
// Report a runtime error in evaluating a Bro script expression. This
|
// Report a runtime error in evaluating a Bro script expression. This
|
||||||
// function will not return but raise an InterpreterException.
|
// function will not return but raise an InterpreterException.
|
||||||
[[noreturn]] void ExprRuntimeError(const Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
[[noreturn]] void ExprRuntimeError(const zeek::detail::Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
// Report a runtime error in evaluating a Bro script expression. This
|
// Report a runtime error in evaluating a Bro script expression. This
|
||||||
// function will not return but raise an InterpreterException.
|
// function will not return but raise an InterpreterException.
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
#include "TraverseTypes.h"
|
#include "TraverseTypes.h"
|
||||||
|
|
||||||
class CompositeHash;
|
class CompositeHash;
|
||||||
class EventExpr;
|
|
||||||
class ListExpr;
|
|
||||||
class Frame;
|
class Frame;
|
||||||
|
|
||||||
namespace zeek::detail {
|
namespace zeek::detail {
|
||||||
|
|
||||||
class StmtList;
|
class StmtList;
|
||||||
class ForStmt;
|
class ForStmt;
|
||||||
|
class EventExpr;
|
||||||
|
class ListExpr;
|
||||||
|
|
||||||
class Stmt : public BroObj {
|
class Stmt : public BroObj {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
class Func;
|
class Func;
|
||||||
class Scope;
|
class Scope;
|
||||||
class Expr;
|
|
||||||
class ID;
|
class ID;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
class TraversalCallback {
|
class TraversalCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -22,8 +22,8 @@ public:
|
||||||
virtual TraversalCode PreStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
virtual TraversalCode PreStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
virtual TraversalCode PostStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreExpr(const Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PreExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostExpr(const Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PostExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreID(const ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostID(const ID*) { return TC_CONTINUE; }
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "iosource/Manager.h"
|
#include "iosource/Manager.h"
|
||||||
|
|
||||||
using namespace trigger;
|
using namespace trigger;
|
||||||
|
using namespace zeek::detail;
|
||||||
|
|
||||||
// Callback class to traverse an expression, registering all relevant IDs and
|
// Callback class to traverse an expression, registering all relevant IDs and
|
||||||
// Vals for change notifications.
|
// Vals for change notifications.
|
||||||
|
@ -30,7 +31,7 @@ public:
|
||||||
~TriggerTraversalCallback()
|
~TriggerTraversalCallback()
|
||||||
{ Unref(trigger); }
|
{ Unref(trigger); }
|
||||||
|
|
||||||
virtual TraversalCode PreExpr(const Expr*);
|
virtual TraversalCode PreExpr(const zeek::detail::Expr*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Trigger* trigger;
|
Trigger* trigger;
|
||||||
|
@ -38,7 +39,7 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
TraversalCode TriggerTraversalCallback::PreExpr(const zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
// We catch all expressions here which in some way reference global
|
// We catch all expressions here which in some way reference global
|
||||||
// state.
|
// state.
|
||||||
|
@ -46,7 +47,7 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
switch ( expr->Tag() ) {
|
switch ( expr->Tag() ) {
|
||||||
case EXPR_NAME:
|
case EXPR_NAME:
|
||||||
{
|
{
|
||||||
const NameExpr* e = static_cast<const NameExpr*>(expr);
|
const auto* e = static_cast<const zeek::detail::NameExpr*>(expr);
|
||||||
if ( e->Id()->IsGlobal() )
|
if ( e->Id()->IsGlobal() )
|
||||||
trigger->Register(e->Id());
|
trigger->Register(e->Id());
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
|
|
||||||
case EXPR_INDEX:
|
case EXPR_INDEX:
|
||||||
{
|
{
|
||||||
const IndexExpr* e = static_cast<const IndexExpr*>(expr);
|
const auto* e = static_cast<const zeek::detail::IndexExpr*>(expr);
|
||||||
BroObj::SuppressErrors no_errors;
|
BroObj::SuppressErrors no_errors;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -122,9 +123,9 @@ protected:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger::Trigger(Expr* arg_cond, zeek::detail::Stmt* arg_body,
|
Trigger::Trigger(zeek::detail::Expr* arg_cond, zeek::detail::Stmt* arg_body,
|
||||||
zeek::detail::Stmt* arg_timeout_stmts,
|
zeek::detail::Stmt* arg_timeout_stmts,
|
||||||
Expr* arg_timeout, Frame* arg_frame,
|
zeek::detail::Expr* arg_timeout, Frame* arg_frame,
|
||||||
bool arg_is_return, const Location* arg_location)
|
bool arg_is_return, const Location* arg_location)
|
||||||
{
|
{
|
||||||
cond = arg_cond;
|
cond = arg_cond;
|
||||||
|
@ -441,7 +442,7 @@ void Trigger::Attach(Trigger *trigger)
|
||||||
Hold();
|
Hold();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trigger::Cache(const CallExpr* expr, Val* v)
|
bool Trigger::Cache(const zeek::detail::CallExpr* expr, Val* v)
|
||||||
{
|
{
|
||||||
if ( disabled || ! v )
|
if ( disabled || ! v )
|
||||||
return false;
|
return false;
|
||||||
|
@ -464,7 +465,7 @@ bool Trigger::Cache(const CallExpr* expr, Val* v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Val* Trigger::Lookup(const CallExpr* expr)
|
Val* Trigger::Lookup(const zeek::detail::CallExpr* expr)
|
||||||
{
|
{
|
||||||
assert(! disabled);
|
assert(! disabled);
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@
|
||||||
#include "iosource/IOSource.h"
|
#include "iosource/IOSource.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
class CallExpr;
|
|
||||||
class Expr;
|
|
||||||
class Frame;
|
class Frame;
|
||||||
class Val;
|
class Val;
|
||||||
class ID;
|
class ID;
|
||||||
class ODesc;
|
class ODesc;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
|
||||||
namespace trigger {
|
namespace trigger {
|
||||||
// Triggers are the heart of "when" statements: expressions that when
|
// Triggers are the heart of "when" statements: expressions that when
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
// instantiation. Note that if the condition is already true, the
|
// instantiation. Note that if the condition is already true, the
|
||||||
// statements are executed immediately and the object is deleted
|
// statements are executed immediately and the object is deleted
|
||||||
// right away.
|
// right away.
|
||||||
Trigger(Expr* cond, zeek::detail::Stmt* body, zeek::detail::Stmt* timeout_stmts, Expr* timeout,
|
Trigger(zeek::detail::Expr* cond, zeek::detail::Stmt* body, zeek::detail::Stmt* timeout_stmts, zeek::detail::Expr* timeout,
|
||||||
Frame* f, bool is_return, const Location* loc);
|
Frame* f, bool is_return, const Location* loc);
|
||||||
~Trigger() override;
|
~Trigger() override;
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ public:
|
||||||
// Cache for return values of delayed function calls. Returns whether
|
// Cache for return values of delayed function calls. Returns whether
|
||||||
// the trigger is queued for later evaluation -- it may not be queued
|
// the trigger is queued for later evaluation -- it may not be queued
|
||||||
// if the Val is null or it's disabled.
|
// if the Val is null or it's disabled.
|
||||||
bool Cache(const CallExpr* expr, Val* val);
|
bool Cache(const zeek::detail::CallExpr* expr, Val* val);
|
||||||
Val* Lookup(const CallExpr*);
|
Val* Lookup(const zeek::detail::CallExpr*);
|
||||||
|
|
||||||
// Disable this trigger completely. Needed because Unref'ing the trigger
|
// Disable this trigger completely. Needed because Unref'ing the trigger
|
||||||
// may not immediately delete it as other references may still exist.
|
// may not immediately delete it as other references may still exist.
|
||||||
|
@ -93,10 +93,10 @@ private:
|
||||||
void Register(Val* val);
|
void Register(Val* val);
|
||||||
void UnregisterAll();
|
void UnregisterAll();
|
||||||
|
|
||||||
Expr* cond;
|
zeek::detail::Expr* cond;
|
||||||
zeek::detail::Stmt* body;
|
zeek::detail::Stmt* body;
|
||||||
zeek::detail::Stmt* timeout_stmts;
|
zeek::detail::Stmt* timeout_stmts;
|
||||||
Expr* timeout;
|
zeek::detail::Expr* timeout;
|
||||||
double timeout_value;
|
double timeout_value;
|
||||||
Frame* frame;
|
Frame* frame;
|
||||||
bool is_return;
|
bool is_return;
|
||||||
|
@ -110,7 +110,7 @@ private:
|
||||||
|
|
||||||
std::vector<std::pair<BroObj *, notifier::Modifiable*>> objs;
|
std::vector<std::pair<BroObj *, notifier::Modifiable*>> objs;
|
||||||
|
|
||||||
using ValCache = std::map<const CallExpr*, Val*>;
|
using ValCache = std::map<const zeek::detail::CallExpr*, Val*>;
|
||||||
ValCache cache;
|
ValCache cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
28
src/Type.cc
28
src/Type.cc
|
@ -95,7 +95,7 @@ IntrusivePtr<BroType> BroType::ShallowClone()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BroType::MatchesIndex(ListExpr* const index) const
|
int BroType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||||
{
|
{
|
||||||
if ( Tag() == TYPE_STRING )
|
if ( Tag() == TYPE_STRING )
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ unsigned int TypeList::MemoryAllocation() const
|
||||||
|
|
||||||
IndexType::~IndexType() = default;
|
IndexType::~IndexType() = default;
|
||||||
|
|
||||||
int IndexType::MatchesIndex(ListExpr* const index) const
|
int IndexType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||||
{
|
{
|
||||||
// If we have a type indexed by subnets, addresses are ok.
|
// If we have a type indexed by subnets, addresses are ok.
|
||||||
const auto& types = indices->Types();
|
const auto& types = indices->Types();
|
||||||
|
@ -353,7 +353,7 @@ bool TableType::IsUnspecifiedTable() const
|
||||||
return indices->Types().empty();
|
return indices->Types().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<ListExpr> arg_elements)
|
SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr> arg_elements)
|
||||||
: TableType(std::move(ind), nullptr), elements(std::move(arg_elements))
|
: TableType(std::move(ind), nullptr), elements(std::move(arg_elements))
|
||||||
{
|
{
|
||||||
if ( elements )
|
if ( elements )
|
||||||
|
@ -471,7 +471,7 @@ string FuncType::FlavorString() const
|
||||||
|
|
||||||
FuncType::~FuncType() = default;
|
FuncType::~FuncType() = default;
|
||||||
|
|
||||||
int FuncType::MatchesIndex(ListExpr* const index) const
|
int FuncType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||||
{
|
{
|
||||||
return check_and_promote_args(index, args.get()) ?
|
return check_and_promote_args(index, args.get()) ?
|
||||||
MATCHES_INDEX_SCALAR : DOES_NOT_MATCH_INDEX;
|
MATCHES_INDEX_SCALAR : DOES_NOT_MATCH_INDEX;
|
||||||
|
@ -995,7 +995,7 @@ string RecordType::GetFieldDeprecationWarning(int field, bool has_check) const
|
||||||
string result;
|
string result;
|
||||||
if ( const auto& deprecation = decl->GetAttr(ATTR_DEPRECATED) )
|
if ( const auto& deprecation = decl->GetAttr(ATTR_DEPRECATED) )
|
||||||
{
|
{
|
||||||
auto expr = static_cast<ConstExpr*>(deprecation->GetExpr().get());
|
auto expr = static_cast<zeek::detail::ConstExpr*>(deprecation->GetExpr().get());
|
||||||
if ( expr )
|
if ( expr )
|
||||||
{
|
{
|
||||||
StringVal* text = expr->Value()->AsStringVal();
|
StringVal* text = expr->Value()->AsStringVal();
|
||||||
|
@ -1094,7 +1094,7 @@ EnumType::~EnumType() = default;
|
||||||
// Note, we use reporter->Error() here (not Error()) to include the current script
|
// Note, we use reporter->Error() here (not Error()) to include the current script
|
||||||
// location in the error message, rather than the one where the type was
|
// location in the error message, rather than the one where the type was
|
||||||
// originally defined.
|
// originally defined.
|
||||||
void EnumType::AddName(const string& module_name, const char* name, bool is_export, Expr* deprecation)
|
void EnumType::AddName(const string& module_name, const char* name, bool is_export, zeek::detail::Expr* deprecation)
|
||||||
{
|
{
|
||||||
/* implicit, auto-increment */
|
/* implicit, auto-increment */
|
||||||
if ( counter < 0)
|
if ( counter < 0)
|
||||||
|
@ -1107,7 +1107,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::AddName(const string& module_name, const char* name, bro_int_t val, bool is_export, Expr* deprecation)
|
void EnumType::AddName(const string& module_name, const char* name, bro_int_t val, bool is_export, zeek::detail::Expr* deprecation)
|
||||||
{
|
{
|
||||||
/* explicit value specified */
|
/* explicit value specified */
|
||||||
if ( counter > 0 )
|
if ( counter > 0 )
|
||||||
|
@ -1121,7 +1121,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
||||||
bro_int_t val, bool is_export, Expr* deprecation)
|
bro_int_t val, bool is_export, zeek::detail::Expr* deprecation)
|
||||||
{
|
{
|
||||||
if ( Lookup(val) )
|
if ( Lookup(val) )
|
||||||
{
|
{
|
||||||
|
@ -1325,7 +1325,7 @@ const IntrusivePtr<BroType>& VectorType::Yield() const
|
||||||
return yield_type;
|
return yield_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VectorType::MatchesIndex(ListExpr* const index) const
|
int VectorType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||||
{
|
{
|
||||||
expr_list& el = index->Exprs();
|
expr_list& el = index->Exprs();
|
||||||
|
|
||||||
|
@ -1938,7 +1938,7 @@ IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& arg_t1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<BroType> merge_type_list(ListExpr* elements)
|
IntrusivePtr<BroType> merge_type_list(zeek::detail::ListExpr* elements)
|
||||||
{
|
{
|
||||||
TypeList* tl_type = elements->GetType()->AsTypeList();
|
TypeList* tl_type = elements->GetType()->AsTypeList();
|
||||||
const auto& tl = tl_type->Types();
|
const auto& tl = tl_type->Types();
|
||||||
|
@ -1983,9 +1983,9 @@ static BroType* reduce_type(BroType* t)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<BroType> init_type(Expr* init)
|
IntrusivePtr<BroType> init_type(zeek::detail::Expr* init)
|
||||||
{
|
{
|
||||||
if ( init->Tag() != EXPR_LIST )
|
if ( init->Tag() != zeek::detail::EXPR_LIST )
|
||||||
{
|
{
|
||||||
auto t = init->InitType();
|
auto t = init->InitType();
|
||||||
|
|
||||||
|
@ -2002,7 +2002,7 @@ IntrusivePtr<BroType> init_type(Expr* init)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListExpr* init_list = init->AsListExpr();
|
zeek::detail::ListExpr* init_list = init->AsListExpr();
|
||||||
const expr_list& el = init_list->Exprs();
|
const expr_list& el = init_list->Exprs();
|
||||||
|
|
||||||
if ( el.length() == 0 )
|
if ( el.length() == 0 )
|
||||||
|
@ -2012,7 +2012,7 @@ IntrusivePtr<BroType> init_type(Expr* init)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could be a record, a set, or a list of table elements.
|
// Could be a record, a set, or a list of table elements.
|
||||||
Expr* e0 = el[0];
|
zeek::detail::Expr* e0 = el[0];
|
||||||
|
|
||||||
if ( e0->IsRecordElement(nullptr) )
|
if ( e0->IsRecordElement(nullptr) )
|
||||||
// ListExpr's know how to build a record from their
|
// ListExpr's know how to build a record from their
|
||||||
|
|
31
src/Type.h
31
src/Type.h
|
@ -119,7 +119,6 @@ constexpr InternalTypeTag to_internal_type_tag(TypeTag tag) noexcept
|
||||||
// Returns the name of the type.
|
// Returns the name of the type.
|
||||||
extern const char* type_name(TypeTag t);
|
extern const char* type_name(TypeTag t);
|
||||||
|
|
||||||
class Expr;
|
|
||||||
class Attributes;
|
class Attributes;
|
||||||
class TypeList;
|
class TypeList;
|
||||||
class TableType;
|
class TableType;
|
||||||
|
@ -127,7 +126,6 @@ class SetType;
|
||||||
class RecordType;
|
class RecordType;
|
||||||
class SubNetType;
|
class SubNetType;
|
||||||
class FuncType;
|
class FuncType;
|
||||||
class ListExpr;
|
|
||||||
class EnumType;
|
class EnumType;
|
||||||
class VectorType;
|
class VectorType;
|
||||||
class TypeType;
|
class TypeType;
|
||||||
|
@ -135,6 +133,9 @@ class OpaqueType;
|
||||||
class EnumVal;
|
class EnumVal;
|
||||||
class TableVal;
|
class TableVal;
|
||||||
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ListExpr, zeek::detail);
|
||||||
|
|
||||||
const int DOES_NOT_MATCH_INDEX = 0;
|
const int DOES_NOT_MATCH_INDEX = 0;
|
||||||
const int MATCHES_INDEX_SCALAR = 1;
|
const int MATCHES_INDEX_SCALAR = 1;
|
||||||
const int MATCHES_INDEX_VECTOR = 2;
|
const int MATCHES_INDEX_VECTOR = 2;
|
||||||
|
@ -168,7 +169,7 @@ public:
|
||||||
// if it matches and produces a vector result; and
|
// if it matches and produces a vector result; and
|
||||||
// DOES_NOT_MATCH_INDEX = 0 if it can't match (or the type
|
// DOES_NOT_MATCH_INDEX = 0 if it can't match (or the type
|
||||||
// is not an indexable type).
|
// is not an indexable type).
|
||||||
virtual int MatchesIndex(ListExpr* index) const;
|
virtual int MatchesIndex(zeek::detail::ListExpr* index) const;
|
||||||
|
|
||||||
// Returns the type yielded by this type. For example, if
|
// Returns the type yielded by this type. For example, if
|
||||||
// this type is a table[string] of port, then returns the "port"
|
// this type is a table[string] of port, then returns the "port"
|
||||||
|
@ -398,7 +399,7 @@ protected:
|
||||||
|
|
||||||
class IndexType : public BroType {
|
class IndexType : public BroType {
|
||||||
public:
|
public:
|
||||||
int MatchesIndex(ListExpr* index) const override;
|
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||||
|
|
||||||
const IntrusivePtr<TypeList>& GetIndices() const
|
const IntrusivePtr<TypeList>& GetIndices() const
|
||||||
{ return indices; }
|
{ return indices; }
|
||||||
|
@ -445,19 +446,19 @@ public:
|
||||||
|
|
||||||
class SetType final : public TableType {
|
class SetType final : public TableType {
|
||||||
public:
|
public:
|
||||||
SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<ListExpr> arg_elements);
|
SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr> arg_elements);
|
||||||
~SetType() override;
|
~SetType() override;
|
||||||
|
|
||||||
IntrusivePtr<BroType> ShallowClone() override;
|
IntrusivePtr<BroType> ShallowClone() override;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use Elements() isntead.")]]
|
[[deprecated("Remove in v4.1. Use Elements() isntead.")]]
|
||||||
ListExpr* SetElements() const { return elements.get(); }
|
zeek::detail::ListExpr* SetElements() const { return elements.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<ListExpr>& Elements() const
|
const IntrusivePtr<zeek::detail::ListExpr>& Elements() const
|
||||||
{ return elements; }
|
{ return elements; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<ListExpr> elements;
|
IntrusivePtr<zeek::detail::ListExpr> elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FuncType final : public BroType {
|
class FuncType final : public BroType {
|
||||||
|
@ -498,7 +499,7 @@ public:
|
||||||
void ClearYieldType(function_flavor arg_flav)
|
void ClearYieldType(function_flavor arg_flav)
|
||||||
{ yield = nullptr; flavor = arg_flav; }
|
{ yield = nullptr; flavor = arg_flav; }
|
||||||
|
|
||||||
int MatchesIndex(ListExpr* index) const override;
|
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||||
bool CheckArgs(const type_list* args, bool is_init = false) const;
|
bool CheckArgs(const type_list* args, bool is_init = false) const;
|
||||||
bool CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
|
bool CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
|
||||||
bool is_init = false) const;
|
bool is_init = false) const;
|
||||||
|
@ -736,12 +737,12 @@ public:
|
||||||
|
|
||||||
// The value of this name is next internal counter value, starting
|
// The value of this name is next internal counter value, starting
|
||||||
// with zero. The internal counter is incremented.
|
// with zero. The internal counter is incremented.
|
||||||
void AddName(const std::string& module_name, const char* name, bool is_export, Expr* deprecation = nullptr);
|
void AddName(const std::string& module_name, const char* name, bool is_export, zeek::detail::Expr* deprecation = nullptr);
|
||||||
|
|
||||||
// The value of this name is set to val. Once a value has been
|
// The value of this name is set to val. Once a value has been
|
||||||
// explicitly assigned using this method, no further names can be
|
// explicitly assigned using this method, no further names can be
|
||||||
// added that aren't likewise explicitly initalized.
|
// added that aren't likewise explicitly initalized.
|
||||||
void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export, Expr* deprecation = nullptr);
|
void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export, zeek::detail::Expr* deprecation = nullptr);
|
||||||
|
|
||||||
// -1 indicates not found.
|
// -1 indicates not found.
|
||||||
bro_int_t Lookup(const std::string& module_name, const char* name) const;
|
bro_int_t Lookup(const std::string& module_name, const char* name) const;
|
||||||
|
@ -761,7 +762,7 @@ protected:
|
||||||
|
|
||||||
void CheckAndAddName(const std::string& module_name,
|
void CheckAndAddName(const std::string& module_name,
|
||||||
const char* name, bro_int_t val, bool is_export,
|
const char* name, bro_int_t val, bool is_export,
|
||||||
Expr* deprecation = nullptr);
|
zeek::detail::Expr* deprecation = nullptr);
|
||||||
|
|
||||||
typedef std::map<std::string, bro_int_t> NameMap;
|
typedef std::map<std::string, bro_int_t> NameMap;
|
||||||
NameMap names;
|
NameMap names;
|
||||||
|
@ -786,7 +787,7 @@ public:
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& Yield() const override;
|
const IntrusivePtr<BroType>& Yield() const override;
|
||||||
|
|
||||||
int MatchesIndex(ListExpr* index) const override;
|
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||||
|
|
||||||
// Returns true if this table type is "unspecified", which is what one
|
// Returns true if this table type is "unspecified", which is what one
|
||||||
// gets using an empty "vector()" constructor.
|
// gets using an empty "vector()" constructor.
|
||||||
|
@ -865,10 +866,10 @@ IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& t1,
|
||||||
// Given a list of expressions, returns a (ref'd) type reflecting
|
// Given a list of expressions, returns a (ref'd) type reflecting
|
||||||
// a merged type consistent across all of them, or nil if this
|
// a merged type consistent across all of them, or nil if this
|
||||||
// cannot be done.
|
// cannot be done.
|
||||||
IntrusivePtr<BroType> merge_type_list(ListExpr* elements);
|
IntrusivePtr<BroType> merge_type_list(zeek::detail::ListExpr* elements);
|
||||||
|
|
||||||
// Given an expression, infer its type when used for an initialization.
|
// Given an expression, infer its type when used for an initialization.
|
||||||
IntrusivePtr<BroType> init_type(Expr* init);
|
IntrusivePtr<BroType> init_type(zeek::detail::Expr* init);
|
||||||
|
|
||||||
// Returns true if argument is an atomic type.
|
// Returns true if argument is an atomic type.
|
||||||
bool is_atomic_type(const BroType& t);
|
bool is_atomic_type(const BroType& t);
|
||||||
|
|
11
src/Val.cc
11
src/Val.cc
|
@ -1824,8 +1824,9 @@ IntrusivePtr<Val> TableVal::Default(const IntrusivePtr<Val>& index)
|
||||||
ytype->AsRecordType()) )
|
ytype->AsRecordType()) )
|
||||||
{
|
{
|
||||||
auto rt = cast_intrusive<RecordType>(ytype);
|
auto rt = cast_intrusive<RecordType>(ytype);
|
||||||
auto coerce = make_intrusive<RecordCoerceExpr>(def_attr->GetExpr(),
|
auto coerce = make_intrusive<zeek::detail::RecordCoerceExpr>(
|
||||||
std::move(rt));
|
def_attr->GetExpr(), std::move(rt));
|
||||||
|
|
||||||
def_val = coerce->Eval(nullptr);
|
def_val = coerce->Eval(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2865,9 +2866,9 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||||
|
|
||||||
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft, v->GetType()) )
|
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft, v->GetType()) )
|
||||||
{
|
{
|
||||||
auto rhs = make_intrusive<ConstExpr>(v);
|
auto rhs = make_intrusive<zeek::detail::ConstExpr>(v);
|
||||||
auto e = make_intrusive<RecordCoerceExpr>(std::move(rhs),
|
auto e = make_intrusive<zeek::detail::RecordCoerceExpr>(std::move(rhs),
|
||||||
cast_intrusive<RecordType>(ft));
|
cast_intrusive<RecordType>(ft));
|
||||||
aggr->Assign(t_i, e->Eval(nullptr));
|
aggr->Assign(t_i, e->Eval(nullptr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1050,13 +1050,13 @@ protected:
|
||||||
IntrusivePtr<TableType> table_type;
|
IntrusivePtr<TableType> table_type;
|
||||||
CompositeHash* table_hash;
|
CompositeHash* table_hash;
|
||||||
IntrusivePtr<Attributes> attrs;
|
IntrusivePtr<Attributes> attrs;
|
||||||
IntrusivePtr<Expr> expire_time;
|
IntrusivePtr<zeek::detail::Expr> expire_time;
|
||||||
IntrusivePtr<Expr> expire_func;
|
IntrusivePtr<zeek::detail::Expr> expire_func;
|
||||||
TableValTimer* timer;
|
TableValTimer* timer;
|
||||||
IterCookie* expire_cookie;
|
IterCookie* expire_cookie;
|
||||||
PrefixTable* subnets;
|
PrefixTable* subnets;
|
||||||
IntrusivePtr<Val> def_val;
|
IntrusivePtr<Val> def_val;
|
||||||
IntrusivePtr<Expr> change_func;
|
IntrusivePtr<zeek::detail::Expr> change_func;
|
||||||
// prevent recursion of change functions
|
// prevent recursion of change functions
|
||||||
bool in_change_func = false;
|
bool in_change_func = false;
|
||||||
|
|
||||||
|
|
61
src/Var.cc
61
src/Var.cc
|
@ -17,7 +17,7 @@
|
||||||
#include "module_util.h"
|
#include "module_util.h"
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
|
|
||||||
static IntrusivePtr<Val> init_val(Expr* init, const BroType* t,
|
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
||||||
IntrusivePtr<Val> aggr)
|
IntrusivePtr<Val> aggr)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -32,7 +32,7 @@ static IntrusivePtr<Val> init_val(Expr* init, const BroType* t,
|
||||||
|
|
||||||
static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
|
static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
|
||||||
std::vector<IntrusivePtr<Attr>>* attrs,
|
std::vector<IntrusivePtr<Attr>>* attrs,
|
||||||
const IntrusivePtr<Expr>& init)
|
const IntrusivePtr<zeek::detail::Expr>& init)
|
||||||
{
|
{
|
||||||
if ( ! IsFunc(id->GetType()->Tag()) )
|
if ( ! IsFunc(id->GetType()->Tag()) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,7 +109,7 @@ static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_class c,
|
static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_class c,
|
||||||
IntrusivePtr<Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt,
|
decl_type dt,
|
||||||
bool do_init)
|
bool do_init)
|
||||||
|
@ -204,17 +204,17 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
if ( init )
|
if ( init )
|
||||||
{
|
{
|
||||||
switch ( init->Tag() ) {
|
switch ( init->Tag() ) {
|
||||||
case EXPR_TABLE_CONSTRUCTOR:
|
case zeek::detail::EXPR_TABLE_CONSTRUCTOR:
|
||||||
{
|
{
|
||||||
TableConstructorExpr* ctor = (TableConstructorExpr*) init.get();
|
auto* ctor = static_cast<zeek::detail::TableConstructorExpr*>(init.get());
|
||||||
if ( ctor->GetAttrs() )
|
if ( ctor->GetAttrs() )
|
||||||
id->AddAttrs(ctor->GetAttrs());
|
id->AddAttrs(ctor->GetAttrs());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXPR_SET_CONSTRUCTOR:
|
case zeek::detail::EXPR_SET_CONSTRUCTOR:
|
||||||
{
|
{
|
||||||
SetConstructorExpr* ctor = (SetConstructorExpr*) init.get();
|
auto* ctor = static_cast<zeek::detail::SetConstructorExpr*>(init.get());
|
||||||
if ( ctor->GetAttrs() )
|
if ( ctor->GetAttrs() )
|
||||||
id->AddAttrs(ctor->GetAttrs());
|
id->AddAttrs(ctor->GetAttrs());
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
if ( do_init )
|
if ( do_init )
|
||||||
{
|
{
|
||||||
if ( c == INIT_NONE && dt == VAR_REDEF && t->IsTable() &&
|
if ( c == INIT_NONE && dt == VAR_REDEF && t->IsTable() &&
|
||||||
init && init->Tag() == EXPR_ASSIGN )
|
init && init->Tag() == zeek::detail::EXPR_ASSIGN )
|
||||||
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
|
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
|
||||||
// intention clearly isn't to overwrite entire existing table val.
|
// intention clearly isn't to overwrite entire existing table val.
|
||||||
c = INIT_EXTRA;
|
c = INIT_EXTRA;
|
||||||
|
@ -248,7 +248,7 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
|
|
||||||
if ( init && t )
|
if ( init && t )
|
||||||
// Have an initialization and type is not deduced.
|
// Have an initialization and type is not deduced.
|
||||||
init = make_intrusive<RecordCoerceExpr>(std::move(init),
|
init = make_intrusive<zeek::detail::RecordCoerceExpr>(std::move(init),
|
||||||
IntrusivePtr{NewRef{}, t->AsRecordType()});
|
IntrusivePtr{NewRef{}, t->AsRecordType()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,9 +307,8 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
|
void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
|
||||||
init_class c, IntrusivePtr<Expr> init,
|
init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt)
|
decl_type dt)
|
||||||
{
|
{
|
||||||
|
@ -317,7 +316,7 @@ void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
|
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
|
||||||
init_class c, IntrusivePtr<Expr> init,
|
init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt)
|
decl_type dt)
|
||||||
{
|
{
|
||||||
|
@ -332,10 +331,10 @@ IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<Bro
|
||||||
const Location location = init->GetLocationInfo() ?
|
const Location location = init->GetLocationInfo() ?
|
||||||
*init->GetLocationInfo() : no_location;
|
*init->GetLocationInfo() : no_location;
|
||||||
|
|
||||||
auto name_expr = make_intrusive<NameExpr>(id, dt == VAR_CONST);
|
auto name_expr = make_intrusive<zeek::detail::NameExpr>(id, dt == VAR_CONST);
|
||||||
auto assign_expr = make_intrusive<AssignExpr>(std::move(name_expr),
|
auto assign_expr = make_intrusive<zeek::detail::AssignExpr>(std::move(name_expr),
|
||||||
std::move(init), 0,
|
std::move(init), 0,
|
||||||
nullptr, id->GetAttrs());
|
nullptr, id->GetAttrs());
|
||||||
auto stmt = make_intrusive<zeek::detail::ExprStmt>(std::move(assign_expr));
|
auto stmt = make_intrusive<zeek::detail::ExprStmt>(std::move(assign_expr));
|
||||||
stmt->SetLocationInfo(&location);
|
stmt->SetLocationInfo(&location);
|
||||||
return stmt;
|
return stmt;
|
||||||
|
@ -348,14 +347,14 @@ IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<Bro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern IntrusivePtr<Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
||||||
IntrusivePtr<Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
IntrusivePtr<Val> val)
|
IntrusivePtr<Val> val)
|
||||||
{
|
{
|
||||||
make_var(id, nullptr, INIT_FULL, init, nullptr, VAR_REGULAR, false);
|
make_var(id, nullptr, INIT_FULL, init, nullptr, VAR_REGULAR, false);
|
||||||
auto name_expr = make_intrusive<NameExpr>(std::move(id));
|
auto name_expr = make_intrusive<zeek::detail::NameExpr>(std::move(id));
|
||||||
return make_intrusive<AssignExpr>(std::move(name_expr), std::move(init),
|
return make_intrusive<zeek::detail::AssignExpr>(std::move(name_expr), std::move(init),
|
||||||
false, std::move(val));
|
false, std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_type(ID* id, IntrusivePtr<BroType> t,
|
void add_type(ID* id, IntrusivePtr<BroType> t,
|
||||||
|
@ -591,26 +590,26 @@ public:
|
||||||
scopes.emplace_back(s);
|
scopes.emplace_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode PreExpr(const Expr*) override;
|
TraversalCode PreExpr(const zeek::detail::Expr*) override;
|
||||||
TraversalCode PostExpr(const Expr*) override;
|
TraversalCode PostExpr(const zeek::detail::Expr*) override;
|
||||||
|
|
||||||
std::vector<Scope*> scopes;
|
std::vector<Scope*> scopes;
|
||||||
std::vector<const NameExpr*> outer_id_references;
|
std::vector<const zeek::detail::NameExpr*> outer_id_references;
|
||||||
};
|
};
|
||||||
|
|
||||||
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
TraversalCode OuterIDBindingFinder::PreExpr(const zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
if ( expr->Tag() == EXPR_LAMBDA )
|
if ( expr->Tag() == zeek::detail::EXPR_LAMBDA )
|
||||||
{
|
{
|
||||||
auto le = static_cast<const LambdaExpr*>(expr);
|
auto le = static_cast<const zeek::detail::LambdaExpr*>(expr);
|
||||||
scopes.emplace_back(le->GetScope());
|
scopes.emplace_back(le->GetScope());
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( expr->Tag() != EXPR_NAME )
|
if ( expr->Tag() != zeek::detail::EXPR_NAME )
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
|
||||||
const NameExpr* e = static_cast<const NameExpr*>(expr);
|
auto* e = static_cast<const zeek::detail::NameExpr*>(expr);
|
||||||
|
|
||||||
if ( e->Id()->IsGlobal() )
|
if ( e->Id()->IsGlobal() )
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
@ -625,9 +624,9 @@ TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode OuterIDBindingFinder::PostExpr(const Expr* expr)
|
TraversalCode OuterIDBindingFinder::PostExpr(const zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
if ( expr->Tag() == EXPR_LAMBDA )
|
if ( expr->Tag() == zeek::detail::EXPR_LAMBDA )
|
||||||
scopes.pop_back();
|
scopes.pop_back();
|
||||||
|
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
|
10
src/Var.h
10
src/Var.h
|
@ -6,7 +6,6 @@
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
|
|
||||||
class Expr;
|
|
||||||
class FuncType;
|
class FuncType;
|
||||||
class Scope;
|
class Scope;
|
||||||
class EventHandlerPtr;
|
class EventHandlerPtr;
|
||||||
|
@ -15,25 +14,26 @@ class TableVal;
|
||||||
class ListVal;
|
class ListVal;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
|
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
|
||||||
|
|
||||||
extern void add_global(const IntrusivePtr<ID>& id,
|
extern void add_global(const IntrusivePtr<ID>& id,
|
||||||
IntrusivePtr<BroType> t,
|
IntrusivePtr<BroType> t,
|
||||||
init_class c,
|
init_class c,
|
||||||
IntrusivePtr<Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt);
|
decl_type dt);
|
||||||
|
|
||||||
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id,
|
||||||
IntrusivePtr<BroType> t,
|
IntrusivePtr<BroType> t,
|
||||||
init_class c,
|
init_class c,
|
||||||
IntrusivePtr<Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt);
|
decl_type dt);
|
||||||
|
|
||||||
extern IntrusivePtr<Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
||||||
IntrusivePtr<Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
IntrusivePtr<Val> val = nullptr);
|
IntrusivePtr<Val> val = nullptr);
|
||||||
|
|
||||||
extern void add_type(ID* id, IntrusivePtr<BroType> t,
|
extern void add_type(ID* id, IntrusivePtr<BroType> t,
|
||||||
|
|
|
@ -50,7 +50,7 @@ inline IntrusivePtr<RecordVal> query_result(IntrusivePtr<RecordVal> data)
|
||||||
*/
|
*/
|
||||||
class StoreQueryCallback {
|
class StoreQueryCallback {
|
||||||
public:
|
public:
|
||||||
StoreQueryCallback(trigger::Trigger* arg_trigger, const CallExpr* arg_call,
|
StoreQueryCallback(trigger::Trigger* arg_trigger, const zeek::detail::CallExpr* arg_call,
|
||||||
broker::store store)
|
broker::store store)
|
||||||
: trigger(arg_trigger), call(arg_call), store(std::move(store))
|
: trigger(arg_trigger), call(arg_call), store(std::move(store))
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
trigger::Trigger* trigger;
|
trigger::Trigger* trigger;
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
broker::store store;
|
broker::store store;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern void add_to_name_list(char* s, char delim, name_list& nl);
|
||||||
|
|
||||||
extern void begin_RE();
|
extern void begin_RE();
|
||||||
|
|
||||||
extern void do_atif(Expr* expr);
|
extern void do_atif(zeek::detail::Expr* expr);
|
||||||
extern void do_atifdef(const char* id);
|
extern void do_atifdef(const char* id);
|
||||||
extern void do_atifndef(const char* id);
|
extern void do_atifndef(const char* id);
|
||||||
extern void do_atelse();
|
extern void do_atelse();
|
||||||
|
|
174
src/parse.y
174
src/parse.y
|
@ -121,7 +121,7 @@ bool is_export = false; // true if in an export {} block
|
||||||
* When parsing an expression for the debugger, where to put the result
|
* When parsing an expression for the debugger, where to put the result
|
||||||
* (obviously not reentrant).
|
* (obviously not reentrant).
|
||||||
*/
|
*/
|
||||||
extern Expr* g_curr_debug_expr;
|
extern zeek::detail::Expr* g_curr_debug_expr;
|
||||||
extern bool in_debug;
|
extern bool in_debug;
|
||||||
extern const char* g_curr_debug_error;
|
extern const char* g_curr_debug_error;
|
||||||
|
|
||||||
|
@ -212,9 +212,9 @@ make_attributes(std::vector<IntrusivePtr<Attr>>* attrs,
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool expr_is_table_type_name(const Expr* expr)
|
static bool expr_is_table_type_name(const zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
if ( expr->Tag() != EXPR_NAME )
|
if ( expr->Tag() != zeek::detail::EXPR_NAME )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto& type = expr->GetType();
|
const auto& type = expr->GetType();
|
||||||
|
@ -237,10 +237,10 @@ static bool expr_is_table_type_name(const Expr* expr)
|
||||||
init_class ic;
|
init_class ic;
|
||||||
Val* val;
|
Val* val;
|
||||||
RE_Matcher* re;
|
RE_Matcher* re;
|
||||||
Expr* expr;
|
zeek::detail::Expr* expr;
|
||||||
EventExpr* event_expr;
|
zeek::detail::EventExpr* event_expr;
|
||||||
zeek::detail::Stmt* stmt;
|
zeek::detail::Stmt* stmt;
|
||||||
ListExpr* list;
|
zeek::detail::ListExpr* list;
|
||||||
BroType* type;
|
BroType* type;
|
||||||
RecordType* record;
|
RecordType* record;
|
||||||
FuncType* func_type;
|
FuncType* func_type;
|
||||||
|
@ -300,169 +300,169 @@ expr:
|
||||||
| TOK_COPY '(' expr ')'
|
| TOK_COPY '(' expr ')'
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new CloneExpr({AdoptRef{}, $3});
|
$$ = new zeek::detail::CloneExpr({AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_INCR expr
|
| TOK_INCR expr
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new IncrExpr(EXPR_INCR, {AdoptRef{}, $2});
|
$$ = new zeek::detail::IncrExpr(zeek::detail::EXPR_INCR, {AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_DECR expr
|
| TOK_DECR expr
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new IncrExpr(EXPR_DECR, {AdoptRef{}, $2});
|
$$ = new zeek::detail::IncrExpr(zeek::detail::EXPR_DECR, {AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '!' expr
|
| '!' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new NotExpr({AdoptRef{}, $2});
|
$$ = new zeek::detail::NotExpr({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '~' expr
|
| '~' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new ComplementExpr({AdoptRef{}, $2});
|
$$ = new zeek::detail::ComplementExpr({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '-' expr %prec '!'
|
| '-' expr %prec '!'
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new NegExpr({AdoptRef{}, $2});
|
$$ = new zeek::detail::NegExpr({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '+' expr %prec '!'
|
| '+' expr %prec '!'
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new PosExpr({AdoptRef{}, $2});
|
$$ = new zeek::detail::PosExpr({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '+' expr
|
| expr '+' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new AddExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::AddExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_ADD_TO expr
|
| expr TOK_ADD_TO expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new AddToExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::AddToExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '-' expr
|
| expr '-' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new SubExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::SubExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_REMOVE_FROM expr
|
| expr TOK_REMOVE_FROM expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new RemoveFromExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::RemoveFromExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '*' expr
|
| expr '*' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new TimesExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::TimesExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '/' expr
|
| expr '/' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new DivideExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::DivideExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '%' expr
|
| expr '%' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new ModExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::ModExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '&' expr
|
| expr '&' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new BitExpr(EXPR_AND, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::BitExpr(zeek::detail::EXPR_AND, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '|' expr
|
| expr '|' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new BitExpr(EXPR_OR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::BitExpr(zeek::detail::EXPR_OR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '^' expr
|
| expr '^' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new BitExpr(EXPR_XOR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::BitExpr(zeek::detail::EXPR_XOR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_AND_AND expr
|
| expr TOK_AND_AND expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new BoolExpr(EXPR_AND_AND, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::BoolExpr(zeek::detail::EXPR_AND_AND, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_OR_OR expr
|
| expr TOK_OR_OR expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new BoolExpr(EXPR_OR_OR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::BoolExpr(zeek::detail::EXPR_OR_OR, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_EQ expr
|
| expr TOK_EQ expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new EqExpr(EXPR_EQ, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::EqExpr(zeek::detail::EXPR_EQ, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_NE expr
|
| expr TOK_NE expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new EqExpr(EXPR_NE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::EqExpr(zeek::detail::EXPR_NE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '<' expr
|
| expr '<' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new RelExpr(EXPR_LT, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::RelExpr(zeek::detail::EXPR_LT, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_LE expr
|
| expr TOK_LE expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new RelExpr(EXPR_LE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::RelExpr(zeek::detail::EXPR_LE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '>' expr
|
| expr '>' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new RelExpr(EXPR_GT, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::RelExpr(zeek::detail::EXPR_GT, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_GE expr
|
| expr TOK_GE expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new RelExpr(EXPR_GE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::RelExpr(zeek::detail::EXPR_GE, {AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '?' expr ':' expr
|
| expr '?' expr ':' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @5);
|
set_location(@1, @5);
|
||||||
$$ = new CondExpr({AdoptRef{}, $1}, {AdoptRef{}, $3}, {AdoptRef{}, $5});
|
$$ = new zeek::detail::CondExpr({AdoptRef{}, $1}, {AdoptRef{}, $3}, {AdoptRef{}, $5});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '=' expr
|
| expr '=' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
|
|
||||||
if ( $1->Tag() == EXPR_INDEX && $1->AsIndexExpr()->IsSlice() )
|
if ( $1->Tag() == zeek::detail::EXPR_INDEX && $1->AsIndexExpr()->IsSlice() )
|
||||||
reporter->Error("index slice assignment may not be used"
|
reporter->Error("index slice assignment may not be used"
|
||||||
" in arbitrary expression contexts, only"
|
" in arbitrary expression contexts, only"
|
||||||
" as a statement");
|
" as a statement");
|
||||||
|
|
||||||
$$ = get_assign_expr({AdoptRef{}, $1}, {AdoptRef{}, $3}, in_init).release();
|
$$ = zeek::detail::get_assign_expr({AdoptRef{}, $1}, {AdoptRef{}, $3}, in_init).release();
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_LOCAL local_id '=' expr
|
| TOK_LOCAL local_id '=' expr
|
||||||
|
@ -475,7 +475,7 @@ expr:
|
||||||
| expr '[' expr_list ']'
|
| expr '[' expr_list ']'
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new IndexExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::IndexExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| index_slice
|
| index_slice
|
||||||
|
@ -483,13 +483,13 @@ expr:
|
||||||
| expr '$' TOK_ID
|
| expr '$' TOK_ID
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new FieldExpr({AdoptRef{}, $1}, $3);
|
$$ = new zeek::detail::FieldExpr({AdoptRef{}, $1}, $3);
|
||||||
}
|
}
|
||||||
|
|
||||||
| '$' TOK_ID '=' expr
|
| '$' TOK_ID '=' expr
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new FieldAssignExpr($2, {AdoptRef{}, $4});
|
$$ = new zeek::detail::FieldAssignExpr($2, {AdoptRef{}, $4});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '$' TOK_ID func_params '='
|
| '$' TOK_ID func_params '='
|
||||||
|
@ -503,21 +503,21 @@ expr:
|
||||||
}
|
}
|
||||||
lambda_body
|
lambda_body
|
||||||
{
|
{
|
||||||
$$ = new FieldAssignExpr($2, IntrusivePtr{AdoptRef{}, $6});
|
$$ = new zeek::detail::FieldAssignExpr($2, IntrusivePtr{AdoptRef{}, $6});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_IN expr
|
| expr TOK_IN expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new InExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::InExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_NOT_IN expr
|
| expr TOK_NOT_IN expr
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new NotExpr(make_intrusive<InExpr>(
|
$$ = new zeek::detail::NotExpr(make_intrusive<zeek::detail::InExpr>(
|
||||||
IntrusivePtr<Expr>{AdoptRef{}, $1},
|
IntrusivePtr<zeek::detail::Expr>{AdoptRef{}, $1},
|
||||||
IntrusivePtr<Expr>{AdoptRef{}, $3}));
|
IntrusivePtr<zeek::detail::Expr>{AdoptRef{}, $3}));
|
||||||
}
|
}
|
||||||
|
|
||||||
| '[' expr_list ']'
|
| '[' expr_list ']'
|
||||||
|
@ -532,7 +532,7 @@ expr:
|
||||||
|
|
||||||
for ( int i = 0; i < $2->Exprs().length(); ++i )
|
for ( int i = 0; i < $2->Exprs().length(); ++i )
|
||||||
{
|
{
|
||||||
if ( $2->Exprs()[i]->Tag() != EXPR_FIELD_ASSIGN )
|
if ( $2->Exprs()[i]->Tag() != zeek::detail::EXPR_FIELD_ASSIGN )
|
||||||
{
|
{
|
||||||
is_record_ctor = false;
|
is_record_ctor = false;
|
||||||
break;
|
break;
|
||||||
|
@ -540,7 +540,7 @@ expr:
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_record_ctor )
|
if ( is_record_ctor )
|
||||||
$$ = new RecordConstructorExpr({AdoptRef{}, $2});
|
$$ = new zeek::detail::RecordConstructorExpr({AdoptRef{}, $2});
|
||||||
else
|
else
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
@ -548,14 +548,14 @@ expr:
|
||||||
| '[' ']'
|
| '[' ']'
|
||||||
{
|
{
|
||||||
// We interpret this as an empty record constructor.
|
// We interpret this as an empty record constructor.
|
||||||
$$ = new RecordConstructorExpr(make_intrusive<ListExpr>());
|
$$ = new zeek::detail::RecordConstructorExpr(make_intrusive<zeek::detail::ListExpr>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
| TOK_RECORD '(' expr_list ')'
|
| TOK_RECORD '(' expr_list ')'
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new RecordConstructorExpr({AdoptRef{}, $3});
|
$$ = new zeek::detail::RecordConstructorExpr({AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_TABLE '(' { ++in_init; } opt_expr_list ')' { --in_init; }
|
| TOK_TABLE '(' { ++in_init; } opt_expr_list ')' { --in_init; }
|
||||||
|
@ -563,20 +563,20 @@ expr:
|
||||||
{ // the ++in_init fixes up the parsing of "[x] = y"
|
{ // the ++in_init fixes up the parsing of "[x] = y"
|
||||||
set_location(@1, @5);
|
set_location(@1, @5);
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs{$7};
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs{$7};
|
||||||
$$ = new TableConstructorExpr({AdoptRef{}, $4}, std::move(attrs));
|
$$ = new zeek::detail::TableConstructorExpr({AdoptRef{}, $4}, std::move(attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_SET '(' opt_expr_list ')' opt_attr
|
| TOK_SET '(' opt_expr_list ')' opt_attr
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs{$5};
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs{$5};
|
||||||
$$ = new SetConstructorExpr({AdoptRef{}, $3}, std::move(attrs));
|
$$ = new zeek::detail::SetConstructorExpr({AdoptRef{}, $3}, std::move(attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_VECTOR '(' opt_expr_list ')'
|
| TOK_VECTOR '(' opt_expr_list ')'
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new VectorConstructorExpr({AdoptRef{}, $3});
|
$$ = new zeek::detail::VectorConstructorExpr({AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr '('
|
| expr '('
|
||||||
|
@ -595,30 +595,30 @@ expr:
|
||||||
{
|
{
|
||||||
set_location(@1, @6);
|
set_location(@1, @6);
|
||||||
|
|
||||||
if ( $1->Tag() == EXPR_NAME && $1->AsNameExpr()->Id()->IsType() )
|
if ( $1->Tag() == zeek::detail::EXPR_NAME && $1->AsNameExpr()->Id()->IsType() )
|
||||||
{
|
{
|
||||||
const auto& ctor_type = $1->AsNameExpr()->Id()->GetType();
|
const auto& ctor_type = $1->AsNameExpr()->Id()->GetType();
|
||||||
|
|
||||||
switch ( ctor_type->Tag() ) {
|
switch ( ctor_type->Tag() ) {
|
||||||
case TYPE_RECORD:
|
case TYPE_RECORD:
|
||||||
{
|
{
|
||||||
auto rce = make_intrusive<RecordConstructorExpr>(
|
auto rce = make_intrusive<zeek::detail::RecordConstructorExpr>(
|
||||||
IntrusivePtr<ListExpr>{AdoptRef{}, $4});
|
IntrusivePtr<zeek::detail::ListExpr>{AdoptRef{}, $4});
|
||||||
auto rt = cast_intrusive<RecordType>(ctor_type);
|
auto rt = cast_intrusive<RecordType>(ctor_type);
|
||||||
$$ = new RecordCoerceExpr(std::move(rce), std::move(rt));
|
$$ = new zeek::detail::RecordCoerceExpr(std::move(rce), std::move(rt));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case TYPE_TABLE:
|
||||||
if ( ctor_type->IsTable() )
|
if ( ctor_type->IsTable() )
|
||||||
$$ = new TableConstructorExpr({AdoptRef{}, $4}, 0, ctor_type);
|
$$ = new zeek::detail::TableConstructorExpr({AdoptRef{}, $4}, 0, ctor_type);
|
||||||
else
|
else
|
||||||
$$ = new SetConstructorExpr({AdoptRef{}, $4}, 0, ctor_type);
|
$$ = new zeek::detail::SetConstructorExpr({AdoptRef{}, $4}, 0, ctor_type);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_VECTOR:
|
case TYPE_VECTOR:
|
||||||
$$ = new VectorConstructorExpr({AdoptRef{}, $4}, ctor_type);
|
$$ = new zeek::detail::VectorConstructorExpr({AdoptRef{}, $4}, ctor_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -628,14 +628,14 @@ expr:
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
$$ = new CallExpr({AdoptRef{}, $1}, {AdoptRef{}, $4}, in_hook > 0);
|
$$ = new zeek::detail::CallExpr({AdoptRef{}, $1}, {AdoptRef{}, $4}, in_hook > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_HOOK { ++in_hook; } expr
|
| TOK_HOOK { ++in_hook; } expr
|
||||||
{
|
{
|
||||||
--in_hook;
|
--in_hook;
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
if ( $3->Tag() != EXPR_CALL )
|
if ( $3->Tag() != zeek::detail::EXPR_CALL )
|
||||||
$3->Error("not a valid hook call expression");
|
$3->Error("not a valid hook call expression");
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ expr:
|
||||||
| expr TOK_HAS_FIELD TOK_ID
|
| expr TOK_HAS_FIELD TOK_ID
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new HasFieldExpr({AdoptRef{}, $1}, $3);
|
$$ = new zeek::detail::HasFieldExpr({AdoptRef{}, $1}, $3);
|
||||||
}
|
}
|
||||||
|
|
||||||
| anonymous_function
|
| anonymous_function
|
||||||
|
@ -652,7 +652,7 @@ expr:
|
||||||
| TOK_SCHEDULE expr '{' event '}'
|
| TOK_SCHEDULE expr '{' event '}'
|
||||||
{
|
{
|
||||||
set_location(@1, @5);
|
set_location(@1, @5);
|
||||||
$$ = new ScheduleExpr({AdoptRef{}, $2}, {AdoptRef{}, $4});
|
$$ = new zeek::detail::ScheduleExpr({AdoptRef{}, $2}, {AdoptRef{}, $4});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_ID
|
| TOK_ID
|
||||||
|
@ -687,7 +687,7 @@ expr:
|
||||||
{
|
{
|
||||||
id->Error("undeclared variable");
|
id->Error("undeclared variable");
|
||||||
id->SetType(error_type());
|
id->SetType(error_type());
|
||||||
$$ = new NameExpr(std::move(id));
|
$$ = new zeek::detail::NameExpr(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( id->IsEnumConst() )
|
else if ( id->IsEnumConst() )
|
||||||
|
@ -697,11 +697,11 @@ expr:
|
||||||
id->Name());
|
id->Name());
|
||||||
if ( intval < 0 )
|
if ( intval < 0 )
|
||||||
reporter->InternalError("enum value not found for %s", id->Name());
|
reporter->InternalError("enum value not found for %s", id->Name());
|
||||||
$$ = new ConstExpr(t->GetVal(intval));
|
$$ = new zeek::detail::ConstExpr(t->GetVal(intval));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$$ = new NameExpr(std::move(id));
|
$$ = new zeek::detail::NameExpr(std::move(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,7 +709,7 @@ expr:
|
||||||
| TOK_CONSTANT
|
| TOK_CONSTANT
|
||||||
{
|
{
|
||||||
set_location(@1);
|
set_location(@1);
|
||||||
$$ = new ConstExpr({AdoptRef{}, $1});
|
$$ = new zeek::detail::ConstExpr({AdoptRef{}, $1});
|
||||||
}
|
}
|
||||||
|
|
||||||
| '/' { begin_RE(); } TOK_PATTERN_TEXT TOK_PATTERN_END
|
| '/' { begin_RE(); } TOK_PATTERN_TEXT TOK_PATTERN_END
|
||||||
|
@ -723,30 +723,30 @@ expr:
|
||||||
re->MakeCaseInsensitive();
|
re->MakeCaseInsensitive();
|
||||||
|
|
||||||
re->Compile();
|
re->Compile();
|
||||||
$$ = new ConstExpr(make_intrusive<PatternVal>(re));
|
$$ = new zeek::detail::ConstExpr(make_intrusive<PatternVal>(re));
|
||||||
}
|
}
|
||||||
|
|
||||||
| '|' expr '|' %prec '('
|
| '|' expr '|' %prec '('
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
IntrusivePtr<Expr> e{AdoptRef{}, $2};
|
IntrusivePtr<zeek::detail::Expr> e{AdoptRef{}, $2};
|
||||||
|
|
||||||
if ( IsIntegral(e->GetType()->Tag()) )
|
if ( IsIntegral(e->GetType()->Tag()) )
|
||||||
e = make_intrusive<ArithCoerceExpr>(std::move(e), TYPE_INT);
|
e = make_intrusive<zeek::detail::ArithCoerceExpr>(std::move(e), TYPE_INT);
|
||||||
|
|
||||||
$$ = new SizeExpr(std::move(e));
|
$$ = new zeek::detail::SizeExpr(std::move(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_AS type
|
| expr TOK_AS type
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new CastExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::CastExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| expr TOK_IS type
|
| expr TOK_IS type
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new IsExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
$$ = new zeek::detail::IsExpr({AdoptRef{}, $1}, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -760,14 +760,14 @@ expr_list:
|
||||||
| expr
|
| expr
|
||||||
{
|
{
|
||||||
set_location(@1);
|
set_location(@1);
|
||||||
$$ = new ListExpr({AdoptRef{}, $1});
|
$$ = new zeek::detail::ListExpr({AdoptRef{}, $1});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_expr_list:
|
opt_expr_list:
|
||||||
expr_list
|
expr_list
|
||||||
|
|
|
|
||||||
{ $$ = new ListExpr(); }
|
{ $$ = new zeek::detail::ListExpr(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
enum_body:
|
enum_body:
|
||||||
|
@ -1109,7 +1109,7 @@ decl:
|
||||||
| TOK_REDEF global_id opt_type init_class opt_init opt_attr ';'
|
| TOK_REDEF global_id opt_type init_class opt_init opt_attr ';'
|
||||||
{
|
{
|
||||||
IntrusivePtr id{AdoptRef{}, $2};
|
IntrusivePtr id{AdoptRef{}, $2};
|
||||||
IntrusivePtr<Expr> init{AdoptRef{}, $5};
|
IntrusivePtr<zeek::detail::Expr> init{AdoptRef{}, $5};
|
||||||
add_global(id, {AdoptRef{}, $3}, $4, init,
|
add_global(id, {AdoptRef{}, $3}, $4, init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||||
VAR_REDEF);
|
VAR_REDEF);
|
||||||
|
@ -1262,7 +1262,7 @@ lambda_body:
|
||||||
auto ingredients = std::make_unique<function_ingredients>(IntrusivePtr{NewRef{}, current_scope()}, IntrusivePtr{AdoptRef{}, $3});
|
auto ingredients = std::make_unique<function_ingredients>(IntrusivePtr{NewRef{}, current_scope()}, IntrusivePtr{AdoptRef{}, $3});
|
||||||
id_list outer_ids = gather_outer_ids(pop_scope().get(), ingredients->body.get());
|
id_list outer_ids = gather_outer_ids(pop_scope().get(), ingredients->body.get());
|
||||||
|
|
||||||
$$ = new LambdaExpr(std::move(ingredients), std::move(outer_ids));
|
$$ = new zeek::detail::LambdaExpr(std::move(ingredients), std::move(outer_ids));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1321,19 +1321,19 @@ index_slice:
|
||||||
{
|
{
|
||||||
set_location(@1, @6);
|
set_location(@1, @6);
|
||||||
|
|
||||||
auto low = $3 ? IntrusivePtr<Expr>{AdoptRef{}, $3} :
|
auto low = $3 ? IntrusivePtr<zeek::detail::Expr>{AdoptRef{}, $3} :
|
||||||
make_intrusive<ConstExpr>(val_mgr->Count(0));
|
make_intrusive<zeek::detail::ConstExpr>(val_mgr->Count(0));
|
||||||
|
|
||||||
auto high = $5 ? IntrusivePtr<Expr>{AdoptRef{}, $5} :
|
auto high = $5 ? IntrusivePtr<zeek::detail::Expr>{AdoptRef{}, $5} :
|
||||||
make_intrusive<SizeExpr>(
|
make_intrusive<zeek::detail::SizeExpr>(
|
||||||
IntrusivePtr<Expr>{NewRef{}, $1});
|
IntrusivePtr<zeek::detail::Expr>{NewRef{}, $1});
|
||||||
|
|
||||||
if ( ! IsIntegral(low->GetType()->Tag()) || ! IsIntegral(high->GetType()->Tag()) )
|
if ( ! IsIntegral(low->GetType()->Tag()) || ! IsIntegral(high->GetType()->Tag()) )
|
||||||
reporter->Error("slice notation must have integral values as indexes");
|
reporter->Error("slice notation must have integral values as indexes");
|
||||||
|
|
||||||
auto le = make_intrusive<ListExpr>(std::move(low));
|
auto le = make_intrusive<zeek::detail::ListExpr>(std::move(low));
|
||||||
le->Append(std::move(high));
|
le->Append(std::move(high));
|
||||||
$$ = new IndexExpr({AdoptRef{}, $1}, std::move(le), true);
|
$$ = new zeek::detail::IndexExpr({AdoptRef{}, $1}, std::move(le), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_attr:
|
opt_attr:
|
||||||
|
@ -1388,7 +1388,7 @@ attr:
|
||||||
| TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
| TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
||||||
{
|
{
|
||||||
if ( IsString($3->GetType()->Tag()) )
|
if ( IsString($3->GetType()->Tag()) )
|
||||||
$$ = new Attr(ATTR_DEPRECATED, make_intrusive<ConstExpr>(IntrusivePtr{AdoptRef{}, $3}));
|
$$ = new Attr(ATTR_DEPRECATED, make_intrusive<zeek::detail::ConstExpr>(IntrusivePtr{AdoptRef{}, $3}));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
@ -1568,7 +1568,7 @@ stmt:
|
||||||
| index_slice '=' expr ';' opt_no_test
|
| index_slice '=' expr ';' opt_no_test
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new zeek::detail::ExprStmt(get_assign_expr({AdoptRef{}, $1},
|
$$ = new zeek::detail::ExprStmt(zeek::detail::get_assign_expr({AdoptRef{}, $1},
|
||||||
{AdoptRef{}, $3}, in_init));
|
{AdoptRef{}, $3}, in_init));
|
||||||
|
|
||||||
if ( ! $5 )
|
if ( ! $5 )
|
||||||
|
@ -1622,7 +1622,7 @@ event:
|
||||||
reporter->Warning("%s", id->GetDeprecationWarning().c_str());
|
reporter->Warning("%s", id->GetDeprecationWarning().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
$$ = new EventExpr($1, {AdoptRef{}, $3});
|
$$ = new zeek::detail::EventExpr($1, {AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1878,19 +1878,19 @@ opt_no_test_block:
|
||||||
|
|
||||||
opt_deprecated:
|
opt_deprecated:
|
||||||
TOK_ATTR_DEPRECATED
|
TOK_ATTR_DEPRECATED
|
||||||
{ $$ = new ConstExpr(make_intrusive<StringVal>("")); }
|
{ $$ = new zeek::detail::ConstExpr(make_intrusive<StringVal>("")); }
|
||||||
|
|
|
|
||||||
TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
||||||
{
|
{
|
||||||
if ( IsString($3->GetType()->Tag()) )
|
if ( IsString($3->GetType()->Tag()) )
|
||||||
$$ = new ConstExpr({AdoptRef{}, $3});
|
$$ = new zeek::detail::ConstExpr({AdoptRef{}, $3});
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
$3->Describe(&d);
|
$3->Describe(&d);
|
||||||
reporter->Error("'&deprecated=%s' must use a string literal",
|
reporter->Error("'&deprecated=%s' must use a string literal",
|
||||||
d.Description());
|
d.Description());
|
||||||
$$ = new ConstExpr(make_intrusive<StringVal>(""));
|
$$ = new zeek::detail::ConstExpr(make_intrusive<StringVal>(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
|
|
10
src/scan.l
10
src/scan.l
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#include "plugin/Manager.h"
|
#include "plugin/Manager.h"
|
||||||
|
|
||||||
|
using namespace zeek::detail;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct ZeekINode {
|
struct ZeekINode {
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
|
@ -724,12 +726,12 @@ public:
|
||||||
LocalNameFinder()
|
LocalNameFinder()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual TraversalCode PreExpr(const Expr* expr)
|
virtual TraversalCode PreExpr(const zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
if ( expr->Tag() != EXPR_NAME )
|
if ( expr->Tag() != EXPR_NAME )
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
|
||||||
const NameExpr* name_expr = static_cast<const NameExpr*>(expr);
|
const zeek::detail::NameExpr* name_expr = static_cast<const zeek::detail::NameExpr*>(expr);
|
||||||
|
|
||||||
if ( name_expr->Id()->IsGlobal() )
|
if ( name_expr->Id()->IsGlobal() )
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
@ -738,10 +740,10 @@ public:
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const NameExpr*> local_names;
|
std::vector<const zeek::detail::NameExpr*> local_names;
|
||||||
};
|
};
|
||||||
|
|
||||||
void do_atif(Expr* expr)
|
void do_atif(zeek::detail::Expr* expr)
|
||||||
{
|
{
|
||||||
++current_depth;
|
++current_depth;
|
||||||
|
|
||||||
|
|
|
@ -3479,7 +3479,7 @@ function dump_packet%(pkt: pcap_packet, file_name: string%) : bool
|
||||||
|
|
||||||
class LookupHostCallback : public DNS_Mgr::LookupCallback {
|
class LookupHostCallback : public DNS_Mgr::LookupCallback {
|
||||||
public:
|
public:
|
||||||
LookupHostCallback(trigger::Trigger* arg_trigger, const CallExpr* arg_call,
|
LookupHostCallback(trigger::Trigger* arg_trigger, const zeek::detail::CallExpr* arg_call,
|
||||||
bool arg_lookup_name)
|
bool arg_lookup_name)
|
||||||
{
|
{
|
||||||
Ref(arg_trigger);
|
Ref(arg_trigger);
|
||||||
|
@ -3532,7 +3532,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
trigger::Trigger* trigger;
|
trigger::Trigger* trigger;
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
bool lookup_name;
|
bool lookup_name;
|
||||||
};
|
};
|
||||||
%%}
|
%%}
|
||||||
|
|
|
@ -32,7 +32,7 @@ IdentifierInfo::~IdentifierInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentifierInfo::AddRedef(const string& script, init_class ic,
|
void IdentifierInfo::AddRedef(const string& script, init_class ic,
|
||||||
IntrusivePtr<Expr> init_expr, const vector<string>& comments)
|
IntrusivePtr<zeek::detail::Expr> init_expr, const vector<string>& comments)
|
||||||
{
|
{
|
||||||
Redefinition* redef = new Redefinition(script, ic, std::move(init_expr), comments);
|
Redefinition* redef = new Redefinition(script, ic, std::move(init_expr), comments);
|
||||||
redefs.push_back(redef);
|
redefs.push_back(redef);
|
||||||
|
@ -142,7 +142,7 @@ time_t IdentifierInfo::DoGetModificationTime() const
|
||||||
IdentifierInfo::Redefinition::Redefinition(
|
IdentifierInfo::Redefinition::Redefinition(
|
||||||
std::string arg_script,
|
std::string arg_script,
|
||||||
init_class arg_ic,
|
init_class arg_ic,
|
||||||
IntrusivePtr<Expr> arg_expr,
|
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
||||||
std::vector<std::string> arg_comments)
|
std::vector<std::string> arg_comments)
|
||||||
: from_script(std::move(arg_script)),
|
: from_script(std::move(arg_script)),
|
||||||
ic(arg_ic),
|
ic(arg_ic),
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
* @param comments Comments associated with the redef statement.
|
* @param comments Comments associated with the redef statement.
|
||||||
*/
|
*/
|
||||||
void AddRedef(const std::string& from_script, init_class ic,
|
void AddRedef(const std::string& from_script, init_class ic,
|
||||||
IntrusivePtr<Expr> init_expr,
|
IntrusivePtr<zeek::detail::Expr> init_expr,
|
||||||
const std::vector<std::string>& comments);
|
const std::vector<std::string>& comments);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,11 +128,11 @@ public:
|
||||||
struct Redefinition {
|
struct Redefinition {
|
||||||
std::string from_script; /**< Name of script doing the redef. */
|
std::string from_script; /**< Name of script doing the redef. */
|
||||||
init_class ic;
|
init_class ic;
|
||||||
IntrusivePtr<Expr> init_expr;
|
IntrusivePtr<zeek::detail::Expr> init_expr;
|
||||||
std::vector<std::string> comments; /**< Zeekygen comments on redef. */
|
std::vector<std::string> comments; /**< Zeekygen comments on redef. */
|
||||||
|
|
||||||
Redefinition(std::string arg_script, init_class arg_ic,
|
Redefinition(std::string arg_script, init_class arg_ic,
|
||||||
IntrusivePtr<Expr> arg_expr,
|
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
||||||
std::vector<std::string> arg_comments);
|
std::vector<std::string> arg_comments);
|
||||||
|
|
||||||
~Redefinition();
|
~Redefinition();
|
||||||
|
|
|
@ -361,7 +361,7 @@ void Manager::RecordField(const ID* id, const TypeDecl* field,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Redef(const ID* id, const string& path,
|
void Manager::Redef(const ID* id, const string& path,
|
||||||
init_class ic, IntrusivePtr<Expr> init_expr)
|
init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr)
|
||||||
{
|
{
|
||||||
if ( disabled )
|
if ( disabled )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
* @param init_expr The intiialization expression that was used.
|
* @param init_expr The intiialization expression that was used.
|
||||||
*/
|
*/
|
||||||
void Redef(const ID* id, const std::string& path,
|
void Redef(const ID* id, const std::string& path,
|
||||||
init_class ic, IntrusivePtr<Expr> init_expr);
|
init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr);
|
||||||
void Redef(const ID* id, const std::string& path,
|
void Redef(const ID* id, const std::string& path,
|
||||||
init_class ic = INIT_NONE);
|
init_class ic = INIT_NONE);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue