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

Function GetOperandIndexForOperandUsages

mediumlevelilinstruction.cpp:251–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249
250
251static unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>>
252 GetOperandIndexForOperandUsages()
253{
254 unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>> result;
255 result.reserve(MediumLevelILInstructionBase::operationOperandUsage.size());
256 for (auto& operation : MediumLevelILInstructionBase::operationOperandUsage)
257 {
258 result[operation.first] = unordered_map<MediumLevelILOperandUsage, size_t>();
259 result[operation.first].reserve(operation.second.size());
260 size_t operand = 0;
261 for (auto usage : operation.second)
262 {
263 result[operation.first][usage] = operand;
264 switch (usage)
265 {
266 case PartialSSAVariableSourceMediumLevelOperandUsage:
267 // SSA variables are usually two slots, but this one has a previously defined
268 // variables and thus only takes one slot
269 operand++;
270 break;
271 case OutputVariablesSubExprMediumLevelOperandUsage:
272 case UntypedParameterExprsMediumLevelOperandUsage:
273 // Represented as subexpression, so only takes one slot even though it is a list
274 operand++;
275 break;
276 case OutputSSAVariablesSubExprMediumLevelOperandUsage:
277 // OutputSSAMemoryVersionMediumLevelOperandUsage follows at same operand
278 break;
279 case UntypedParameterSSAExprsMediumLevelOperandUsage:
280 // ParameterSSAMemoryVersionMediumLevelOperandUsage follows at same operand
281 break;
282 default:
283 switch (MediumLevelILInstructionBase::operandTypeForUsage[usage])
284 {
285 case SSAVariableMediumLevelOperand:
286 case IndexListMediumLevelOperand:
287 case IndexMapMediumLevelOperand:
288 case VariableListMediumLevelOperand:
289 case SSAVariableListMediumLevelOperand:
290 case ExprListMediumLevelOperand:
291 // SSA variables and lists take two operand slots
292 operand += 2;
293 break;
294 default:
295 operand++;
296 break;
297 }
298 break;
299 }
300 }
301 }
302 return result;
303}
304
305
306unordered_map<BNMediumLevelILOperation, unordered_map<MediumLevelILOperandUsage, size_t>>

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected