Stmt: Introduce STMT_EXTERN

It's currently possible for plugin's to implement their own statement
subclasses and override the Exec() implementation. This has been leveraged
by ZeekJS [1] and zeek-perf-support [2] as well as a private WASM plugin.
All of these used STMT_ANY as the tag of their own statement subclasses.

With STMT_EXTERN, we make the possibility to add external code into the AST
somewhat more supported. It's all in detail space and plugin authors have
no guarantee for stability, but it seems such a powerful extension point
that IMO we should keep it.

I'm conscious there's the broader topic how this interacts with ZAM
optimization like in-lining or rewriting of statements. However, this
already applies to the STMT_ANY usage of the mentioned plugins.

[1] https://github.com/corelight/zeekjs
[2] https://github.com/zeek/zeek-perf-support
This commit is contained in:
Arne Welzel 2024-02-06 14:17:39 +01:00
parent 160ccda45f
commit a5c941139c
2 changed files with 3 additions and 1 deletions

View file

@ -52,6 +52,7 @@ const char* stmt_name(StmtTag t) {
"ZAM",
"null",
"assert",
"extern",
};
return stmt_names[int(t)];