object.cc (13161:8bef8ce2784f) object.cc (13179:7445c43d036b)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 96 unchanged lines hidden (view full) ---

105 // We're "within" a parent module, ie we're being created while its
106 // constructor or end_of_elaboration callback is running.
107 parent = p->obj()->_sc_obj;
108 } else if (scheduler.current()) {
109 // Our parent is the currently running process.
110 parent = scheduler.current();
111 }
112
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 96 unchanged lines hidden (view full) ---

105 // We're "within" a parent module, ie we're being created while its
106 // constructor or end_of_elaboration callback is running.
107 parent = p->obj()->_sc_obj;
108 } else if (scheduler.current()) {
109 // Our parent is the currently running process.
110 parent = scheduler.current();
111 }
112
113 sc_gem5::pickUniqueName(parent, _basename);
113 std::string original_name = _basename;
114 _basename = sc_gem5::pickUniqueName(parent, original_name);
114
115 if (parent)
116 addObject(&parent->_gem5_object->children, _sc_obj);
117 else
118 addObject(&topLevelObjects, _sc_obj);
119
120 addObject(&allObjects, _sc_obj);
121
115
116 if (parent)
117 addObject(&parent->_gem5_object->children, _sc_obj);
118 else
119 addObject(&topLevelObjects, _sc_obj);
120
121 addObject(&allObjects, _sc_obj);
122
122 _name = _basename;
123 sc_core::sc_object *sc_p = parent;
123 sc_core::sc_object *sc_p = parent;
124 std::string path = "";
124 while (sc_p) {
125 while (sc_p) {
125 _name = std::string(sc_p->basename()) + std::string(".") + _name;
126 path = std::string(sc_p->basename()) + std::string(".") + path;
126 sc_p = sc_p->get_parent_object();
127 }
127 sc_p = sc_p->get_parent_object();
128 }
129
130 if (_basename != original_name) {
131 std::string message = path + original_name +
132 ". Latter declaration will be renamed to " +
133 path + _basename;
134 SC_REPORT_WARNING("(W505) object already exists", message.c_str());
135 }
136 _name = path + _basename;
128}
129
130Object::Object(sc_core::sc_object *_sc_obj, const Object &arg) :
131 Object(_sc_obj, arg._basename.c_str())
132{}
133
134Object &
135Object::operator = (const Object &)

--- 118 unchanged lines hidden (view full) ---

254Object::delChildEvent(sc_core::sc_event *e)
255{
256 EventsIt it = std::find(events.begin(), events.end(), e);
257 assert(it != events.end());
258 std::swap(*it, events.back());
259 events.pop_back();
260}
261
137}
138
139Object::Object(sc_core::sc_object *_sc_obj, const Object &arg) :
140 Object(_sc_obj, arg._basename.c_str())
141{}
142
143Object &
144Object::operator = (const Object &)

--- 118 unchanged lines hidden (view full) ---

263Object::delChildEvent(sc_core::sc_event *e)
264{
265 EventsIt it = std::find(events.begin(), events.end(), e);
266 assert(it != events.end());
267 std::swap(*it, events.back());
268 events.pop_back();
269}
270
262void
263Object::pickUniqueName(std::string &base)
271std::string
272Object::pickUniqueName(std::string base)
264{
265 std::string seed = base;
266 while (!nameIsUnique(&children, &events, base))
267 base = ::sc_core::sc_gen_unique_name(seed.c_str());
273{
274 std::string seed = base;
275 while (!nameIsUnique(&children, &events, base))
276 base = ::sc_core::sc_gen_unique_name(seed.c_str());
277
278 return base;
268}
269
279}
280
270void
271pickUniqueName(::sc_core::sc_object *parent, std::string &base)
281std::string
282pickUniqueName(::sc_core::sc_object *parent, std::string base)
272{
283{
273 if (parent) {
274 Object::getFromScObject(parent)->pickUniqueName(base);
275 return;
276 }
284 if (parent)
285 return Object::getFromScObject(parent)->pickUniqueName(base);
277
278 std::string seed = base;
279 while (!nameIsUnique(&topLevelObjects, &topLevelEvents, base))
280 base = ::sc_core::sc_gen_unique_name(seed.c_str());
286
287 std::string seed = base;
288 while (!nameIsUnique(&topLevelObjects, &topLevelEvents, base))
289 base = ::sc_core::sc_gen_unique_name(seed.c_str());
290
291 return base;
281}
282
283
284Objects topLevelObjects;
285Objects allObjects;
286
287const std::vector<sc_core::sc_object *> &
288getTopLevelScObjects()

--- 12 unchanged lines hidden ---
292}
293
294
295Objects topLevelObjects;
296Objects allObjects;
297
298const std::vector<sc_core::sc_object *> &
299getTopLevelScObjects()

--- 12 unchanged lines hidden ---