/// <summary> /// If the <paramref name="instruction"/> has a variable operand, retrieves it. /// </summary> /// <param name="instruction"><see cref="Instruction"/> to look at</param> /// <param name="indexedVariables">Collection of variables that are potentially referenced by the operand</param> /// <param name="variable"><see cref="VariableDefinition"/> to populate with the referenced indexed variable, if possible.</param> /// <returns><c>true</c> if the operand is an index for a variable in the <paramref name="indexedVariables"/>, else <c>false</c>.</returns> private static bool TryGetIndexedVariableOperand( Instruction instruction, IEnumerable<VariableDefinition> indexedVariables, ref VariableDefinition variable) { int? variableIndex; if (!instruction.TryGetVariableIndex(out variableIndex)) { return false; } Contract.Assert(variableIndex.HasValue); variable = indexedVariables.FirstOrDefault( possibleInitializationVariable => possibleInitializationVariable.Index == variableIndex.Value); return variable != null; }