mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
tracking of optimization information associated with expressions
This commit is contained in:
parent
3ac725f44b
commit
074b18f3e8
3 changed files with 36 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "zeek/module_util.h"
|
#include "zeek/module_util.h"
|
||||||
#include "zeek/DebugLogger.h"
|
#include "zeek/DebugLogger.h"
|
||||||
#include "zeek/Hash.h"
|
#include "zeek/Hash.h"
|
||||||
|
#include "zeek/script_opt/ExprOptInfo.h"
|
||||||
|
|
||||||
#include "zeek/broker/Data.h"
|
#include "zeek/broker/Data.h"
|
||||||
|
|
||||||
|
@ -79,6 +80,12 @@ const char* expr_name(BroExprTag t)
|
||||||
Expr::Expr(BroExprTag arg_tag) : tag(arg_tag), paren(false), type(nullptr)
|
Expr::Expr(BroExprTag arg_tag) : tag(arg_tag), paren(false), type(nullptr)
|
||||||
{
|
{
|
||||||
SetLocationInfo(&start_location, &end_location);
|
SetLocationInfo(&start_location, &end_location);
|
||||||
|
opt_info = new ExprOptInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
Expr::~Expr()
|
||||||
|
{
|
||||||
|
delete opt_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListExpr* Expr::AsListExpr() const
|
const ListExpr* Expr::AsListExpr() const
|
||||||
|
|
12
src/Expr.h
12
src/Expr.h
|
@ -117,6 +117,8 @@ using RefExprPtr = IntrusivePtr<RefExpr>;
|
||||||
class Stmt;
|
class Stmt;
|
||||||
using StmtPtr = IntrusivePtr<Stmt>;
|
using StmtPtr = IntrusivePtr<Stmt>;
|
||||||
|
|
||||||
|
class ExprOptInfo;
|
||||||
|
|
||||||
class Expr : public Obj {
|
class Expr : public Obj {
|
||||||
public:
|
public:
|
||||||
const TypePtr& GetType() const
|
const TypePtr& GetType() const
|
||||||
|
@ -389,6 +391,12 @@ public:
|
||||||
return Obj::GetLocationInfo();
|
return Obj::GetLocationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access script optimization information associated with
|
||||||
|
// this statement.
|
||||||
|
ExprOptInfo* GetOptInfo() const { return opt_info; }
|
||||||
|
|
||||||
|
~Expr() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Expr() = default;
|
Expr() = default;
|
||||||
explicit Expr(BroExprTag arg_tag);
|
explicit Expr(BroExprTag arg_tag);
|
||||||
|
@ -418,6 +426,10 @@ protected:
|
||||||
// derived, if any. Used as an aid for generating meaningful
|
// derived, if any. Used as an aid for generating meaningful
|
||||||
// and correctly-localized error messages.
|
// and correctly-localized error messages.
|
||||||
ExprPtr original = nullptr;
|
ExprPtr original = nullptr;
|
||||||
|
|
||||||
|
// Information associated with the Expr for purposes of
|
||||||
|
// script optimization.
|
||||||
|
ExprOptInfo* opt_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NameExpr final : public Expr {
|
class NameExpr final : public Expr {
|
||||||
|
|
17
src/script_opt/ExprOptInfo.h
Normal file
17
src/script_opt/ExprOptInfo.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
|
// Auxiliary information associated with expressions to aid script
|
||||||
|
// optimization.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
class ExprOptInfo {
|
||||||
|
public:
|
||||||
|
// The AST number of the statement in which this expression
|
||||||
|
// appears.
|
||||||
|
int stmt_num = -1; // -1 = not assigned yet
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
Loading…
Add table
Add a link
Reference in a new issue