From e852f9e31a8157f109058e6f3fdb4e86cc0cb10c Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Mon, 25 Oct 2004 00:56:47 -0400 Subject: Add explicit phases to order ParamContext initializations. --HG-- extra : convert_revision : c24fba2bded2493a892fa93de0c61f9674cfedbb --- sim/param.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sim/param.cc') diff --git a/sim/param.cc b/sim/param.cc index 84ecbf8f9..d20be8d33 100644 --- a/sim/param.cc +++ b/sim/param.cc @@ -560,15 +560,27 @@ SimObjectBaseParam::parse(const string &s, vector&value) list *ParamContext::ctxList = NULL; -ParamContext::ParamContext(const string &_iniSection, bool noAutoParse) +ParamContext::ParamContext(const string &_iniSection, InitPhase _initPhase) : iniFilePtr(NULL), // initialized on call to parseParams() - iniSection(_iniSection), paramList(NULL) + iniSection(_iniSection), paramList(NULL), + initPhase(_initPhase) { - if (!noAutoParse) { + // Put this context on global list for initialization + if (initPhase != NoAutoInit) { if (ctxList == NULL) ctxList = new list(); - (*ctxList).push_back(this); + // keep list sorted by ascending initPhase values + list::iterator i = ctxList->begin(); + list::iterator end = ctxList->end(); + for (; i != end; ++i) { + if (initPhase <= (*i)->initPhase) { + // found where we want to insert + break; + } + } + // (fall through case: insert at end) + ctxList->insert(i, this); } } -- cgit v1.2.3