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 std::string original_name = _basename; 114 _basename = sc_gem5::pickUniqueName(parent, original_name); |
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 |
123 sc_core::sc_object *sc_p = parent; |
124 std::string path = ""; |
125 while (sc_p) { |
126 path = std::string(sc_p->basename()) + std::string(".") + path; |
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; |
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 |
271std::string 272Object::pickUniqueName(std::string base) |
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; |
279} 280 |
281std::string 282pickUniqueName(::sc_core::sc_object *parent, std::string base) |
283{ |
284 if (parent) 285 return Object::getFromScObject(parent)->pickUniqueName(base); |
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; |
292} 293 294 295Objects topLevelObjects; 296Objects allObjects; 297 298const std::vector<sc_core::sc_object *> & 299getTopLevelScObjects() --- 12 unchanged lines hidden --- |