/// <summary> /// Makes a copy of this error message, changing only Location and SourceLocation to come from the /// given source document. Returns the same instance if the given source document is the same /// as this.SourceLocation.SourceDocument. /// </summary> /// <param name="targetDocument">The document to which the resulting error message must refer.</param> public override ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) //^^ requires targetDocument == this.SourceLocation.SourceDocument || targetDocument.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); //^^ ensures targetDocument == this.SourceLocation.SourceDocument ==> result == this; { if (this.SourceLocation.SourceDocument == targetDocument) { return(this); } return(new AstErrorMessage(targetDocument.GetCorrespondingSourceLocation(this.SourceLocation), this.Code, this.MessageKey, this.RelatedLocations, this.MessageArguments())); }
public static TokenizerStream Preprocess(ISourceDocument Document, CompilationParameters Parameters) { var sourceFile = new SourceFile(Document, Parameters); var preprocessor = new PreprocessorState(PreprocessorEnvironment.Static_Singleton.Instance.CreateDefaultEnvironment(Parameters.Log), sourceFile); var result = preprocessor.Expand(Document); if (Parameters.Log.Options.GetOption <bool>("output-preprocessed", false) || Parameters.Log.Options.GetOption <bool>("E", false)) { Parameters.Log.LogMessage(new LogEntry(Document.Identifier + " after preprocessing", result.ToString())); } return(new TokenizerStream(result.ToStream())); }
/// <summary> /// Makes a shallow copy of the source document /// </summary> /// <param name="targetDocument"></param> /// <returns></returns> public override ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) { if (base.SourceLocation.SourceDocument == targetDocument) { return this; } return new CcsErrorMessage( this.resourceType, targetDocument.GetCorrespondingSourceLocation(base.SourceLocation), base.Code, base.MessageKey, base.RelatedLocations, base.MessageArguments()); }
/// <summary> /// Allocates an object that describes an edit to a compilation as being either the addition, deletion or modification of a definition. /// </summary> /// <param name="kind">The kind of edit that has been performed (addition, deletion or modification).</param> /// <param name="affectedDefinition">The definition that has been added, deleted or modified.</param> /// <param name="modifiedParent">The new version of the parent of the affected definition (see also this.OriginalParent). /// If the edit is an addition or modification, this.ModifiedParent is the actual parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.ModifiedParent is the same as this.AffectedDefinition.</param> /// <param name="originalParent">The original parent of the affected definition (see also this.ModifiedParent). /// If the edit is a deletion, this.OriginalParent is the parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.OriginalParent is the same as this.AffectedDefinition.</param> /// <param name="modifiedSourceDocument">The source document that is the result of the edit described by this edit instance.</param> /// <param name="originalSourceDocument">The source document that has been edited as described by this edit instance.</param> public EditDescriptor(EditEventKind kind, IDefinition affectedDefinition, IDefinition modifiedParent, IDefinition originalParent, ISourceDocument modifiedSourceDocument, ISourceDocument originalSourceDocument) //^ requires modifiedSourceDocument.IsUpdatedVersionOf(originalSourceDocument); { this.kind = kind; this.affectedDefinition = affectedDefinition; this.modifiedSourceDocument = modifiedSourceDocument; this.modifiedParent = modifiedParent; this.originalSourceDocument = originalSourceDocument; this.originalParent = originalParent; }
/// <summary> /// Allocates an object that describes an edit to a source file. /// </summary> protected SourceDocumentEdit(ISourceLocation sourceLocationBeforeEdit, ISourceDocument sourceDocumentAfterEdit) //^ requires sourceDocumentAfterEdit.IsUpdatedVersionOf(sourceLocationBeforeEdit.SourceDocument); { this.sourceLocationBeforeEdit = sourceLocationBeforeEdit; this.sourceDocumentAfterEdit = sourceDocumentAfterEdit; }
public bool Contains(ISourceDocument sourceDocument) { return(false); }
//^ [Confined] bool ISourceDocument.IsUpdatedVersionOf(ISourceDocument sourceDocument) { return(false); }
public SourceFile(ISourceDocument Document, CompilationParameters Parameters) { this.Document = Document; this.Parameters = Parameters; }
public bool Contains(ISourceDocument sourceDocument) { return false; }
//^ [Confined] bool ISourceDocument.IsUpdatedVersionOf(ISourceDocument sourceDocument) { return false; }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { ISourceLocation sloc = this.SourceLocation; //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition ISourceLocation dsloc = this.DefinedSymbol.SourceLocation; //^ assume sloc.Contains(dsloc); //follows from the preconditon of the constructor PreprocessorSymbol newSymbol = new PreprocessorSymbol(this.DefinedSymbol.Name, newDocumentToPreprocess.GetCorrespondingSourceLocation(dsloc)); return new UndefDirective(newSymbol, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc)); }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { ISourceLocation sloc = this.SourceLocation; //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition RegionDirective result = new RegionDirective(this.Label, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc)); if (this.Endregion != null) result.endregion = new EndregionPart(this.Endregion.Label, newDocumentToPreprocess.GetCorrespondingSourceLocation(this.Endregion.SourceLocation)); return result; }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { List<WarningNumber> newWarnings = new List<WarningNumber>(this.Warnings); for (int i = 0, n = newWarnings.Count; i < n; i++) { newWarnings[i] = new WarningNumber(newWarnings[i].Value, newDocumentToPreprocess.GetCorrespondingSourceLocation(newWarnings[i].SourceLocation)); } return new PragmaWarningDirective(this.Disabled, newWarnings, newDocumentToPreprocess.GetCorrespondingSourceLocation(this.SourceLocation)); }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { ISourceLocation sloc = this.SourceLocation; //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition //unsatisfied precondition: requires this.IsUpdatedVersionOf(sourceLocationInPreviousVersionOfDocument.SourceDocument); return new LineDirective(this.LineNumber, this.DocumentName, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc)); }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { ISourceLocation sloc = this.SourceLocation; //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition //unsatisfied precondition: requires this.IsUpdatedVersionOf(sourceLocationInPreviousVersionOfDocument.SourceDocument); IfDirective result = new IfDirective(this.Condition, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc)); foreach (ElifPart elifPart in this.Elifs) result.elifs.Add(new ElifPart(elifPart.Condition, newDocumentToPreprocess.GetCorrespondingSourceLocation(elifPart.SourceLocation))); if (this.Else != null) result.@else = new ElsePart(newDocumentToPreprocess.GetCorrespondingSourceLocation(this.Else.SourceLocation)); if (this.Endif != null) result.endif = new EndifPart(newDocumentToPreprocess.GetCorrespondingSourceLocation(this.Endif.SourceLocation)); return result; }
/// <summary> /// Makes a shallow copy of the directive by updating its source location to come from the given document, /// but otherwise keeping all of the information the same. /// </summary> internal abstract Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess);
/// <summary> /// Makes a copy of this error message, changing only Location and SourceLocation to come from the /// given source document. Returns the same instance if the given source document is the same /// as this.SourceLocation.SourceDocument. /// </summary> /// <param name="targetDocument">The document to which the resulting error message must refer.</param> public override ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) //^^ requires targetDocument == this.SourceLocation.SourceDocument || targetDocument.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); //^^ ensures targetDocument == this.SourceLocation.SourceDocument ==> result == this; { if (this.SourceLocation.SourceDocument == targetDocument) return this; return new AstErrorMessage(targetDocument.GetCorrespondingSourceLocation(this.SourceLocation), this.Code, this.MessageKey, this.RelatedLocations, this.MessageArguments()); }
internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess) //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument); { ISourceLocation sloc = this.SourceLocation; //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition return new WarningDirective(this.Message, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc)); }
public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { throw new NotImplementedException(); }
public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { throw new NotImplementedException(); }
//^ [Confined] public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { return sourceDocument == SourceDummy.SourceDocument; }
/// <summary> /// Allocates an object that describes an edit to a source file. /// </summary> protected SourceDocumentEdit(ISourceLocation sourceLocationBeforeEdit, ISourceDocument sourceDocumentAfterEdit) { Contract.Requires(sourceLocationBeforeEdit != null); Contract.Requires(sourceDocumentAfterEdit != null); Contract.Requires(sourceDocumentAfterEdit.IsUpdatedVersionOf(sourceLocationBeforeEdit.SourceDocument)); this.sourceLocationBeforeEdit = sourceLocationBeforeEdit; this.sourceDocumentAfterEdit = sourceDocumentAfterEdit; }
//^ requires sourceDocumentAfterEdit.IsUpdatedVersionOf(sourceLocationBeforeEdit.SourceDocument); /// <summary> /// Allocates an object that describes an edit to a source file. /// </summary> protected SourceDocumentEdit(ISourceLocation sourceLocationBeforeEdit, ISourceDocument sourceDocumentAfterEdit) { this.sourceLocationBeforeEdit = sourceLocationBeforeEdit; this.sourceDocumentAfterEdit = sourceDocumentAfterEdit; }
public ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) { return(new TranslationMessage(loc, (int)code, msg, isWarning)); }
public ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) { return new TranslationMessage(loc, (int)code, msg, isWarning); }
// ^ ensures this.SourceDocument == sourceLocation.SourceDocument; //TODO: Spec# should allow such post conditions /// <summary> /// Allocates a mutable class that allows a source location to be built in an incremental fashion. /// </summary> /// <param name="sourceLocation">An initial source location.</param> public SourceLocationBuilder(ISourceLocation sourceLocation) { this.sourceDocument = sourceLocation.SourceDocument; this.length = sourceLocation.Length; this.startIndex = sourceLocation.StartIndex; }
/// <summary> /// Allocates an object that describes an edit to a compilation as being either the addition, deletion or modification of a definition. /// </summary> /// <param name="kind">The kind of edit that has been performed (addition, deletion or modification).</param> /// <param name="affectedDefinition">The definition that has been added, deleted or modified.</param> /// <param name="modifiedParent">The new version of the parent of the affected definition (see also this.OriginalParent). /// If the edit is an addition or modification, this.ModifiedParent is the actual parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.ModifiedParent is the same as this.AffectedDefinition.</param> /// <param name="originalParent">The original parent of the affected definition (see also this.ModifiedParent). /// If the edit is a deletion, this.OriginalParent is the parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.OriginalParent is the same as this.AffectedDefinition.</param> /// <param name="modifiedSourceDocument">The source document that is the result of the edit described by this edit instance.</param> /// <param name="originalSourceDocument">The source document that has been edited as described by this edit instance.</param> public EditDescriptor(EditEventKind kind, IDefinition affectedDefinition, IDefinition modifiedParent, IDefinition originalParent, ISourceDocument modifiedSourceDocument, ISourceDocument originalSourceDocument) { Contract.Requires(affectedDefinition != null); Contract.Requires(modifiedParent != null); Contract.Requires(originalParent != null); Contract.Requires(modifiedSourceDocument != null); Contract.Requires(originalSourceDocument != null); Contract.Requires(modifiedSourceDocument.IsUpdatedVersionOf(originalSourceDocument)); this.kind = kind; this.affectedDefinition = affectedDefinition; this.modifiedSourceDocument = modifiedSourceDocument; this.modifiedParent = modifiedParent; this.originalSourceDocument = originalSourceDocument; this.originalParent = originalParent; }
//^ requires modifiedSourceDocument.IsUpdatedVersionOf(originalSourceDocument); /// <summary> /// Allocates an object that describes an edit to a compilation as being either the addition, deletion or modification of a definition. /// </summary> /// <param name="kind">The kind of edit that has been performed (addition, deletion or modification).</param> /// <param name="affectedDefinition">The definition that has been added, deleted or modified.</param> /// <param name="modifiedParent">The new version of the parent of the affected definition (see also this.OriginalParent). /// If the edit is an addition or modification, this.ModifiedParent is the actual parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.ModifiedParent is the same as this.AffectedDefinition.</param> /// <param name="originalParent">The original parent of the affected definition (see also this.ModifiedParent). /// If the edit is a deletion, this.OriginalParent is the parent of this.AffectedDefinition. /// If this.AffectedDefinition does not have a parent then this.OriginalParent is the same as this.AffectedDefinition.</param> /// <param name="modifiedSourceDocument">The source document that is the result of the edit described by this edit instance.</param> /// <param name="originalSourceDocument">The source document that has been edited as described by this edit instance.</param> public EditDescriptor(EditEventKind kind, IDefinition affectedDefinition, IDefinition modifiedParent, IDefinition originalParent, ISourceDocument modifiedSourceDocument, ISourceDocument originalSourceDocument) { this.kind = kind; this.affectedDefinition = affectedDefinition; this.modifiedSourceDocument = modifiedSourceDocument; this.modifiedParent = modifiedParent; this.originalSourceDocument = originalSourceDocument; this.originalParent = originalParent; }
//^ [Confined] public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { return(sourceDocument == SourceDummy.SourceDocument); }
public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { Contract.Requires(sourceDocument != null); throw new NotImplementedException(); }
//^^ requires 0 <= position && (position < this.Length || position == 0); //^^ requires 0 <= length; //^^ requires length <= this.Length; //^^ requires position+length <= this.Length; //^^ ensures result.SourceDocument == this; //^^ ensures result.StartIndex == position; //^^ ensures result.Length == length; /// <summary> /// Returns true if this source document has been created by editing the given source document (or a updated /// version of the given source document). /// </summary> //^ [Confined] public virtual bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { WeakReference/*?*/ previousDocument = this.previousVersion; while (previousDocument != null) { SourceDocument/*?*/ prev = previousDocument.Target as SourceDocument; if (prev == null) return false; if (prev == sourceDocument) return true; previousDocument = prev.previousVersion; } return false; }
public ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) { Contract.Requires(targetDocument != null); Contract.Requires(targetDocument == this.SourceLocation.SourceDocument || targetDocument.IsUpdatedVersionOf(this.SourceLocation.SourceDocument)); Contract.Ensures(Contract.Result<ISourceErrorMessage>() != null); Contract.Ensures(!(targetDocument == this.SourceLocation.SourceDocument) || Contract.Result<ISourceErrorMessage>() == this); throw new NotImplementedException(); }
/// <summary> /// Returns true if this source document has been created by editing the given source document (or a updated /// version of the given source document). /// </summary> //^ [Confined] public bool IsUpdatedVersionOf(ISourceDocument sourceDocument) { return this.WrappedDocument.IsUpdatedVersionOf(sourceDocument); }
public bool Contains(ISourceDocument sourceDocument) { Contract.Requires(sourceDocument != null); throw new NotImplementedException(); }
/// <summary> /// Makes a copy of this error message, changing only Location and SourceLocation to come from the /// given source document. Returns the same instance if the given source document is the same /// as this.SourceLocation.SourceDocument. /// </summary> /// <param name="targetDocument">The document to which the resulting error message must refer.</param> public abstract ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument);
public override ISourceErrorMessage MakeShallowCopy(ISourceDocument targetDocument) { if (this.SourceLocation.SourceDocument == targetDocument) return this; return new SmallBasicErrorMessage(this.SourceLocation, this.Code, this.MessageKey, this.MessageArguments()); }