From 46ecd8305dbf16f01b02b5da74d1d8544fc78331 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Tue, 9 Apr 2024 16:25:51 +0200 Subject: [PATCH 1/2] Bump Spicy. Includes necessary changes to work with current Spicy version. --- auxil/spicy | 2 +- src/spicy/spicyz/glue-compiler.cc | 3 ++- src/spicy/spicyz/glue-compiler.h | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/auxil/spicy b/auxil/spicy index 18a7377024..d38f31a95f 160000 --- a/auxil/spicy +++ b/auxil/spicy @@ -1 +1 @@ -Subproject commit 18a7377024003040db19c060f67484ec90ba0753 +Subproject commit d38f31a95f93b1d9ea81fa01f0c92a72cf40f38c diff --git a/src/spicy/spicyz/glue-compiler.cc b/src/spicy/spicyz/glue-compiler.cc index c29bc7a10c..cc17312343 100644 --- a/src/spicy/spicyz/glue-compiler.cc +++ b/src/spicy/spicyz/glue-compiler.cc @@ -1374,7 +1374,8 @@ bool GlueCompiler::CreateSpicyHook(glue::Event* ev) { body.addCall("zeek_rt::raise_event", {handler_expr, builder()->move(builder()->id("args"))}, meta); auto attrs = builder()->attributeSet({builder()->attribute("&priority", builder()->integer(ev->priority))}); - auto unit_hook = builder()->declarationHook(ev->parameters, body.block(), ::spicy::Engine::All, attrs, meta); + auto parameters = hilti::util::transform(ev->parameters, [](const auto& p) { return p.get(); }); + auto unit_hook = builder()->declarationHook(parameters, body.block(), ::spicy::Engine::All, attrs, meta); auto hook_decl = builder()->declarationUnitHook(ev->hook, unit_hook, meta); ev->spicy_module->spicy_module->add(context(), hook_decl); diff --git a/src/spicy/spicyz/glue-compiler.h b/src/spicy/spicyz/glue-compiler.h index b3b84ffb81..44b5572988 100644 --- a/src/spicy/spicyz/glue-compiler.h +++ b/src/spicy/spicyz/glue-compiler.h @@ -101,25 +101,27 @@ struct SpicyModule { std::set evts; /**< EVT files that refer to this module. */ // Generated code. - hilti::declaration::Module* spicy_module = nullptr; /**< the ``BroHooks_*.spicy`` module. */ + hilti::node::RetainedPtr spicy_module = + nullptr; /**< the ``BroHooks_*.spicy`` module. */ }; /** Representation of an event parsed from an EVT file. */ struct Event { // Information parsed directly from the *.evt file. - hilti::rt::filesystem::path file; /**< The path of the *.evt file we parsed this from. */ - hilti::ID name; /**< The name of the event. */ - hilti::ID path; /**< The hook path as specified in the evt file. */ - hilti::type::function::Parameters parameters; /**< Event parameters specified in the evt file. */ - std::string condition; /**< Condition that must be true for the event to trigger. */ - std::vector exprs; /**< The argument expressions. */ - int priority; /**< Event/hook priority. */ - hilti::Location location; /**< Location where event is defined. */ + hilti::rt::filesystem::path file; /**< The path of the *.evt file we parsed this from. */ + hilti::ID name; /**< The name of the event. */ + hilti::ID path; /**< The hook path as specified in the evt file. */ + std::vector> + parameters; /**< Event parameters specified in the evt file. */ + std::string condition; /**< Condition that must be true for the event to trigger. */ + std::vector exprs; /**< The argument expressions. */ + int priority; /**< Event/hook priority. */ + hilti::Location location; /**< Location where event is defined. */ // Computed information. - hilti::ID hook; /**< The name of the hook triggering the event. */ - hilti::ID unit; /**< The fully qualified name of the unit type. */ - ::spicy::type::Unit* unit_type = nullptr; /**< The Spicy type of referenced unit. */ + hilti::ID hook; /**< The name of the hook triggering the event. */ + hilti::ID unit; /**< The fully qualified name of the unit type. */ + hilti::node::RetainedPtr<::spicy::type::Unit> unit_type = nullptr; /**< The Spicy type of referenced unit. */ hilti::ID unit_module_id; /**< The name of the module the referenced unit is defined in. */ hilti::rt::filesystem::path unit_module_path; /**< The path of the module that the referenced unit is defined in. */ std::shared_ptr @@ -167,7 +169,7 @@ public: * Returns the AST context in use. Only available once the driver has * initialized the glue compiler. */ - auto* context() { return _driver->context()->astContext().get(); } + auto* context() { return _driver->context()->astContext(); } /** * Returns the AST builder in use. Only available once the driver has From da21712fb9a9dc5d1c182fe1846c9d9ea5b0b37e Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Tue, 9 Apr 2024 16:32:18 +0200 Subject: [PATCH 2/2] Remove some unused Spicy state. --- src/spicy/spicyz/glue-compiler.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/spicy/spicyz/glue-compiler.h b/src/spicy/spicyz/glue-compiler.h index 44b5572988..58e42909f3 100644 --- a/src/spicy/spicyz/glue-compiler.h +++ b/src/spicy/spicyz/glue-compiler.h @@ -127,11 +127,7 @@ struct Event { std::shared_ptr spicy_module; /**< State for the Spichy module the referenced unit is defined in. */ - // TODO: The following aren't set yet. - // Code generation. - ::spicy::type::unit::item::UnitHook* spicy_hook = nullptr; /**< The generated Spicy hook. */ - hilti::declaration::Function* hilti_raise = nullptr; /**< The generated HILTI raise() function. */ std::vector expression_accessors; /**< One HILTI function per expression to access the value. */ };