Jurassic.Compiler.OptimizationInfo.PushBreakOrContinueInfo C# (CSharp) Метод

PushBreakOrContinueInfo() публичный Метод

Pushes information about break or continue targets to a stack.
public PushBreakOrContinueInfo ( IList labelNames, ILLabel breakTarget, ILLabel continueTarget, bool labelledOnly ) : void
labelNames IList The label names associated with the break or continue target. /// Can be null.
breakTarget ILLabel The IL label to jump to if a break statement is encountered.
continueTarget ILLabel The IL label to jump to if a continue statement is /// encountered. Can be null.
labelledOnly bool true if break or continue statements without a label /// should ignore this entry; false otherwise.
Результат void
        public void PushBreakOrContinueInfo(IList<string> labelNames, ILLabel breakTarget, ILLabel continueTarget, bool labelledOnly)
        {
            if (breakTarget == null)
                throw new ArgumentNullException("breakTarget");

            // Check the label doesn't already exist.
            if (labelNames != null)
            {
                foreach (var labelName in labelNames)
                    foreach (var info in this.breakOrContinueStack)
                        if (info.LabelNames != null && info.LabelNames.Contains(labelName) == true)
                            throw new JavaScriptException(this.Engine, ErrorType.SyntaxError, string.Format("Label '{0}' has already been declared", labelName), this.SourceSpan.StartLine, this.Source.Path, this.FunctionName);
            }

            // Push the info to the stack.
            this.breakOrContinueStack.Push(new BreakOrContinueInfo()
            {
                LabelNames = labelNames,
                LabelledOnly = labelledOnly,
                BreakTarget = breakTarget,
                ContinueTarget = continueTarget
            });
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Generates CIL for the start of every statement.
        /// </summary>
        /// <param name="generator"> The generator to output the CIL to. </param>
        /// <param name="optimizationInfo"> Information about any optimizations that should be performed. </param>
        /// <param name="locals"> Variables common to both GenerateStartOfStatement() and GenerateEndOfStatement(). </param>
        public void GenerateStartOfStatement(ILGenerator generator, OptimizationInfo optimizationInfo, StatementLocals locals)
        {
#if DEBUG && !SILVERLIGHT
            // Statements must not produce or consume any values on the stack.
            if (generator is DynamicILGenerator)
            {
                locals.OriginalStackSize = ((DynamicILGenerator)generator).StackSize;
            }
#endif

            if (locals.NonDefaultBreakStatementBehavior == false && this.HasLabels == true)
            {
                // Set up the information needed by the break statement.
                locals.EndOfStatement = generator.CreateLabel();
                optimizationInfo.PushBreakOrContinueInfo(this.Labels, locals.EndOfStatement, null, labelledOnly: true);
            }

            // Emit debugging information.
            if (locals.NonDefaultSourceSpanBehavior == false)
            {
                optimizationInfo.MarkSequencePoint(generator, this.SourceSpan);
            }
        }
All Usage Examples Of Jurassic.Compiler.OptimizationInfo::PushBreakOrContinueInfo