internal void EmitLoad(LocalOrParameter localOrParameter) { if (localOrParameter.Local != null) { EmitLocalLoad(localOrParameter.Local); } else { EmitLoadArgumentOpcode(localOrParameter.ParameterIndex); } }
/// <summary> /// Primary method for emitting integer switch jump table. /// </summary> /// <param name="caseLabels">switch case labels</param> /// <param name="fallThroughLabel">fall through label for the jump table.</param> /// <param name="key">Local or parameter holding the value to switch on. /// This value has already been loaded onto the execution stack. /// </param> /// <param name="keyTypeCode">Primitive type code of switch key.</param> internal void EmitIntegerSwitchJumpTable( KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalOrParameter key, Cci.PrimitiveTypeCode keyTypeCode) { Debug.Assert(caseLabels.Length > 0); Debug.Assert(keyTypeCode != Cci.PrimitiveTypeCode.String); // CONSIDER: SwitchIntegralJumpTableEmitter will modify the caseLabels array by sorting it. // CONSIDER: Currently, only purpose of creating this caseLabels array is for Emitting the jump table. // CONSIDER: If this requirement changes, we may want to pass in ArrayBuilder<KeyValuePair<ConstantValue, object>> instead. var emitter = new SwitchIntegralJumpTableEmitter(this, caseLabels, fallThroughLabel, keyTypeCode, key); emitter.EmitJumpTable(); }
internal SwitchIntegralJumpTableEmitter( ILBuilder builder, KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, Cci.PrimitiveTypeCode keyTypeCode, LocalOrParameter key) { _builder = builder; _key = key; _keyTypeCode = keyTypeCode; _fallThroughLabel = fallThroughLabel; // Sort the switch case labels, see comments below for more details. Debug.Assert(caseLabels.Length > 0); Array.Sort(caseLabels, CompareIntegralSwitchLabels); _sortedCaseLabels = ImmutableArray.Create(caseLabels); }
internal SwitchStringJumpTableEmitter( ILBuilder builder, LocalOrParameter key, KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalDefinition keyHash, EmitStringCompareAndBranch emitStringCondBranchDelegate, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels.Length > 0); Debug.Assert(emitStringCondBranchDelegate != null); _builder = builder; _key = key; _caseLabels = caseLabels; _fallThroughLabel = fallThroughLabel; _keyHash = keyHash; _emitStringCondBranchDelegate = emitStringCondBranchDelegate; _computeStringHashcodeDelegate = computeStringHashcodeDelegate; }
/// <summary> /// Primary method for emitting string switch jump table /// </summary> /// <param name="caseLabels">switch case labels</param> /// <param name="fallThroughLabel">fall through label for the jump table</param> /// <param name="key">Local holding the value to switch on. /// This value has already been loaded onto the execution stack. /// </param> /// <param name="keyHash">Local holding the hash value of the key for emitting /// hash table switch. Hash value has already been computed and loaded into keyHash. /// This parameter is null if emitting non hash table switch. /// </param> /// <param name="emitStringCondBranchDelegate"> /// Delegate to emit string compare call and conditional branch based on the compare result. /// </param> /// <param name="computeStringHashcodeDelegate"> /// Delegate to compute string hash consistent with value of keyHash. /// </param> internal void EmitStringSwitchJumpTable( KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalOrParameter key, LocalDefinition keyHash, SwitchStringJumpTableEmitter.EmitStringCompareAndBranch emitStringCondBranchDelegate, SwitchStringJumpTableEmitter.GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels.Length > 0); var emitter = new SwitchStringJumpTableEmitter( this, key, caseLabels, fallThroughLabel, keyHash, emitStringCondBranchDelegate, computeStringHashcodeDelegate); emitter.EmitJumpTable(); }