/// <summary>
        /// Called when the item is a label item.
        /// </summary>
        /// <param name="target">The object that was passed to IParseItem.Visit.</param>
        /// <returns>The passed target or a modification of it.</returns>
        /// <exception cref="System.ArgumentNullException">If target is null.</exception>
        public IParseItem Visit(LabelItem target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            tree.DefineLabel(target);

            return target;
        }
Example #2
0
        /// <summary>
        /// Defines a new label in the current block.
        /// </summary>
        /// <param name="label">The label to define.</param>
        public void DefineLabel(LabelItem/*!*/ label)
        {
            foreach (var item in cur.Labels)
            {
                if (item.Name == label.Name)
                    throw new ArgumentException(string.Format(Resources.LabelAlreadyDefined, item.Name));
            }

            cur.Labels.Add(label);
        }
        /// <summary>
        /// Called when the item is a label item.
        /// </summary>
        /// <param name="target">The object that was passed to IParseItem.Visit.</param>
        /// <returns>The passed target or a modification of it.</returns>
        /// <exception cref="System.ArgumentNullException">If target is null.</exception>
        public IParseItem Visit(LabelItem target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            target.UserData = target.UserData ?? compiler.CurrentGenerator.DefineLabel();
            compiler.CurrentGenerator.MarkLabel((Label)target.UserData);

            return target;
        }