Deprecate Scope::Lookup(), replace with Scope::Find()

This commit is contained in:
Jon Siwek 2020-05-12 22:20:42 -07:00
parent a5762c12cc
commit 8f95a2a0bb
27 changed files with 65 additions and 72 deletions

2
NEWS
View file

@ -174,6 +174,8 @@ Deprecated Functionality
- Most global type/value pointers in NetVar.h are deprecated, but one can - Most global type/value pointers in NetVar.h are deprecated, but one can
still always perform the lookup themselves. still always perform the lookup themselves.
- ``Scope::Lookup()`` is deprecated, use ``Scope::Find()``.
Zeek 3.1.0 Zeek 3.1.0
========== ==========

View file

@ -368,17 +368,17 @@ void init_ip_addr_anonymizers()
ip_anonymizer[PREFIX_PRESERVING_A50] = new AnonymizeIPAddr_A50(); ip_anonymizer[PREFIX_PRESERVING_A50] = new AnonymizeIPAddr_A50();
ip_anonymizer[PREFIX_PRESERVING_MD5] = new AnonymizeIPAddr_PrefixMD5(); ip_anonymizer[PREFIX_PRESERVING_MD5] = new AnonymizeIPAddr_PrefixMD5();
auto id = global_scope()->Lookup("preserve_orig_addr"); auto id = global_scope()->Find("preserve_orig_addr");
if ( id ) if ( id )
anon_preserve_orig_addr = cast_intrusive<TableVal>(id->GetVal()); anon_preserve_orig_addr = cast_intrusive<TableVal>(id->GetVal());
id = global_scope()->Lookup("preserve_resp_addr"); id = global_scope()->Find("preserve_resp_addr");
if ( id ) if ( id )
anon_preserve_resp_addr = cast_intrusive<TableVal>(id->GetVal()); anon_preserve_resp_addr = cast_intrusive<TableVal>(id->GetVal());
id = global_scope()->Lookup("preserve_other_addr"); id = global_scope()->Find("preserve_other_addr");
if ( id ) if ( id )
anon_preserve_other_addr = cast_intrusive<TableVal>(id->GetVal()); anon_preserve_other_addr = cast_intrusive<TableVal>(id->GetVal());

View file

@ -4227,7 +4227,7 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing,
my_name = "lambda_<" + std::to_string(h[0]) + ">"; my_name = "lambda_<" + std::to_string(h[0]) + ">";
auto fullname = make_full_var_name(current_module.data(), my_name.data()); auto fullname = make_full_var_name(current_module.data(), my_name.data());
auto id = global_scope()->Lookup(fullname); const auto& id = global_scope()->Find(fullname);
if ( id ) if ( id )
// Just try again to make a unique lambda name. If two peer // Just try again to make a unique lambda name. If two peer

View file

