fixes for initializing scripts compiled to C++

This commit is contained in:
Vern Paxson 2022-09-29 15:09:37 -07:00
parent 1af905a14f
commit 5c21240daf
3 changed files with 8 additions and 2 deletions

View file

@ -18,7 +18,7 @@ shared_ptr<CPP_InitInfo> CPPCompile::RegisterAttributes(const AttributesPtr& att
if ( pa != processed_attrs.end() )
return pa->second;
attributes.AddKey(attrs);
attributes.AddKey(attrs, pfs.HashAttrs(attrs));
// The cast is just so we can make an IntrusivePtr.
auto a_rep = const_cast<Attributes*>(attributes.GetRep(attrs));
@ -49,7 +49,7 @@ shared_ptr<CPP_InitInfo> CPPCompile::RegisterAttr(const AttrPtr& attr)
const auto& e = a->GetExpr();
if ( e && ! IsSimpleInitExpr(e) )
init_exprs.AddKey(e);
init_exprs.AddKey(e, p_hash(e));
auto gi = make_shared<AttrInfo>(this, attr);
attr_info->AddInstance(gi);

View file

@ -439,6 +439,9 @@ ListTypeInfo::ListTypeInfo(CPPCompile* _c, TypePtr _t)
if ( gi )
init_cohort = max(init_cohort, gi->InitCohort());
}
if ( ! types.empty() )
++init_cohort;
}
void ListTypeInfo::AddInitializerVals(std::vector<std::string>& ivs) const

View file

@ -917,7 +917,10 @@ p_hash_type ProfileFuncs::HashAttrs(const AttributesPtr& Attrs)
// can vary in structure due to compilation of elements. We
// do though enforce consistency for their types.
if ( e )
{
h = merge_p_hashes(h, HashType(e->GetType()));
h = merge_p_hashes(h, p_hash(e.get()));
}
}
return h;