Example #1
0
 public CodePosition GetPosition()
 {
     var p = new CodePosition();
     //Offset within the code block
     for (int n = 0; n < offset; n++)
     {
         switch (code[n])
         {
             case '\r':
                 continue; //Assume we have a '\n' in pair
             case '\n':
                 p.Line += 1;
                 p.Column = 0;
                 break;
             default:
                 p.Column += 1;
                 break;
         }
     }
     //Add code block offset
     p += statement.CodePosition;
     return p;
 }
Example #2
0
		public override Expr Visit (Expr e)
		{
			Instruction inst;
			if (this.instructionLookup.TryGetValue (e, out inst)) {
				var seq = inst.SequencePoint;
				if (seq != null) {
					this.SourceCodeFileName = seq.Document.Url;
					var instStart = new CodePosition(seq.StartLine, seq.StartColumn);
					if (this.StartPosition.IsEmpty || instStart < this.StartPosition) {
						this.StartPosition = instStart;
					}
					var instEnd = new CodePosition (seq.EndLine, seq.EndColumn);
					if (this.EndPosition.IsEmpty || instEnd > this.EndPosition) {
						this.EndPosition = instEnd;
					}
				}
			}
			return base.Visit (e);
		}
Example #3
0
 public SyntaxError(CodePosition pos, string message)
     : this(new CodeRange(pos), message)
 { }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompilationError"/> class with the specified program posistion and message.
 /// </summary>
 /// <param name="position">The position of the program this exception is being thrown.</param>
 /// <param name="message">The exception message describing the error.</param>
 public CompilationError(CodePosition position, string message)
 {
     Position = position;
     Message = message;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompilationError"/> class with the specified program posistion.
 /// </summary>
 /// <param name="position">The position of the program this exception is being thrown.</param>
 public CompilationError(CodePosition position)
 {
     Position = position;
 }