From 0e5042e4512fbfb6325e4367949ef99ce41aff39 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 15 Sep 2025 14:28:07 -0700 Subject: [PATCH] fix for associating attributes with globals for -O gen-standalone-C++ --- src/script_opt/CPP/Inits.cc | 7 +++---- src/script_opt/CPP/RuntimeOps.cc | 4 ---- src/script_opt/CPP/RuntimeOps.h | 3 --- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/script_opt/CPP/Inits.cc b/src/script_opt/CPP/Inits.cc index a73b96a379..b286ef14de 100644 --- a/src/script_opt/CPP/Inits.cc +++ b/src/script_opt/CPP/Inits.cc @@ -225,10 +225,9 @@ void CPPCompile::InitializeGlobals() { const auto& attrs = g->GetAttrs(); if ( attrs ) { - string attr_tags; - string attr_vals; - BuildAttrs(attrs, attr_tags, attr_vals); - Emit("assign_attrs__CPP(%s, %s, %s);", globals[g->Name()], attr_tags, attr_vals); + auto attrs_offset = AttributesOffset(attrs); + auto attrs_str = "CPP__Attributes__[" + Fmt(attrs_offset) + "]"; + Emit("%s->SetAttrs(%s);", globals[g->Name()], attrs_str); } } diff --git a/src/script_opt/CPP/RuntimeOps.cc b/src/script_opt/CPP/RuntimeOps.cc index 03973a2e74..47d0585e6d 100644 --- a/src/script_opt/CPP/RuntimeOps.cc +++ b/src/script_opt/CPP/RuntimeOps.cc @@ -239,10 +239,6 @@ TableValPtr table_constructor__CPP(vector indices, vector vals, 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 vals, RecordTypePtr t) { auto rv = make_intrusive(t); auto n = vals.size(); diff --git a/src/script_opt/CPP/RuntimeOps.h b/src/script_opt/CPP/RuntimeOps.h index 6a31f8c1a7..2f7eef45b1 100644 --- a/src/script_opt/CPP/RuntimeOps.h +++ b/src/script_opt/CPP/RuntimeOps.h @@ -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, 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 // assigned to the corresponding elements of the given vector of values. extern RecordValPtr record_constructor__CPP(ValVec vals, RecordTypePtr t);