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

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

Returns the break target for the statement with the given label, if one is provided, or the top-most break target otherwise.
public GetBreakTarget ( string labelName = null ) : ILLabel
labelName string The label associated with the break target. Can be /// null.
Результат ILLabel
        public ILLabel GetBreakTarget(string labelName = null)
        {
            if (labelName == null)
            {
                foreach (var info in this.breakOrContinueStack)
                {
                    if (info.LabelledOnly == false)
                        return info.BreakTarget;
                }
                throw new JavaScriptException(this.Engine, ErrorType.SyntaxError, "Illegal break statement", this.SourceSpan.StartLine, this.Source.Path, this.FunctionName);
            }
            else
            {
                foreach (var info in this.breakOrContinueStack)
                {
                    if (info.LabelNames != null && info.LabelNames.Contains(labelName) == true)
                        return info.BreakTarget;
                }
                throw new JavaScriptException(this.Engine, ErrorType.SyntaxError, string.Format("Undefined label '{0}'", labelName), this.SourceSpan.StartLine, this.Source.Path, this.FunctionName);
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Generates CIL for the 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>
        public override void GenerateCode(ILGenerator generator, OptimizationInfo optimizationInfo)
        {
            // Generate code for the start of the statement.
            var statementLocals = new StatementLocals();
            GenerateStartOfStatement(generator, optimizationInfo, statementLocals);

            // Emit an unconditional branch.
            // Note: the break statement might be branching from inside a try { } or finally { }
            // block to outside.  EmitLongJump() handles this.
            optimizationInfo.EmitLongJump(generator, optimizationInfo.GetBreakTarget(this.Label));

            // Generate code for the end of the statement.
            GenerateEndOfStatement(generator, optimizationInfo, statementLocals);
        }
All Usage Examples Of Jurassic.Compiler.OptimizationInfo::GetBreakTarget