mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Superficial changes to script-opt related code
* Rename overly generic ACCESSORS macro with ZEEK_ prefix * A few places where whitespace was noticeably wrong/distracting * Minor/obvious reference/move semantics improvements suggested by linter * Remove unused detail::Scope::Remove(), no need for deprecation
This commit is contained in:
parent
ff7d9e3d72
commit
481d989495
9 changed files with 23 additions and 46 deletions
17
src/Expr.h
17
src/Expr.h
|
@ -179,19 +179,18 @@ public:
|
||||||
void MarkParen() { paren = true; }
|
void MarkParen() { paren = true; }
|
||||||
bool IsParen() const { return paren; }
|
bool IsParen() const { return paren; }
|
||||||
|
|
||||||
#undef ACCESSORS
|
#define ZEEK_EXPR_ACCESSOR_DECLS(ctype) \
|
||||||
#define ACCESSORS(ctype) \
|
|
||||||
const ctype* As ## ctype () const; \
|
const ctype* As ## ctype () const; \
|
||||||
ctype* As ## ctype (); \
|
ctype* As ## ctype (); \
|
||||||
IntrusivePtr<ctype> As ## ctype ## Ptr ();
|
IntrusivePtr<ctype> As ## ctype ## Ptr ();
|
||||||
|
|
||||||
ACCESSORS(ListExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(ListExpr)
|
||||||
ACCESSORS(NameExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(NameExpr)
|
||||||
ACCESSORS(ConstExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(ConstExpr)
|
||||||
ACCESSORS(CallExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(CallExpr)
|
||||||
ACCESSORS(AssignExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(AssignExpr)
|
||||||
ACCESSORS(IndexExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(IndexExpr)
|
||||||
ACCESSORS(EventExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(EventExpr)
|
||||||
|
|
||||||
void Describe(ODesc* d) const override final;
|
void Describe(ODesc* d) const override final;
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,8 @@ private:
|
||||||
/** Associates ID's offsets with values. */
|
/** Associates ID's offsets with values. */
|
||||||
std::unique_ptr<Element[]> frame;
|
std::unique_ptr<Element[]> frame;
|
||||||
|
|
||||||
/** The offset we're currently using for references into the frame.
|
/**
|
||||||
|
* The offset we're currently using for references into the frame.
|
||||||
* This is how we support inlined functions without having to
|
* This is how we support inlined functions without having to
|
||||||
* alter the offsets associated with their local variables.
|
* alter the offsets associated with their local variables.
|
||||||
*/
|
*/
|
||||||
|
|
10
src/Func.h
10
src/Func.h
|
@ -64,16 +64,10 @@ public:
|
||||||
~Func() override;
|
~Func() override;
|
||||||
|
|
||||||
zeek::detail::ScriptFunc* AsScriptFunc()
|
zeek::detail::ScriptFunc* AsScriptFunc()
|
||||||
{
|
{ return GetKind() == SCRIPT_FUNC ? (detail::ScriptFunc*) this : nullptr; }
|
||||||
return GetKind() == SCRIPT_FUNC ?
|
|
||||||
(zeek::detail::ScriptFunc*) this : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const zeek::detail::ScriptFunc* AsScriptFunc() const
|
const zeek::detail::ScriptFunc* AsScriptFunc() const
|
||||||
{
|
{ return GetKind() == SCRIPT_FUNC ? (detail::ScriptFunc*) this : nullptr; }
|
||||||
return GetKind() == SCRIPT_FUNC ?
|
|
||||||
(zeek::detail::ScriptFunc*) this : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool IsPure() const = 0;
|
virtual bool IsPure() const = 0;
|
||||||
FunctionFlavor Flavor() const { return GetType()->Flavor(); }
|
FunctionFlavor Flavor() const { return GetType()->Flavor(); }
|
||||||
|
|
14
src/Scope.cc
14
src/Scope.cc
|
@ -47,20 +47,6 @@ const IDPtr& Scope::Find(std::string_view name) const
|
||||||
return ID::nil;
|
return ID::nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDPtr Scope::Remove(std::string_view name)
|
|
||||||
{
|
|
||||||
auto entry = local.find(name);
|
|
||||||
|
|
||||||
if ( entry != local.end() )
|
|
||||||
{
|
|
||||||
auto id = std::move(entry->second);
|
|
||||||
local.erase(entry);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDPtr Scope::GenerateTemporary(const char* name)
|
IDPtr Scope::GenerateTemporary(const char* name)
|
||||||
{
|
{
|
||||||
return make_intrusive<ID>(name, SCOPE_FUNCTION, false);
|
return make_intrusive<ID>(name, SCOPE_FUNCTION, false);
|
||||||
|
|
|
@ -50,9 +50,6 @@ public:
|
||||||
ordered_vars.push_back(std::forward<I>(id));
|
ordered_vars.push_back(std::forward<I>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
IDPtr Remove(std::string_view name);
|
|
||||||
[[deprecated("Remove in v4.1 as an unused API call.")]]
|
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetID().")]]
|
[[deprecated("Remove in v4.1. Use GetID().")]]
|
||||||
ID* ScopeID() const { return scope_id.get(); }
|
ID* ScopeID() const { return scope_id.get(); }
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr<CallExpr> c)
|
||||||
if ( ! func->IsGlobal() )
|
if ( ! func->IsGlobal() )
|
||||||
return std::move(c);
|
return std::move(c);
|
||||||
|
|
||||||
auto func_v = func->GetVal();
|
const auto& func_v = func->GetVal();
|
||||||
if ( ! func_v )
|
if ( ! func_v )
|
||||||
return std::move(c);
|
return std::move(c);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ TraversalCode ProfileFunc::PreStmt(const Stmt* s)
|
||||||
|
|
||||||
if ( tag == STMT_INIT )
|
if ( tag == STMT_INIT )
|
||||||
{
|
{
|
||||||
for ( auto id : s->AsInitStmt()->Inits() )
|
for ( const auto& id : s->AsInitStmt()->Inits() )
|
||||||
inits.insert(id.get());
|
inits.insert(id.get());
|
||||||
|
|
||||||
// Don't recurse into these, as we don't want to consider
|
// Don't recurse into these, as we don't want to consider
|
||||||
|
|
|
@ -34,9 +34,9 @@ class FuncInfo {
|
||||||
public:
|
public:
|
||||||
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body)
|
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body)
|
||||||
{
|
{
|
||||||
func = _func;
|
func = std::move(_func);
|
||||||
scope = _scope;
|
scope = std::move(_scope);
|
||||||
body = _body;
|
body = std::move(_body);
|
||||||
}
|
}
|
||||||
|
|
||||||
~FuncInfo();
|
~FuncInfo();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue