mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -6,9 +6,8 @@
|
|||
#include "zeek/script_opt/DefPoint.h"
|
||||
#include "zeek/script_opt/ReachingDefs.h"
|
||||
|
||||
|
||||
namespace zeek::detail {
|
||||
|
||||
namespace zeek::detail
|
||||
{
|
||||
|
||||
// Class for managing collections of reaching definitions associated
|
||||
// with AST nodes.
|
||||
|
@ -43,15 +42,14 @@ namespace zeek::detail {
|
|||
// here captures the notion that "x is definitely assigned to a value
|
||||
// at this point, but it's uncertain just what that value is".
|
||||
|
||||
class DefSetsMgr {
|
||||
class DefSetsMgr
|
||||
{
|
||||
public:
|
||||
DefSetsMgr();
|
||||
|
||||
// Returns the minimal or maximal pre-RDs associated with a given node.
|
||||
RDPtr GetPreMinRDs(const Obj* o) const
|
||||
{ return GetRDs(pre_min_defs, o); }
|
||||
RDPtr GetPreMaxRDs(const Obj* o) const
|
||||
{ return GetRDs(pre_max_defs, o); }
|
||||
RDPtr GetPreMinRDs(const Obj* o) const { return GetRDs(pre_min_defs, o); }
|
||||
RDPtr GetPreMaxRDs(const Obj* o) const { return GetRDs(pre_max_defs, o); }
|
||||
|
||||
// Same, but for post-RDs.
|
||||
RDPtr GetPostMinRDs(const Obj* o) const
|
||||
|
@ -120,80 +118,66 @@ public:
|
|||
}
|
||||
|
||||
// Fine-grained control for setting RDs.
|
||||
void SetPreMinRDs(const Obj* o, RDPtr rd)
|
||||
{ pre_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPreMaxRDs(const Obj* o, RDPtr rd)
|
||||
{ pre_max_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPreMinRDs(const Obj* o, RDPtr rd) { pre_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPreMaxRDs(const Obj* o, RDPtr rd) { pre_max_defs->SetRDs(o, std::move(rd)); }
|
||||
|
||||
void SetPostMinRDs(const Obj* o, RDPtr rd)
|
||||
{ post_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPostMaxRDs(const Obj* o, RDPtr rd)
|
||||
{ post_max_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPostMinRDs(const Obj* o, RDPtr rd) { post_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPostMaxRDs(const Obj* o, RDPtr rd) { post_max_defs->SetRDs(o, std::move(rd)); }
|
||||
|
||||
// Used for confluence: add a set of RDs into those already
|
||||
// associated with a node's pre-RDs / post-RDs. Only applies
|
||||
// to maximal RDs.
|
||||
void MergeIntoPre(const Obj* o, const RDPtr& rds)
|
||||
{ pre_max_defs->AddRDs(o, rds); }
|
||||
void MergeIntoPost(const Obj* o, const RDPtr& rds)
|
||||
{ post_max_defs->AddRDs(o, rds); }
|
||||
void MergeIntoPre(const Obj* o, const RDPtr& rds) { pre_max_defs->AddRDs(o, rds); }
|
||||
void MergeIntoPost(const Obj* o, const RDPtr& rds) { post_max_defs->AddRDs(o, rds); }
|
||||
|
||||
// The same, but merging a node's own maximal post-RDs into
|
||||
// its maximal pre-RDs.
|
||||
void MergePostIntoPre(const Obj* o)
|
||||
{ MergeIntoPre(o, GetPostMaxRDs(o)); }
|
||||
|
||||
void MergePostIntoPre(const Obj* o) { MergeIntoPre(o, GetPostMaxRDs(o)); }
|
||||
|
||||
// The following predicates look up whether a given node exists
|
||||
// in the given pre/post minimal/maximal RDs.
|
||||
bool HasPreMinRDs(const Obj* o) const
|
||||
{ return pre_min_defs && pre_min_defs->HasRDs(o); }
|
||||
bool HasPreMaxRDs(const Obj* o) const
|
||||
{ return pre_max_defs && pre_max_defs->HasRDs(o); }
|
||||
bool HasPreMinRDs(const Obj* o) const { return pre_min_defs && pre_min_defs->HasRDs(o); }
|
||||
bool HasPreMaxRDs(const Obj* o) const { return pre_max_defs && pre_max_defs->HasRDs(o); }
|
||||
|
||||
bool HasPostMinRDs(const Obj* o) const
|
||||
{ return post_min_defs && post_min_defs->HasRDs(o); }
|
||||
bool HasPostMaxRDs(const Obj* o) const
|
||||
{ return post_max_defs && post_max_defs->HasRDs(o); }
|
||||
bool HasPostMinRDs(const Obj* o) const { return post_min_defs && post_min_defs->HasRDs(o); }
|
||||
bool HasPostMaxRDs(const Obj* o) const { return post_max_defs && post_max_defs->HasRDs(o); }
|
||||
|
||||
// True if the given node has a minimal pre-RD associated
|
||||
// with the given identifier.
|
||||
bool HasPreMinRD(const Obj* o, const ID* id) const
|
||||
{ return pre_min_defs && pre_min_defs->HasRD(o, id); }
|
||||
{
|
||||
return pre_min_defs && pre_min_defs->HasRD(o, id);
|
||||
}
|
||||
|
||||
// True if at the given node, there's a single *unambiguous*
|
||||
// pre RD for the given identifier.
|
||||
bool HasSinglePreMinRD(const Obj* o, const ID* id) const
|
||||
{ return pre_min_defs && pre_min_defs->HasSingleRD(o, id); }
|
||||
|
||||
{
|
||||
return pre_min_defs && pre_min_defs->HasSingleRD(o, id);
|
||||
}
|
||||
|
||||
// Methods for creating new pre/post RDs. If min_only is true,
|
||||
// then only done for minimal RDs.
|
||||
void CreatePreDef(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool min_only)
|
||||
{ CreateDef(std::move(di), dp, true, min_only); }
|
||||
void CreatePreDef(std::shared_ptr<DefinitionItem> di, DefinitionPoint dp, bool min_only)
|
||||
{
|
||||
CreateDef(std::move(di), dp, true, min_only);
|
||||
}
|
||||
void CreatePostDef(const ID* id, DefinitionPoint dp, bool min_only);
|
||||
void CreatePostDef(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool min_only);
|
||||
void CreatePostDef(std::shared_ptr<DefinitionItem> di, DefinitionPoint dp, bool min_only);
|
||||
|
||||
std::shared_ptr<DefinitionItem> GetExprDI(const Expr* e)
|
||||
{ return item_map.GetExprDI(e); }
|
||||
std::shared_ptr<DefinitionItem> GetID_DI(const ID* id)
|
||||
{ return item_map.GetID_DI(id); }
|
||||
const DefinitionItem* GetConstID_DI(const ID* id) const
|
||||
{ return item_map.GetConstID_DI(id); }
|
||||
const DefinitionItem* GetConstID_DI(const DefinitionItem* di,
|
||||
const char* field_name) const
|
||||
{ return item_map.GetConstID_DI(di, field_name); }
|
||||
std::shared_ptr<DefinitionItem> GetExprDI(const Expr* e) { return item_map.GetExprDI(e); }
|
||||
std::shared_ptr<DefinitionItem> GetID_DI(const ID* id) { return item_map.GetID_DI(id); }
|
||||
const DefinitionItem* GetConstID_DI(const ID* id) const { return item_map.GetConstID_DI(id); }
|
||||
const DefinitionItem* GetConstID_DI(const DefinitionItem* di, const char* field_name) const
|
||||
{
|
||||
return item_map.GetConstID_DI(di, field_name);
|
||||
}
|
||||
|
||||
private:
|
||||
void CreateDef(std::shared_ptr<DefinitionItem> di, DefinitionPoint dp,
|
||||
bool is_pre, bool min_only);
|
||||
void CreateDef(std::shared_ptr<DefinitionItem> di, DefinitionPoint dp, bool is_pre,
|
||||
bool min_only);
|
||||
|
||||
RDPtr GetRDs(const RDSetPtr& defs, const Obj* o) const
|
||||
{
|
||||
return defs->FindRDs(o);
|
||||
}
|
||||
RDPtr GetRDs(const RDSetPtr& defs, const Obj* o) const { return defs->FindRDs(o); }
|
||||
|
||||
// Mappings of minimal reaching defs pre- and post- execution
|
||||
// of the given node.
|
||||
|
@ -206,7 +190,6 @@ private:
|
|||
RDSetPtr post_max_defs;
|
||||
|
||||
DefItemMap item_map;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // zeek::detail
|
||||
} // zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue