Merge remote-tracking branch 'origin/topic/vern/standalone-CPP-global-attrs'

* origin/topic/vern/standalone-CPP-global-attrs:
  fix for associating attributes with globals for -O gen-standalone-C++
This commit is contained in:
Tim Wojtulewicz 2025-09-16 11:02:35 -07:00
commit 71eca7c9e6
5 changed files with 8 additions and 12 deletions

View file

@ -1,3 +1,7 @@
8.1.0-dev.544 | 2025-09-16 11:02:35 -0700
* fix for associating attributes with globals for -O gen-standalone-C++ (Vern Paxson, Corelight)
8.1.0-dev.542 | 2025-09-16 10:53:04 -0700 8.1.0-dev.542 | 2025-09-16 10:53:04 -0700
* fix for tracking identifiers and aggregates when compiling to standalone-C++ (Vern Paxson, Corelight) * fix for tracking identifiers and aggregates when compiling to standalone-C++ (Vern Paxson, Corelight)

View file

@ -1 +1 @@
8.1.0-dev.542 8.1.0-dev.544

View file

@ -225,10 +225,9 @@ void CPPCompile::InitializeGlobals() {
const auto& attrs = g->GetAttrs(); const auto& attrs = g->GetAttrs();
if ( attrs ) { if ( attrs ) {
string attr_tags; auto attrs_offset = AttributesOffset(attrs);
string attr_vals; auto attrs_str = "CPP__Attributes__[" + Fmt(attrs_offset) + "]";
BuildAttrs(attrs, attr_tags, attr_vals); Emit("%s->SetAttrs(%s);", globals[g->Name()], attrs_str);
Emit("assign_attrs__CPP(%s, %s, %s);", globals[g->Name()], attr_tags, attr_vals);
} }
} }

View file

@ -239,10 +239,6 @@ TableValPtr table_constructor__CPP(vector<ValPtr> indices, vector<ValPtr> vals,
return aggr; return aggr;
} }
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)));
}
RecordValPtr record_constructor__CPP(vector<ValPtr> vals, RecordTypePtr t) { RecordValPtr record_constructor__CPP(vector<ValPtr> vals, RecordTypePtr t) {
auto rv = make_intrusive<RecordVal>(t); auto rv = make_intrusive<RecordVal>(t);
auto n = vals.size(); auto n = vals.size();

View file

@ -229,9 +229,6 @@ extern TableValPtr set_constructor__CPP(ValVec elements, TableTypePtr t, IntVec
extern TableValPtr table_constructor__CPP(ValVec indices, ValVec vals, TableTypePtr t, IntVec attr_tags, extern TableValPtr table_constructor__CPP(ValVec indices, ValVec vals, TableTypePtr t, IntVec attr_tags,
ValVec attr_vals); ValVec attr_vals);
// Assigns a set of attributes to an identifier.
extern void assign_attrs__CPP(IDPtr id, IntVec attr_tags, ValVec attr_vals);
// Constructs a record of the given type, whose (ordered) fields are // Constructs a record of the given type, whose (ordered) fields are
// assigned to the corresponding elements of the given vector of values. // assigned to the corresponding elements of the given vector of values.
extern RecordValPtr record_constructor__CPP(ValVec vals, RecordTypePtr t); extern RecordValPtr record_constructor__CPP(ValVec vals, RecordTypePtr t);