mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
36
src/Scope.cc
36
src/Scope.cc
|
@ -1,22 +1,22 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
#include "zeek/Scope.h"
|
||||
|
||||
#include "zeek/Desc.h"
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/IntrusivePtr.h"
|
||||
#include "zeek/Val.h"
|
||||
#include "zeek/Reporter.h"
|
||||
#include "zeek/Val.h"
|
||||
#include "zeek/module_util.h"
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
namespace zeek::detail {
|
||||
namespace zeek::detail
|
||||
{
|
||||
|
||||
static std::vector<ScopePtr> scopes;
|
||||
static ScopePtr top_scope;
|
||||
|
||||
Scope::Scope(IDPtr id,
|
||||
std::unique_ptr<std::vector<AttrPtr>> al)
|
||||
Scope::Scope(IDPtr id, std::unique_ptr<std::vector<AttrPtr>> al)
|
||||
: scope_id(std::move(id)), attrs(std::move(al))
|
||||
{
|
||||
return_type = nullptr;
|
||||
|
@ -104,16 +104,14 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
|||
return TC_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
const IDPtr& lookup_ID(const char* name, const char* curr_module,
|
||||
bool no_global, bool same_module_only,
|
||||
bool check_export)
|
||||
const IDPtr& lookup_ID(const char* name, const char* curr_module, bool no_global,
|
||||
bool same_module_only, bool check_export)
|
||||
{
|
||||
std::string fullname = make_full_var_name(curr_module, name);
|
||||
|
||||
std::string ID_module = extract_module_name(fullname.c_str());
|
||||
bool need_export = check_export && (ID_module != GLOBAL_MODULE_NAME &&
|
||||
ID_module != curr_module);
|
||||
bool need_export =
|
||||
check_export && (ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module);
|
||||
|
||||
for ( auto s_i = scopes.rbegin(); s_i != scopes.rend(); ++s_i )
|
||||
{
|
||||
|
@ -122,15 +120,13 @@ const IDPtr& lookup_ID(const char* name, const char* curr_module,
|
|||
if ( id )
|
||||
{
|
||||
if ( need_export && ! id->IsExport() && ! in_debug )
|
||||
reporter->Error("identifier is not exported: %s",
|
||||
fullname.c_str());
|
||||
reporter->Error("identifier is not exported: %s", fullname.c_str());
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 ||
|
||||
! same_module_only) )
|
||||
if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 || ! same_module_only) )
|
||||
{
|
||||
std::string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name);
|
||||
return global_scope()->Find(globalname);
|
||||
|
@ -139,16 +135,14 @@ const IDPtr& lookup_ID(const char* name, const char* curr_module,
|
|||
return ID::nil;
|
||||
}
|
||||
|
||||
IDPtr install_ID(const char* name, const char* module_name,
|
||||
bool is_global, bool is_export)
|
||||
IDPtr install_ID(const char* name, const char* module_name, bool is_global, bool is_export)
|
||||
{
|
||||
if ( scopes.empty() && ! is_global )
|
||||
reporter->InternalError("local identifier in global scope");
|
||||
|
||||
IDScope scope;
|
||||
if ( is_export || ! module_name ||
|
||||
(is_global &&
|
||||
normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
||||
(is_global && normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
||||
scope = SCOPE_GLOBAL;
|
||||
else if ( is_global )
|
||||
scope = SCOPE_MODULE;
|
||||
|
@ -205,4 +199,4 @@ ScopePtr global_scope()
|
|||
return scopes.empty() ? 0 : scopes.front();
|
||||
}
|
||||
|
||||
} // namespace zeek::detail
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue