mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
track more information about temporary variables
This commit is contained in:
parent
64ef7f0eb2
commit
b581c6435e
2 changed files with 45 additions and 1 deletions
|
@ -11,7 +11,31 @@ TempVar::TempVar(int num, const TypePtr& t, ExprPtr _rhs) : type(t)
|
|||
char buf[8192];
|
||||
snprintf(buf, sizeof buf, "#%d", num);
|
||||
name = buf;
|
||||
id = nullptr;
|
||||
rhs = _rhs;
|
||||
}
|
||||
|
||||
void TempVar::SetAlias(IDPtr _alias, const DefPoints* _dps)
|
||||
{
|
||||
if ( alias )
|
||||
reporter->InternalError("Re-aliasing a temporary");
|
||||
|
||||
if ( ! _dps )
|
||||
{
|
||||
printf("trying to alias %s to %s\n", name.c_str(), _alias->Name());
|
||||
reporter->InternalError("Empty dps for alias");
|
||||
}
|
||||
|
||||
if ( alias == id )
|
||||
reporter->InternalError("Creating alias loop");
|
||||
|
||||
alias = _alias;
|
||||
dps = _dps;
|
||||
}
|
||||
|
||||
void TempVar::SetDPs(const DefPoints* _dps)
|
||||
{
|
||||
ASSERT(_dps->length() == 1);
|
||||
dps = _dps;
|
||||
}
|
||||
|
||||
} // zeek::detail
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/Expr.h"
|
||||
#include "zeek/script_opt/ReachingDefs.h"
|
||||
|
||||
namespace zeek::detail {
|
||||
|
||||
|
@ -25,12 +26,31 @@ public:
|
|||
void Deactivate() { active = false; }
|
||||
bool IsActive() const { return active; }
|
||||
|
||||
// Associated constant expression, if any.
|
||||
const ConstExpr* Const() const { return const_expr; }
|
||||
|
||||
// The most use of "const" in any single line in the Zeek
|
||||
// codebase :-P ... though only by one!
|
||||
void SetConst(const ConstExpr* _const) { const_expr = _const; }
|
||||
|
||||
IDPtr Alias() const { return alias; }
|
||||
const DefPoints* DPs() const { return dps; }
|
||||
void SetAlias(IDPtr id, const DefPoints* dps);
|
||||
void SetDPs(const DefPoints* _dps);
|
||||
|
||||
const RDPtr& MaxRDs() const { return max_rds; }
|
||||
void SetMaxRDs(RDPtr rds) { max_rds = rds; }
|
||||
|
||||
protected:
|
||||
std::string name;
|
||||
IDPtr id;
|
||||
const TypePtr& type;
|
||||
ExprPtr rhs;
|
||||
bool active = true;
|
||||
const ConstExpr* const_expr = nullptr;
|
||||
IDPtr alias;
|
||||
const DefPoints* dps = nullptr;
|
||||
RDPtr max_rds;
|
||||
};
|
||||
|
||||
} // zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue