AddLabelInfo() private méthode

private AddLabelInfo ( LabelTarget target, LabelInfo info ) : void
target LabelTarget
info LabelInfo
Résultat void
 internal void Define(LabelScopeInfo block)
 {
     for (LabelScopeInfo info = block; info != null; info = info.Parent)
     {
         if (info.ContainsTarget(this._node))
         {
             throw System.Linq.Expressions.Error.LabelTargetAlreadyDefined(this._node.Name);
         }
     }
     this._definitions.Add(block);
     block.AddLabelInfo(this._node, this);
     if (this._definitions.Count == 1)
     {
         foreach (LabelScopeInfo info2 in this._references)
         {
             this.ValidateJump(info2);
         }
     }
     else
     {
         if (this._acrossBlockJump)
         {
             throw System.Linq.Expressions.Error.AmbiguousJump(this._node.Name);
         }
         this._labelDefined = false;
     }
 }
Exemple #2
0
        // Returns true if the label was successfully defined
        // or false if the label is now ambiguous
        internal void Define(LabelScopeInfo block)
        {
            // Prevent the label from being shadowed, which enforces cleaner
            // trees. Also we depend on this for simplicity (keeping only one
            // active IL Label per LabelInfo)
            for (var j = block; j != null; j = j.Parent)
            {
                if (j.ContainsTarget(_node))
                {
                    throw new InvalidOperationException($"Cannot redefine label '{_node.Name}' in an inner block.");
                }
            }

            _definitions.Add(block);
            block.AddLabelInfo(_node, this);

            // Once defined, validate all jumps
            if (_definitions.Count == 1)
            {
                foreach (var r in _references)
                {
                    ValidateJump(r);
                }
            }
            else
            {
                // Was just redefined, if we had any across block jumps, they're
                // now invalid
                if (_acrossBlockJump)
                {
                    throw new InvalidOperationException($"Cannot jump to ambiguous label '{_node.Name}'.");
                }

                // For local jumps, we need a new IL label
                // This is okay because:
                //   1. no across block jumps have been made or will be made
                //   2. we don't allow the label to be shadowed
                _labelDefined = false;
            }
        }
Exemple #3
0
        // Returns true if the label was successfully defined
        // or false if the label is now ambiguous
        internal void Define(LabelScopeInfo block) {
            // Prevent the label from being shadowed, which enforces cleaner
            // trees. Also we depend on this for simplicity (keeping only one
            // active IL Label per LabelInfo)
            for (LabelScopeInfo j = block; j != null; j = j.Parent) {
                if (j.ContainsTarget(_node)) {
                    throw Error.LabelTargetAlreadyDefined(_node.Name);
                }
            }

            _definitions.Add(block);
            block.AddLabelInfo(_node, this);

            // Once defined, validate all jumps
            if (_definitions.Count == 1) {
                foreach (var r in _references) {
                    ValidateJump(r);
                }
            } else {
                // Was just redefined, if we had any across block jumps, they're
                // now invalid
                if (_acrossBlockJump) {
                    throw Error.AmbiguousJump(_node.Name);
                }
                // For local jumps, we need a new IL label
                // This is okay because:
                //   1. no across block jumps have been made or will be made
                //   2. we don't allow the label to be shadowed
                _labelDefined = false;
            }
        }