/// <summary> /// Creates a parser that can read the body of a function. /// </summary> /// <param name="parser"> The parser for the parent context. </param> /// <param name="scope"> The function scope. </param> /// <returns> A new parser. </returns> private static Parser CreateFunctionBodyParser(Parser parser, Scope scope) { var result = (Parser)parser.MemberwiseClone(); result.currentScope = result.initialScope = scope; result.methodOptimizationHints = new MethodOptimizationHints(); result.context = CodeContext.Function; result.endToken = PunctuatorToken.RightBrace; result.DirectivePrologueProcessedCallback = null; return result; }
/// <summary> /// Creates a parser that can read the body of a function. /// </summary> /// <param name="parser"> The parser for the parent context. </param> /// <param name="scope"> The function scope. </param> /// <param name="optimizationHints"> Hints about whether optimization is possible. </param> /// <returns> A new parser. </returns> private static Parser CreateFunctionBodyParser(Parser parser, Scope scope, MethodOptimizationHints optimizationHints) { var result = (Parser)parser.MemberwiseClone(); result.SetInitialScope(scope); result.methodOptimizationHints = optimizationHints; result.context = CodeContext.Function; result.endToken = PunctuatorToken.RightBrace; return result; }