MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / initialize

Method initialize

cp-profiler/src/cpprofiler/name_map.cpp:236–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234NameMap::NameMap() {}
235
236bool NameMap::initialize(const std::string &path_filename,
237 const std::string &model_filename)
238{
239 vector<string> model_lines = read_file_by_lines(model_filename);
240 vector<string> paths_lines = read_file_by_lines(path_filename);
241
242 if (model_lines.size() == 0 || paths_lines.size() == 0)
243 return false;
244
245 try
246 {
247
248 for (auto &line : paths_lines)
249 {
250 const auto parts = utils::split(line, '\t');
251
252 const auto id = parts.at(0);
253 const auto nice_name = parts.at(1);
254 const auto path = parts.at(2);
255 const auto loc = getLocation(parts.at(2));
256
257 id_map_.insert({id, SymbolRecord(nice_name, path, loc.first)});
258
259 const auto is_final = loc.second;
260
261 /// TODO: handle complex expressions
262
263 // // if a nice name is not actually nice
264 // if (nice_name.substr(0, 12) == "X_INTRODUCED") {
265 // /// example: X_INTRODUCED_16_ should become ...
266 // addIdExpressionToMap(model_lines, parts.at(0));
267 // } else {
268 // // addDecompIdExpressionToMap(s[0], modelText);
269 // }
270 }
271
272 return true;
273 }
274 catch (std::exception &e)
275 {
276 qDebug() << "ERR: invalid name map";
277 return false;
278 }
279}
280
281const NiceName &NameMap::getNiceName(const std::string &ident) const
282{

Callers 1

handleStartMethod · 0.80

Calls 5

read_file_by_linesFunction · 0.85
splitFunction · 0.85
getLocationFunction · 0.85
SymbolRecordClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected