Cilador.Clone.MultiplexedConstructor.TryGetIndexedVariableOperand C# (CSharp) 메소드

TryGetIndexedVariableOperand() 개인적인 정적인 메소드

If the instruction has a variable operand, retrieves it.
private static TryGetIndexedVariableOperand ( Instruction instruction, IEnumerable indexedVariables, Mono.Cecil.Cil.VariableDefinition &variable ) : bool
instruction Mono.Cecil.Cil.Instruction to look at
indexedVariables IEnumerable Collection of variables that are potentially referenced by the operand
variable Mono.Cecil.Cil.VariableDefinition to populate with the referenced indexed variable, if possible.
리턴 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;
        }

Usage Example

예제 #1
0
 /// <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));
 }