Skip to content

Commit

Permalink
Merge branch 'topic/bbannier/parser-engine'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Jul 15, 2024
2 parents 28ff26a + 3897349 commit 4a1b43e
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 178 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
1.11.0-dev.262 | 2024-07-15 11:49:46 +0200

* Remove unused `Engine` type and tracking. (Benjamin Bannier, Corelight)

* Remove API customization points for `spicy::Engine`. (Benjamin Bannier, Corelight)

* Remove support for customizable Spicy hook and field engine. (Benjamin Bannier, Corelight)

1.11.0-dev.258 | 2024-07-12 16:34:16 +0200

* GH-1784: Fix import HILTI vs Spicy confusion. (Robin Sommer, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0-dev.258
1.11.0-dev.262
1 change: 0 additions & 1 deletion spicy/toolchain/include/ast/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <spicy/ast/ctors/all.h>
#include <spicy/ast/declarations/all.h>
#include <spicy/ast/engine.h>
#include <spicy/ast/forward.h>
#include <spicy/ast/node-tag.h>
#include <spicy/ast/operators/all.h>
Expand Down
71 changes: 35 additions & 36 deletions spicy/toolchain/include/ast/builder/node-factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class NodeFactory {
auto ctorUnit(ctor::unit::Fields fields, Meta meta = {}) {
return spicy::ctor::Unit::create(context(), std::move(fields), std::move(meta));
}
auto declarationHook(const hilti::declaration::Parameters& parameters, Statement* body, Engine engine,
AttributeSet* attrs, const Meta& m = Meta()) {
return spicy::declaration::Hook::create(context(), parameters, body, engine, attrs, m);
auto declarationHook(const hilti::declaration::Parameters& parameters, Statement* body, AttributeSet* attrs,
const Meta& m = Meta()) {
return spicy::declaration::Hook::create(context(), parameters, body, attrs, m);
}
auto declarationUnitHook(const ID& id, declaration::Hook* hook, Meta meta = {}) {
return spicy::declaration::UnitHook::create(context(), id, hook, std::move(meta));
Expand All @@ -52,22 +52,21 @@ class NodeFactory {
auto typeUnit(hilti::type::Wildcard _, Meta meta = {}) {
return spicy::type::Unit::create(context(), _, std::move(meta));
}
auto typeUnitItemField(const ID& id, Ctor* ctor, Engine engine, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond, spicy::declaration::Hooks hooks,
Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, ctor, engine, skip, std::move(args), repeat,
auto typeUnitItemField(const ID& id, Ctor* ctor, bool skip, Expressions args, Expression* repeat, Expressions sinks,
AttributeSet* attrs, Expression* cond, spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, ctor, skip, std::move(args), repeat,
std::move(sinks), attrs, cond, std::move(hooks), std::move(meta));
}
auto typeUnitItemField(const ID& id, QualifiedType* type, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, type, engine, skip, std::move(args), repeat,
auto typeUnitItemField(const ID& id, QualifiedType* type, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond, spicy::declaration::Hooks hooks,
Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, type, skip, std::move(args), repeat,
std::move(sinks), attrs, cond, std::move(hooks), std::move(meta));
}
auto typeUnitItemField(const ID& id, type::unit::Item* item, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, item, engine, skip, std::move(args), repeat,
auto typeUnitItemField(const ID& id, type::unit::Item* item, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond, spicy::declaration::Hooks hooks,
Meta meta = {}) {
return spicy::type::unit::item::Field::create(context(), id, item, skip, std::move(args), repeat,
std::move(sinks), attrs, cond, std::move(hooks), std::move(meta));
}
auto typeUnitItemProperty(ID id, AttributeSet* attrs, bool inherited = false, Meta meta = {}) {
Expand All @@ -80,10 +79,10 @@ class NodeFactory {
auto typeUnitItemSink(ID id, AttributeSet* attrs, Meta meta = {}) {
return spicy::type::unit::item::Sink::create(context(), std::move(id), attrs, std::move(meta));
}
auto typeUnitItemSwitch(Expression* expr, type::unit::item::switch_::Cases cases, Engine engine, Expression* cond,
auto typeUnitItemSwitch(Expression* expr, type::unit::item::switch_::Cases cases, Expression* cond,
spicy::declaration::Hooks hooks, AttributeSet* attrs, Meta meta = {}) {
return spicy::type::unit::item::Switch::create(context(), expr, std::move(cases), engine, cond,
std::move(hooks), attrs, std::move(meta));
return spicy::type::unit::item::Switch::create(context(), expr, std::move(cases), cond, std::move(hooks), attrs,
std::move(meta));
}
auto typeUnitItemSwitchCase(const Expressions& exprs, const type::unit::Items& items, const Meta& m = Meta()) {
return spicy::type::unit::item::switch_::Case::create(context(), exprs, items, m);
Expand All @@ -97,33 +96,33 @@ class NodeFactory {
auto typeUnitItemUnitHook(const ID& id, spicy::declaration::Hook* hook, Meta meta = {}) {
return spicy::type::unit::item::UnitHook::create(context(), id, hook, std::move(meta));
}
auto typeUnitItemUnresolvedField(ID id, Ctor* ctor, Engine engine, bool skip, Expressions args, Expression* repeat,
auto typeUnitItemUnresolvedField(ID id, Ctor* ctor, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), ctor, engine, skip,
std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), ctor, skip, std::move(args),
repeat, std::move(sinks), attrs, cond, std::move(hooks),
std::move(meta));
}
auto typeUnitItemUnresolvedField(ID id, ID unresolved_id, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
auto typeUnitItemUnresolvedField(ID id, ID unresolved_id, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), std::move(unresolved_id),
engine, skip, std::move(args), repeat, std::move(sinks),
attrs, cond, std::move(hooks), std::move(meta));
skip, std::move(args), repeat, std::move(sinks), attrs,
cond, std::move(hooks), std::move(meta));
}
auto typeUnitItemUnresolvedField(ID id, QualifiedType* type, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
auto typeUnitItemUnresolvedField(ID id, QualifiedType* type, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), type, engine, skip,
std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), type, skip, std::move(args),
repeat, std::move(sinks), attrs, cond, std::move(hooks),
std::move(meta));
}
auto typeUnitItemUnresolvedField(ID id, type::unit::Item* item, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
auto typeUnitItemUnresolvedField(ID id, type::unit::Item* item, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), item, engine, skip,
std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
return spicy::type::unit::item::UnresolvedField::create(context(), std::move(id), item, skip, std::move(args),
repeat, std::move(sinks), attrs, cond, std::move(hooks),
std::move(meta));
}
auto typeUnitItemVariable(ID id, QualifiedType* type, Expression* default_, AttributeSet* attrs, Meta meta = {}) {
return spicy::type::unit::item::Variable::create(context(), std::move(id), type, default_, attrs,
Expand Down
12 changes: 4 additions & 8 deletions spicy/toolchain/include/ast/declarations/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <hilti/ast/types/function.h>
#include <hilti/ast/types/void.h>

#include <spicy/ast/engine.h>
#include <spicy/ast/forward.h>
#include <spicy/ast/node.h>

Expand Down Expand Up @@ -44,7 +43,6 @@ class Hook : public Declaration {
auto ftype() const { return function()->ftype(); }
auto type() const { return function()->type(); }

Engine engine() const { return _engine; }
auto unitTypeIndex() { return _unit_type_index; }
auto unitFieldIndex() { return _unit_field_index; }

Expand Down Expand Up @@ -81,7 +79,7 @@ class Hook : public Declaration {
node::Properties properties() const final;

static auto create(ASTContext* ctx, const hilti::declaration::Parameters& parameters, Statement* body,
Engine engine, AttributeSet* attrs, const Meta& m = Meta()) {
AttributeSet* attrs, const Meta& m = Meta()) {
if ( ! attrs )
attrs = AttributeSet::create(ctx);

Expand All @@ -91,19 +89,17 @@ class Hook : public Declaration {
parameters, hilti::type::function::Flavor::Hook, m);
auto func = hilti::Function::create(ctx, hilti::ID(), ftype, body, hilti::function::CallingConvention::Standard,
attrs, m);
return ctx->make<Hook>(ctx, {func, nullptr}, engine, m);
return ctx->make<Hook>(ctx, {func, nullptr}, m);
}

protected:
Hook(ASTContext* ctx, Nodes children, Engine engine, Meta m = Meta())
Hook(ASTContext* ctx, Nodes children, Meta m = Meta())
: Declaration(ctx, NodeTags, std::move(children), hilti::ID(), hilti::declaration::Linkage::Private,
std::move(m)),
_engine(engine) {}
std::move(m)) {}

SPICY_NODE_1(declaration::Hook, Declaration, final);

private:
Engine _engine = {};
hilti::ast::TypeIndex _unit_type_index;
hilti::ast::DeclarationIndex _unit_field_index;
};
Expand Down
32 changes: 0 additions & 32 deletions spicy/toolchain/include/ast/engine.h

This file was deleted.

32 changes: 13 additions & 19 deletions spicy/toolchain/include/ast/types/unit-items/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <hilti/base/uniquer.h>

#include <spicy/ast/declarations/hook.h>
#include <spicy/ast/engine.h>
#include <spicy/ast/types/sink.h>
#include <spicy/ast/types/unit-item.h>
#include <spicy/ast/types/unit-items/unit-hook.h>
Expand All @@ -40,8 +39,6 @@ class Field : public unit::Item {
auto sinks() const { return children<Expression>(_sinks_start, _sinks_end); }
auto hooks() const { return children<declaration::Hook>(_hooks_start, _hooks_end); }

Engine engine() const { return _engine; }

auto isSkip() const { return _is_skip; }
auto isContainer() const { return repeatCount() != nullptr; }
auto isForwarding() const { return _is_forwarding; }
Expand Down Expand Up @@ -104,43 +101,41 @@ class Field : public unit::Item {
std::string_view displayName() const final { return "unit field"; }

node::Properties properties() const final {
auto p = node::Properties{{"engine", to_string(_engine)},
{"anonymous", _is_anonymous},
auto p = node::Properties{{"anonymous", _is_anonymous},
{"transient", _is_transient},
{"forwarding", _is_forwarding},
{"index", _index},
{"skip", _is_skip}};
return unit::Item::properties() + p;
}

static auto create(ASTContext* ctx, const ID& id, QualifiedType* type, Engine engine, bool skip, Expressions args,
static auto create(ASTContext* ctx, const ID& id, QualifiedType* type, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return _create(ctx, id, type, type, engine, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
return _create(ctx, id, type, type, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
}

static auto create(ASTContext* ctx, const ID& id, Ctor* ctor, Engine engine, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return _create(ctx, id, nullptr, ctor, engine, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
static auto create(ASTContext* ctx, const ID& id, Ctor* ctor, bool skip, Expressions args, Expression* repeat,
Expressions sinks, AttributeSet* attrs, Expression* cond, spicy::declaration::Hooks hooks,
Meta meta = {}) {
return _create(ctx, id, nullptr, ctor, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
}

static auto create(ASTContext* ctx, const ID& id, type::unit::Item* item, Engine engine, bool skip,
Expressions args, Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
static auto create(ASTContext* ctx, const ID& id, type::unit::Item* item, bool skip, Expressions args,
Expression* repeat, Expressions sinks, AttributeSet* attrs, Expression* cond,
spicy::declaration::Hooks hooks, Meta meta = {}) {
return _create(ctx, id, nullptr, item, engine, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
return _create(ctx, id, nullptr, item, skip, std::move(args), repeat, std::move(sinks), attrs, cond,
std::move(hooks), std::move(meta));
}

protected:
Field(ASTContext* ctx, Nodes children, size_t args_start, size_t args_end, size_t sinks_start, size_t sinks_end,
size_t hooks_start, size_t hooks_end, const ID& id, Engine engine, bool skip, Meta meta)
size_t hooks_start, size_t hooks_end, const ID& id, bool skip, Meta meta)
: unit::Item(ctx, NodeTags, std::move(children), (id ? id : _uniquer.get("_anon", false)), std::move(meta)),
_is_anonymous(! id),
_is_skip(skip),
_engine(engine),
_args_start(static_cast<int>(args_start)),
_args_end(static_cast<int>(args_end)),
_sinks_start(static_cast<int>(sinks_start)),
Expand All @@ -151,7 +146,7 @@ class Field : public unit::Item {
SPICY_NODE_2(type::unit::item::Field, type::unit::Item, Declaration, final);

private:
static Field* _create(ASTContext* ctx, const ID& id, QualifiedType* org_type, Node* node, Engine engine, bool skip,
static Field* _create(ASTContext* ctx, const ID& id, QualifiedType* org_type, Node* node, bool skip,
Expressions args, Expression* repeat, Expressions sinks, AttributeSet* attrs,
Expression* cond, spicy::declaration::Hooks hooks, Meta meta) {
if ( ! attrs )
Expand All @@ -166,14 +161,13 @@ class Field : public unit::Item {
node::flatten(auto_, org_type, auto_, auto_, node, repeat, attrs, cond, std::move(args),
std::move(sinks), std::move(hooks)),
8U, 8U + num_args, 8U + num_args, 8U + num_args + num_sinks, 8U + num_args + num_sinks,
8U + num_args + num_sinks + num_hooks, id, engine, skip, std::move(meta));
8U + num_args + num_sinks + num_hooks, id, skip, std::move(meta));
}

bool _is_forwarding = false;
bool _is_transient = false;
bool _is_anonymous;
bool _is_skip;
Engine _engine;
std::optional<uint64_t> _index;
const int _args_start;
const int _args_end;
Expand Down
Loading

0 comments on commit 4a1b43e

Please sign in to comment.