all: Change to use Func::GetName()

This commit is contained in:
Arne Welzel 2024-09-27 12:53:42 +02:00
parent 71e9c8d436
commit 77b9510c8a
13 changed files with 29 additions and 31 deletions

View file

@ -703,7 +703,7 @@ int dbg_handle_debug_input() {
Frame* curr_frame = g_frame_stack.back();
const ScriptFunc* func = curr_frame->GetFunction();
if ( func )
current_module = extract_module_name(func->Name());
current_module = extract_module_name(func->GetName().c_str());
else
current_module = GLOBAL_MODULE_NAME;

View file

@ -615,7 +615,7 @@ std::string DeltaUnsupportedCreate::Generate(ValTraceMgr* vtm) const {
}
EventTrace::EventTrace(const ScriptFunc* _ev, double _nt, size_t event_num) : ev(_ev), nt(_nt) {
auto ev_name = std::regex_replace(ev->Name(), std::regex(":"), "_");
auto ev_name = std::regex_replace(ev->GetName(), std::regex(":"), "_");
name = ev_name + "_" + std::to_string(event_num) + "__et";
}
@ -678,7 +678,7 @@ void EventTrace::Generate(FILE* f, ValTraceMgr& vtm, const DeltaGenVec& dvec, st
if ( ! dvec.empty() )
fprintf(f, "\n");
fprintf(f, "\tevent %s(%s);\n\n", ev->Name(), args.c_str());
fprintf(f, "\tevent %s(%s);\n\n", ev->GetName().c_str(), args.c_str());
if ( successor.empty() ) {
// The following isn't necessary with our current approach
@ -880,7 +880,7 @@ std::string ValTraceMgr::GenValName(const ValPtr& v) {
break;
}
case TYPE_FUNC: rep = v->AsFunc()->Name(); break;
case TYPE_FUNC: rep = v->AsFunc()->GetName(); break;
case TYPE_TIME: {
auto tm = v->AsDouble();
@ -1004,11 +1004,11 @@ EventTraceMgr::~EventTraceMgr() {
}
void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
if ( script_events.count(ev->Name()) > 0 )
if ( script_events.count(ev->GetName()) > 0 )
return;
auto nt = run_state::network_time;
if ( nt == 0.0 || util::streq(ev->Name(), "zeek_init") )
if ( nt == 0.0 || ev->GetName() == "zeek_init" )
return;
if ( ! vtm.GetBaseTime() )
@ -1021,10 +1021,10 @@ void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
}
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
if ( script_events.count(ev->Name()) > 0 )
if ( script_events.count(ev->GetName()) > 0 )
return;
if ( run_state::network_time > 0.0 && ! util::streq(ev->Name(), "zeek_init") )
if ( run_state::network_time > 0.0 && ev->GetName() != "zeek_init" )
vtm.FinishCurrentEvent(args);
}

View file

@ -4469,7 +4469,7 @@ TraversalCode EventExpr::Traverse(TraversalCallback* cb) const {
// to infinite traversals. We do, however, see if we can
// locate the corresponding identifier, and traverse that.
auto& id = lookup_ID(f->Name(), GLOBAL_MODULE_NAME, false, false, false);
auto& id = lookup_ID(f->GetName().c_str(), GLOBAL_MODULE_NAME, false, false, false);
if ( id ) {
tc = id->Traverse(cb);

View file

@ -437,7 +437,7 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID && ! GetType()->ExpressionlessReturnOkay() &&
(flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) &&
! f->HasDelayed() )
reporter->Warning("non-void function returning without a value: %s", Name());
reporter->Warning("non-void function returning without a value: %s", GetName().c_str());
if ( result && g_trace_state.DoTrace() ) {
ODesc d;

View file

@ -121,7 +121,7 @@ ScriptProfileMgr::~ScriptProfileMgr() {
auto func = body_to_func[o];
if ( func_stats.count(func) == 0 )
func_stats[func] = ScriptProfileStats(func->Name());
func_stats[func] = ScriptProfileStats(func->GetName());
func_stats[func].AddIn(p);
}

View file

@ -87,7 +87,7 @@ private:
class ScriptProfile : public ScriptProfileStats {
public:
ScriptProfile(const Func* _func, const detail::StmtPtr& body) : ScriptProfileStats(_func->Name()) {
ScriptProfile(const Func* _func, const detail::StmtPtr& body) : ScriptProfileStats(_func->GetName()) {
func = {NewRef{}, const_cast<Func*>(_func)};
is_BiF = body == nullptr;

View file

@ -761,12 +761,10 @@ std::optional<broker::data> val_to_data(const Val* v) {
case TYPE_FILE: return {string(v->AsFile()->Name())};
case TYPE_FUNC: {
const Func* f = v->AsFunc();
std::string name(f->Name());
broker::vector rval;
rval.emplace_back(name);
rval.emplace_back(f->GetName());
if ( name.find("lambda_<") == 0 ) {
if ( f->GetName().find("lambda_<") == 0 ) {
// Only ScriptFuncs have closures.
if ( auto b = dynamic_cast<const zeek::detail::ScriptFunc*>(f) ) {
auto bc = b->SerializeCaptures();

View file

@ -803,9 +803,9 @@ bool Manager::AutoPublishEvent(string topic, Val* event) {
return false;
}
auto handler = event_registry->Lookup(event_val->Name());
auto handler = event_registry->Lookup(event_val->GetName());
if ( ! handler ) {
Error("Broker::auto_publish failed to lookup event '%s'", event_val->Name());
Error("Broker::auto_publish failed to lookup event '%s'", event_val->GetName().c_str());
return false;
}
@ -828,10 +828,10 @@ bool Manager::AutoUnpublishEvent(const string& topic, Val* event) {
return false;
}
auto handler = event_registry->Lookup(event_val->Name());
auto handler = event_registry->Lookup(event_val->GetName());
if ( ! handler ) {
Error("Broker::auto_event_stop failed to lookup event '%s'", event_val->Name());
Error("Broker::auto_event_stop failed to lookup event '%s'", event_val->GetName().c_str());
return false;
}
@ -886,7 +886,7 @@ zeek::RecordValPtr Manager::MakeEvent(ArgsSpan args) {
return rval;
}
rval->Assign(0, func->Name());
rval->Assign(0, func->GetName());
continue;
}

View file

@ -28,10 +28,10 @@ file_analysis::Analyzer* DataEvent::Instantiate(RecordValPtr args, file_analysis
EventHandlerPtr stream;
if ( chunk_val )
chunk = event_registry->Lookup(chunk_val->AsFunc()->Name());
chunk = event_registry->Lookup(chunk_val->AsFunc()->GetName());
if ( stream_val )
stream = event_registry->Lookup(stream_val->AsFunc()->Name());
stream = event_registry->Lookup(stream_val->AsFunc()->GetName());
return new DataEvent(std::move(args), file, chunk, stream);
}

View file

@ -412,8 +412,8 @@ bool Manager::CreateEventStream(RecordVal* fval) {
stream->num_fields = fieldsV.size();
stream->fields = fields->Ref()->AsRecordType();
stream->event = event_registry->Lookup(event->Name());
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
stream->event = event_registry->Lookup(event->GetName());
stream->error_event = error_event ? event_registry->Lookup(error_event->GetName()) : nullptr;
stream->want_record = (want_record->InternalInt() == 1);
assert(stream->reader);
@ -679,8 +679,8 @@ bool Manager::CreateTableStream(RecordVal* fval) {
stream->tab = dst.release()->AsTableVal();
stream->rtype = val.release();
stream->itype = idx->Ref()->AsRecordType();
stream->event = event ? event_registry->Lookup(event->Name()) : nullptr;
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
stream->event = event ? event_registry->Lookup(event->GetName()) : nullptr;
stream->error_event = error_event ? event_registry->Lookup(error_event->GetName()) : nullptr;
stream->currDict = new PDict<InputHash>;
stream->currDict->SetDeleteFunc(input_hash_delete_func);
stream->lastDict = new PDict<InputHash>;

View file

@ -587,7 +587,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval) {
streams[idx]->id = id->Ref()->AsEnumVal();
streams[idx]->enabled = true;
streams[idx]->name = id->GetType()->AsEnumType()->Lookup(idx);
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : nullptr;
streams[idx]->event = event ? event_registry->Lookup(event->GetName()) : nullptr;
streams[idx]->policy = policy;
streams[idx]->columns = columns->Ref()->AsRecordType();
streams[idx]->max_delay_interval = sval->GetField("max_delay_interval")->AsInterval();
@ -1651,7 +1651,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
if ( f->postprocessor ) {
delete[] winfo->info->post_proc_func;
winfo->info->post_proc_func = util::copy_string(f->postprocessor->Name());
winfo->info->post_proc_func = util::copy_string(f->postprocessor->GetName().c_str());
}
break;

View file

@ -784,7 +784,7 @@ void Ascii::RotateLeftoverLogs() {
reporter->Info("Rotated/postprocessed leftover log '%s' -> '%s' ", ll.filename.data(),
rotation_path.data());
} catch ( InterpreterException& e ) {
reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", ppf->Name(),
reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", ppf->GetName().c_str(),
ll.filename.data());
}
}

View file

@ -103,7 +103,7 @@ void HookArgument::Describe(ODesc* d) const {
case FUNC:
if ( arg.func )
d->Add(arg.func->Name());
d->Add(arg.func->GetName());
else
d->Add("<null>");
break;