private int GetLabelPos(Label lbl)
        {
            int labelValue = lbl.GetLabelValue();

            if ((labelValue < 0) || (labelValue >= this.m_labelCount))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel"));
            }
            if (this.m_labelList[labelValue] < 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent"));
            }
            return(this.m_labelList[labelValue]);
        }
        public virtual void MarkLabel(Label loc)
        {
            int labelValue = loc.GetLabelValue();

            if ((labelValue < 0) || (labelValue >= this.m_labelList.Length))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLabel"));
            }
            if (this.m_labelList[labelValue] != -1)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_RedefinedLabel"));
            }
            this.m_labelList[labelValue] = this.m_length;
        }
 public virtual void Emit(OpCode opcode, Label label)
 {
     label.GetLabelValue();
     this.EnsureCapacity(7);
     this.InternalEmit(opcode);
     if (OpCodes.TakesSingleByteArgument(opcode))
     {
         this.AddFixup(label, this.m_length, 1);
         this.m_length++;
     }
     else
     {
         this.AddFixup(label, this.m_length, 4);
         this.m_length += 4;
     }
 }
        public virtual void EndExceptionBlock()
        {
            if (this.m_currExcStackCount == 0)
            {
                throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
            }
            __ExceptionInfo info = this.m_currExcStack[this.m_currExcStackCount - 1];

            this.m_currExcStack[this.m_currExcStackCount - 1] = null;
            this.m_currExcStackCount--;
            Label endLabel = info.GetEndLabel();

            switch (info.GetCurrentState())
            {
            case 1:
            case 0:
                throw new InvalidOperationException(Environment.GetResourceString("Argument_BadExceptionCodeGen"));

            case 2:
                this.Emit(OpCodes.Leave, endLabel);
                break;

            case 3:
            case 4:
                this.Emit(OpCodes.Endfinally);
                break;
            }
            if (this.m_labelList[endLabel.GetLabelValue()] == -1)
            {
                this.MarkLabel(endLabel);
            }
            else
            {
                this.MarkLabel(info.GetFinallyEndLabel());
            }
            info.Done(this.m_length);
        }
示例#5
0
        public virtual void Emit(OpCode opcode, Label label) 
        {
            // Puts opcode onto the stream and leaves space to include label
            // when fixups are done.  Labels are created using ILGenerator.DefineLabel and
            // their location within the stream is fixed by using ILGenerator.MarkLabel.
            // If a single-byte instruction (designated by the _S suffix in OpCodes.cs) is used,
            // the label can represent a jump of at most 127 bytes along the stream.
            //
            // opcode must represent a branch instruction (although we don't explicitly
            // verify this).  Since branches are relative instructions, label will be replaced with the
            // correct offset to branch during the fixup process.
            
            int tempVal = label.GetLabelValue();
            EnsureCapacity(7);

             
            InternalEmit(opcode);
            if (OpCodes.TakesSingleByteArgument(opcode)) {
                AddFixup(label, m_length, 1);
                m_length++;
            } else {
                AddFixup(label, m_length, 4);
                m_length+=4;
            }
        }
示例#6
0
        private int GetLabelPos(Label lbl)
        {
            // Gets the position in the stream of a particular label.
            // Verifies that the label exists and that it has been given a value.

            int index = lbl.GetLabelValue();
            
            if (index < 0 || index >= m_labelCount)
                throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel"));

            if (m_labelList[index] < 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent"));

            return m_labelList[index];
        }
示例#7
0
        public virtual void MarkLabel(Label loc) 
        {
            // Defines a label by setting the position where that label is found within the stream.
            // Does not allow a label to be defined more than once.

            int labelIndex = loc.GetLabelValue();

            //This should never happen.
            if (labelIndex<0 || labelIndex>=m_labelList.Length) {
                throw new ArgumentException (Environment.GetResourceString("Argument_InvalidLabel"));
            }

            if (m_labelList[labelIndex]!=-1) {
                throw new ArgumentException (Environment.GetResourceString("Argument_RedefinedLabel"));
            }

            m_labelList[labelIndex]=m_length;
        }
 public virtual void MarkLabel(Label loc)
 {
     int labelValue = loc.GetLabelValue();
     if ((labelValue < 0) || (labelValue >= this.m_labelList.Length))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLabel"));
     }
     if (this.m_labelList[labelValue] != -1)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_RedefinedLabel"));
     }
     this.m_labelList[labelValue] = this.m_length;
 }
 private int GetLabelPos(Label lbl)
 {
     int labelValue = lbl.GetLabelValue();
     if ((labelValue < 0) || (labelValue >= this.m_labelCount))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel"));
     }
     if (this.m_labelList[labelValue] < 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent"));
     }
     return this.m_labelList[labelValue];
 }
 public virtual void Emit(OpCode opcode, Label label)
 {
     label.GetLabelValue();
     this.EnsureCapacity(7);
     this.InternalEmit(opcode);
     if (OpCodes.TakesSingleByteArgument(opcode))
     {
         this.AddFixup(label, this.m_length, 1);
         this.m_length++;
     }
     else
     {
         this.AddFixup(label, this.m_length, 4);
         this.m_length += 4;
     }
 }
示例#11
0
        // Puts opcode onto the stream and leaves space to include label
        // when fixups are done.  Labels are created using ILGenerator.DefineLabel and
        // their location within the stream is fixed by using ILGenerator.MarkLabel.
        // If a single-byte instruction (designated by the _S suffix in OpCodes.cs) is used,
        // the label can represent a jump of at most 127 bytes along the stream.
        //
        // opcode must represent a branch instruction (although we don't explicitly
        // verify this).  Since branches are relative instructions, label will be replaced with the
        // correct offset to branch during the fixup process.
        //
        /// <include file='doc\ILGenerator.uex' path='docs/doc[@for="ILGenerator.Emit12"]/*' />
        public virtual void Emit(OpCode opcode, Label label) {
            int tempVal = label.GetLabelValue();
            EnsureCapacity(7);

            internalEmit(opcode);
            if (OpCodes.TakesSingleByteArgument(opcode)) {
                AddFixup(label, m_length, 1);
                m_length++;
            } else {
                AddFixup(label, m_length, 4);
                m_length+=4;
            }
        }
示例#12
0
 // Gets the position in the stream of a particular label.
 // Verifies that the label exists and that it has been given a value.
 //
 internal virtual int GetLabelPos (Label lbl) {
     int index = lbl.GetLabelValue();
     if (index<0 || index>=m_labelCount) {
         throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel"));
     }
     if (m_labelList[index]<0) {
         throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent"));
     }
     return m_labelList[index];
 }
示例#13
0
        // Defines a label by setting the position where that label is found within the stream.
        // Does not allow a label to be defined more than once.
        //
        /// <include file='doc\ILGenerator.uex' path='docs/doc[@for="ILGenerator.MarkLabel"]/*' />
        public virtual void MarkLabel(Label loc) {
            int labelIndex = loc.GetLabelValue();

            //This should never happen.
            if (labelIndex<0 || labelIndex>=m_labelList.Length) {
                throw new ArgumentException (Environment.GetResourceString("Argument_InvalidLabel"));
            }

            if (m_labelList[labelIndex]!=-1) {
                throw new ArgumentException (Environment.GetResourceString("Argument_RedefinedLabel"));
            }

            m_labelList[labelIndex]=m_length;
        }