MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / CreateOperatorGroups

Function CreateOperatorGroups

formatter/generic/genericformatter.cpp:358–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356
357
358static vector<Item> CreateOperatorGroups(const vector<Item>& items)
359{
360 vector<Item> result, pending;
361 bool hasOperators = false;
362 for (auto& i : items)
363 {
364 if (i.type == Operator)
365 {
366 if (pending.size() == 1)
367 result.push_back(pending[0]);
368 else if (!pending.empty())
369 result.push_back(Item {Group, pending, {}, 0});
370 result.push_back(i);
371 pending.clear();
372 hasOperators = true;
373 continue;
374 }
375
376 if (i.type == StartOfContainer && pending.empty())
377 {
378 result.push_back(i);
379 }
380 else if (i.type == EndOfContainer && hasOperators && pending.size() > 1)
381 {
382 result.push_back(Item {Group, pending, {}, 0});
383 result.push_back(i);
384 pending.clear();
385 }
386 else
387 {
388 pending.push_back(Item {i.type, CreateOperatorGroups(i.items), i.tokens, 0});
389 }
390 }
391
392 if (!pending.empty())
393 {
394 if (hasOperators && pending.size() > 1)
395 result.push_back(Item {Group, pending, {}, 0});
396 else
397 result.insert(result.end(), pending.begin(), pending.end());
398 }
399
400 return result;
401}
402
403
404static vector<Item> CreateOperatorPrecedenceGroups(const vector<Item>& items)

Callers 1

FormatLinesMethod · 0.85

Calls 7

push_backMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected