mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
header tweaks to provide gen-C++ script optimization with more flexibility
This commit is contained in:
parent
5a3b519fb4
commit
77c34787f3
4 changed files with 17 additions and 10 deletions
|
@ -291,6 +291,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SetCaptures(Frame* f);
|
virtual void SetCaptures(Frame* f);
|
||||||
|
|
||||||
|
// Captures when using ZVal block instead of a Frame.
|
||||||
|
std::unique_ptr<std::vector<ZVal>> captures_vec;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t frame_size = 0;
|
size_t frame_size = 0;
|
||||||
|
|
||||||
|
@ -304,9 +307,6 @@ private:
|
||||||
|
|
||||||
OffsetMap* captures_offset_mapping = nullptr;
|
OffsetMap* captures_offset_mapping = nullptr;
|
||||||
|
|
||||||
// Captures when using ZVal block instead of a Frame.
|
|
||||||
std::unique_ptr<std::vector<ZVal>> captures_vec;
|
|
||||||
|
|
||||||
// The most recently added/updated body ...
|
// The most recently added/updated body ...
|
||||||
StmtPtr current_body;
|
StmtPtr current_body;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ class CompositeHash;
|
||||||
class Expr;
|
class Expr;
|
||||||
class ListExpr;
|
class ListExpr;
|
||||||
class ZAMCompiler;
|
class ZAMCompiler;
|
||||||
|
class CPPRuntime;
|
||||||
|
|
||||||
using ExprPtr = IntrusivePtr<Expr>;
|
using ExprPtr = IntrusivePtr<Expr>;
|
||||||
using ListExprPtr = IntrusivePtr<ListExpr>;
|
using ListExprPtr = IntrusivePtr<ListExpr>;
|
||||||
|
@ -752,6 +753,7 @@ private:
|
||||||
class CreationInitsOptimizer;
|
class CreationInitsOptimizer;
|
||||||
friend zeek::RecordVal;
|
friend zeek::RecordVal;
|
||||||
friend zeek::detail::ZAMCompiler;
|
friend zeek::detail::ZAMCompiler;
|
||||||
|
friend zeek::detail::CPPRuntime;
|
||||||
const auto& DeferredInits() const { return deferred_inits; }
|
const auto& DeferredInits() const { return deferred_inits; }
|
||||||
const auto& CreationInits() const { return creation_inits; }
|
const auto& CreationInits() const { return creation_inits; }
|
||||||
|
|
||||||
|
|
|
@ -194,11 +194,7 @@ void remove_element__CPP(TableValPtr aggr, ListValPtr indices) {
|
||||||
check_iterators__CPP(iterators_invalidated);
|
check_iterators__CPP(iterators_invalidated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function that takes a parallel vectors of attribute tags
|
AttributesPtr build_attrs__CPP(IntVec attr_tags, vector<ValPtr> attr_vals) {
|
||||||
// and values and returns a collective AttributesPtr corresponding to
|
|
||||||
// those instantiated attributes. For attributes that don't have
|
|
||||||
// associated expressions, the corresponding value should be nil.
|
|
||||||
static AttributesPtr build_attrs__CPP(vector<int> attr_tags, vector<ValPtr> attr_vals) {
|
|
||||||
vector<AttrPtr> attrs;
|
vector<AttrPtr> attrs;
|
||||||
int nattrs = attr_tags.size();
|
int nattrs = attr_tags.size();
|
||||||
for ( auto i = 0; i < nattrs; ++i ) {
|
for ( auto i = 0; i < nattrs; ++i ) {
|
||||||
|
@ -243,7 +239,7 @@ TableValPtr table_constructor__CPP(vector<ValPtr> indices, vector<ValPtr> vals,
|
||||||
return aggr;
|
return aggr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assign_attrs__CPP(IDPtr id, std::vector<int> attr_tags, std::vector<ValPtr> attr_vals) {
|
void assign_attrs__CPP(IDPtr id, IntVec attr_tags, ValVec attr_vals) {
|
||||||
id->SetAttrs(build_attrs__CPP(std::move(attr_tags), std::move(attr_vals)));
|
id->SetAttrs(build_attrs__CPP(std::move(attr_tags), std::move(attr_vals)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,16 @@ namespace detail {
|
||||||
|
|
||||||
class CPPRuntime {
|
class CPPRuntime {
|
||||||
public:
|
public:
|
||||||
static auto RawOptField(const RecordValPtr& rv, int field) { return rv->RawOptField(field); }
|
static auto& RawField(const RecordValPtr& rv, int field) { return rv->RawField(field); }
|
||||||
|
static auto& RawField(RecordVal* rv, int field) { return rv->RawField(field); }
|
||||||
|
static auto& RawOptField(const RecordValPtr& rv, int field) { return rv->RawOptField(field); }
|
||||||
|
static auto& RawOptField(RecordVal* rv, int field) { return rv->RawOptField(field); }
|
||||||
|
|
||||||
|
static const auto& GetCreationInits(const RecordType* rt) { return rt->CreationInits(); }
|
||||||
|
|
||||||
|
static RecordVal* BuildRecordVal(RecordTypePtr t, std::vector<std::optional<ZVal>> init_vals) {
|
||||||
|
return new RecordVal(std::move(t), std::move(init_vals));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the concatenation of the given strings.
|
// Returns the concatenation of the given strings.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue