-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description Make reporting of related locations more consistent, so related locations are always shown on a separate line. Example: ``` -git-issue-864y.dfy(6,9): Error: duplicate name of top-level declaration: A [Related location] git-issue-864y.dfy(7,8) +git-issue-864y.dfy(6,9): Error: duplicate name of top-level declaration: A +git-issue-864y.dfy(7,8): Related location ``` ### How has this been tested? Expect files have been updated to match the new related location format. <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
- Loading branch information
1 parent
2ef450b
commit 7d14cad
Showing
26 changed files
with
643 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Contracts; | ||
|
||
namespace Microsoft.Dafny; | ||
|
||
public class MapType : CollectionType { | ||
public bool Finite { | ||
get { return finite; } | ||
set { finite = value; } | ||
} | ||
private bool finite; | ||
public Type Range { | ||
get { return range; } | ||
} | ||
private Type range; | ||
public override void SetTypeArgs(Type domain, Type range) { | ||
base.SetTypeArgs(domain, range); | ||
Contract.Assume(this.range == null); // Can only set once. This is really a precondition. | ||
this.range = range; | ||
} | ||
public MapType(bool finite, Type domain, Type range) : base(domain, range) { | ||
Contract.Requires((domain == null && range == null) || (domain != null && range != null)); | ||
this.finite = finite; | ||
this.range = range; | ||
} | ||
public Type Domain { | ||
get { return Arg; } | ||
} | ||
public override string CollectionTypeName { get { return finite ? "map" : "imap"; } } | ||
[System.Diagnostics.Contracts.Pure] | ||
public override string TypeName(DafnyOptions options, ModuleDefinition context, bool parseAble) { | ||
Contract.Ensures(Contract.Result<string>() != null); | ||
var targs = HasTypeArg() ? this.TypeArgsToString(options, context, parseAble) : ""; | ||
return CollectionTypeName + targs; | ||
} | ||
public override bool Equals(Type that, bool keepConstraints = false) { | ||
var t = that.NormalizeExpand(keepConstraints) as MapType; | ||
return t != null && Finite == t.Finite && Arg.Equals(t.Arg, keepConstraints) && Range.Equals(t.Range, keepConstraints); | ||
} | ||
|
||
public override Type Subst(IDictionary<TypeParameter, Type> subst) { | ||
var dom = Domain.Subst(subst); | ||
if (dom is InferredTypeProxy) { | ||
((InferredTypeProxy)dom).KeepConstraints = true; | ||
} | ||
var ran = Range.Subst(subst); | ||
if (ran is InferredTypeProxy) { | ||
((InferredTypeProxy)ran).KeepConstraints = true; | ||
} | ||
if (dom == Domain && ran == Range) { | ||
return this; | ||
} else { | ||
return new MapType(Finite, dom, ran); | ||
} | ||
} | ||
|
||
public override Type ReplaceTypeArguments(List<Type> arguments) { | ||
return new MapType(Finite, arguments[0], arguments[1]); | ||
} | ||
|
||
public override bool SupportsEquality { | ||
get { | ||
// A map type supports equality if both its Keys type and Values type does. It is checked | ||
// that the Keys type always supports equality, so we only need to check the Values type here. | ||
return range.SupportsEquality; | ||
} | ||
} | ||
public override bool ComputeMayInvolveReferences(ISet<DatatypeDecl> visitedDatatypes) { | ||
return Domain.ComputeMayInvolveReferences(visitedDatatypes) || Range.ComputeMayInvolveReferences(visitedDatatypes); | ||
} | ||
|
||
public override BinaryExpr.ResolvedOpcode ResolvedOpcodeForIn => BinaryExpr.ResolvedOpcode.InMap; | ||
public override ComprehensionExpr.CollectionBoundedPool GetBoundedPool(Expression source) { | ||
return new ComprehensionExpr.MapBoundedPool(source, Domain, Domain, Finite); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.