//^ invariant isInitialized ==> this.members != null; private void Parse(Parser parser) //^ ensures this.members != null; { List<INamespaceDeclarationMember> members = this.members = new List<INamespaceDeclarationMember>(); List<SourceCustomAttribute> sourceAttributes = this.sourceAttributes = new List<SourceCustomAttribute>(); parser.ParseNamespaceBody(members, sourceAttributes); members.TrimExcess(); sourceAttributes.TrimExcess(); //^ assume this.members != null; }
protected override void InitializeIfNecessary() //^^ ensures this.members != null; { if (this.isInitialized) return; lock (GlobalLock.LockingObject) { if (this.isInitialized) return; //^ assume this.CompilationPart is SpecSharpCompilationPart; //The constructor ensures this SpecSharpCompilationPart cp = (SpecSharpCompilationPart)this.CompilationPart; Parser parser = new Parser(this.Compilation, this.SourceLocation, cp.ScannerAndParserErrors); //TODO: get options from Compilation this.Parse(parser); this.SetContainingNodes(); ErrorEventArgs errorEventArguments = new ErrorEventArgs(ErrorReporter.Instance, this.SourceLocation, cp.ScannerAndParserErrors.AsReadOnly()); this.Compilation.HostEnvironment.ReportErrors(errorEventArguments); errorEventArguments = new ErrorEventArgs(ErrorReporter.Instance, cp.UnpreprocessedDocument.SourceLocation, cp.PreprocessorErrors); this.Compilation.HostEnvironment.ReportErrors(errorEventArguments); this.isInitialized = true; } }
internal void Parse(Parser parser, SpecSharpCompilationPart compilationPart) { this.Parse(parser); this.compilationPart = compilationPart; this.SetContainingNodes(); this.isInitialized = true; }