script optimization fixes:

new initialization model for standalone C++ scripts
 type coercion fix
 ZAM fix for compiling using C++ optimizer
 disambiguate empty constructors
This commit is contained in:
Vern Paxson 2022-11-20 12:16:25 -08:00
parent dbb2aa88a6
commit 134f8f2ef5
14 changed files with 80 additions and 96 deletions

View file

@ -49,7 +49,15 @@ shared_ptr<CPP_InitInfo> CPPCompile::RegisterAttr(const AttrPtr& attr)
const auto& e = a->GetExpr();
if ( e && ! IsSimpleInitExpr(e) )
init_exprs.AddKey(e, p_hash(e));
{
auto h = p_hash(e);
// Include the type in the hash, otherwise expressions
// like "vector()" are ambiguous.
h = merge_p_hashes(h, p_hash(e->GetType()));
init_exprs.AddKey(e, h);
}
auto gi = make_shared<AttrInfo>(this, attr);
attr_info->AddInstance(gi);