internal bool PossiblyDefinedOutsideOfTry(LocalDefinition local) { foreach (var s in _scopes) { if (s.ContainsLocal(local)) { return(false); } if (s.Type == ScopeType.Try) { return(true); } } // not recorded in scopes, could be a temp // we cannot tell anything. return(true); }
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(); }
internal void EmitLocalAddress(LocalDefinition local) { if (local.IsReference) { EmitLocalLoad(local); } else { int slot = local.SlotIndex; if (slot < 0xFF) { EmitOpCode(ILOpCode.Ldloca_s); EmitInt8(unchecked ((sbyte)slot)); } else { EmitOpCode(ILOpCode.Ldloca); EmitInt32(slot); } } }
internal override bool ContainsLocal(LocalDefinition local) { var locals = _localVariables; return(locals != null && locals.Contains(local)); }
internal virtual bool ContainsLocal(LocalDefinition local) => false;
internal void AddLocal(LocalDefinition variable) { var scope = (LocalScopeInfo)CurrentScope; scope.AddLocal(variable); }
/// <summary> /// Puts local variable into current scope. /// </summary> internal void AddLocalToScope(LocalDefinition local) { HasDynamicLocal |= !local.DynamicTransformFlags.IsEmpty; _scopeManager.AddLocal(local); }
internal bool PossiblyDefinedOutsideOfTry(LocalDefinition local) => _scopeManager.PossiblyDefinedOutsideOfTry(local);
/// <summary> /// Frees a local slot. /// </summary> internal void FreeSlot(LocalDefinition slot) { Debug.Assert(slot.Name == null); FreeSlots.Push(new LocalSignature(slot.Type, slot.Constraints), slot); }
private LocalOrParameter(LocalDefinition local, int parameterIndex) { this.Local = local; this.ParameterIndex = parameterIndex; }
/// <summary> /// Puts local variable into current scope. /// </summary> internal void AddLocalToScope(LocalDefinition local) { _scopeManager.AddLocal(local); }