mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
fixes for initializing scripts compiled to C++
This commit is contained in:
parent
1af905a14f
commit
5c21240daf
3 changed files with 8 additions and 2 deletions
|
@ -18,7 +18,7 @@ shared_ptr<CPP_InitInfo> CPPCompile::RegisterAttributes(const AttributesPtr& att
|
||||||
if ( pa != processed_attrs.end() )
|
if ( pa != processed_attrs.end() )
|
||||||
return pa->second;
|
return pa->second;
|
||||||
|
|
||||||
attributes.AddKey(attrs);
|
attributes.AddKey(attrs, pfs.HashAttrs(attrs));
|
||||||
|
|
||||||
// The cast is just so we can make an IntrusivePtr.
|
// The cast is just so we can make an IntrusivePtr.
|
||||||
auto a_rep = const_cast<Attributes*>(attributes.GetRep(attrs));
|
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();
|
const auto& e = a->GetExpr();
|
||||||
if ( e && ! IsSimpleInitExpr(e) )
|
if ( e && ! IsSimpleInitExpr(e) )
|
||||||
init_exprs.AddKey(e);
|
init_exprs.AddKey(e, p_hash(e));
|
||||||
|
|
||||||
auto gi = make_shared<AttrInfo>(this, attr);
|
auto gi = make_shared<AttrInfo>(this, attr);
|
||||||
attr_info->AddInstance(gi);
|
attr_info->AddInstance(gi);
|
||||||
|
|
|
@ -439,6 +439,9 @@ ListTypeInfo::ListTypeInfo(CPPCompile* _c, TypePtr _t)
|
||||||
if ( gi )
|
if ( gi )
|
||||||
init_cohort = max(init_cohort, gi->InitCohort());
|
init_cohort = max(init_cohort, gi->InitCohort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! types.empty() )
|
||||||
|
++init_cohort;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListTypeInfo::AddInitializerVals(std::vector<std::string>& ivs) const
|
void ListTypeInfo::AddInitializerVals(std::vector<std::string>& ivs) const
|
||||||
|
|
|
@ -917,7 +917,10 @@ p_hash_type ProfileFuncs::HashAttrs(const AttributesPtr& Attrs)
|
||||||
// can vary in structure due to compilation of elements. We
|
// can vary in structure due to compilation of elements. We
|
||||||
// do though enforce consistency for their types.
|
// do though enforce consistency for their types.
|
||||||
if ( e )
|
if ( e )
|
||||||
|
{
|
||||||
h = merge_p_hashes(h, HashType(e->GetType()));
|
h = merge_p_hashes(h, HashType(e->GetType()));
|
||||||
|
h = merge_p_hashes(h, p_hash(e.get()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue