using System;
using System.Collections.Generic;
using System.IO;
+using System.Security.Cryptography;
namespace Mono.CSharp
{
if (rc.HasSet (ResolveContext.Options.CheckedScope))
flags |= ResolveContext.Options.CheckedScope;
+
+ if (rc.IsInProbingMode)
+ flags |= ResolveContext.Options.ProbingMode;
+
+ if (rc.HasSet (ResolveContext.Options.FieldInitializerScope))
+ flags |= ResolveContext.Options.FieldInitializerScope;
+
+ if (rc.HasSet (ResolveContext.Options.ExpressionTreeConversion))
+ flags |= ResolveContext.Options.ExpressionTreeConversion;
+
+ if (rc.HasSet (ResolveContext.Options.BaseInitializer))
+ flags |= ResolveContext.Options.BaseInitializer;
}
public override FlowBranching CurrentBranching {
get { return return_type; }
}
+ public bool IsUnreachable {
+ get {
+ return HasSet (Options.UnreachableScope);
+ }
+ set {
+ flags = value ? flags | Options.UnreachableScope : flags & ~Options.UnreachableScope;
+ }
+ }
+
+ public bool UnreachableReported {
+ get {
+ return HasSet (Options.UnreachableReported);
+ }
+ set {
+ flags = value ? flags | Options.UnreachableReported : flags & ~Options.UnreachableScope;
+ }
+ }
+
// <summary>
// Starts a new code branching. This inherits the state of all local
// variables and parameters from the current branching.
LockScope = 1 << 13,
+ UnreachableScope = 1 << 14,
+
+ UnreachableReported = 1 << 15,
+
/// <summary>
/// Whether control flow analysis is enabled
/// </summary>
// or it's a parameter
//
if (CurrentAnonymousMethod.IsIterator)
- return local.IsParameter || CurrentBlock.Explicit.HasYield;
+ return local.IsParameter || local.Block.Explicit.HasYield;
//
// Capture only if this or any of child blocks contain await
// or it's a parameter
//
if (CurrentAnonymousMethod is AsyncInitializer)
- return CurrentBlock.Explicit.HasAwait;
+ return local.IsParameter || local.Block.Explicit.HasAwait || CurrentBlock.Explicit.HasAwait;
return local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original;
}
return new FlagsHandle (this, options, enable ? options : 0);
}
}
+
+ //
+ // Parser session objects. We could recreate all these objects for each parser
+ // instance but the best parser performance the session object can be reused
+ //
+ public class ParserSession
+ {
+ MD5 md5;
+
+ public readonly char[] StreamReaderBuffer = new char[SeekableStreamReader.DefaultReadAheadSize * 2];
+ public readonly Dictionary<char[], string>[] Identifiers = new Dictionary<char[], string>[Tokenizer.MaxIdentifierLength + 1];
+ public readonly List<Parameter> ParametersStack = new List<Parameter> (4);
+ public readonly char[] IDBuilder = new char[Tokenizer.MaxIdentifierLength];
+ public readonly char[] NumberBuilder = new char[Tokenizer.MaxNumberLength];
+
+ public LocationsBag LocationsBag { get; set; }
+ public bool UseJayGlobalArrays { get; set; }
+ public Tokenizer.LocatedToken[] LocatedTokens { get; set; }
+
+ public MD5 GetChecksumAlgorithm ()
+ {
+ return md5 ?? (md5 = MD5.Create ());
+ }
+ }
}