示例#1
0
            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);
            }
示例#2
0
        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;
        }
示例#3
0
        /// <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();
        }
示例#4
0
        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);
                }
            }
        }
示例#5
0
            internal override bool ContainsLocal(LocalDefinition local)
            {
                var locals = _localVariables;

                return(locals != null && locals.Contains(local));
            }
示例#6
0
 internal virtual bool ContainsLocal(LocalDefinition local) => false;
示例#7
0
            internal void AddLocal(LocalDefinition variable)
            {
                var scope = (LocalScopeInfo)CurrentScope;

                scope.AddLocal(variable);
            }
示例#8
0
 /// <summary>
 /// Puts local variable into current scope.
 /// </summary>
 internal void AddLocalToScope(LocalDefinition local)
 {
     HasDynamicLocal |= !local.DynamicTransformFlags.IsEmpty;
     _scopeManager.AddLocal(local);
 }
示例#9
0
 internal bool PossiblyDefinedOutsideOfTry(LocalDefinition local)
 => _scopeManager.PossiblyDefinedOutsideOfTry(local);
示例#10
0
 /// <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);
 }
示例#11
0
 private LocalOrParameter(LocalDefinition local, int parameterIndex)
 {
     this.Local          = local;
     this.ParameterIndex = parameterIndex;
 }
示例#12
0
 /// <summary>
 /// Puts local variable into current scope.
 /// </summary>
 internal void AddLocalToScope(LocalDefinition local)
 {
     _scopeManager.AddLocal(local);
 }