A local binding instruction that can be added to a list of CILInstructions.
Inheritance: DebugInst
Esempio n. 1
0
        internal LocalBinding AddLocalBinding(string name, int index)
        {
            LocalBinding binding;
               if ((binding = FindLocalBinding(name)) != null)
             return binding;

               binding = new LocalBinding(index, name);
               _localBindings.Add(binding);
               return binding;
        }
Esempio n. 2
0
        /// <summary>
        /// Bind a local to the current scope.
        /// </summary>
        /// <param name="name">The name of the variable.</param>
        /// <param name="idx">The index of the variable in the locals table.</param>
        /// <param name="token">The symbol token for the given variable.</param>
        /// <param name="startOffset">The starting offset for the binding.  Set to 0 to default to current scope.</param>
        /// <param name="endOffset">The ending offset for the binding.  Set to 0 to default to current scope.</param>
        public void BindLocal(string name, int idx, uint token, int startOffset, int endOffset)
        {
            // Check to make sure a scope is open
            if (currentScope == null)
                throw new Exception("You must have an open scope in order to bind locals.");

            // Create the new local binding object
            LocalBinding lb = new LocalBinding();
            lb.Name = name;
            lb.Index = idx;
            lb.Token = new SymbolToken((int)token);
            lb.OffsetStart = startOffset;
            lb.OffsetEnd = endOffset;

            // Add to the current scope
            currentScope.Locals.Add(lb);
        }