@ -31,19 +31,14 @@ IntrusivePtr<TableType> zeek::id::count_set;
IntrusivePtr<VectorType> zeek::id::string_vec; IntrusivePtr<VectorType> zeek::id::string_vec;
IntrusivePtr<VectorType> zeek::id::index_vec; IntrusivePtr<VectorType> zeek::id::index_vec;
IntrusivePtr<ID> zeek::id::lookup(const char* name) const IntrusivePtr<ID>& zeek::id::lookup(const char* name)
{ {
auto id = global_scope()->Lookup(name); return global_scope()->Find(name);
if ( ! id )
return nullptr;
return {NewRef{}, id};
} }
const IntrusivePtr<BroType>& zeek::id::lookup_type(const char* name) const IntrusivePtr<BroType>& zeek::id::lookup_type(const char* name)
{ {
auto id = zeek::id::lookup(name); auto id = global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find type named: %s", name); reporter->InternalError("Failed to find type named: %s", name);
@ -53,7 +48,7 @@ const IntrusivePtr<BroType>& zeek::id::lookup_type(const char* name)
const IntrusivePtr<Val>& zeek::id::lookup_val(const char* name) const IntrusivePtr<Val>& zeek::id::lookup_val(const char* name)
{ {
auto id = zeek::id::lookup(name); auto id = global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", name); reporter->InternalError("Failed to find variable named: %s", name);
@ -63,7 +58,7 @@ const IntrusivePtr<Val>& zeek::id::lookup_val(const char* name)
const IntrusivePtr<Val>& zeek::id::lookup_const(const char* name) const IntrusivePtr<Val>& zeek::id::lookup_const(const char* name)
{ {
auto id = zeek::id::lookup(name); auto id = global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", name); reporter->InternalError("Failed to find variable named: %s", name);

View file

@ -165,7 +165,7 @@ namespace zeek { namespace id {
* @return The identifier, which may reference a nil object if no such * @return The identifier, which may reference a nil object if no such
* name exists. * name exists.
*/ */
IntrusivePtr<ID> lookup(const char* name); const IntrusivePtr<ID>& lookup(const char* name);
/** /**
* Lookup an ID by its name and return its type. A fatal occurs if the ID * Lookup an ID by its name and return its type. A fatal occurs if the ID

View file

@ -193,7 +193,7 @@ void net_init(const std::optional<std::string>& interface,
reporter->FatalError("problem opening dump file %s (%s)", reporter->FatalError("problem opening dump file %s (%s)",
writefile, pkt_dumper->ErrorMsg()); writefile, pkt_dumper->ErrorMsg());
if ( ID* id = global_scope()->Lookup("trace_output_file") ) if ( const auto& id = global_scope()->Find("trace_output_file") )
id->SetVal(make_intrusive<StringVal>(writefile)); id->SetVal(make_intrusive<StringVal>(writefile));
else else
reporter->Error("trace_output_file not defined in bro.init"); reporter->Error("trace_output_file not defined in bro.init");

View file

@ -126,7 +126,7 @@ BroType* OpaqueVal::UnserializeType(const broker::data& data)
if ( ! name ) if ( ! name )
return nullptr; return nullptr;
ID* id = global_scope()->Lookup(*name); const auto& id = global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return nullptr; return nullptr;

View file

@ -129,7 +129,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state,
RuleConditionEval::RuleConditionEval(const char* func) RuleConditionEval::RuleConditionEval(const char* func)
{ {
id = global_scope()->Lookup(func); id = global_scope()->Find(func).get();
if ( ! id ) if ( ! id )
{ {
rules_error("unknown identifier", func); rules_error("unknown identifier", func);

View file

@ -129,24 +129,23 @@ IntrusivePtr<ID> lookup_ID(const char* name, const char* curr_module,
for ( int i = scopes.length() - 1; i >= 0; --i ) for ( int i = scopes.length() - 1; i >= 0; --i )
{ {
ID* id = scopes[i]->Lookup(fullname); const auto& id = scopes[i]->Find(fullname);
if ( id ) if ( id )
{ {
if ( need_export && ! id->IsExport() && ! in_debug ) if ( need_export && ! id->IsExport() && ! in_debug )
reporter->Error("identifier is not exported: %s", reporter->Error("identifier is not exported: %s",
fullname.c_str()); fullname.c_str());
return {NewRef{}, id}; return id;
} }
} }
if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 || if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 ||
! same_module_only) ) ! same_module_only) )
{ {
std::string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name); std::string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name);
ID* id = global_scope()->Lookup(globalname); return global_scope()->Find(globalname);
if ( id )
return {NewRef{}, id};
} }
return nullptr; return nullptr;

View file

@ -22,14 +22,22 @@ public:
~Scope() override; ~Scope() override;
template<typename N> template<typename N>
ID* Lookup(N&& name) const const IntrusivePtr<ID>& Find(N&& name) const
{ {
static IntrusivePtr<ID> nil;
const auto& entry = local.find(std::forward<N>(name)); const auto& entry = local.find(std::forward<N>(name));
if ( entry != local.end() ) if ( entry != local.end() )
return entry->second.get(); return entry->second;
return nullptr; return nil;
}
template<typename N>
[[deprecated("Remove in v4.1. Use Find().")]]
ID* Lookup(N&& name) const
{
return Find(name).get();
} }
template<typename N, typename I> template<typename N, typename I>

View file

@ -1766,7 +1766,7 @@ IntrusivePtr<BroType> merge_types(const BroType* t1, const BroType* t2)
// Doing a lookup here as a roundabout way of ref-ing t1, without // Doing a lookup here as a roundabout way of ref-ing t1, without
// changing the function params which has t1 as const and also // changing the function params which has t1 as const and also
// (potentially) avoiding a pitfall mentioned earlier about clones. // (potentially) avoiding a pitfall mentioned earlier about clones.
auto id = global_scope()->Lookup(t1->GetName()); const auto& id = global_scope()->Find(t1->GetName());
if ( id && id->IsType() && id->GetType()->Tag() == TYPE_ENUM ) if ( id && id->IsType() && id->GetType()->Tag() == TYPE_ENUM )
// It should make most sense to return the real type here rather // It should make most sense to return the real type here rather

View file

@ -371,7 +371,7 @@ void Val::ValDescribeReST(ODesc* d) const
#ifdef DEBUG #ifdef DEBUG
ID* Val::GetID() const ID* Val::GetID() const
{ {
return bound_id ? global_scope()->Lookup(bound_id) : nullptr; return bound_id ? global_scope()->Find(bound_id).get() : nullptr;
} }
void Val::SetID(ID* id) void Val::SetID(ID* id)

View file

@ -609,7 +609,7 @@ TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
return TC_CONTINUE; return TC_CONTINUE;
for ( const auto& scope : scopes ) for ( const auto& scope : scopes )
if ( scope->Lookup(e->Id()->Name()) ) if ( scope->Find(e->Id()->Name()) )
// Shadowing is not allowed, so if it's found at inner scope, it's // Shadowing is not allowed, so if it's found at inner scope, it's
// not something we have to worry about also being at outer scope. // not something we have to worry about also being at outer scope.
return TC_CONTINUE; return TC_CONTINUE;

View file

@ -90,7 +90,7 @@ void Manager::InitPreScript()
void Manager::InitPostScript() void Manager::InitPostScript()
{ {
auto id = global_scope()->Lookup("Tunnel::vxlan_ports"); const auto& id = global_scope()->Find("Tunnel::vxlan_ports");
if ( ! (id && id->GetVal()) ) if ( ! (id && id->GetVal()) )
reporter->FatalError("Tunnel::vxlan_ports not defined"); reporter->FatalError("Tunnel::vxlan_ports not defined");

View file

@ -9,20 +9,10 @@
using namespace analyzer::MQTT; using namespace analyzer::MQTT;
const ::ID* MQTT_Analyzer::max_payload_size = nullptr;
MQTT_Analyzer::MQTT_Analyzer(Connection* c) MQTT_Analyzer::MQTT_Analyzer(Connection* c)
: tcp::TCP_ApplicationAnalyzer("MQTT", c) : tcp::TCP_ApplicationAnalyzer("MQTT", c)
{ {
interp = new binpac::MQTT::MQTT_Conn(this); interp = new binpac::MQTT::MQTT_Conn(this);
if ( ! max_payload_size )
{
max_payload_size = global_scope()->Lookup("MQTT::max_payload_size");
if ( ! max_payload_size )
reporter->FatalError("option not defined: 'MQTT::max_payload_size'");
}
} }
MQTT_Analyzer::~MQTT_Analyzer() MQTT_Analyzer::~MQTT_Analyzer()

View file

@ -23,8 +23,6 @@ public:
static analyzer::Analyzer* InstantiateAnalyzer(Connection* conn) static analyzer::Analyzer* InstantiateAnalyzer(Connection* conn)
{ return new MQTT_Analyzer(conn); } { return new MQTT_Analyzer(conn); }
static const ::ID* max_payload_size;
protected: protected:
binpac::MQTT::MQTT_Conn* interp; binpac::MQTT::MQTT_Conn* interp;

View file

@ -31,7 +31,8 @@ refine flow MQTT_Flow += {
reinterpret_cast<const char*>(${msg.topic.str}.begin()))); reinterpret_cast<const char*>(${msg.topic.str}.begin())));
auto len = ${msg.payload}.length(); auto len = ${msg.payload}.length();
auto max = analyzer::MQTT::MQTT_Analyzer::max_payload_size->GetVal()->AsCount(); static auto max_payload_size = zeek::id::lookup("MQTT::max_payload_size");
auto max = max_payload_size->GetVal()->AsCount();
if ( len > static_cast<int>(max) ) if ( len > static_cast<int>(max) )
len = max; len = max;

View file

@ -353,7 +353,7 @@ struct val_converter {
if ( ! name ) if ( ! name )
return nullptr; return nullptr;
auto id = global_scope()->Lookup(*name); const auto& id = global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return nullptr; return nullptr;
@ -697,7 +697,7 @@ struct type_checker {
if ( ! name ) if ( ! name )
return false; return false;
auto id = global_scope()->Lookup(*name); const auto& id = global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return false; return false;

View file

@ -29,7 +29,7 @@ namespace bro_broker {
static inline Val* get_option(const char* option) static inline Val* get_option(const char* option)
{ {
auto id = global_scope()->Lookup(option); const auto& id = global_scope()->Find(option);
if ( ! (id && id->GetVal()) ) if ( ! (id && id->GetVal()) )
reporter->FatalError("Unknown Broker option %s", option); reporter->FatalError("Unknown Broker option %s", option);
@ -412,7 +412,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
if ( peer_count == 0 ) if ( peer_count == 0 )
return true; return true;
ID* i = global_scope()->Lookup(id); const auto& i = global_scope()->Find(id);
if ( ! i ) if ( ! i )
return false; return false;
@ -1186,7 +1186,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
++statistics.num_ids_incoming; ++statistics.num_ids_incoming;
auto id_name = std::move(iu.id_name()); auto id_name = std::move(iu.id_name());
auto id_value = std::move(iu.id_value()); auto id_value = std::move(iu.id_value());
auto id = global_scope()->Lookup(id_name); const auto& id = global_scope()->Find(id_name);
if ( ! id ) if ( ! id )
{ {

View file

@ -185,7 +185,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
static Func* topic_func = 0; static Func* topic_func = 0;
if ( ! topic_func ) if ( ! topic_func )
topic_func = global_scope()->Lookup("Cluster::rr_topic")->GetVal()->AsFunc(); topic_func = global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc();
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}}; zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
auto topic = topic_func->Call(vl); auto topic = topic_func->Call(vl);
@ -222,7 +222,7 @@ function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
static Func* topic_func = 0; static Func* topic_func = 0;
if ( ! topic_func ) if ( ! topic_func )
topic_func = global_scope()->Lookup("Cluster::hrw_topic")->GetVal()->AsFunc(); topic_func = global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc();
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}}; zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
auto topic = topic_func->Call(vl); auto topic = topic_func->Call(vl);

View file

@ -2498,7 +2498,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
// Enums are not a base-type, so need to look it up. // Enums are not a base-type, so need to look it up.
const auto& sv = val->val.set_val.vals[0]->val.string_val; const auto& sv = val->val.set_val.vals[0]->val.string_val;
std::string enum_name(sv.data, sv.length); std::string enum_name(sv.data, sv.length);
auto enum_id = global_scope()->Lookup(enum_name); const auto& enum_id = global_scope()->Find(enum_name);
if ( ! enum_id ) if ( ! enum_id )
{ {

View file

@ -1182,7 +1182,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
if ( ! found_filter_match ) if ( ! found_filter_match )
{ {
ID* id = global_scope()->Lookup("Log::default_rotation_interval"); const auto& id = global_scope()->Find("Log::default_rotation_interval");
assert(id); assert(id);
winfo->interval = id->GetVal()->AsInterval(); winfo->interval = id->GetVal()->AsInterval();
} }
@ -1525,7 +1525,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
Func* func = winfo->postprocessor; Func* func = winfo->postprocessor;
if ( ! func ) if ( ! func )
{ {
ID* id = global_scope()->Lookup("Log::__default_rotation_postprocessor"); const auto& id = global_scope()->Find("Log::__default_rotation_postprocessor");
assert(id); assert(id);
func = id->GetVal()->AsFunc(); func = id->GetVal()->AsFunc();
} }

View file

@ -7,7 +7,7 @@ module Option;
#include "NetVar.h" #include "NetVar.h"
#include "broker/Data.h" #include "broker/Data.h"
static bool call_option_handlers_and_set_value(StringVal* name, ID* i, static bool call_option_handlers_and_set_value(StringVal* name, const IntrusivePtr<ID>& i,
IntrusivePtr<Val> val, IntrusivePtr<Val> val,
StringVal* location) StringVal* location)
{ {
@ -59,7 +59,7 @@ static bool call_option_handlers_and_set_value(StringVal* name, ID* i,
## lower-level function. ## lower-level function.
function Option::set%(ID: string, val: any, location: string &default=""%): bool function Option::set%(ID: string, val: any, location: string &default=""%): bool
%{ %{
auto i = global_scope()->Lookup(ID->CheckString()); const auto& i = global_scope()->Find(ID->CheckString());
if ( ! i ) if ( ! i )
{ {
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString())); builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
@ -144,7 +144,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
## .. zeek:see:: Option::set ## .. zeek:see:: Option::set
function Option::set_change_handler%(ID: string, on_change: any, priority: int &default=0%): bool function Option::set_change_handler%(ID: string, on_change: any, priority: int &default=0%): bool
%{ %{
auto i = global_scope()->Lookup(ID->CheckString()); const auto& i = global_scope()->Find(ID->CheckString());
if ( ! i ) if ( ! i )
{ {
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString())); builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));

View file

@ -1172,7 +1172,7 @@ IntrusivePtr<RecordVal> Supervisor::Node::ToRecord() const
static IntrusivePtr<Val> supervisor_role_to_cluster_node_type(BifEnum::Supervisor::ClusterRole role) static IntrusivePtr<Val> supervisor_role_to_cluster_node_type(BifEnum::Supervisor::ClusterRole role)
{ {
static auto node_type = global_scope()->Lookup("Cluster::NodeType")->GetType()->AsEnumType(); static auto node_type = global_scope()->Find("Cluster::NodeType")->GetType()->AsEnumType();
switch ( role ) { switch ( role ) {
case BifEnum::Supervisor::LOGGER: case BifEnum::Supervisor::LOGGER:
@ -1193,9 +1193,9 @@ bool Supervisor::SupervisedNode::InitCluster() const
if ( config.cluster.empty() ) if ( config.cluster.empty() )
return false; return false;
auto cluster_node_type = global_scope()->Lookup("Cluster::Node")->GetType()->AsRecordType(); const auto& cluster_node_type = global_scope()->Find("Cluster::Node")->GetType()->AsRecordType();
auto cluster_nodes_id = global_scope()->Lookup("Cluster::nodes"); const auto& cluster_nodes_id = global_scope()->Find("Cluster::nodes");
auto cluster_manager_is_logger_id = global_scope()->Lookup("Cluster::manager_is_logger"); const auto& cluster_manager_is_logger_id = global_scope()->Find("Cluster::manager_is_logger");
auto cluster_nodes = cluster_nodes_id->GetVal()->AsTableVal(); auto cluster_nodes = cluster_nodes_id->GetVal()->AsTableVal();
auto has_logger = false; auto has_logger = false;
std::optional<std::string> manager_name; std::optional<std::string> manager_name;

View file

@ -630,11 +630,11 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
// Must come after plugin activation (and also after hash // Must come after plugin activation (and also after hash
// initialization). // initialization).
binpac::FlowBuffer::Policy flowbuffer_policy; binpac::FlowBuffer::Policy flowbuffer_policy;
flowbuffer_policy.max_capacity = global_scope()->Lookup( flowbuffer_policy.max_capacity = global_scope()->Find(
"BinPAC::flowbuffer_capacity_max")->GetVal()->AsCount(); "BinPAC::flowbuffer_capacity_max")->GetVal()->AsCount();
flowbuffer_policy.min_capacity = global_scope()->Lookup( flowbuffer_policy.min_capacity = global_scope()->Find(
"BinPAC::flowbuffer_capacity_min")->GetVal()->AsCount(); "BinPAC::flowbuffer_capacity_min")->GetVal()->AsCount();
flowbuffer_policy.contract_threshold = global_scope()->Lookup( flowbuffer_policy.contract_threshold = global_scope()->Find(
"BinPAC::flowbuffer_contract_threshold")->GetVal()->AsCount(); "BinPAC::flowbuffer_contract_threshold")->GetVal()->AsCount();
binpac::init(&flowbuffer_policy); binpac::init(&flowbuffer_policy);
@ -685,7 +685,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
if ( options.pcap_filter ) if ( options.pcap_filter )
{ {
ID* id = global_scope()->Lookup("cmd_line_bpf_filter"); const auto& id = global_scope()->Find("cmd_line_bpf_filter");
if ( ! id ) if ( ! id )
reporter->InternalError("global cmd_line_bpf_filter not defined"); reporter->InternalError("global cmd_line_bpf_filter not defined");
@ -769,7 +769,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
// Print the ID. // Print the ID.
if ( options.identifier_to_print ) if ( options.identifier_to_print )
{ {
ID* id = global_scope()->Lookup(*options.identifier_to_print); const auto& id = global_scope()->Find(*options.identifier_to_print);
if ( ! id ) if ( ! id )
reporter->FatalError("No such ID: %s\n", options.identifier_to_print->data()); reporter->FatalError("No such ID: %s\n", options.identifier_to_print->data());

View file

@ -1975,7 +1975,7 @@ function global_ids%(%): id_table
## the string ``"<unknown id>"`` or ``"<no ID value>"`` is returned. ## the string ``"<unknown id>"`` or ``"<no ID value>"`` is returned.
function lookup_ID%(id: string%) : any function lookup_ID%(id: string%) : any
%{ %{
ID* i = global_scope()->Lookup(id->CheckString()); const auto& i = global_scope()->Find(id->CheckString());
if ( ! i ) if ( ! i )
return make_intrusive<StringVal>("<unknown id>"); return make_intrusive<StringVal>("<unknown id>");
@ -1998,7 +1998,7 @@ function record_fields%(rec: any%): record_field_table
if ( rec->GetType()->Tag() == TYPE_STRING ) if ( rec->GetType()->Tag() == TYPE_STRING )
{ {
auto id = global_scope()->Lookup(rec->AsStringVal()->ToStdString()); const auto& id = global_scope()->Find(rec->AsStringVal()->ToStdString());
if ( ! id || ! id->IsType() || id->GetType()->Tag() != TYPE_RECORD ) if ( ! id || ! id->IsType() || id->GetType()->Tag() != TYPE_RECORD )
{ {

View file

@ -257,13 +257,13 @@ void ScriptInfo::DoInitPostScript()
// so just manually associating them with scripts for now. // so just manually associating them with scripts for now.
if ( name == "base/frameworks/input/main.zeek" ) if ( name == "base/frameworks/input/main.zeek" )
{ {
auto id = global_scope()->Lookup("Input::Reader"); const auto& id = global_scope()->Find("Input::Reader");
types.push_back(new IdentifierInfo({NewRef{}, id}, this)); types.push_back(new IdentifierInfo(id, this));
} }
else if ( name == "base/frameworks/logging/main.zeek" ) else if ( name == "base/frameworks/logging/main.zeek" )
{ {
auto id = global_scope()->Lookup("Log::Writer"); const auto& id = global_scope()->Find("Log::Writer");
types.push_back(new IdentifierInfo({NewRef{}, id}, this)); types.push_back(new IdentifierInfo(id, this));
} }
} }