Example #1
0
 /// <summary>
 /// Parses a #region-#endregion directive, starting at the character following "region". 
 /// Adds a corresponding RegionDirective instance to this.preprocesorInformation.
 /// Leaves this.fragmentIndex pointing to the start of the first line after the matching #endif directive.
 /// Returns all source locations that are to be included in the preprocessor output. (No locations are returned if the include parameter is false.)
 /// </summary>
 /// <param name="include">True if the directive is part of an included block. If false, the directive is parsed but ignored. (No locations are returned.)</param>
 private IEnumerable<ISourceLocation> ParseRegion(bool include) {
   SourceLocationBuilder slb = new SourceLocationBuilder(this.GetSourceLocation(this.startOfCurrentLine, this.fragmentIndex-this.startOfCurrentLine));
   string label = this.ScanMessage();
   RegionDirective regionDirective = new RegionDirective(label, slb);
   this.preprocessorInformation.directives.Add(regionDirective);
   foreach (ISourceLocation includedSourceFragment in this.ParseSection(false, false, true, include, false))
     yield return includedSourceFragment;
   slb.UpdateToSpan(this.GetSourceLocation(this.fragmentIndex-1, 0));
 }
 public override object/*?*/ Resolve() {
   if (this.rootClass != null) {
     FieldDefinition/*?*/ localField = null;
     this.rootClass.localFieldFor.TryGetValue(this.Name.UniqueKeyIgnoringCase, out localField);
     if (localField != null) return localField;
   }
   object/*?*/ binding = base.Resolve();
   if (binding == null && this.expressionToInferTargetTypeFrom != null) {
     SourceLocationBuilder slb = new SourceLocationBuilder(this.SourceLocation);
     slb.UpdateToSpan(this.expressionToInferTargetTypeFrom.SourceLocation);
     return this.rootClass.AddFieldForLocal(this, this.expressionToInferTargetTypeFrom, slb).FieldDefinition;
   }
   return binding;
 }
Example #3
0
 /// <summary>
 /// Parses the #if part of an #if-#elif-#else-#endif construct, starting at the character following "if". 
 /// Adds a corresponding IfDirective instance to this.preprocesorInformation.
 /// Leaves this.fragmentIndex pointing to the start of the first line after the matching #endif directive.
 /// Returns all source locations that are to be included in the preprocessor output. (No locations are returned if the include parameter is false.)
 /// </summary>
 /// <param name="include">True if the directive is part of an included block. If false, the directive is parsed but ignored. (No locations are returned.)</param>
 private IEnumerable<ISourceLocation> ParseIf(bool include)  {
   SourceLocationBuilder slb = new SourceLocationBuilder(this.GetSourceLocation(this.startOfCurrentLine, this.fragmentIndex-this.startOfCurrentLine));
   Expression condition = this.ParseExpression();
   IfDirective ifDirective = new IfDirective(condition, slb);
   this.preprocessorInformation.directives.Add(ifDirective);
   this.SkipPastBlanksCommentAndNewLine();
   bool allowElseToInclude = include;
   if (include) {
     include = condition.IsDefined(this.preprocessorDefinedSymbols);
     if (include)
       allowElseToInclude = false;
   }
   foreach (ISourceLocation includedSourceFragment in this.ParseSection(true, true, false, include, allowElseToInclude))
     yield return includedSourceFragment;
   slb.UpdateToSpan(this.GetSourceLocation(this.fragmentIndex-1, 0));
 }