private static TryGetIndexedVariableOperand ( |
||
instruction | ||
indexedVariables | IEnumerable |
Collection of variables that are potentially referenced by the operand |
variable | Mono.Cecil.Cil.VariableDefinition | |
return | bool |
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;
}
/// <summary> /// Finds a variable, if any, that is referenced by an instruction. /// </summary> /// <param name="instruction">Instruction that may reference a variable.</param> /// <param name="variable">When populated, this is the referenced variable.</param> /// <returns><c>true</c> if a variable referenced by the instruction was found, else <c>false</c>.</returns> private bool TryGetReferencedVariable(Instruction instruction, out VariableDefinition variable) { return (MultiplexedConstructor.TryGetVariableDefinitionOperand(instruction, out variable) || MultiplexedConstructor.TryGetIndexedVariableOperand(instruction, this.Constructor.Body.Variables, ref variable)); }