summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Unknown <afd@afd-THINK>2012-07-02 11:27:27 +0100
committerGravatar Unknown <afd@afd-THINK>2012-07-02 11:27:27 +0100
commitac278e7fb6d5077401165e861f34f0e7ff311a02 (patch)
tree9fdbb38f8fff49eb96967bb48c52be544fb5c84a
parent4fffb5b2570db1c0acacddc6aa6dfd9304ef98ec (diff)
parentecd0247b305d98dc868c1915252f70db04801ca7 (diff)
Merge
-rw-r--r--Binaries/DafnyPrelude.bpl7
-rw-r--r--Source/Dafny/Compiler.cs8
-rw-r--r--Source/Dafny/Dafny.atg188
-rw-r--r--Source/Dafny/DafnyAst.cs152
-rw-r--r--Source/Dafny/DafnyMain.cs6
-rw-r--r--Source/Dafny/DafnyPipeline.csproj1
-rw-r--r--Source/Dafny/Parser.cs1092
-rw-r--r--Source/Dafny/Printer.cs76
-rw-r--r--Source/Dafny/RefinementTransformer.cs139
-rw-r--r--Source/Dafny/Resolver.cs838
-rw-r--r--Source/Dafny/Rewriter.cs12
-rw-r--r--Source/Dafny/Scanner.cs100
-rw-r--r--Source/Dafny/Translator.cs30
-rw-r--r--Source/Dafny/Util.cs20
-rw-r--r--Source/GPUVerify/RaceInstrumenter.cs1042
-rw-r--r--Source/GPUVerify/ReducedStrengthAnalysis.cs166
-rwxr-xr-xSource/GPUVerify/StrideConstraint.cs141
-rw-r--r--Test/dafny0/Answer101
-rw-r--r--Test/dafny0/LiberalEquality.dfy2
-rw-r--r--Test/dafny0/Modules0.dfy74
-rw-r--r--Test/dafny0/Modules1.dfy25
-rw-r--r--Test/dafny0/ModulesCycle.dfy35
-rw-r--r--Test/dafny0/Predicates.dfy10
-rw-r--r--Test/dafny0/Refinement.dfy5
-rw-r--r--Test/dafny1/Answer4
-rw-r--r--Test/dafny1/ListContents.dfy13
-rw-r--r--Test/dafny1/runtest.bat2
-rw-r--r--Test/dafny2/Answer4
-rw-r--r--Test/dafny2/runtest.bat4
-rw-r--r--Test/test15/Answer52
-rw-r--r--Test/vstte2012/Answer4
-rw-r--r--Test/vstte2012/runtest.bat3
-rw-r--r--Util/VS2010/Dafny/DafnyLanguageService/Grammar.cs3
-rw-r--r--_admin/Boogie/aste/summary.log21
-rw-r--r--_admin/Chalice/aste/summary.log18
35 files changed, 1846 insertions, 2552 deletions
diff --git a/Binaries/DafnyPrelude.bpl b/Binaries/DafnyPrelude.bpl
index fef8fe1f..53d0b471 100644
--- a/Binaries/DafnyPrelude.bpl
+++ b/Binaries/DafnyPrelude.bpl
@@ -500,6 +500,13 @@ axiom (forall f: Field BoxType, i: int :: { MultiIndexField(f,i) }
function DeclType<T>(Field T): ClassName;
+type NameFamily;
+function DeclName<T>(Field T): NameFamily;
+function FieldOfDecl<alpha>(ClassName, NameFamily): Field alpha;
+axiom (forall<T> cl : ClassName, nm: NameFamily ::
+ {FieldOfDecl(cl, nm): Field T}
+ DeclType(FieldOfDecl(cl, nm): Field T) == cl && DeclName(FieldOfDecl(cl, nm): Field T) == nm);
+
// ---------------------------------------------------------------
// -- Allocatedness ----------------------------------------------
// ---------------------------------------------------------------
diff --git a/Source/Dafny/Compiler.cs b/Source/Dafny/Compiler.cs
index e72c04dd..7f48e551 100644
--- a/Source/Dafny/Compiler.cs
+++ b/Source/Dafny/Compiler.cs
@@ -66,7 +66,7 @@ namespace Microsoft.Dafny {
ReadRuntimeSystem();
CompileBuiltIns(program.BuiltIns);
- foreach (ModuleDecl m in program.Modules) {
+ foreach (ModuleDefinition m in program.Modules) {
if (m.IsGhost) {
// the purpose of a ghost module is to skip compilation
continue;
@@ -91,7 +91,7 @@ namespace Microsoft.Dafny {
wr.WriteLine(" { }");
CompileDatatypeConstructors(dt, indent);
CompileDatatypeStruct(dt, indent);
- } else {
+ } else if (d is ClassDecl) {
ClassDecl cl = (ClassDecl)d;
Indent(indent);
wr.Write("public class @{0}", cl.CompileName);
@@ -101,7 +101,9 @@ namespace Microsoft.Dafny {
wr.WriteLine(" {");
CompileClassMembers(cl, indent+IndentAmount);
Indent(indent); wr.WriteLine("}");
- }
+ } else if (d is ModuleDecl) {
+ // nop
+ } else { Contract.Assert(false); }
}
if (!m.IsDefaultModule) {
wr.WriteLine("}} // end of namespace {0}", m.CompileName);
diff --git a/Source/Dafny/Dafny.atg b/Source/Dafny/Dafny.atg
index 4b9e0c27..bfce5122 100644
--- a/Source/Dafny/Dafny.atg
+++ b/Source/Dafny/Dafny.atg
@@ -14,7 +14,7 @@ using System.IO;
using System.Text;
COMPILER Dafny
/*--------------------------------------------------------------------------*/
-static List<ModuleDecl/*!*/> theModules;
+static ModuleDecl theModule;
static BuiltIns theBuiltIns;
static Expression/*!*/ dummyExpr = new LiteralExpr(Token.NoToken);
static FrameExpression/*!*/ dummyFrameExpr = new FrameExpression(dummyExpr, null);
@@ -28,51 +28,51 @@ struct MemberModifiers {
// helper routine for parsing call statements
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members) from "filename"
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner.
///</summary>
-public static int Parse (string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns) /* throws System.IO.IOException */ {
+public static int Parse (string/*!*/ filename, ModuleDecl module, BuiltIns builtIns) /* throws System.IO.IOException */ {
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
string s;
if (filename == "stdin.dfy") {
s = Microsoft.Boogie.ParserHelper.Fill(System.Console.In, new List<string>());
- return Parse(s, filename, modules, builtIns);
+ return Parse(s, filename, module, builtIns);
} else {
using (System.IO.StreamReader reader = new System.IO.StreamReader(filename)) {
s = Microsoft.Boogie.ParserHelper.Fill(reader, new List<string>());
- return Parse(s, filename, modules, builtIns);
+ return Parse(s, filename, module, builtIns);
}
}
}
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members)
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner.
///</summary>
-public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns) {
+public static int Parse (string/*!*/ s, string/*!*/ filename, ModuleDecl module, BuiltIns builtIns) {
Contract.Requires(s != null);
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
Errors errors = new Errors();
- return Parse(s, filename, modules, builtIns, errors);
+ return Parse(s, filename, module, builtIns, errors);
}
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members)
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner with the given Errors sink.
///</summary>
-public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns,
+public static int Parse (string/*!*/ s, string/*!*/ filename, ModuleDecl module, BuiltIns builtIns,
Errors/*!*/ errors) {
Contract.Requires(s != null);
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
Contract.Requires(errors != null);
- List<ModuleDecl/*!*/> oldModules = theModules;
- theModules = modules;
+ var oldModule = theModule;
+ theModule = module;
BuiltIns oldBuiltIns = builtIns;
theBuiltIns = builtIns;
byte[]/*!*/ buffer = cce.NonNull( UTF8Encoding.Default.GetBytes(s));
@@ -80,7 +80,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!
Scanner scanner = new Scanner(ms, errors, filename);
Parser parser = new Parser(scanner, errors);
parser.Parse();
- theModules = oldModules;
+ theModule = oldModule;
theBuiltIns = oldBuiltIns;
return parser.errors.count;
}
@@ -131,43 +131,19 @@ IGNORE cr + lf + tab
PRODUCTIONS
Dafny
= (. ClassDecl/*!*/ c; DatatypeDecl/*!*/ dt; ArbitraryTypeDecl at;
- Attributes attrs; IToken/*!*/ id; List<string/*!*/> theImports;
List<MemberDecl/*!*/> membersDefaultClass = new List<MemberDecl/*!*/>();
- List<MemberDecl/*!*/> namedModuleDefaultClassMembers;
- ModuleDecl module;
- // to support multiple files, create a default module only if theModules doesn't already contain one
- DefaultModuleDecl defaultModule = null;
- foreach (ModuleDecl mdecl in theModules) {
- defaultModule = mdecl as DefaultModuleDecl;
- if (defaultModule != null) { break; }
- }
- bool defaultModuleCreatedHere = false;
- if (defaultModule == null) {
- defaultModuleCreatedHere = true;
- defaultModule = new DefaultModuleDecl();
- }
- IToken idRefined;
+ ModuleDecl submodule;
+ // to support multiple files, create a default module only if theModule is null
+ DefaultModuleDecl defaultModule = (DefaultModuleDecl)((LiteralModuleDecl)theModule).ModuleDef;
+ // theModule should be a DefaultModuleDecl (actually, the singular DefaultModuleDecl)
+ Contract.Assert(defaultModule != null);
bool isGhost;
.)
{ (. isGhost = false; .)
[ "ghost" (. isGhost = true; .) ]
- ( "module" (. attrs = null; idRefined = null; theImports = new List<string/*!*/>();
- namedModuleDefaultClassMembers = new List<MemberDecl>();
- .)
- { Attribute<ref attrs> }
- Ident<out id> (. defaultModule.ImportNames.Add(id.val); .)
- [ "refines" Ident<out idRefined> ]
- [ "imports" Idents<theImports> ] (. module = new ModuleDecl(id, id.val, isGhost, idRefined == null ? null : idRefined.val, theImports, attrs); .)
- "{" (. module.BodyStartTok = t; .)
- { ClassDecl<module, out c> (. module.TopLevelDecls.Add(c); .)
- | DatatypeDecl<module, out dt> (. module.TopLevelDecls.Add(dt); .)
- | ArbitraryTypeDecl<module, out at>(. module.TopLevelDecls.Add(at); .)
- | ClassMemberDecl<namedModuleDefaultClassMembers, false, false>
- }
- "}" (. module.BodyEndTok = t;
- module.TopLevelDecls.Add(new DefaultClassDecl(module, namedModuleDefaultClassMembers));
- theModules.Add(module); .)
+ ( SubModuleDecl<defaultModule, isGhost, out submodule>
+ (. defaultModule.TopLevelDecls.Add(submodule); .)
| (. if (isGhost) { SemErr(t, "a class is not allowed to be declared as 'ghost'"); } .)
ClassDecl<defaultModule, out c> (. defaultModule.TopLevelDecls.Add(c); .)
| (. if (isGhost) { SemErr(t, "a datatype/codatatype is not allowed to be declared as 'ghost'"); } .)
@@ -177,23 +153,67 @@ Dafny
| ClassMemberDecl<membersDefaultClass, isGhost, false>
)
}
- (. if (defaultModuleCreatedHere) {
- defaultModule.TopLevelDecls.Add(new DefaultClassDecl(defaultModule, membersDefaultClass));
- theModules.Add(defaultModule);
- } else {
- // find the default class in the default module, then append membersDefaultClass to its member list
- foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
- DefaultClassDecl defaultClass = topleveldecl as DefaultClassDecl;
- if (defaultClass != null) {
- defaultClass.Members.AddRange(membersDefaultClass);
- break;
- }
+ (. // find the default class in the default module, then append membersDefaultClass to its member list
+ DefaultClassDecl defaultClass = null;
+ foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
+ defaultClass = topleveldecl as DefaultClassDecl;
+ if (defaultClass != null) {
+ defaultClass.Members.AddRange(membersDefaultClass);
+ break;
}
}
- .)
+ if (defaultClass == null) { // create the default class here, because it wasn't found
+ defaultClass = new DefaultClassDecl(defaultModule, membersDefaultClass);
+ defaultModule.TopLevelDecls.Add(defaultClass);
+ } .)
EOF
.
-ClassDecl<ModuleDecl/*!*/ module, out ClassDecl/*!*/ c>
+SubModuleDecl<ModuleDefinition parent, bool isOverallModuleGhost, out ModuleDecl submodule>
+= (. ClassDecl/*!*/ c; DatatypeDecl/*!*/ dt; ArbitraryTypeDecl at;
+ Attributes attrs = null; IToken/*!*/ id;
+ List<MemberDecl/*!*/> namedModuleDefaultClassMembers = new List<MemberDecl>();;
+ List<IToken> idRefined = null, idPath = null;
+ bool isGhost = false;
+ ModuleDefinition module;
+ ModuleDecl sm;
+ submodule = null; // appease compiler
+ .)
+ "module"
+ { Attribute<ref attrs> }
+ NoUSIdent<out id>
+ ((
+ [ "refines" QualifiedName<out idRefined> ] (. module = new ModuleDefinition(id, id.val, isOverallModuleGhost, false, idRefined == null ? null : idRefined, attrs); .)
+ "{" (. module.BodyStartTok = t; .)
+ { (. isGhost = false; .)
+ [ "ghost" (. isGhost = true; .) ]
+ ( SubModuleDecl<module, isGhost, out sm> (. module.TopLevelDecls.Add(sm); .)
+ | (. if (isGhost) { SemErr(t, "a class is not allowed to be declared as 'ghost'"); } .)
+ ClassDecl<module, out c> (. module.TopLevelDecls.Add(c); .)
+ | (. if (isGhost) { SemErr(t, "a datatype/codatatype is not allowed to be declared as 'ghost'"); } .)
+ DatatypeDecl<module, out dt> (. module.TopLevelDecls.Add(dt); .)
+ | (. if (isGhost) { SemErr(t, "a type is not allowed to be declared as 'ghost'"); } .)
+ ArbitraryTypeDecl<module, out at> (. module.TopLevelDecls.Add(at); .)
+ | ClassMemberDecl<namedModuleDefaultClassMembers, isGhost, false>
+ )
+ }
+ "}" (. module.BodyEndTok = t;
+ module.TopLevelDecls.Add(new DefaultClassDecl(module, namedModuleDefaultClassMembers));
+ submodule = new LiteralModuleDecl(module, parent); .)
+ ) |
+ "=" QualifiedName<out idPath> ";" (. submodule = new AliasModuleDecl(idPath, id, parent); .)
+ |
+ "as" QualifiedName<out idPath> ";" (.submodule = new AbstractModuleDecl(idPath, id, parent); .)
+ )
+.
+
+QualifiedName<.out List<IToken> ids.>
+= (. IToken id; ids = new List<IToken>(); .)
+ Ident<out id> (. ids.Add(id); .)
+ { "." Ident<out id> (. ids.Add(id); .)
+ }
+ .
+
+ClassDecl<ModuleDefinition/*!*/ module, out ClassDecl/*!*/ c>
= (. Contract.Requires(module != null);
Contract.Ensures(Contract.ValueAtReturn(out c) != null);
IToken/*!*/ id;
@@ -205,7 +225,7 @@ ClassDecl<ModuleDecl/*!*/ module, out ClassDecl/*!*/ c>
SYNC
"class"
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
[ GenericParameters<typeArgs> ]
"{" (. bodyStart = t; .)
{ ClassMemberDecl<members, false, true>
@@ -231,7 +251,7 @@ ClassMemberDecl<.List<MemberDecl/*!*/>/*!*/ mm, bool isAlreadyGhost, bool allowC
| MethodDecl<mmod, allowConstructors, out m> (. mm.Add(m); .)
)
.
-DatatypeDecl<ModuleDecl/*!*/ module, out DatatypeDecl/*!*/ dt>
+DatatypeDecl<ModuleDefinition/*!*/ module, out DatatypeDecl/*!*/ dt>
= (. Contract.Requires(module != null);
Contract.Ensures(Contract.ValueAtReturn(out dt)!=null);
IToken/*!*/ id;
@@ -246,7 +266,7 @@ DatatypeDecl<ModuleDecl/*!*/ module, out DatatypeDecl/*!*/ dt>
| "codatatype" (. co = true; .)
)
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
[ GenericParameters<typeArgs> ]
"=" (. bodyStart = t; .)
DatatypeMemberDecl<ctors>
@@ -268,7 +288,7 @@ DatatypeMemberDecl<.List<DatatypeCtor/*!*/>/*!*/ ctors.>
List<Formal/*!*/> formals = new List<Formal/*!*/>();
.)
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
[ FormalsOptionalIds<formals> ]
(. ctors.Add(new DatatypeCtor(id, id.val, formals, attrs)); .)
.
@@ -287,14 +307,14 @@ FieldDecl<.MemberModifiers mmod, List<MemberDecl/*!*/>/*!*/ mm.>
}
SYNC ";"
.
-ArbitraryTypeDecl<ModuleDecl/*!*/ module, out ArbitraryTypeDecl at>
+ArbitraryTypeDecl<ModuleDefinition/*!*/ module, out ArbitraryTypeDecl at>
= (. IToken/*!*/ id;
Attributes attrs = null;
var eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
.)
"type"
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
[ "(" "==" ")" (. eqSupport = TypeParameter.EqualitySupportValue.Required; .)
] (. at = new ArbitraryTypeDecl(id, id.val, module, eqSupport, attrs); .)
SYNC ";"
@@ -310,14 +330,14 @@ GIdentType<bool allowGhostKeyword, out IToken/*!*/ id, out Type/*!*/ ty, out boo
.
IdentType<out IToken/*!*/ id, out Type/*!*/ ty>
= (.Contract.Ensures(Contract.ValueAtReturn(out id) != null); Contract.Ensures(Contract.ValueAtReturn(out ty) != null);.)
- Ident<out id>
+ NoUSIdent<out id>
":"
Type<out ty>
.
LocalIdentTypeOptional<out VarDecl/*!*/ var, bool isGhost>
= (. IToken/*!*/ id; Type/*!*/ ty; Type optType = null;
.)
- Ident<out id>
+ NoUSIdent<out id>
[ ":" Type<out ty> (. optType = ty; .)
]
(. var = new VarDecl(id, id.val, optType == null ? new InferredTypeProxy() : optType, isGhost); .)
@@ -325,7 +345,7 @@ LocalIdentTypeOptional<out VarDecl/*!*/ var, bool isGhost>
IdentTypeOptional<out BoundVar/*!*/ var>
= (. Contract.Ensures(Contract.ValueAtReturn(out var)!=null); IToken/*!*/ id; Type/*!*/ ty; Type optType = null;
.)
- Ident<out id>
+ NoUSIdent<out id>
[ ":" Type<out ty> (. optType = ty; .)
]
(. var = new BoundVar(id, id.val, optType == null ? new InferredTypeProxy() : optType); .)
@@ -363,10 +383,10 @@ GenericParameters<.List<TypeParameter/*!*/>/*!*/ typeArgs.>
TypeParameter.EqualitySupportValue eqSupport;
.)
"<"
- Ident<out id> (. eqSupport = TypeParameter.EqualitySupportValue.Unspecified; .)
+ NoUSIdent<out id> (. eqSupport = TypeParameter.EqualitySupportValue.Unspecified; .)
[ "(" "==" ")" (. eqSupport = TypeParameter.EqualitySupportValue.Required; .)
] (. typeArgs.Add(new TypeParameter(id, id.val, eqSupport)); .)
- { "," Ident<out id> (. eqSupport = TypeParameter.EqualitySupportValue.Unspecified; .)
+ { "," NoUSIdent<out id> (. eqSupport = TypeParameter.EqualitySupportValue.Unspecified; .)
[ "(" "==" ")" (. eqSupport = TypeParameter.EqualitySupportValue.Required; .)
] (. typeArgs.Add(new TypeParameter(id, id.val, eqSupport)); .)
}
@@ -412,7 +432,7 @@ MethodDecl<MemberModifiers mmod, bool allowConstructor, out Method/*!*/ m>
}
.)
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
(
[ GenericParameters<typeArgs> ]
Formals<true, !mmod.IsGhost, ins, out openParen>
@@ -572,7 +592,7 @@ FunctionDecl<MemberModifiers mmod, out Function/*!*/ f>
(. if (mmod.IsGhost) { SemErr(t, "functions cannot be declared 'ghost' (they are ghost by default)"); }
.)
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
(
[ GenericParameters<typeArgs> ]
Formals<true, isFunctionMethod, formals, out openParen>
@@ -589,7 +609,7 @@ FunctionDecl<MemberModifiers mmod, out Function/*!*/ f>
(. if (mmod.IsGhost) { SemErr(t, "predicates cannot be declared 'ghost' (they are ghost by default)"); }
.)
{ Attribute<ref attrs> }
- Ident<out id>
+ NoUSIdent<out id>
(
[ GenericParameters<typeArgs> ]
[ Formals<true, isFunctionMethod, formals, out openParen>
@@ -699,10 +719,10 @@ OneStmt<out Statement/*!*/ s>
| MatchStmt<out s>
| ParallelStmt<out s>
| "label" (. x = t; .)
- Ident<out id> ":"
+ NoUSIdent<out id> ":"
OneStmt<out s> (. s.Labels = new LList<Label>(new Label(x, id.val), s.Labels); .)
| "break" (. x = t; breakCount = 1; label = null; .)
- ( Ident<out id> (. label = id.val; .)
+ ( NoUSIdent<out id> (. label = id.val; .)
| { "break" (. breakCount++; .)
}
)
@@ -1643,16 +1663,20 @@ AttributeArg<out Attributes.Argument/*!*/ arg>
)
.
/*------------------------------------------------------------------------*/
-Idents<.List<string/*!*/>/*!*/ ids.>
-= (. IToken/*!*/ id; .)
- Ident<out id> (. ids.Add(id.val); .)
- { "," Ident<out id> (. ids.Add(id.val); .)
- }
- .
Ident<out IToken/*!*/ x>
= (. Contract.Ensures(Contract.ValueAtReturn(out x) != null); .)
ident (. x = t; .)
.
+// Identifier, disallowing leading underscores
+NoUSIdent<out IToken/*!*/ x>
+= (. Contract.Ensures(Contract.ValueAtReturn(out x) != null); .)
+ ident (. x = t;
+ if (x.val.Length > 0 && x.val.StartsWith("_")) {
+ SemErr("cannot declare identifier beginning with underscore");
+ }
+ .)
+ .
+
Nat<out BigInteger n>
=
digits
diff --git a/Source/Dafny/DafnyAst.cs b/Source/Dafny/DafnyAst.cs
index bf985ddc..ee4592ce 100644
--- a/Source/Dafny/DafnyAst.cs
+++ b/Source/Dafny/DafnyAst.cs
@@ -15,30 +15,37 @@ namespace Microsoft.Dafny {
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(Name != null);
- Contract.Invariant(cce.NonNullElements(Modules));
+ Contract.Invariant(DefaultModule != null);
}
public readonly string Name;
- public readonly List<ModuleDecl/*!*/>/*!*/ Modules;
+ public List<ModuleDefinition/*!*/>/*!*/ Modules; // filled in during resolution.
+ // Resolution essentially flattens the module heirarchy, for
+ // purposes of translation and compilation.
+ public readonly ModuleDecl DefaultModule;
+ public readonly ModuleDefinition DefaultModuleDef;
public readonly BuiltIns BuiltIns;
- public Program(string name, [Captured] List<ModuleDecl/*!*/>/*!*/ modules, [Captured] BuiltIns builtIns) {
+ public Program(string name, [Captured] ModuleDecl module, [Captured] BuiltIns builtIns) {
Contract.Requires(name != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
+ Contract.Requires(module is LiteralModuleDecl);
Name = name;
- Modules = modules;
+ DefaultModule = module;
+ DefaultModuleDef = (DefaultModuleDecl)((LiteralModuleDecl)module).ModuleDef;
BuiltIns = builtIns;
+ Modules = new List<ModuleDefinition>();
}
}
public class BuiltIns
{
- public readonly ModuleDecl SystemModule = new ModuleDecl(Token.NoToken, "_System", false, null, new List<string>(), null);
+ public readonly ModuleDefinition SystemModule = new ModuleDefinition(Token.NoToken, "_System", false, false, null, null);
Dictionary<int, ClassDecl/*!*/> arrayTypeDecls = new Dictionary<int, ClassDecl>();
-
+ public readonly ClassDecl ObjectDecl;
public BuiltIns() {
// create class 'object'
- ClassDecl obj = new ClassDecl(Token.NoToken, "object", SystemModule, new List<TypeParameter>(), new List<MemberDecl>(), null);
- SystemModule.TopLevelDecls.Add(obj);
+ ObjectDecl = new ClassDecl(Token.NoToken, "object", SystemModule, new List<TypeParameter>(), new List<MemberDecl>(), null);
+ SystemModule.TopLevelDecls.Add(ObjectDecl);
// add one-dimensional arrays, since they may arise during type checking
UserDefinedType tmp = ArrayType(Token.NoToken, 1, Type.Int, true);
}
@@ -782,47 +789,120 @@ namespace Microsoft.Dafny {
}
}
- public class ModuleDecl : Declaration {
- public readonly string RefinementBaseName; // null if no refinement base
- public ModuleDecl RefinementBase; // filled in during resolution (null if no refinement base)
- public readonly List<string/*!*/>/*!*/ ImportNames; // contains no duplicates
- public readonly List<ModuleDecl>/*!*/ Imports = new List<ModuleDecl>(); // filled in during resolution, contains no duplicates
+ // Represents a submodule declartion at module level scope
+ abstract public class ModuleDecl : TopLevelDecl
+ {
+ public ModuleSignature Signature; // filled in by resolution, in topological order.
+ public int Height;
+ public ModuleDecl(IToken tok, string name, ModuleDefinition parent)
+ : base(tok, name, parent, new List<TypeParameter>(), null) {
+ Height = -1;
+ Signature = null;
+ }
+ }
+ // Represents module X { ... }
+ public class LiteralModuleDecl : ModuleDecl
+ {
+ public readonly ModuleDefinition ModuleDef;
+ public LiteralModuleDecl(ModuleDefinition module, ModuleDefinition parent)
+ : base(module.tok, module.Name, parent) {
+ ModuleDef = module;
+ }
+ }
+ // Represents "module name = path;", where name is a identifier and path is a possibly qualified name.
+ public class AliasModuleDecl : ModuleDecl
+ {
+ public ModuleDecl ModuleReference; // should refer to another declaration somewhere. NOTE: cyclicity is possible, and should
+ // be detected and warned.
+ public readonly List<IToken> Path; // generated by the parser, this is looked up
+ public ModuleDecl Root; // the moduleDecl that Path[0] refers to.
+ public AliasModuleDecl(List<IToken> path, IToken name, ModuleDefinition parent)
+ : base(name, name.val, parent) {
+ Contract.Requires(path != null && path.Count > 0);
+ Path = path;
+ ModuleReference = null;
+ }
+ }
+ // Represents "module name as path;", where name is a identifier and path is a possibly qualified name.
+ public class AbstractModuleDecl : ModuleDecl
+ {
+ public ModuleDecl Root;
+ public readonly List<IToken> Path;
+ public ModuleSignature OriginalSignature;
+ public AbstractModuleDecl(List<IToken> path, IToken name, ModuleDefinition parent)
+ : base(name, name.val, parent) {
+ Path = path;
+ Root = null;
+ }
+ }
+
+ public class ModuleSignature {
+
+ public readonly Dictionary<string, TopLevelDecl> TopLevels = new Dictionary<string, TopLevelDecl>();
+ public readonly Dictionary<string, Tuple<DatatypeCtor, bool>> Ctors = new Dictionary<string, Tuple<DatatypeCtor, bool>>();
+ public ModuleDefinition ModuleDef; // Note: this is null if this signature does not correspond to a specific definition (i.e.
+ // it is abstract). Otherwise, it points to that definition.
+ public ModuleSignature Refines;
+ public ModuleSignature() {}
+
+ public bool FindSubmodule(string name, out ModuleSignature pp) {
+ TopLevelDecl top;
+ pp = null;
+ if (TopLevels.TryGetValue(name, out top)) {
+ if (top is ModuleDecl) {
+ pp = ((ModuleDecl)top).Signature;
+ return true;
+ } else return false;
+ } else return false;
+ }
+
+
+ }
+ public class ModuleDefinition : Declaration {
+ public readonly List<IToken> RefinementBaseName; // null if no refinement base
+ public ModuleDecl RefinementBaseRoot; // filled in early during resolution, corresponds to RefinementBaseName[0]
+ public ModuleDefinition RefinementBase; // filled in during resolution (null if no refinement base)
+
public readonly List<TopLevelDecl/*!*/> TopLevelDecls = new List<TopLevelDecl/*!*/>(); // filled in by the parser; readonly after that
public readonly Graph<MemberDecl/*!*/> CallGraph = new Graph<MemberDecl/*!*/>(); // filled in during resolution
public int Height; // height in the topological sorting of modules; filled in during resolution
public readonly bool IsGhost;
+ public readonly bool IsAbstract; // True iff this module represents an abstract interface
[ContractInvariantMethod]
void ObjectInvariant() {
- Contract.Invariant(cce.NonNullElements(ImportNames));
Contract.Invariant(cce.NonNullElements(TopLevelDecls));
Contract.Invariant(CallGraph != null);
}
- public ModuleDecl(IToken tok, string name, bool isGhost, string refinementBase, [Captured] List<string/*!*/>/*!*/ imports, Attributes attributes)
+ public ModuleDefinition(IToken tok, string name, bool isGhost, bool isAbstract, List<IToken> refinementBase, Attributes attributes)
: base(tok, name, attributes) {
Contract.Requires(tok != null);
Contract.Requires(name != null);
- Contract.Requires(cce.NonNullElements(imports));
RefinementBaseName = refinementBase;
- // set "ImportNames" to "imports" minus any duplicates
- ImportNames = new List<string>();
- foreach (var nm in imports) {
- if (!ImportNames.Contains(nm)) {
- ImportNames.Add(nm);
- }
- }
IsGhost = isGhost;
+ IsAbstract = isAbstract;
+ RefinementBaseRoot = null;
+ RefinementBase = null;
}
public virtual bool IsDefaultModule {
get {
return false;
}
}
+ string compileName;
+ new public string CompileName {
+ get {
+ if (compileName == null) {
+ compileName = "_" + Height.ToString() + "_" + NonglobalVariable.CompilerizeName(Name);
+ }
+ return compileName;
+ }
+ }
}
- public class DefaultModuleDecl : ModuleDecl {
- public DefaultModuleDecl() : base(Token.NoToken, "_default", false, null, new List<string/*!*/>(), null) {
+ public class DefaultModuleDecl : ModuleDefinition {
+ public DefaultModuleDecl() : base(Token.NoToken, "_module", false, false, null, null) {
}
public override bool IsDefaultModule {
get {
@@ -832,19 +912,17 @@ namespace Microsoft.Dafny {
}
public abstract class TopLevelDecl : Declaration, TypeParameter.ParentType {
- public readonly ModuleDecl Module;
+ public readonly ModuleDefinition Module;
public readonly List<TypeParameter/*!*/>/*!*/ TypeArgs;
[ContractInvariantMethod]
void ObjectInvariant() {
- Contract.Invariant(Module != null);
Contract.Invariant(cce.NonNullElements(TypeArgs));
}
- public TopLevelDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs, Attributes attributes)
+ public TopLevelDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition module, List<TypeParameter/*!*/>/*!*/ typeArgs, Attributes attributes)
: base(tok, name, attributes) {
Contract.Requires(tok != null);
Contract.Requires(name != null);
- Contract.Requires(module != null);
Contract.Requires(cce.NonNullElements(typeArgs));
Module = module;
TypeArgs = typeArgs;
@@ -870,7 +948,7 @@ namespace Microsoft.Dafny {
Contract.Invariant(cce.NonNullElements(Members));
}
- public ClassDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module,
+ public ClassDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition/*!*/ module,
List<TypeParameter/*!*/>/*!*/ typeArgs, [Captured] List<MemberDecl/*!*/>/*!*/ members, Attributes attributes)
: base(tok, name, module, typeArgs, attributes) {
Contract.Requires(tok != null);
@@ -890,7 +968,7 @@ namespace Microsoft.Dafny {
}
public class DefaultClassDecl : ClassDecl {
- public DefaultClassDecl(ModuleDecl/*!*/ module, [Captured] List<MemberDecl/*!*/>/*!*/ members)
+ public DefaultClassDecl(ModuleDefinition/*!*/ module, [Captured] List<MemberDecl/*!*/>/*!*/ members)
: base(Token.NoToken, "_default", module, new List<TypeParameter/*!*/>(), members, null) {
Contract.Requires(module != null);
Contract.Requires(cce.NonNullElements(members));
@@ -904,7 +982,7 @@ namespace Microsoft.Dafny {
public class ArrayClassDecl : ClassDecl {
public readonly int Dims;
- public ArrayClassDecl(int dims, ModuleDecl module)
+ public ArrayClassDecl(int dims, ModuleDefinition module)
: base(Token.NoToken, BuiltIns.ArrayClassName(dims), module,
new List<TypeParameter>(new TypeParameter[]{new TypeParameter(Token.NoToken, "arg")}),
new List<MemberDecl>(), null)
@@ -924,7 +1002,7 @@ namespace Microsoft.Dafny {
Contract.Invariant(1 <= Ctors.Count);
}
- public DatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
+ public DatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
[Captured] List<DatatypeCtor/*!*/>/*!*/ ctors, Attributes attributes)
: base(tok, name, module, typeArgs, attributes) {
Contract.Requires(tok != null);
@@ -945,7 +1023,7 @@ namespace Microsoft.Dafny {
public enum ES { NotYetComputed, Never, ConsultTypeArguments }
public ES EqualitySupport = ES.NotYetComputed;
- public IndDatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
+ public IndDatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
[Captured] List<DatatypeCtor/*!*/>/*!*/ ctors, Attributes attributes)
: base(tok, name, module, typeArgs, ctors, attributes) {
Contract.Requires(tok != null);
@@ -959,7 +1037,7 @@ namespace Microsoft.Dafny {
public class CoDatatypeDecl : DatatypeDecl
{
- public CoDatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
+ public CoDatatypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition/*!*/ module, List<TypeParameter/*!*/>/*!*/ typeArgs,
[Captured] List<DatatypeCtor/*!*/>/*!*/ ctors, Attributes attributes)
: base(tok, name, module, typeArgs, ctors, attributes) {
Contract.Requires(tok != null);
@@ -1109,7 +1187,7 @@ namespace Microsoft.Dafny {
Contract.Invariant(TheType != null && Name == TheType.Name);
}
- public ArbitraryTypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDecl/*!*/ module, TypeParameter.EqualitySupportValue equalitySupport, Attributes attributes)
+ public ArbitraryTypeDecl(IToken/*!*/ tok, string/*!*/ name, ModuleDefinition/*!*/ module, TypeParameter.EqualitySupportValue equalitySupport, Attributes attributes)
: base(tok, name, module, new List<TypeParameter>(), attributes) {
Contract.Requires(tok != null);
Contract.Requires(name != null);
diff --git a/Source/Dafny/DafnyMain.cs b/Source/Dafny/DafnyMain.cs
index 62facb31..6091e522 100644
--- a/Source/Dafny/DafnyMain.cs
+++ b/Source/Dafny/DafnyMain.cs
@@ -20,7 +20,7 @@ namespace Microsoft.Dafny {
Contract.Requires(programName != null);
Contract.Requires(fileNames != null);
program = null;
- List<ModuleDecl> modules = new List<ModuleDecl>();
+ ModuleDecl module = new LiteralModuleDecl(new DefaultModuleDecl(), null);
BuiltIns builtIns = new BuiltIns();
foreach (string dafnyFileName in fileNames){
Contract.Assert(dafnyFileName != null);
@@ -35,7 +35,7 @@ namespace Microsoft.Dafny {
int errorCount;
try
{
- errorCount = Dafny.Parser.Parse(dafnyFileName, modules, builtIns);
+ errorCount = Dafny.Parser.Parse(dafnyFileName, module, builtIns);
if (errorCount != 0)
{
return string.Format("{0} parse errors detected in {1}", errorCount, dafnyFileName);
@@ -47,7 +47,7 @@ namespace Microsoft.Dafny {
}
}
- program = new Program(programName, modules, builtIns);
+ program = new Program(programName, module, builtIns);
if (DafnyOptions.O.DafnyPrintFile != null) {
string filename = DafnyOptions.O.DafnyPrintFile;
diff --git a/Source/Dafny/DafnyPipeline.csproj b/Source/Dafny/DafnyPipeline.csproj
index cf2b51eb..14ff3348 100644
--- a/Source/Dafny/DafnyPipeline.csproj
+++ b/Source/Dafny/DafnyPipeline.csproj
@@ -151,6 +151,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Util.cs" />
<Compile Include="Compiler.cs" />
<Compile Include="DafnyAst.cs" />
<Compile Include="DafnyMain.cs" />
diff --git a/Source/Dafny/Parser.cs b/Source/Dafny/Parser.cs
index a4e51924..9ad05d3b 100644
--- a/Source/Dafny/Parser.cs
+++ b/Source/Dafny/Parser.cs
@@ -34,7 +34,7 @@ public class Parser {
public Token/*!*/ la; // lookahead token
int errDist = minErrDist;
-static List<ModuleDecl/*!*/> theModules;
+static ModuleDecl theModule;
static BuiltIns theBuiltIns;
static Expression/*!*/ dummyExpr = new LiteralExpr(Token.NoToken);
static FrameExpression/*!*/ dummyFrameExpr = new FrameExpression(dummyExpr, null);
@@ -48,51 +48,51 @@ struct MemberModifiers {
// helper routine for parsing call statements
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members) from "filename"
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner.
///</summary>
-public static int Parse (string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns) /* throws System.IO.IOException */ {
+public static int Parse (string/*!*/ filename, ModuleDecl module, BuiltIns builtIns) /* throws System.IO.IOException */ {
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
string s;
if (filename == "stdin.dfy") {
s = Microsoft.Boogie.ParserHelper.Fill(System.Console.In, new List<string>());
- return Parse(s, filename, modules, builtIns);
+ return Parse(s, filename, module, builtIns);
} else {
using (System.IO.StreamReader reader = new System.IO.StreamReader(filename)) {
s = Microsoft.Boogie.ParserHelper.Fill(reader, new List<string>());
- return Parse(s, filename, modules, builtIns);
+ return Parse(s, filename, module, builtIns);
}
}
}
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members)
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner.
///</summary>
-public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns) {
+public static int Parse (string/*!*/ s, string/*!*/ filename, ModuleDecl module, BuiltIns builtIns) {
Contract.Requires(s != null);
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
Errors errors = new Errors();
- return Parse(s, filename, modules, builtIns, errors);
+ return Parse(s, filename, module, builtIns, errors);
}
///<summary>
/// Parses top-level things (modules, classes, datatypes, class members)
-/// and appends them in appropriate form to "modules".
+/// and appends them in appropriate form to "module".
/// Returns the number of parsing errors encountered.
/// Note: first initialize the Scanner with the given Errors sink.
///</summary>
-public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!*/>/*!*/ modules, BuiltIns builtIns,
+public static int Parse (string/*!*/ s, string/*!*/ filename, ModuleDecl module, BuiltIns builtIns,
Errors/*!*/ errors) {
Contract.Requires(s != null);
Contract.Requires(filename != null);
- Contract.Requires(cce.NonNullElements(modules));
+ Contract.Requires(module != null);
Contract.Requires(errors != null);
- List<ModuleDecl/*!*/> oldModules = theModules;
- theModules = modules;
+ var oldModule = theModule;
+ theModule = module;
BuiltIns oldBuiltIns = builtIns;
theBuiltIns = builtIns;
byte[]/*!*/ buffer = cce.NonNull( UTF8Encoding.Default.GetBytes(s));
@@ -100,7 +100,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*!
Scanner scanner = new Scanner(ms, errors, filename);
Parser parser = new Parser(scanner, errors);
parser.Parse();
- theModules = oldModules;
+ theModule = oldModule;
theBuiltIns = oldBuiltIns;
return parser.errors.count;
}
@@ -181,22 +181,12 @@ bool IsAttribute() {
void Dafny() {
ClassDecl/*!*/ c; DatatypeDecl/*!*/ dt; ArbitraryTypeDecl at;
- Attributes attrs; IToken/*!*/ id; List<string/*!*/> theImports;
List<MemberDecl/*!*/> membersDefaultClass = new List<MemberDecl/*!*/>();
- List<MemberDecl/*!*/> namedModuleDefaultClassMembers;
- ModuleDecl module;
- // to support multiple files, create a default module only if theModules doesn't already contain one
- DefaultModuleDecl defaultModule = null;
- foreach (ModuleDecl mdecl in theModules) {
- defaultModule = mdecl as DefaultModuleDecl;
- if (defaultModule != null) { break; }
- }
- bool defaultModuleCreatedHere = false;
- if (defaultModule == null) {
- defaultModuleCreatedHere = true;
- defaultModule = new DefaultModuleDecl();
- }
- IToken idRefined;
+ ModuleDecl submodule;
+ // to support multiple files, create a default module only if theModule is null
+ DefaultModuleDecl defaultModule = (DefaultModuleDecl)((LiteralModuleDecl)theModule).ModuleDef;
+ // theModule should be a DefaultModuleDecl (actually, the singular DefaultModuleDecl)
+ Contract.Assert(defaultModule != null);
bool isGhost;
while (StartOf(1)) {
@@ -206,101 +196,105 @@ bool IsAttribute() {
isGhost = true;
}
if (la.kind == 9) {
- Get();
- attrs = null; idRefined = null; theImports = new List<string/*!*/>();
- namedModuleDefaultClassMembers = new List<MemberDecl>();
-
- while (la.kind == 6) {
- Attribute(ref attrs);
- }
- Ident(out id);
- defaultModule.ImportNames.Add(id.val);
- if (la.kind == 10) {
- Get();
- Ident(out idRefined);
- }
- if (la.kind == 11) {
- Get();
- Idents(theImports);
- }
- module = new ModuleDecl(id, id.val, isGhost, idRefined == null ? null : idRefined.val, theImports, attrs);
- Expect(6);
- module.BodyStartTok = t;
- while (StartOf(2)) {
- if (la.kind == 12) {
- ClassDecl(module, out c);
- module.TopLevelDecls.Add(c);
- } else if (la.kind == 14 || la.kind == 15) {
- DatatypeDecl(module, out dt);
- module.TopLevelDecls.Add(dt);
- } else if (la.kind == 21) {
- ArbitraryTypeDecl(module, out at);
- module.TopLevelDecls.Add(at);
- } else {
- ClassMemberDecl(namedModuleDefaultClassMembers, false, false);
- }
- }
- Expect(7);
- module.BodyEndTok = t;
- module.TopLevelDecls.Add(new DefaultClassDecl(module, namedModuleDefaultClassMembers));
- theModules.Add(module);
- } else if (la.kind == 12) {
+ SubModuleDecl(defaultModule, isGhost, out submodule);
+ defaultModule.TopLevelDecls.Add(submodule);
+ } else if (la.kind == 15) {
if (isGhost) { SemErr(t, "a class is not allowed to be declared as 'ghost'"); }
ClassDecl(defaultModule, out c);
defaultModule.TopLevelDecls.Add(c);
- } else if (la.kind == 14 || la.kind == 15) {
+ } else if (la.kind == 17 || la.kind == 18) {
if (isGhost) { SemErr(t, "a datatype/codatatype is not allowed to be declared as 'ghost'"); }
DatatypeDecl(defaultModule, out dt);
defaultModule.TopLevelDecls.Add(dt);
- } else if (la.kind == 21) {
+ } else if (la.kind == 22) {
if (isGhost) { SemErr(t, "a type is not allowed to be declared as 'ghost'"); }
ArbitraryTypeDecl(defaultModule, out at);
defaultModule.TopLevelDecls.Add(at);
- } else if (StartOf(3)) {
+ } else if (StartOf(2)) {
ClassMemberDecl(membersDefaultClass, isGhost, false);
} else SynErr(108);
}
- if (defaultModuleCreatedHere) {
- defaultModule.TopLevelDecls.Add(new DefaultClassDecl(defaultModule, membersDefaultClass));
- theModules.Add(defaultModule);
- } else {
- // find the default class in the default module, then append membersDefaultClass to its member list
- foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
- DefaultClassDecl defaultClass = topleveldecl as DefaultClassDecl;
- if (defaultClass != null) {
- defaultClass.Members.AddRange(membersDefaultClass);
- break;
- }
+ DefaultClassDecl defaultClass = null;
+ foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
+ defaultClass = topleveldecl as DefaultClassDecl;
+ if (defaultClass != null) {
+ defaultClass.Members.AddRange(membersDefaultClass);
+ break;
}
}
-
+ if (defaultClass == null) { // create the default class here, because it wasn't found
+ defaultClass = new DefaultClassDecl(defaultModule, membersDefaultClass);
+ defaultModule.TopLevelDecls.Add(defaultClass);
+ }
Expect(0);
}
- void Attribute(ref Attributes attrs) {
- Expect(6);
- AttributeBody(ref attrs);
- Expect(7);
- }
-
- void Ident(out IToken/*!*/ x) {
- Contract.Ensures(Contract.ValueAtReturn(out x) != null);
- Expect(1);
- x = t;
- }
-
- void Idents(List<string/*!*/>/*!*/ ids) {
- IToken/*!*/ id;
- Ident(out id);
- ids.Add(id.val);
- while (la.kind == 20) {
- Get();
- Ident(out id);
- ids.Add(id.val);
+ void SubModuleDecl(ModuleDefinition parent, bool isOverallModuleGhost, out ModuleDecl submodule) {
+ ClassDecl/*!*/ c; DatatypeDecl/*!*/ dt; ArbitraryTypeDecl at;
+ Attributes attrs = null; IToken/*!*/ id;
+ List<MemberDecl/*!*/> namedModuleDefaultClassMembers = new List<MemberDecl>();;
+ List<IToken> idRefined = null, idPath = null;
+ bool isGhost = false;
+ ModuleDefinition module;
+ ModuleDecl sm;
+ submodule = null; // appease compiler
+
+ Expect(9);
+ while (la.kind == 6) {
+ Attribute(ref attrs);
}
+ NoUSIdent(out id);
+ if (la.kind == 6 || la.kind == 10) {
+ if (la.kind == 10) {
+ Get();
+ QualifiedName(out idRefined);
+ }
+ module = new ModuleDefinition(id, id.val, isOverallModuleGhost, false, idRefined == null ? null : idRefined, attrs);
+ Expect(6);
+ module.BodyStartTok = t;
+ while (StartOf(1)) {
+ isGhost = false;
+ if (la.kind == 8) {
+ Get();
+ isGhost = true;
+ }
+ if (la.kind == 9) {
+ SubModuleDecl(module, isGhost, out sm);
+ module.TopLevelDecls.Add(sm);
+ } else if (la.kind == 15) {
+ if (isGhost) { SemErr(t, "a class is not allowed to be declared as 'ghost'"); }
+ ClassDecl(module, out c);
+ module.TopLevelDecls.Add(c);
+ } else if (la.kind == 17 || la.kind == 18) {
+ if (isGhost) { SemErr(t, "a datatype/codatatype is not allowed to be declared as 'ghost'"); }
+ DatatypeDecl(module, out dt);
+ module.TopLevelDecls.Add(dt);
+ } else if (la.kind == 22) {
+ if (isGhost) { SemErr(t, "a type is not allowed to be declared as 'ghost'"); }
+ ArbitraryTypeDecl(module, out at);
+ module.TopLevelDecls.Add(at);
+ } else if (StartOf(2)) {
+ ClassMemberDecl(namedModuleDefaultClassMembers, isGhost, false);
+ } else SynErr(109);
+ }
+ Expect(7);
+ module.BodyEndTok = t;
+ module.TopLevelDecls.Add(new DefaultClassDecl(module, namedModuleDefaultClassMembers));
+ submodule = new LiteralModuleDecl(module, parent);
+ } else if (la.kind == 11) {
+ Get();
+ QualifiedName(out idPath);
+ Expect(12);
+ submodule = new AliasModuleDecl(idPath, id, parent);
+ } else if (la.kind == 13) {
+ Get();
+ QualifiedName(out idPath);
+ Expect(12);
+ submodule = new AbstractModuleDecl(idPath, id, parent);
+ } else SynErr(110);
}
- void ClassDecl(ModuleDecl/*!*/ module, out ClassDecl/*!*/ c) {
+ void ClassDecl(ModuleDefinition/*!*/ module, out ClassDecl/*!*/ c) {
Contract.Requires(module != null);
Contract.Ensures(Contract.ValueAtReturn(out c) != null);
IToken/*!*/ id;
@@ -309,18 +303,18 @@ bool IsAttribute() {
List<MemberDecl/*!*/> members = new List<MemberDecl/*!*/>();
IToken bodyStart;
- while (!(la.kind == 0 || la.kind == 12)) {SynErr(109); Get();}
- Expect(12);
+ while (!(la.kind == 0 || la.kind == 15)) {SynErr(111); Get();}
+ Expect(15);
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 25) {
+ NoUSIdent(out id);
+ if (la.kind == 26) {
GenericParameters(typeArgs);
}
Expect(6);
bodyStart = t;
- while (StartOf(3)) {
+ while (StartOf(2)) {
ClassMemberDecl(members, false, true);
}
Expect(7);
@@ -330,7 +324,7 @@ bool IsAttribute() {
}
- void DatatypeDecl(ModuleDecl/*!*/ module, out DatatypeDecl/*!*/ dt) {
+ void DatatypeDecl(ModuleDefinition/*!*/ module, out DatatypeDecl/*!*/ dt) {
Contract.Requires(module != null);
Contract.Ensures(Contract.ValueAtReturn(out dt)!=null);
IToken/*!*/ id;
@@ -340,29 +334,29 @@ bool IsAttribute() {
IToken bodyStart = Token.NoToken; // dummy assignment
bool co = false;
- while (!(la.kind == 0 || la.kind == 14 || la.kind == 15)) {SynErr(110); Get();}
- if (la.kind == 14) {
+ while (!(la.kind == 0 || la.kind == 17 || la.kind == 18)) {SynErr(112); Get();}
+ if (la.kind == 17) {
Get();
- } else if (la.kind == 15) {
+ } else if (la.kind == 18) {
Get();
co = true;
- } else SynErr(111);
+ } else SynErr(113);
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 25) {
+ NoUSIdent(out id);
+ if (la.kind == 26) {
GenericParameters(typeArgs);
}
- Expect(16);
+ Expect(11);
bodyStart = t;
DatatypeMemberDecl(ctors);
- while (la.kind == 17) {
+ while (la.kind == 19) {
Get();
DatatypeMemberDecl(ctors);
}
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(112); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(114); Get();}
+ Expect(12);
if (co) {
dt = new CoDatatypeDecl(id, id.val, module, typeArgs, ctors, attrs);
} else {
@@ -373,25 +367,25 @@ bool IsAttribute() {
}
- void ArbitraryTypeDecl(ModuleDecl/*!*/ module, out ArbitraryTypeDecl at) {
+ void ArbitraryTypeDecl(ModuleDefinition/*!*/ module, out ArbitraryTypeDecl at) {
IToken/*!*/ id;
Attributes attrs = null;
var eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
- Expect(21);
+ Expect(22);
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 22) {
+ NoUSIdent(out id);
+ if (la.kind == 23) {
Get();
- Expect(23);
Expect(24);
+ Expect(25);
eqSupport = TypeParameter.EqualitySupportValue.Required;
}
at = new ArbitraryTypeDecl(id, id.val, module, eqSupport, attrs);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(113); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(115); Get();}
+ Expect(12);
}
void ClassMemberDecl(List<MemberDecl/*!*/>/*!*/ mm, bool isAlreadyGhost, bool allowConstructors) {
@@ -401,7 +395,7 @@ bool IsAttribute() {
MemberModifiers mmod = new MemberModifiers();
mmod.IsGhost = isAlreadyGhost;
- while (la.kind == 8 || la.kind == 13) {
+ while (la.kind == 8 || la.kind == 16) {
if (la.kind == 8) {
Get();
mmod.IsGhost = true;
@@ -410,15 +404,48 @@ bool IsAttribute() {
mmod.IsStatic = true;
}
}
- if (la.kind == 19) {
+ if (la.kind == 20) {
FieldDecl(mmod, mm);
} else if (la.kind == 45 || la.kind == 46) {
FunctionDecl(mmod, out f);
mm.Add(f);
- } else if (la.kind == 27 || la.kind == 28) {
+ } else if (la.kind == 28 || la.kind == 29) {
MethodDecl(mmod, allowConstructors, out m);
mm.Add(m);
- } else SynErr(114);
+ } else SynErr(116);
+ }
+
+ void Attribute(ref Attributes attrs) {
+ Expect(6);
+ AttributeBody(ref attrs);
+ Expect(7);
+ }
+
+ void NoUSIdent(out IToken/*!*/ x) {
+ Contract.Ensures(Contract.ValueAtReturn(out x) != null);
+ Expect(1);
+ x = t;
+ if (x.val.Length > 0 && x.val.StartsWith("_")) {
+ SemErr("cannot declare identifier beginning with underscore");
+ }
+
+ }
+
+ void QualifiedName(out List<IToken> ids) {
+ IToken id; ids = new List<IToken>();
+ Ident(out id);
+ ids.Add(id);
+ while (la.kind == 14) {
+ Get();
+ Ident(out id);
+ ids.Add(id);
+ }
+ }
+
+ void Ident(out IToken/*!*/ x) {
+ Contract.Ensures(Contract.ValueAtReturn(out x) != null);
+ Expect(1);
+ x = t;
}
void GenericParameters(List<TypeParameter/*!*/>/*!*/ typeArgs) {
@@ -426,29 +453,29 @@ bool IsAttribute() {
IToken/*!*/ id;
TypeParameter.EqualitySupportValue eqSupport;
- Expect(25);
- Ident(out id);
+ Expect(26);
+ NoUSIdent(out id);
eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
- Expect(23);
Expect(24);
+ Expect(25);
eqSupport = TypeParameter.EqualitySupportValue.Required;
}
typeArgs.Add(new TypeParameter(id, id.val, eqSupport));
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
- Ident(out id);
+ NoUSIdent(out id);
eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
- Expect(23);
Expect(24);
+ Expect(25);
eqSupport = TypeParameter.EqualitySupportValue.Required;
}
typeArgs.Add(new TypeParameter(id, id.val, eqSupport));
}
- Expect(26);
+ Expect(27);
}
void FieldDecl(MemberModifiers mmod, List<MemberDecl/*!*/>/*!*/ mm) {
@@ -456,8 +483,8 @@ bool IsAttribute() {
Attributes attrs = null;
IToken/*!*/ id; Type/*!*/ ty;
- while (!(la.kind == 0 || la.kind == 19)) {SynErr(115); Get();}
- Expect(19);
+ while (!(la.kind == 0 || la.kind == 20)) {SynErr(117); Get();}
+ Expect(20);
if (mmod.IsStatic) { SemErr(t, "fields cannot be declared 'static'"); }
while (la.kind == 6) {
@@ -465,13 +492,13 @@ bool IsAttribute() {
}
IdentType(out id, out ty);
mm.Add(new Field(id, id.val, mmod.IsGhost, ty, attrs));
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentType(out id, out ty);
mm.Add(new Field(id, id.val, mmod.IsGhost, ty, attrs));
}
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(116); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(118); Get();}
+ Expect(12);
}
void FunctionDecl(MemberModifiers mmod, out Function/*!*/ f) {
@@ -495,7 +522,7 @@ bool IsAttribute() {
if (la.kind == 45) {
Get();
- if (la.kind == 27) {
+ if (la.kind == 28) {
Get();
isFunctionMethod = true;
}
@@ -504,23 +531,23 @@ bool IsAttribute() {
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 22 || la.kind == 25) {
- if (la.kind == 25) {
+ NoUSIdent(out id);
+ if (la.kind == 23 || la.kind == 26) {
+ if (la.kind == 26) {
GenericParameters(typeArgs);
}
Formals(true, isFunctionMethod, formals, out openParen);
Expect(5);
Type(out returnType);
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
signatureOmitted = true;
openParen = Token.NoToken;
- } else SynErr(117);
+ } else SynErr(119);
} else if (la.kind == 46) {
Get();
isPredicate = true;
- if (la.kind == 27) {
+ if (la.kind == 28) {
Get();
isFunctionMethod = true;
}
@@ -529,25 +556,25 @@ bool IsAttribute() {
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (StartOf(4)) {
- if (la.kind == 25) {
+ NoUSIdent(out id);
+ if (StartOf(3)) {
+ if (la.kind == 26) {
GenericParameters(typeArgs);
}
- if (la.kind == 22) {
+ if (la.kind == 23) {
Formals(true, isFunctionMethod, formals, out openParen);
if (la.kind == 5) {
Get();
SemErr(t, "predicates do not have an explicitly declared return type; it is always bool");
}
}
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
signatureOmitted = true;
openParen = Token.NoToken;
- } else SynErr(118);
- } else SynErr(119);
- while (StartOf(5)) {
+ } else SynErr(120);
+ } else SynErr(121);
+ while (StartOf(4)) {
FunctionSpec(reqs, reads, ens, decreases);
}
if (la.kind == 6) {
@@ -585,10 +612,10 @@ bool IsAttribute() {
IToken bodyStart = Token.NoToken;
IToken bodyEnd = Token.NoToken;
- while (!(la.kind == 0 || la.kind == 27 || la.kind == 28)) {SynErr(120); Get();}
- if (la.kind == 27) {
+ while (!(la.kind == 0 || la.kind == 28 || la.kind == 29)) {SynErr(122); Get();}
+ if (la.kind == 28) {
Get();
- } else if (la.kind == 28) {
+ } else if (la.kind == 29) {
Get();
if (allowConstructor) {
isConstructor = true;
@@ -596,7 +623,7 @@ bool IsAttribute() {
SemErr(t, "constructors are only allowed in classes");
}
- } else SynErr(121);
+ } else SynErr(123);
if (isConstructor) {
if (mmod.IsGhost) {
SemErr(t, "constructors cannot be declared 'ghost'");
@@ -609,22 +636,22 @@ bool IsAttribute() {
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 22 || la.kind == 25) {
- if (la.kind == 25) {
+ NoUSIdent(out id);
+ if (la.kind == 23 || la.kind == 26) {
+ if (la.kind == 26) {
GenericParameters(typeArgs);
}
Formals(true, !mmod.IsGhost, ins, out openParen);
- if (la.kind == 29) {
+ if (la.kind == 30) {
Get();
if (isConstructor) { SemErr(t, "constructors cannot have out-parameters"); }
Formals(false, !mmod.IsGhost, outs, out openParen);
}
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
signatureOmitted = true; openParen = Token.NoToken;
- } else SynErr(122);
- while (StartOf(6)) {
+ } else SynErr(124);
+ while (StartOf(5)) {
MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs);
}
if (la.kind == 6) {
@@ -651,8 +678,8 @@ bool IsAttribute() {
while (la.kind == 6) {
Attribute(ref attrs);
}
- Ident(out id);
- if (la.kind == 22) {
+ NoUSIdent(out id);
+ if (la.kind == 23) {
FormalsOptionalIds(formals);
}
ctors.Add(new DatatypeCtor(id, id.val, formals, attrs));
@@ -660,22 +687,22 @@ bool IsAttribute() {
void FormalsOptionalIds(List<Formal/*!*/>/*!*/ formals) {
Contract.Requires(cce.NonNullElements(formals)); IToken/*!*/ id; Type/*!*/ ty; string/*!*/ name; bool isGhost;
- Expect(22);
- if (StartOf(7)) {
+ Expect(23);
+ if (StartOf(6)) {
TypeIdentOptional(out id, out name, out ty, out isGhost);
formals.Add(new Formal(id, name, ty, true, isGhost));
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
TypeIdentOptional(out id, out name, out ty, out isGhost);
formals.Add(new Formal(id, name, ty, true, isGhost));
}
}
- Expect(24);
+ Expect(25);
}
void IdentType(out IToken/*!*/ id, out Type/*!*/ ty) {
Contract.Ensures(Contract.ValueAtReturn(out id) != null); Contract.Ensures(Contract.ValueAtReturn(out ty) != null);
- Ident(out id);
+ NoUSIdent(out id);
Expect(5);
Type(out ty);
}
@@ -699,7 +726,7 @@ bool IsAttribute() {
void LocalIdentTypeOptional(out VarDecl/*!*/ var, bool isGhost) {
IToken/*!*/ id; Type/*!*/ ty; Type optType = null;
- Ident(out id);
+ NoUSIdent(out id);
if (la.kind == 5) {
Get();
Type(out ty);
@@ -711,7 +738,7 @@ bool IsAttribute() {
void IdentTypeOptional(out BoundVar/*!*/ var) {
Contract.Ensures(Contract.ValueAtReturn(out var)!=null); IToken/*!*/ id; Type/*!*/ ty; Type optType = null;
- Ident(out id);
+ NoUSIdent(out id);
if (la.kind == 5) {
Get();
Type(out ty);
@@ -754,22 +781,22 @@ bool IsAttribute() {
List<Type/*!*/>/*!*/ gt;
switch (la.kind) {
- case 36: {
+ case 37: {
Get();
tok = t;
break;
}
- case 37: {
+ case 38: {
Get();
tok = t; ty = new NatType();
break;
}
- case 38: {
+ case 39: {
Get();
tok = t; ty = new IntType();
break;
}
- case 39: {
+ case 40: {
Get();
tok = t; gt = new List<Type/*!*/>();
GenericInstantiation(gt);
@@ -780,7 +807,7 @@ bool IsAttribute() {
break;
}
- case 40: {
+ case 41: {
Get();
tok = t; gt = new List<Type/*!*/>();
GenericInstantiation(gt);
@@ -791,7 +818,7 @@ bool IsAttribute() {
break;
}
- case 41: {
+ case 42: {
Get();
tok = t; gt = new List<Type/*!*/>();
GenericInstantiation(gt);
@@ -802,7 +829,7 @@ bool IsAttribute() {
break;
}
- case 42: {
+ case 43: {
Get();
tok = t; gt = new List<Type/*!*/>();
GenericInstantiation(gt);
@@ -813,28 +840,28 @@ bool IsAttribute() {
break;
}
- case 1: case 3: case 43: {
+ case 1: case 3: case 44: {
ReferenceType(out tok, out ty);
break;
}
- default: SynErr(123); break;
+ default: SynErr(125); break;
}
}
void Formals(bool incoming, bool allowGhostKeyword, List<Formal/*!*/>/*!*/ formals, out IToken openParen) {
Contract.Requires(cce.NonNullElements(formals)); IToken/*!*/ id; Type/*!*/ ty; bool isGhost;
- Expect(22);
+ Expect(23);
openParen = t;
if (la.kind == 1 || la.kind == 8) {
GIdentType(allowGhostKeyword, out id, out ty, out isGhost);
formals.Add(new Formal(id, id.val, ty, incoming, isGhost));
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
GIdentType(allowGhostKeyword, out id, out ty, out isGhost);
formals.Add(new Formal(id, id.val, ty, incoming, isGhost));
}
}
- Expect(24);
+ Expect(25);
}
void MethodSpec(List<MaybeFreeExpression/*!*/>/*!*/ req, List<FrameExpression/*!*/>/*!*/ mod, List<MaybeFreeExpression/*!*/>/*!*/ ens,
@@ -842,53 +869,53 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Contract.Requires(cce.NonNullElements(req)); Contract.Requires(cce.NonNullElements(mod)); Contract.Requires(cce.NonNullElements(ens)); Contract.Requires(cce.NonNullElements(decreases));
Expression/*!*/ e; FrameExpression/*!*/ fe; bool isFree = false; Attributes ensAttrs = null;
- while (!(StartOf(8))) {SynErr(124); Get();}
- if (la.kind == 31) {
+ while (!(StartOf(7))) {SynErr(126); Get();}
+ if (la.kind == 32) {
Get();
while (IsAttribute()) {
Attribute(ref modAttrs);
}
- if (StartOf(9)) {
+ if (StartOf(8)) {
FrameExpression(out fe);
mod.Add(fe);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
FrameExpression(out fe);
mod.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(125); Get();}
- Expect(18);
- } else if (la.kind == 32 || la.kind == 33 || la.kind == 34) {
- if (la.kind == 32) {
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(127); Get();}
+ Expect(12);
+ } else if (la.kind == 33 || la.kind == 34 || la.kind == 35) {
+ if (la.kind == 33) {
Get();
isFree = true;
}
- if (la.kind == 33) {
+ if (la.kind == 34) {
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(126); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(128); Get();}
+ Expect(12);
req.Add(new MaybeFreeExpression(e, isFree));
- } else if (la.kind == 34) {
+ } else if (la.kind == 35) {
Get();
while (IsAttribute()) {
Attribute(ref ensAttrs);
}
Expression(out e);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(127); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(129); Get();}
+ Expect(12);
ens.Add(new MaybeFreeExpression(e, isFree, ensAttrs));
- } else SynErr(128);
- } else if (la.kind == 35) {
+ } else SynErr(130);
+ } else if (la.kind == 36) {
Get();
while (IsAttribute()) {
Attribute(ref decAttrs);
}
DecreasesList(decreases, false);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(129); Get();}
- Expect(18);
- } else SynErr(130);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(131); Get();}
+ Expect(12);
+ } else SynErr(132);
}
void BlockStmt(out BlockStmt/*!*/ block, out IToken bodyStart, out IToken bodyEnd) {
@@ -897,7 +924,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(6);
bodyStart = t;
- while (StartOf(10)) {
+ while (StartOf(9)) {
Stmt(body);
}
Expect(7);
@@ -929,7 +956,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
decreases.Add(e);
}
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
PossiblyWildExpression(out e);
if (!allowWildcard && e is WildcardExpr) {
@@ -943,15 +970,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
void GenericInstantiation(List<Type/*!*/>/*!*/ gt) {
Contract.Requires(cce.NonNullElements(gt)); Type/*!*/ ty;
- Expect(25);
+ Expect(26);
Type(out ty);
gt.Add(ty);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Type(out ty);
gt.Add(ty);
}
- Expect(26);
+ Expect(27);
}
void ReferenceType(out IToken/*!*/ tok, out Type/*!*/ ty) {
@@ -960,7 +987,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IToken moduleName = null;
List<Type/*!*/>/*!*/ gt;
- if (la.kind == 43) {
+ if (la.kind == 44) {
Get();
tok = t; ty = new ObjectType();
} else if (la.kind == 3) {
@@ -979,53 +1006,53 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 1) {
Ident(out tok);
gt = new List<Type/*!*/>();
- if (la.kind == 44) {
+ if (la.kind == 14) {
moduleName = tok;
Get();
Ident(out tok);
}
- if (la.kind == 25) {
+ if (la.kind == 26) {
GenericInstantiation(gt);
}
ty = new UserDefinedType(tok, tok.val, gt, moduleName);
- } else SynErr(131);
+ } else SynErr(133);
}
void FunctionSpec(List<Expression/*!*/>/*!*/ reqs, List<FrameExpression/*!*/>/*!*/ reads, List<Expression/*!*/>/*!*/ ens, List<Expression/*!*/>/*!*/ decreases) {
Contract.Requires(cce.NonNullElements(reqs)); Contract.Requires(cce.NonNullElements(reads)); Contract.Requires(cce.NonNullElements(decreases));
Expression/*!*/ e; FrameExpression/*!*/ fe;
- if (la.kind == 33) {
- while (!(la.kind == 0 || la.kind == 33)) {SynErr(132); Get();}
+ if (la.kind == 34) {
+ while (!(la.kind == 0 || la.kind == 34)) {SynErr(134); Get();}
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(133); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(135); Get();}
+ Expect(12);
reqs.Add(e);
} else if (la.kind == 47) {
Get();
- if (StartOf(11)) {
+ if (StartOf(10)) {
PossiblyWildFrameExpression(out fe);
reads.Add(fe);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
PossiblyWildFrameExpression(out fe);
reads.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(134); Get();}
- Expect(18);
- } else if (la.kind == 34) {
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(136); Get();}
+ Expect(12);
+ } else if (la.kind == 35) {
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(135); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(137); Get();}
+ Expect(12);
ens.Add(e);
- } else if (la.kind == 35) {
+ } else if (la.kind == 36) {
Get();
DecreasesList(decreases, false);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(136); Get();}
- Expect(18);
- } else SynErr(137);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(138); Get();}
+ Expect(12);
+ } else SynErr(139);
}
void FunctionBody(out Expression/*!*/ e, out IToken bodyStart, out IToken bodyEnd) {
@@ -1042,9 +1069,9 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (la.kind == 48) {
Get();
fe = new FrameExpression(new WildcardExpr(t), null);
- } else if (StartOf(9)) {
+ } else if (StartOf(8)) {
FrameExpression(out fe);
- } else SynErr(138);
+ } else SynErr(140);
}
void PossiblyWildExpression(out Expression/*!*/ e) {
@@ -1053,9 +1080,9 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (la.kind == 48) {
Get();
e = new WildcardExpr(t);
- } else if (StartOf(9)) {
+ } else if (StartOf(8)) {
Expression(out e);
- } else SynErr(139);
+ } else SynErr(141);
}
void Stmt(List<Statement/*!*/>/*!*/ ss) {
@@ -1072,7 +1099,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IToken bodyStart, bodyEnd;
int breakCount;
- while (!(StartOf(12))) {SynErr(140); Get();}
+ while (!(StartOf(11))) {SynErr(142); Get();}
switch (la.kind) {
case 6: {
BlockStmt(out bs, out bodyStart, out bodyEnd);
@@ -1091,11 +1118,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
PrintStmt(out s);
break;
}
- case 1: case 2: case 17: case 22: case 92: case 93: case 94: case 95: case 96: case 97: case 98: {
+ case 1: case 2: case 19: case 23: case 92: case 93: case 94: case 95: case 96: case 97: case 98: {
UpdateStmt(out s);
break;
}
- case 8: case 19: {
+ case 8: case 20: {
VarDeclStatement(out s);
break;
}
@@ -1118,7 +1145,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
case 50: {
Get();
x = t;
- Ident(out id);
+ NoUSIdent(out id);
Expect(5);
OneStmt(out s);
s.Labels = new LList<Label>(new Label(x, id.val), s.Labels);
@@ -1128,16 +1155,16 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
x = t; breakCount = 1; label = null;
if (la.kind == 1) {
- Ident(out id);
+ NoUSIdent(out id);
label = id.val;
- } else if (la.kind == 18 || la.kind == 51) {
+ } else if (la.kind == 12 || la.kind == 51) {
while (la.kind == 51) {
Get();
breakCount++;
}
- } else SynErr(141);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(142); Get();}
- Expect(18);
+ } else SynErr(143);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(144); Get();}
+ Expect(12);
s = label != null ? new BreakStmt(x, label) : new BreakStmt(x, breakCount);
break;
}
@@ -1145,13 +1172,13 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
ReturnStmt(out s);
break;
}
- case 30: {
+ case 31: {
Get();
s = new SkeletonStatement(t);
- Expect(18);
+ Expect(12);
break;
}
- default: SynErr(143); break;
+ default: SynErr(145); break;
}
}
@@ -1164,12 +1191,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
while (IsAttribute()) {
Attribute(ref attrs);
}
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expression(out e);
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
- } else SynErr(144);
- Expect(18);
+ } else SynErr(146);
+ Expect(12);
if (e == null) {
s = new SkeletonStatement(new AssertStmt(x, new LiteralExpr(x, true), attrs), true, false);
} else {
@@ -1187,18 +1214,18 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
while (IsAttribute()) {
Attribute(ref attrs);
}
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expression(out e);
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
- } else SynErr(145);
+ } else SynErr(147);
if (e == null) {
s = new SkeletonStatement(new AssumeStmt(x, new LiteralExpr(x, true), attrs), true, false);
} else {
s = new AssumeStmt(x, e, attrs);
}
- Expect(18);
+ Expect(12);
}
void PrintStmt(out Statement/*!*/ s) {
@@ -1209,12 +1236,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
x = t;
AttributeArg(out arg);
args.Add(arg);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
AttributeArg(out arg);
args.Add(arg);
}
- Expect(18);
+ Expect(12);
s = new PrintStmt(x, args);
}
@@ -1230,15 +1257,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Lhs(out e);
x = e.tok;
- if (la.kind == 6 || la.kind == 18) {
+ if (la.kind == 6 || la.kind == 12) {
while (la.kind == 6) {
Attribute(ref attrs);
}
- Expect(18);
+ Expect(12);
rhss.Add(new ExprRhs(e, attrs));
- } else if (la.kind == 20 || la.kind == 53 || la.kind == 54) {
+ } else if (la.kind == 21 || la.kind == 53 || la.kind == 54) {
lhss.Add(e); lhs0 = e;
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Lhs(out e);
lhss.Add(e);
@@ -1248,7 +1275,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
x = t;
Rhs(out r, lhs0);
rhss.Add(r);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Rhs(out r, lhs0);
rhss.Add(r);
@@ -1261,12 +1288,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
suchThatAssume = t;
}
Expression(out suchThat);
- } else SynErr(146);
- Expect(18);
+ } else SynErr(148);
+ Expect(12);
} else if (la.kind == 5) {
Get();
SemErr(t, "invalid statement (did you forget the 'label' keyword?)");
- } else SynErr(147);
+ } else SynErr(149);
if (suchThat != null) {
s = new AssignSuchThatStmt(x, lhss, suchThat, suchThatAssume);
} else {
@@ -1288,11 +1315,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
isGhost = true; x = t;
}
- Expect(19);
+ Expect(20);
if (!isGhost) { x = t; }
LocalIdentTypeOptional(out d, isGhost);
lhss.Add(d);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
LocalIdentTypeOptional(out d, isGhost);
lhss.Add(d);
@@ -1306,7 +1333,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Rhs(out r, lhs0);
rhss.Add(r);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Rhs(out r, lhs0);
rhss.Add(r);
@@ -1321,7 +1348,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expression(out suchThat);
}
}
- Expect(18);
+ Expect(12);
ConcreteUpdateStatement update;
if (suchThat != null) {
var ies = new List<Expression>();
@@ -1355,8 +1382,8 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(60);
x = t;
- if (la.kind == 22 || la.kind == 30) {
- if (la.kind == 22) {
+ if (la.kind == 23 || la.kind == 31) {
+ if (la.kind == 23) {
Guard(out guard);
} else {
Get();
@@ -1371,7 +1398,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 6) {
BlockStmt(out bs, out bodyStart, out bodyEnd);
els = bs;
- } else SynErr(148);
+ } else SynErr(150);
}
if (guardOmitted) {
ifStmt = new SkeletonStatement(new IfStmt(x, guard, thn, els), true, false);
@@ -1382,7 +1409,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 6) {
AlternativeBlock(out alternatives);
ifStmt = new AlternativeStmt(x, alternatives);
- } else SynErr(149);
+ } else SynErr(151);
}
void WhileStmt(out Statement/*!*/ stmt) {
@@ -1400,8 +1427,8 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(64);
x = t;
- if (la.kind == 22 || la.kind == 30) {
- if (la.kind == 22) {
+ if (la.kind == 23 || la.kind == 31) {
+ if (la.kind == 23) {
Guard(out guard);
Contract.Assume(guard == null || cce.Owner.None(guard));
} else {
@@ -1411,10 +1438,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
LoopSpec(out invariants, out decreases, out mod, ref decAttrs, ref modAttrs);
if (la.kind == 6) {
BlockStmt(out body, out bodyStart, out bodyEnd);
- } else if (la.kind == 30) {
+ } else if (la.kind == 31) {
Get();
bodyOmitted = true;
- } else SynErr(150);
+ } else SynErr(152);
if (guardOmitted || bodyOmitted) {
if (mod != null) {
SemErr(mod[0].E.tok, "'modifies' clauses are not allowed on refining loops");
@@ -1428,11 +1455,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
stmt = new WhileStmt(x, guard, invariants, new Specification<Expression>(decreases, decAttrs), new Specification<FrameExpression>(mod, modAttrs), body);
}
- } else if (StartOf(13)) {
+ } else if (StartOf(12)) {
LoopSpec(out invariants, out decreases, out mod, ref decAttrs, ref modAttrs);
AlternativeBlock(out alternatives);
stmt = new AlternativeLoopStmt(x, invariants, new Specification<Expression>(decreases, decAttrs), new Specification<FrameExpression>(mod, modAttrs), alternatives);
- } else SynErr(151);
+ } else SynErr(153);
}
void MatchStmt(out Statement/*!*/ s) {
@@ -1465,7 +1492,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(69);
x = t;
- Expect(22);
+ Expect(23);
if (la.kind == 1) {
List<BoundVar/*!*/> bvarsX; Attributes attrsX; Expression rangeX;
QuantifierDomain(out bvarsX, out attrsX, out rangeX);
@@ -1475,16 +1502,16 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (bvars == null) { bvars = new List<BoundVar>(); }
if (range == null) { range = new LiteralExpr(x, true); }
- Expect(24);
- while (la.kind == 32 || la.kind == 34) {
+ Expect(25);
+ while (la.kind == 33 || la.kind == 35) {
isFree = false;
- if (la.kind == 32) {
+ if (la.kind == 33) {
Get();
isFree = true;
}
- Expect(34);
+ Expect(35);
Expression(out e);
- Expect(18);
+ Expect(12);
ens.Add(new MaybeFreeExpression(e, isFree));
}
BlockStmt(out block, out bodyStart, out bodyEnd);
@@ -1498,16 +1525,16 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(52);
returnTok = t;
- if (StartOf(14)) {
+ if (StartOf(13)) {
Rhs(out r, null);
rhss = new List<AssignmentRhs>(); rhss.Add(r);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Rhs(out r, null);
rhss.Add(r);
}
}
- Expect(18);
+ Expect(12);
s = new ReturnStmt(returnTok, rhss);
}
@@ -1524,7 +1551,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
newToken = t;
TypeAndToken(out x, out ty);
- if (la.kind == 22 || la.kind == 44 || la.kind == 57) {
+ if (la.kind == 14 || la.kind == 23 || la.kind == 57) {
if (la.kind == 57) {
Get();
ee = new List<Expression>();
@@ -1532,15 +1559,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(58);
UserDefinedType tmp = theBuiltIns.ArrayType(x, ee.Count, new IntType(), true);
- } else if (la.kind == 44) {
+ } else if (la.kind == 14) {
Get();
Ident(out x);
- Expect(22);
+ Expect(23);
args = new List<Expression/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(args);
}
- Expect(24);
+ Expect(25);
initCall = new CallStmt(x, new List<Expression>(), receiverForInitCall, x.val, args);
} else {
Get();
@@ -1555,10 +1582,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
x = null;
}
args = new List<Expression/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(args);
}
- Expect(24);
+ Expect(25);
if (x != null) {
initCall = new CallStmt(x, new List<Expression>(), receiverForInitCall, x.val, args);
}
@@ -1579,10 +1606,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 48) {
Get();
r = new HavocRhs(t);
- } else if (StartOf(9)) {
+ } else if (StartOf(8)) {
Expression(out e);
r = new ExprRhs(e);
- } else SynErr(152);
+ } else SynErr(154);
while (la.kind == 6) {
Attribute(ref attrs);
}
@@ -1594,23 +1621,23 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (la.kind == 1) {
DottedIdentifiersAndFunction(out e);
- while (la.kind == 44 || la.kind == 57) {
+ while (la.kind == 14 || la.kind == 57) {
Suffix(ref e);
}
- } else if (StartOf(15)) {
+ } else if (StartOf(14)) {
ConstAtomExpression(out e);
Suffix(ref e);
- while (la.kind == 44 || la.kind == 57) {
+ while (la.kind == 14 || la.kind == 57) {
Suffix(ref e);
}
- } else SynErr(153);
+ } else SynErr(155);
}
void Expressions(List<Expression/*!*/>/*!*/ args) {
Contract.Requires(cce.NonNullElements(args)); Expression/*!*/ e;
Expression(out e);
args.Add(e);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Expression(out e);
args.Add(e);
@@ -1619,15 +1646,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
void Guard(out Expression e) {
Expression/*!*/ ee; e = null;
- Expect(22);
+ Expect(23);
if (la.kind == 48) {
Get();
e = null;
- } else if (StartOf(9)) {
+ } else if (StartOf(8)) {
Expression(out ee);
e = ee;
- } else SynErr(154);
- Expect(24);
+ } else SynErr(156);
+ Expect(25);
}
void AlternativeBlock(out List<GuardedAlternative> alternatives) {
@@ -1643,7 +1670,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expression(out e);
Expect(63);
body = new List<Statement>();
- while (StartOf(10)) {
+ while (StartOf(9)) {
Stmt(body);
}
alternatives.Add(new GuardedAlternative(x, e, body));
@@ -1658,47 +1685,47 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
decreases = new List<Expression/*!*/>();
mod = null;
- while (StartOf(16)) {
- if (la.kind == 32 || la.kind == 65) {
+ while (StartOf(15)) {
+ if (la.kind == 33 || la.kind == 65) {
Invariant(out invariant);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(155); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(157); Get();}
+ Expect(12);
invariants.Add(invariant);
- } else if (la.kind == 35) {
- while (!(la.kind == 0 || la.kind == 35)) {SynErr(156); Get();}
+ } else if (la.kind == 36) {
+ while (!(la.kind == 0 || la.kind == 36)) {SynErr(158); Get();}
Get();
while (IsAttribute()) {
Attribute(ref decAttrs);
}
DecreasesList(decreases, true);
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(157); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(159); Get();}
+ Expect(12);
} else {
- while (!(la.kind == 0 || la.kind == 31)) {SynErr(158); Get();}
+ while (!(la.kind == 0 || la.kind == 32)) {SynErr(160); Get();}
Get();
while (IsAttribute()) {
Attribute(ref modAttrs);
}
mod = mod ?? new List<FrameExpression>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
FrameExpression(out fe);
mod.Add(fe);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
FrameExpression(out fe);
mod.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(159); Get();}
- Expect(18);
+ while (!(la.kind == 0 || la.kind == 12)) {SynErr(161); Get();}
+ Expect(12);
}
}
}
void Invariant(out MaybeFreeExpression/*!*/ invariant) {
bool isFree = false; Expression/*!*/ e; List<string> ids = new List<string>(); invariant = null; Attributes attrs = null;
- while (!(la.kind == 0 || la.kind == 32 || la.kind == 65)) {SynErr(160); Get();}
- if (la.kind == 32) {
+ while (!(la.kind == 0 || la.kind == 33 || la.kind == 65)) {SynErr(162); Get();}
+ if (la.kind == 33) {
Get();
isFree = true;
}
@@ -1720,19 +1747,19 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(62);
x = t;
Ident(out id);
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
IdentTypeOptional(out bv);
arguments.Add(bv);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentTypeOptional(out bv);
arguments.Add(bv);
}
- Expect(24);
+ Expect(25);
}
Expect(63);
- while (StartOf(10)) {
+ while (StartOf(9)) {
Stmt(body);
}
c = new MatchCaseStmt(x, id.val, arguments, body);
@@ -1743,10 +1770,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (la.kind == 4) {
Get();
arg = new Attributes.Argument(t, t.val.Substring(1, t.val.Length-2));
- } else if (StartOf(9)) {
+ } else if (StartOf(8)) {
Expression(out e);
arg = new Attributes.Argument(t, e);
- } else SynErr(161);
+ } else SynErr(163);
}
void QuantifierDomain(out List<BoundVar/*!*/> bvars, out Attributes attrs, out Expression range) {
@@ -1757,7 +1784,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IdentTypeOptional(out bv);
bvars.Add(bv);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentTypeOptional(out bv);
bvars.Add(bv);
@@ -1765,7 +1792,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
while (la.kind == 6) {
Attribute(ref attrs);
}
- if (la.kind == 17) {
+ if (la.kind == 19) {
Get();
Expression(out range);
}
@@ -1798,13 +1825,13 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 71) {
Get();
- } else SynErr(162);
+ } else SynErr(164);
}
void LogicalExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
RelationalExpression(out e0);
- if (StartOf(17)) {
+ if (StartOf(16)) {
if (la.kind == 74 || la.kind == 75) {
AndOp();
x = t;
@@ -1836,7 +1863,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 73) {
Get();
- } else SynErr(163);
+ } else SynErr(165);
}
void RelationalExpression(out Expression/*!*/ e) {
@@ -1853,7 +1880,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Term(out e0);
e = e0;
- if (StartOf(18)) {
+ if (StartOf(17)) {
RelOp(out x, out op);
firstOpTok = x;
Term(out e1);
@@ -1861,7 +1888,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (op == BinaryExpr.Opcode.Disjoint)
acc = new BinaryExpr(x, BinaryExpr.Opcode.Add, e0, e1); // accumulate first two operands.
- while (StartOf(18)) {
+ while (StartOf(17)) {
if (chain == null) {
chain = new List<Expression>();
ops = new List<BinaryExpr.Opcode>();
@@ -1934,7 +1961,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 75) {
Get();
- } else SynErr(164);
+ } else SynErr(166);
}
void OrOp() {
@@ -1942,7 +1969,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 77) {
Get();
- } else SynErr(165);
+ } else SynErr(167);
}
void Term(out Expression/*!*/ e0) {
@@ -1961,17 +1988,17 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IToken y;
switch (la.kind) {
- case 23: {
+ case 24: {
Get();
x = t; op = BinaryExpr.Opcode.Eq;
break;
}
- case 25: {
+ case 26: {
Get();
x = t; op = BinaryExpr.Opcode.Lt;
break;
}
- case 26: {
+ case 27: {
Get();
x = t; op = BinaryExpr.Opcode.Gt;
break;
@@ -2034,7 +2061,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
x = t; op = BinaryExpr.Opcode.Ge;
break;
}
- default: SynErr(166); break;
+ default: SynErr(168); break;
}
}
@@ -2056,7 +2083,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 88) {
Get();
x = t; op = BinaryExpr.Opcode.Sub;
- } else SynErr(167);
+ } else SynErr(169);
}
void UnaryExpression(out Expression/*!*/ e) {
@@ -2076,13 +2103,13 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
e = new UnaryExpr(x, UnaryExpr.Opcode.Not, e);
break;
}
- case 19: case 39: case 55: case 60: case 66: case 67: case 101: case 102: case 103: case 104: {
+ case 20: case 40: case 55: case 60: case 66: case 67: case 101: case 102: case 103: case 104: {
EndlessExpression(out e);
break;
}
case 1: {
DottedIdentifiersAndFunction(out e);
- while (la.kind == 44 || la.kind == 57) {
+ while (la.kind == 14 || la.kind == 57) {
Suffix(ref e);
}
break;
@@ -2091,22 +2118,22 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
DisplayExpr(out e);
break;
}
- case 40: {
+ case 41: {
MultiSetExpr(out e);
break;
}
- case 42: {
+ case 43: {
MapExpr(out e);
break;
}
- case 2: case 17: case 22: case 92: case 93: case 94: case 95: case 96: case 97: case 98: {
+ case 2: case 19: case 23: case 92: case 93: case 94: case 95: case 96: case 97: case 98: {
ConstAtomExpression(out e);
- while (la.kind == 44 || la.kind == 57) {
+ while (la.kind == 14 || la.kind == 57) {
Suffix(ref e);
}
break;
}
- default: SynErr(168); break;
+ default: SynErr(170); break;
}
}
@@ -2121,7 +2148,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 90) {
Get();
x = t; op = BinaryExpr.Opcode.Mod;
- } else SynErr(169);
+ } else SynErr(171);
}
void NegOp() {
@@ -2129,7 +2156,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 91) {
Get();
- } else SynErr(170);
+ } else SynErr(172);
}
void EndlessExpression(out Expression e) {
@@ -2159,7 +2186,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
QuantifierGuts(out e);
break;
}
- case 39: {
+ case 40: {
ComprehensionExpr(out e);
break;
}
@@ -2167,7 +2194,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
x = t;
Expression(out e0);
- Expect(18);
+ Expect(12);
Expression(out e1);
e = new AssertExpr(x, e0, e1);
break;
@@ -2176,19 +2203,19 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
x = t;
Expression(out e0);
- Expect(18);
+ Expect(12);
Expression(out e1);
e = new AssumeExpr(x, e0, e1);
break;
}
- case 19: {
+ case 20: {
Get();
x = t;
letVars = new List<BoundVar>();
letRHSs = new List<Expression>();
IdentTypeOptional(out d);
letVars.Add(d);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentTypeOptional(out d);
letVars.Add(d);
@@ -2196,17 +2223,17 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(53);
Expression(out e);
letRHSs.Add(e);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Expression(out e);
letRHSs.Add(e);
}
- Expect(18);
+ Expect(12);
Expression(out e);
e = new LetExpr(x, letVars, letRHSs, e);
break;
}
- default: SynErr(171); break;
+ default: SynErr(173); break;
}
}
@@ -2217,18 +2244,18 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Ident(out id);
idents.Add(id);
- while (la.kind == 44) {
+ while (la.kind == 14) {
Get();
Ident(out id);
idents.Add(id);
}
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
openParen = t; args = new List<Expression>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(args);
}
- Expect(24);
+ Expect(25);
}
e = new IdentifierSequence(idents, openParen, args);
}
@@ -2239,29 +2266,29 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
List<Expression> multipleIndices = null;
bool func = false;
- if (la.kind == 44) {
+ if (la.kind == 14) {
Get();
Ident(out id);
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
IToken openParen = t; args = new List<Expression/*!*/>(); func = true;
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(args);
}
- Expect(24);
+ Expect(25);
e = new FunctionCallExpr(id, id.val, e, openParen, args);
}
if (!func) { e = new ExprDotName(id, e, id.val); }
} else if (la.kind == 57) {
Get();
x = t;
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expression(out ee);
e0 = ee;
if (la.kind == 100) {
Get();
anyDots = true;
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expression(out ee);
e1 = ee;
}
@@ -2269,8 +2296,8 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
Expression(out ee);
e1 = ee;
- } else if (la.kind == 20 || la.kind == 58) {
- while (la.kind == 20) {
+ } else if (la.kind == 21 || la.kind == 58) {
+ while (la.kind == 21) {
Get();
Expression(out ee);
if (multipleIndices == null) {
@@ -2280,15 +2307,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
multipleIndices.Add(ee);
}
- } else SynErr(172);
+ } else SynErr(174);
} else if (la.kind == 100) {
Get();
anyDots = true;
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expression(out ee);
e1 = ee;
}
- } else SynErr(173);
+ } else SynErr(175);
if (multipleIndices != null) {
e = new MultiSelectExpr(x, e, multipleIndices);
// make sure an array class with this dimensionality exists
@@ -2312,7 +2339,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
}
Expect(58);
- } else SynErr(174);
+ } else SynErr(176);
}
void DisplayExpr(out Expression e) {
@@ -2323,7 +2350,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
if (la.kind == 6) {
Get();
x = t; elements = new List<Expression/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(elements);
}
e = new SetDisplayExpr(x, elements);
@@ -2331,12 +2358,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 57) {
Get();
x = t; elements = new List<Expression/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(elements);
}
e = new SeqDisplayExpr(x, elements);
Expect(58);
- } else SynErr(175);
+ } else SynErr(177);
}
void MultiSetExpr(out Expression e) {
@@ -2344,25 +2371,25 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IToken/*!*/ x = null; List<Expression/*!*/>/*!*/ elements;
e = dummyExpr;
- Expect(40);
+ Expect(41);
x = t;
if (la.kind == 6) {
Get();
elements = new List<Expression/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
Expressions(elements);
}
e = new MultiSetDisplayExpr(x, elements);
Expect(7);
- } else if (la.kind == 22) {
+ } else if (la.kind == 23) {
Get();
x = t; elements = new List<Expression/*!*/>();
Expression(out e);
e = new MultiSetFormingExpr(x, e);
- Expect(24);
- } else if (StartOf(19)) {
+ Expect(25);
+ } else if (StartOf(18)) {
SemErr("multiset must be followed by multiset literal or expression to coerce in parentheses.");
- } else SynErr(176);
+ } else SynErr(178);
}
void MapExpr(out Expression e) {
@@ -2371,12 +2398,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
List<ExpressionPair/*!*/>/*!*/ elements;
e = dummyExpr;
- Expect(42);
+ Expect(43);
x = t;
if (la.kind == 57) {
Get();
elements = new List<ExpressionPair/*!*/>();
- if (StartOf(9)) {
+ if (StartOf(8)) {
MapLiteralExpressions(out elements);
}
e = new MapDisplayExpr(x, elements);
@@ -2389,14 +2416,14 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IdentTypeOptional(out bv);
bvars.Add(bv);
- Expect(17);
+ Expect(19);
Expression(out range);
QSep();
Expression(out body);
e = new MapComprehension(x, bvars, range, body);
- } else if (StartOf(19)) {
+ } else if (StartOf(18)) {
SemErr("map must be followed by literal in brackets or comprehension.");
- } else SynErr(177);
+ } else SynErr(179);
}
void ConstAtomExpression(out Expression/*!*/ e) {
@@ -2433,47 +2460,47 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
case 96: {
Get();
x = t;
- Expect(22);
+ Expect(23);
Expression(out e);
- Expect(24);
+ Expect(25);
e = new FreshExpr(x, e);
break;
}
case 97: {
Get();
x = t;
- Expect(22);
+ Expect(23);
Expression(out e);
- Expect(24);
+ Expect(25);
e = new AllocatedExpr(x, e);
break;
}
case 98: {
Get();
x = t;
- Expect(22);
+ Expect(23);
Expression(out e);
- Expect(24);
+ Expect(25);
e = new OldExpr(x, e);
break;
}
- case 17: {
+ case 19: {
Get();
x = t;
Expression(out e);
e = new UnaryExpr(x, UnaryExpr.Opcode.SeqLength, e);
- Expect(17);
+ Expect(19);
break;
}
- case 22: {
+ case 23: {
Get();
x = t;
Expression(out e);
e = new ParensExpression(x, e);
- Expect(24);
+ Expect(25);
break;
}
- default: SynErr(178); break;
+ default: SynErr(180); break;
}
}
@@ -2495,7 +2522,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(53);
Expression(out r);
elements.Add(new ExpressionPair(d,r));
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
Expression(out d);
Expect(53);
@@ -2509,7 +2536,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 106) {
Get();
- } else SynErr(179);
+ } else SynErr(181);
}
void MatchExpression(out Expression/*!*/ e) {
@@ -2540,7 +2567,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
} else if (la.kind == 103 || la.kind == 104) {
Exists();
x = t;
- } else SynErr(180);
+ } else SynErr(182);
QuantifierDomain(out bvars, out attrs, out range);
QSep();
Expression(out body);
@@ -2560,16 +2587,16 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expression/*!*/ range;
Expression body = null;
- Expect(39);
+ Expect(40);
x = t;
IdentTypeOptional(out bv);
bvars.Add(bv);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentTypeOptional(out bv);
bvars.Add(bv);
}
- Expect(17);
+ Expect(19);
Expression(out range);
if (la.kind == 105 || la.kind == 106) {
QSep();
@@ -2589,16 +2616,16 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(62);
x = t;
Ident(out id);
- if (la.kind == 22) {
+ if (la.kind == 23) {
Get();
IdentTypeOptional(out bv);
arguments.Add(bv);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
IdentTypeOptional(out bv);
arguments.Add(bv);
}
- Expect(24);
+ Expect(25);
}
Expect(63);
Expression(out body);
@@ -2610,7 +2637,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 102) {
Get();
- } else SynErr(181);
+ } else SynErr(183);
}
void Exists() {
@@ -2618,7 +2645,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Get();
} else if (la.kind == 104) {
Get();
- } else SynErr(182);
+ } else SynErr(184);
}
void AttributeBody(ref Attributes attrs) {
@@ -2629,10 +2656,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expect(5);
Expect(1);
aName = t.val;
- if (StartOf(20)) {
+ if (StartOf(19)) {
AttributeArg(out aArg);
aArgs.Add(aArg);
- while (la.kind == 20) {
+ while (la.kind == 21) {
Get();
AttributeArg(out aArg);
aArgs.Add(aArg);
@@ -2654,27 +2681,26 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
}
static readonly bool[,]/*!*/ set = {
- {T,T,T,x, x,x,T,x, T,x,x,x, T,x,T,T, x,T,T,T, x,x,T,x, x,x,x,T, T,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, T,T,x,x, T,T,T,T, x,x,x,T, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, T,x,x,x, T,T,T,T, x,x,x,T, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {T,x,x,x, x,x,T,T, T,T,x,x, T,T,T,T, x,x,x,T, x,T,T,x, x,T,x,T, T,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,x,T, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {x,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {T,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,T, T,T,x,T, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {T,T,T,x, x,x,T,x, T,x,x,x, T,x,x,T, x,T,T,T, T,x,x,T, x,x,x,x, T,T,x,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,T, T,T,T,x, T,x,T,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {T,x,x,x, x,x,T,T, T,T,x,x, x,x,x,T, T,T,T,x, T,x,T,T, x,x,T,x, T,T,x,x, x,x,T,T, T,x,x,x, x,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,T,x,T, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
+ {x,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, T,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
+ {T,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,T, x,x,x,x, T,x,x,x, T,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, T,x,x,x, x,x,x,T, T,T,x,T, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
+ {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,T,x, x,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,T,x, x},
- {x,T,T,x, T,x,T,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x}
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+ {x,x,x,x, x,x,T,T, x,x,x,x, T,x,x,x, x,x,x,T, x,T,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,T,x, x,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,T,x, x},
+ {x,T,T,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,T, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x}
};
} // end Parser
@@ -2710,40 +2736,40 @@ public class Errors {
case 8: s = "\"ghost\" expected"; break;
case 9: s = "\"module\" expected"; break;
case 10: s = "\"refines\" expected"; break;
- case 11: s = "\"imports\" expected"; break;
- case 12: s = "\"class\" expected"; break;
- case 13: s = "\"static\" expected"; break;
- case 14: s = "\"datatype\" expected"; break;
- case 15: s = "\"codatatype\" expected"; break;
- case 16: s = "\"=\" expected"; break;
- case 17: s = "\"|\" expected"; break;
- case 18: s = "\";\" expected"; break;
- case 19: s = "\"var\" expected"; break;
- case 20: s = "\",\" expected"; break;
- case 21: s = "\"type\" expected"; break;
- case 22: s = "\"(\" expected"; break;
- case 23: s = "\"==\" expected"; break;
- case 24: s = "\")\" expected"; break;
- case 25: s = "\"<\" expected"; break;
- case 26: s = "\">\" expected"; break;
- case 27: s = "\"method\" expected"; break;
- case 28: s = "\"constructor\" expected"; break;
- case 29: s = "\"returns\" expected"; break;
- case 30: s = "\"...\" expected"; break;
- case 31: s = "\"modifies\" expected"; break;
- case 32: s = "\"free\" expected"; break;
- case 33: s = "\"requires\" expected"; break;
- case 34: s = "\"ensures\" expected"; break;
- case 35: s = "\"decreases\" expected"; break;
- case 36: s = "\"bool\" expected"; break;
- case 37: s = "\"nat\" expected"; break;
- case 38: s = "\"int\" expected"; break;
- case 39: s = "\"set\" expected"; break;
- case 40: s = "\"multiset\" expected"; break;
- case 41: s = "\"seq\" expected"; break;
- case 42: s = "\"map\" expected"; break;
- case 43: s = "\"object\" expected"; break;
- case 44: s = "\".\" expected"; break;
+ case 11: s = "\"=\" expected"; break;
+ case 12: s = "\";\" expected"; break;
+ case 13: s = "\"as\" expected"; break;
+ case 14: s = "\".\" expected"; break;
+ case 15: s = "\"class\" expected"; break;
+ case 16: s = "\"static\" expected"; break;
+ case 17: s = "\"datatype\" expected"; break;
+ case 18: s = "\"codatatype\" expected"; break;
+ case 19: s = "\"|\" expected"; break;
+ case 20: s = "\"var\" expected"; break;
+ case 21: s = "\",\" expected"; break;
+ case 22: s = "\"type\" expected"; break;
+ case 23: s = "\"(\" expected"; break;
+ case 24: s = "\"==\" expected"; break;
+ case 25: s = "\")\" expected"; break;
+ case 26: s = "\"<\" expected"; break;
+ case 27: s = "\">\" expected"; break;
+ case 28: s = "\"method\" expected"; break;
+ case 29: s = "\"constructor\" expected"; break;
+ case 30: s = "\"returns\" expected"; break;
+ case 31: s = "\"...\" expected"; break;
+ case 32: s = "\"modifies\" expected"; break;
+ case 33: s = "\"free\" expected"; break;
+ case 34: s = "\"requires\" expected"; break;
+ case 35: s = "\"ensures\" expected"; break;
+ case 36: s = "\"decreases\" expected"; break;
+ case 37: s = "\"bool\" expected"; break;
+ case 38: s = "\"nat\" expected"; break;
+ case 39: s = "\"int\" expected"; break;
+ case 40: s = "\"set\" expected"; break;
+ case 41: s = "\"multiset\" expected"; break;
+ case 42: s = "\"seq\" expected"; break;
+ case 43: s = "\"map\" expected"; break;
+ case 44: s = "\"object\" expected"; break;
case 45: s = "\"function\" expected"; break;
case 46: s = "\"predicate\" expected"; break;
case 47: s = "\"reads\" expected"; break;
@@ -2808,80 +2834,82 @@ public class Errors {
case 106: s = "\"\\u2022\" expected"; break;
case 107: s = "??? expected"; break;
case 108: s = "invalid Dafny"; break;
- case 109: s = "this symbol not expected in ClassDecl"; break;
- case 110: s = "this symbol not expected in DatatypeDecl"; break;
- case 111: s = "invalid DatatypeDecl"; break;
+ case 109: s = "invalid SubModuleDecl"; break;
+ case 110: s = "invalid SubModuleDecl"; break;
+ case 111: s = "this symbol not expected in ClassDecl"; break;
case 112: s = "this symbol not expected in DatatypeDecl"; break;
- case 113: s = "this symbol not expected in ArbitraryTypeDecl"; break;
- case 114: s = "invalid ClassMemberDecl"; break;
- case 115: s = "this symbol not expected in FieldDecl"; break;
- case 116: s = "this symbol not expected in FieldDecl"; break;
- case 117: s = "invalid FunctionDecl"; break;
- case 118: s = "invalid FunctionDecl"; break;
+ case 113: s = "invalid DatatypeDecl"; break;
+ case 114: s = "this symbol not expected in DatatypeDecl"; break;
+ case 115: s = "this symbol not expected in ArbitraryTypeDecl"; break;
+ case 116: s = "invalid ClassMemberDecl"; break;
+ case 117: s = "this symbol not expected in FieldDecl"; break;
+ case 118: s = "this symbol not expected in FieldDecl"; break;
case 119: s = "invalid FunctionDecl"; break;
- case 120: s = "this symbol not expected in MethodDecl"; break;
- case 121: s = "invalid MethodDecl"; break;
- case 122: s = "invalid MethodDecl"; break;
- case 123: s = "invalid TypeAndToken"; break;
- case 124: s = "this symbol not expected in MethodSpec"; break;
- case 125: s = "this symbol not expected in MethodSpec"; break;
+ case 120: s = "invalid FunctionDecl"; break;
+ case 121: s = "invalid FunctionDecl"; break;
+ case 122: s = "this symbol not expected in MethodDecl"; break;
+ case 123: s = "invalid MethodDecl"; break;
+ case 124: s = "invalid MethodDecl"; break;
+ case 125: s = "invalid TypeAndToken"; break;
case 126: s = "this symbol not expected in MethodSpec"; break;
case 127: s = "this symbol not expected in MethodSpec"; break;
- case 128: s = "invalid MethodSpec"; break;
+ case 128: s = "this symbol not expected in MethodSpec"; break;
case 129: s = "this symbol not expected in MethodSpec"; break;
case 130: s = "invalid MethodSpec"; break;
- case 131: s = "invalid ReferenceType"; break;
- case 132: s = "this symbol not expected in FunctionSpec"; break;
- case 133: s = "this symbol not expected in FunctionSpec"; break;
+ case 131: s = "this symbol not expected in MethodSpec"; break;
+ case 132: s = "invalid MethodSpec"; break;
+ case 133: s = "invalid ReferenceType"; break;
case 134: s = "this symbol not expected in FunctionSpec"; break;
case 135: s = "this symbol not expected in FunctionSpec"; break;
case 136: s = "this symbol not expected in FunctionSpec"; break;
- case 137: s = "invalid FunctionSpec"; break;
- case 138: s = "invalid PossiblyWildFrameExpression"; break;
- case 139: s = "invalid PossiblyWildExpression"; break;
- case 140: s = "this symbol not expected in OneStmt"; break;
- case 141: s = "invalid OneStmt"; break;
+ case 137: s = "this symbol not expected in FunctionSpec"; break;
+ case 138: s = "this symbol not expected in FunctionSpec"; break;
+ case 139: s = "invalid FunctionSpec"; break;
+ case 140: s = "invalid PossiblyWildFrameExpression"; break;
+ case 141: s = "invalid PossiblyWildExpression"; break;
case 142: s = "this symbol not expected in OneStmt"; break;
case 143: s = "invalid OneStmt"; break;
- case 144: s = "invalid AssertStmt"; break;
- case 145: s = "invalid AssumeStmt"; break;
- case 146: s = "invalid UpdateStmt"; break;
- case 147: s = "invalid UpdateStmt"; break;
- case 148: s = "invalid IfStmt"; break;
- case 149: s = "invalid IfStmt"; break;
- case 150: s = "invalid WhileStmt"; break;
- case 151: s = "invalid WhileStmt"; break;
- case 152: s = "invalid Rhs"; break;
- case 153: s = "invalid Lhs"; break;
- case 154: s = "invalid Guard"; break;
- case 155: s = "this symbol not expected in LoopSpec"; break;
- case 156: s = "this symbol not expected in LoopSpec"; break;
+ case 144: s = "this symbol not expected in OneStmt"; break;
+ case 145: s = "invalid OneStmt"; break;
+ case 146: s = "invalid AssertStmt"; break;
+ case 147: s = "invalid AssumeStmt"; break;
+ case 148: s = "invalid UpdateStmt"; break;
+ case 149: s = "invalid UpdateStmt"; break;
+ case 150: s = "invalid IfStmt"; break;
+ case 151: s = "invalid IfStmt"; break;
+ case 152: s = "invalid WhileStmt"; break;
+ case 153: s = "invalid WhileStmt"; break;
+ case 154: s = "invalid Rhs"; break;
+ case 155: s = "invalid Lhs"; break;
+ case 156: s = "invalid Guard"; break;
case 157: s = "this symbol not expected in LoopSpec"; break;
case 158: s = "this symbol not expected in LoopSpec"; break;
case 159: s = "this symbol not expected in LoopSpec"; break;
- case 160: s = "this symbol not expected in Invariant"; break;
- case 161: s = "invalid AttributeArg"; break;
- case 162: s = "invalid EquivOp"; break;
- case 163: s = "invalid ImpliesOp"; break;
- case 164: s = "invalid AndOp"; break;
- case 165: s = "invalid OrOp"; break;
- case 166: s = "invalid RelOp"; break;
- case 167: s = "invalid AddOp"; break;
- case 168: s = "invalid UnaryExpression"; break;
- case 169: s = "invalid MulOp"; break;
- case 170: s = "invalid NegOp"; break;
- case 171: s = "invalid EndlessExpression"; break;
- case 172: s = "invalid Suffix"; break;
- case 173: s = "invalid Suffix"; break;
+ case 160: s = "this symbol not expected in LoopSpec"; break;
+ case 161: s = "this symbol not expected in LoopSpec"; break;
+ case 162: s = "this symbol not expected in Invariant"; break;
+ case 163: s = "invalid AttributeArg"; break;
+ case 164: s = "invalid EquivOp"; break;
+ case 165: s = "invalid ImpliesOp"; break;
+ case 166: s = "invalid AndOp"; break;
+ case 167: s = "invalid OrOp"; break;
+ case 168: s = "invalid RelOp"; break;
+ case 169: s = "invalid AddOp"; break;
+ case 170: s = "invalid UnaryExpression"; break;
+ case 171: s = "invalid MulOp"; break;
+ case 172: s = "invalid NegOp"; break;
+ case 173: s = "invalid EndlessExpression"; break;
case 174: s = "invalid Suffix"; break;
- case 175: s = "invalid DisplayExpr"; break;
- case 176: s = "invalid MultiSetExpr"; break;
- case 177: s = "invalid MapExpr"; break;
- case 178: s = "invalid ConstAtomExpression"; break;
- case 179: s = "invalid QSep"; break;
- case 180: s = "invalid QuantifierGuts"; break;
- case 181: s = "invalid Forall"; break;
- case 182: s = "invalid Exists"; break;
+ case 175: s = "invalid Suffix"; break;
+ case 176: s = "invalid Suffix"; break;
+ case 177: s = "invalid DisplayExpr"; break;
+ case 178: s = "invalid MultiSetExpr"; break;
+ case 179: s = "invalid MapExpr"; break;
+ case 180: s = "invalid ConstAtomExpression"; break;
+ case 181: s = "invalid QSep"; break;
+ case 182: s = "invalid QuantifierGuts"; break;
+ case 183: s = "invalid Forall"; break;
+ case 184: s = "invalid Exists"; break;
default: s = "error " + n; break;
}
diff --git a/Source/Dafny/Printer.cs b/Source/Dafny/Printer.cs
index 3654c672..a49a906e 100644
--- a/Source/Dafny/Printer.cs
+++ b/Source/Dafny/Printer.cs
@@ -32,33 +32,8 @@ namespace Microsoft.Dafny {
wr.WriteLine("// " + Bpl.CommandLineOptions.Clo.Environment);
}
wr.WriteLine("// {0}", prog.Name);
- foreach (ModuleDecl module in prog.Modules) {
- wr.WriteLine();
- if (module.IsDefaultModule) {
- PrintTopLevelDecls(module.TopLevelDecls, 0);
- } else {
- wr.Write("module");
- PrintAttributes(module.Attributes);
- wr.Write(" {0} ", module.Name);
- if (module.RefinementBaseName != null) {
- wr.Write("refines {0} ", module.RefinementBaseName);
- }
- if (module.ImportNames.Count != 0) {
- string sep = "imports ";
- foreach (string imp in module.ImportNames) {
- wr.Write("{0}{1}", sep, imp);
- sep = ", ";
- }
- }
- if (module.TopLevelDecls.Count == 0) {
- wr.WriteLine(" { }");
- } else {
- wr.WriteLine(" {");
- PrintTopLevelDecls(module.TopLevelDecls, IndentAmount);
- wr.WriteLine("}");
- }
- }
- }
+ wr.WriteLine();
+ PrintTopLevelDecls(prog.DefaultModuleDef.TopLevelDecls, 0);
}
public void PrintTopLevelDecls(List<TopLevelDecl> classes, int indent) {
@@ -78,7 +53,7 @@ namespace Microsoft.Dafny {
} else if (d is DatatypeDecl) {
if (i++ != 0) { wr.WriteLine(); }
PrintDatatype((DatatypeDecl)d, indent);
- } else {
+ } else if (d is ClassDecl) {
ClassDecl cl = (ClassDecl)d;
if (!cl.IsDefaultClass) {
if (i++ != 0) { wr.WriteLine(); }
@@ -89,6 +64,34 @@ namespace Microsoft.Dafny {
if (i++ != 0) { wr.WriteLine(); }
PrintClass_Members(cl, indent);
}
+ } else if (d is ModuleDecl) {
+ wr.WriteLine();
+ Indent(indent);
+ if (d is LiteralModuleDecl) {
+ ModuleDefinition module = ((LiteralModuleDecl)d).ModuleDef;
+ wr.Write("module");
+ PrintAttributes(module.Attributes);
+ wr.Write(" {0} ", module.Name);
+ if (module.RefinementBaseName != null) {
+ wr.Write("refines {0} ", Util.Comma(".", module.RefinementBaseName, id => id.val));
+ }
+ if (module.TopLevelDecls.Count == 0) {
+ wr.WriteLine("{ }");
+ } else {
+ wr.WriteLine("{");
+ PrintTopLevelDecls(module.TopLevelDecls, indent + IndentAmount);
+ Indent(indent);
+ wr.WriteLine("}");
+ }
+ } else if (d is AliasModuleDecl) {
+ wr.Write("module");
+ wr.Write(" {0} ", ((AliasModuleDecl)d).Name);
+ wr.WriteLine("= {0};", Util.Comma(".", ((AliasModuleDecl)d).Path, id => id.val));
+ } else if (d is AbstractModuleDecl) {
+ wr.Write("module");
+ wr.Write(" {0} ", ((AbstractModuleDecl)d).Name);
+ wr.WriteLine("as {0};", Util.Comma(".", ((AbstractModuleDecl)d).Path, id => id.val));
+ }
}
}
}
@@ -147,17 +150,10 @@ namespace Microsoft.Dafny {
wr.Write(" {0}", name);
if (typeArgs.Count != 0) {
- wr.Write("<");
- string sep = "";
- foreach (TypeParameter tp in typeArgs) {
- Contract.Assert(tp != null);
- wr.Write("{0}{1}", sep, tp.Name);
- if (tp.EqualitySupport == TypeParameter.EqualitySupportValue.Required) {
- wr.Write("(==)");
- }
- sep = ", ";
- }
- wr.Write(">");
+ wr.Write("<" +
+ Util.Comma(", ", typeArgs,
+ tp => tp.Name + (tp.EqualitySupport == TypeParameter.EqualitySupportValue.Required? "(==)": ""))
+ + ">");
}
}
@@ -262,7 +258,7 @@ namespace Microsoft.Dafny {
// ----------------------------- PrintMethod -----------------------------
- const int IndentAmount = 2;
+ const int IndentAmount = 2; // The amount of indent for each new scope
const string BunchaSpaces = " ";
void Indent(int amount)
{ Contract.Requires( 0 <= amount);
diff --git a/Source/Dafny/RefinementTransformer.cs b/Source/Dafny/RefinementTransformer.cs
index bbc12d6a..0d32e24e 100644
--- a/Source/Dafny/RefinementTransformer.cs
+++ b/Source/Dafny/RefinementTransformer.cs
@@ -21,8 +21,8 @@ using IToken = Microsoft.Boogie.IToken;
namespace Microsoft.Dafny {
public class RefinementToken : TokenWrapper
{
- public readonly ModuleDecl InheritingModule;
- public RefinementToken(IToken tok, ModuleDecl m)
+ public readonly ModuleDefinition InheritingModule;
+ public RefinementToken(IToken tok, ModuleDefinition m)
: base(tok)
{
Contract.Requires(tok != null);
@@ -30,7 +30,7 @@ namespace Microsoft.Dafny {
this.InheritingModule = m;
}
- public static bool IsInherited(IToken tok, ModuleDecl m) {
+ public static bool IsInherited(IToken tok, ModuleDefinition m) {
while (tok is NestedToken) {
var n = (NestedToken)tok;
// check Outer
@@ -58,33 +58,19 @@ namespace Microsoft.Dafny {
this.reporter = reporter;
}
- private ModuleDecl moduleUnderConstruction; // non-null for the duration of Construct calls
+ private ModuleDefinition moduleUnderConstruction; // non-null for the duration of Construct calls
private Queue<Action> postTasks = new Queue<Action>(); // empty whenever moduleUnderConstruction==null, these tasks are for the post-resolve phase of module moduleUnderConstruction
- public void PreResolve(ModuleDecl m) {
- if (m.RefinementBase == null) {
- // This Rewriter doesn't do anything
- return;
- }
+ public void PreResolve(ModuleDefinition m) {
+ Contract.Requires(m != null);
+ Contract.Requires(m.RefinementBase != null);
if (moduleUnderConstruction != null) {
postTasks.Clear();
}
+
moduleUnderConstruction = m;
- var prev = m.RefinementBase;
-
- // Include the imports of the base. Note, prev is itself NOT added as an import
- // of m; instead, the contents from prev is merged directly into m.
- // (Here, we change the import declarations. But edges for these imports will
- // not be added to the importGraph of the calling resolver. However, the refines
- // clause gave rise to an edge in the importGraph, so the transitive import edges
- // are represented in the importGraph.)
- foreach (var im in prev.Imports) {
- if (!m.ImportNames.Contains(im.Name)) {
- m.ImportNames.Add(im.Name);
- m.Imports.Add(im);
- }
- }
+ var prev = m.RefinementBase;
// Create a simple name-to-decl dictionary. Ignore any duplicates at this time.
var declaredNames = new Dictionary<string, int>();
@@ -96,40 +82,71 @@ namespace Microsoft.Dafny {
}
// Merge the declarations of prev into the declarations of m
-
foreach (var d in prev.TopLevelDecls) {
int index;
if (!declaredNames.TryGetValue(d.Name, out index)) {
m.TopLevelDecls.Add(CloneDeclaration(d, m));
} else {
var nw = m.TopLevelDecls[index];
- if (d is ArbitraryTypeDecl) {
- bool dDemandsEqualitySupport = ((ArbitraryTypeDecl)d).MustSupportEquality;
- if (nw is ArbitraryTypeDecl) {
- if (dDemandsEqualitySupport != ((ArbitraryTypeDecl)nw).MustSupportEquality) {
- reporter.Error(nw, "type declaration '{0}' is not allowed to change the requirement of supporting equality", nw.Name);
+ if (d is ModuleDecl) {
+ if (!(nw is ModuleDecl)) {
+ reporter.Error(nw, "a module ({0}) must refine another module", nw.Name);
+ } else if (!(d is AbstractModuleDecl)) {
+ reporter.Error(nw, "a module ({0}) can only refine abstract modules", nw.Name);
+ } else {
+ ModuleSignature original = ((AbstractModuleDecl)d).OriginalSignature;
+ ModuleSignature derived = null;
+ if (nw is AliasModuleDecl) {
+ derived = ((AliasModuleDecl)nw).Signature;
+ } else if (nw is AbstractModuleDecl) {
+ derived = ((AbstractModuleDecl)nw).Signature;
+ } else {
+ reporter.Error(nw, "a module ({0}) can only be refined by alias or abstract modules", d.Name);
}
- } else if (dDemandsEqualitySupport) {
- if (nw is ClassDecl) {
- // fine, as long as "nw" does not take any type parameters
- if (nw.TypeArgs.Count != 0) {
- reporter.Error(nw, "arbitrary type '{0}' is not allowed to be replaced by a class that takes type parameters", nw.Name);
+ if (derived != null) {
+ // check that the new module refines the previous declaration
+ while (derived != null) {
+ if (derived == original)
+ break;
+ derived = derived.Refines;
}
- } else if (nw is CoDatatypeDecl) {
- reporter.Error(nw, "a type declaration that requires equality support cannot be replaced by a codatatype");
- } else {
- Contract.Assert(nw is IndDatatypeDecl);
- if (nw.TypeArgs.Count != 0) {
- reporter.Error(nw, "arbitrary type '{0}' is not allowed to be replaced by a datatype that takes type parameters", nw.Name);
+ if (derived != original) {
+ reporter.Error(nw, "a module ({0}) can only be replaced by a refinement of the original module", d.Name);
+ }
+ }
+ }
+ } else if (d is ArbitraryTypeDecl) {
+ if (nw is ModuleDecl) {
+ reporter.Error(nw, "a module ({0}) must refine another module", nw.Name);
+ } else {
+ bool dDemandsEqualitySupport = ((ArbitraryTypeDecl)d).MustSupportEquality;
+ if (nw is ArbitraryTypeDecl) {
+ if (dDemandsEqualitySupport != ((ArbitraryTypeDecl)nw).MustSupportEquality) {
+ reporter.Error(nw, "type declaration '{0}' is not allowed to change the requirement of supporting equality", nw.Name);
+ }
+ } else if (dDemandsEqualitySupport) {
+ if (nw is ClassDecl) {
+ // fine, as long as "nw" does not take any type parameters
+ if (nw.TypeArgs.Count != 0) {
+ reporter.Error(nw, "arbitrary type '{0}' is not allowed to be replaced by a class that takes type parameters", nw.Name);
+ }
+ } else if (nw is CoDatatypeDecl) {
+ reporter.Error(nw, "a type declaration that requires equality support cannot be replaced by a codatatype");
} else {
- // Here, we need to figure out if the new type supports equality. But we won't know about that until resolution has
- // taken place, so we defer it until the PostResolve phase.
- var udt = new UserDefinedType(nw.tok, nw.Name, nw, new List<Type>());
- postTasks.Enqueue(delegate() {
- if (!udt.SupportsEquality) {
- reporter.Error(udt.tok, "datatype '{0}' is used to refine an arbitrary type with equality support, but '{0}' does not support equality", udt.Name);
- }
- });
+ Contract.Assert(nw is IndDatatypeDecl);
+ if (nw.TypeArgs.Count != 0) {
+ reporter.Error(nw, "arbitrary type '{0}' is not allowed to be replaced by a datatype that takes type parameters", nw.Name);
+ } else {
+ // Here, we need to figure out if the new type supports equality. But we won't know about that until resolution has
+ // taken place, so we defer it until the PostResolve phase.
+ var udt = new UserDefinedType(nw.tok, nw.Name, nw, new List<Type>());
+ postTasks.Enqueue(delegate()
+ {
+ if (!udt.SupportsEquality) {
+ reporter.Error(udt.tok, "datatype '{0}' is used to refine an arbitrary type with equality support, but '{0}' does not support equality", udt.Name);
+ }
+ });
+ }
}
}
}
@@ -151,7 +168,7 @@ namespace Microsoft.Dafny {
Contract.Assert(moduleUnderConstruction == m); // this should be as it was set earlier in this method
}
- public void PostResolve(ModuleDecl m) {
+ public void PostResolve(ModuleDefinition m) {
if (m == moduleUnderConstruction) {
while (this.postTasks.Count != 0) {
var a = postTasks.Dequeue();
@@ -173,7 +190,8 @@ namespace Microsoft.Dafny {
// -------------------------------------------------- Cloning ---------------------------------------------------------------
- TopLevelDecl CloneDeclaration(TopLevelDecl d, ModuleDecl m) {
+ // Clone a toplevel, specifying that its parent module should be m (i.e. it will be added to m.TopLevelDecls).
+ TopLevelDecl CloneDeclaration(TopLevelDecl d, ModuleDefinition m) {
Contract.Requires(d != null);
Contract.Requires(m != null);
@@ -198,6 +216,25 @@ namespace Microsoft.Dafny {
var mm = dd.Members.ConvertAll(CloneMember);
var cl = new ClassDecl(Tok(dd.tok), dd.Name, m, tps, mm, null);
return cl;
+ } else if (d is ModuleDecl) {
+ if (d is LiteralModuleDecl) {
+ return new LiteralModuleDecl(((LiteralModuleDecl)d).ModuleDef,m);
+ } else if (d is AliasModuleDecl) {
+ var a = (AliasModuleDecl)d;
+ var alias = new AliasModuleDecl(a.Path, a.tok, m);
+ alias.ModuleReference = a.ModuleReference;
+ alias.Signature = a.Signature;
+ return alias;
+ } else if (d is AbstractModuleDecl) {
+ var a = (AbstractModuleDecl)d;
+ var abs = new AbstractModuleDecl(a.Path, a.tok, m);
+ abs.Signature = a.Signature;
+ abs.OriginalSignature = a.OriginalSignature;
+ return abs;
+ } else {
+ Contract.Assert(false); // unexpected declaration
+ return null; // to please compiler
+ }
} else {
Contract.Assert(false); // unexpected declaration
return null; // to please compiler
@@ -1217,7 +1254,7 @@ namespace Microsoft.Dafny {
// ---------------------- additional methods -----------------------------------------------------------------------------
- public static bool ContainsChange(Expression expr, ModuleDecl m) {
+ public static bool ContainsChange(Expression expr, ModuleDefinition m) {
Contract.Requires(expr != null);
Contract.Requires(m != null);
diff --git a/Source/Dafny/Resolver.cs b/Source/Dafny/Resolver.cs
index 3d99f732..098bcc2e 100644
--- a/Source/Dafny/Resolver.cs
+++ b/Source/Dafny/Resolver.cs
@@ -63,12 +63,15 @@ namespace Microsoft.Dafny {
public class Resolver : ResolutionErrorReporter {
readonly BuiltIns builtIns;
- Dictionary<string/*!*/,TopLevelDecl/*!*/>/*!*/ classes; // can map to AmbiguousTopLevelDecl
+ //Dictionary<string/*!*/,TopLevelDecl/*!*/>/*!*/ classes; // can map to AmbiguousTopLevelDecl
+ //Dictionary<string, ModuleDecl> importedNames; // the imported modules, as a map.
+ ModuleSignature moduleInfo = null;
+
class AmbiguousTopLevelDecl : TopLevelDecl // only used with "classes"
{
readonly TopLevelDecl A;
readonly TopLevelDecl B;
- public AmbiguousTopLevelDecl(ModuleDecl m, TopLevelDecl a, TopLevelDecl b)
+ public AmbiguousTopLevelDecl(ModuleDefinition m, TopLevelDecl a, TopLevelDecl b)
: base(a.tok, a.Name + "/" + b.Name, m, new List<TypeParameter>(), null) {
A = a;
B = b;
@@ -88,13 +91,12 @@ namespace Microsoft.Dafny {
return nm;
}
}
- Dictionary<string/*!*/, Tuple<DatatypeCtor, bool>> allDatatypeCtors;
+ //Dictionary<string/*!*/, Tuple<DatatypeCtor, bool>> allDatatypeCtors;
readonly Dictionary<ClassDecl/*!*/, Dictionary<string/*!*/, MemberDecl/*!*/>/*!*/>/*!*/ classMembers = new Dictionary<ClassDecl/*!*/, Dictionary<string/*!*/, MemberDecl/*!*/>/*!*/>();
readonly Dictionary<DatatypeDecl/*!*/, Dictionary<string/*!*/, MemberDecl/*!*/>/*!*/>/*!*/ datatypeMembers = new Dictionary<DatatypeDecl/*!*/, Dictionary<string/*!*/, MemberDecl/*!*/>/*!*/>();
readonly Dictionary<DatatypeDecl/*!*/, Dictionary<string/*!*/, DatatypeCtor/*!*/>/*!*/>/*!*/ datatypeCtors = new Dictionary<DatatypeDecl/*!*/, Dictionary<string/*!*/, DatatypeCtor/*!*/>/*!*/>();
- readonly Graph<ModuleDecl/*!*/>/*!*/ importGraph = new Graph<ModuleDecl/*!*/>();
-
+ readonly Graph<ModuleDecl/*!*/>/*!*/ dependencies = new Graph<ModuleDecl/*!*/>();
public Resolver(Program prog) {
Contract.Requires(prog != null);
builtIns = prog.BuiltIns;
@@ -103,106 +105,113 @@ namespace Microsoft.Dafny {
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(builtIns != null);
- Contract.Invariant(cce.NonNullElements(importGraph));
+ Contract.Invariant(cce.NonNullElements(dependencies));
Contract.Invariant(cce.NonNullDictionaryAndValues(classMembers) && Contract.ForAll(classMembers.Values, v => cce.NonNullDictionaryAndValues(v)));
Contract.Invariant(cce.NonNullDictionaryAndValues(datatypeCtors) && Contract.ForAll(datatypeCtors.Values, v => cce.NonNullDictionaryAndValues(v)));
}
public void ResolveProgram(Program prog) {
Contract.Requires(prog != null);
- // register modules
- var modules = new Dictionary<string,ModuleDecl>();
- foreach (var m in prog.Modules) {
- if (modules.ContainsKey(m.Name)) {
- Error(m, "Duplicate module name: {0}", m.Name);
- } else {
- modules.Add(m.Name, m);
- }
- }
- // resolve refines and imports
- foreach (var m in prog.Modules) {
- importGraph.AddVertex(m);
- if (m.RefinementBaseName != null) {
- ModuleDecl other;
- if (!modules.TryGetValue(m.RefinementBaseName, out other)) {
- Error(m, "module {0} named as refinement base does not exist", m.RefinementBaseName);
- } else if (other == m) {
- Error(m, "module cannot refine itself: {0}", m.RefinementBaseName);
- } else {
- Contract.Assert(other != null); // follows from postcondition of TryGetValue
- importGraph.AddEdge(m, other);
- m.RefinementBase = other;
- }
- }
- foreach (string imp in m.ImportNames) {
- ModuleDecl other;
- if (!modules.TryGetValue(imp, out other)) {
- Error(m, "module {0} named among imports does not exist", imp);
- } else if (other == m) {
- Error(m, "module must not import itself: {0}", imp);
- } else {
- Contract.Assert(other != null); // follows from postcondition of TryGetValue
- importGraph.AddEdge(m, other);
- m.Imports.Add(other);
- }
- }
- }
+ var bindings = new ModuleBindings(null);
+ var b = BindModuleNames(prog.DefaultModuleDef, bindings);
+ bindings.BindName("_module", prog.DefaultModule , b);
+ if (ErrorCount > 0) { return; } // if there were errors, then the implict ModuleBindings data structure invariant
+ // is violated, so Processing dependencies will not succeed.
+ ProcessDependencies(prog.DefaultModule, b, dependencies);
// check for cycles in the import graph
- List<ModuleDecl> cycle = importGraph.TryFindCycle();
+ List<ModuleDecl> cycle = dependencies.TryFindCycle();
if (cycle != null) {
- string cy = "";
- string sep = "";
- foreach (ModuleDecl m in cycle) {
- cy = m.Name + sep + cy;
- sep = " -> ";
- }
- Error(cycle[0], "import graph contains a cycle: {0}", cy);
- return; // give up on trying to resolve anything else
+ var cy = Util.Comma(" -> ", cycle, m => m.Name);
+ Error(cycle[0], "module definition contains a cycle (note: parent modules implicitly depend on submodules): {0}", cy);
}
+ if (ErrorCount > 0) { return; } // give up on trying to resolve anything else
// fill in module heights
- List<ModuleDecl> mm = importGraph.TopologicallySortedComponents();
- Contract.Assert(mm.Count == prog.Modules.Count); // follows from the fact that there are no cycles
+ List<ModuleDecl> sortedDecls = dependencies.TopologicallySortedComponents();
int h = 0;
- foreach (ModuleDecl m in mm) {
+ foreach (ModuleDecl m in sortedDecls) {
m.Height = h;
+ if (m is LiteralModuleDecl) {
+ var mdef = ((LiteralModuleDecl)m).ModuleDef;
+ mdef.Height = h;
+ prog.Modules.Add(mdef);
+ }
h++;
}
- // register top-level declarations
- var rewriters = new List<IRewriter>();
- // The following line could be generalized to allow rewriter plug-ins; to support such, just add command-line
- // switches and .Add to "rewriters" here.
- rewriters.Add(new AutoContractsRewriter());
- rewriters.Add(new RefinementTransformer(this));
-
- var systemNameInfo = RegisterTopLevelDecls(prog.BuiltIns.SystemModule.TopLevelDecls);
- var moduleNameInfo = new ModuleNameInformation[h];
- foreach (var m in mm) {
- rewriters.Iter(r => r.PreResolve(m));
-
- moduleNameInfo[m.Height] = RegisterTopLevelDecls(m.TopLevelDecls);
-
- // set up environment
- ModuleNameInformation info = ModuleNameInformation.Merge(m, systemNameInfo, moduleNameInfo);
- classes = info.Classes;
- allDatatypeCtors = info.Ctors;
- // resolve
- var datatypeDependencies = new Graph<IndDatatypeDecl>();
- int prevErrorCount = ErrorCount;
- ResolveTopLevelDecls_Signatures(m.TopLevelDecls, datatypeDependencies);
- if (prevErrorCount == ErrorCount) {
+ var refinementTransformer = new RefinementTransformer(this);
+
+ //Rewriter rewriter = new AutoContractsRewriter();
+ var systemNameInfo = RegisterTopLevelDecls(prog.BuiltIns.SystemModule);
+ foreach (var decl in sortedDecls) {
+ if (decl is LiteralModuleDecl) {
+ // The declaration is a literal module, so it has members and such that we need
+ // to resolve. First we do refinement transformation. Then we construct the signature
+ // of the module. This is the public, externally visible signature. Then we add in
+ // everything that the system defines, as well as any "import" (i.e. "opened" modules)
+ // directives (currently not supported, but this is where we would do it.) This signature,
+ // which is only used while resolving the members of the module is stored in the (basically)
+ // global variable moduleInfo. Then the signatures of the module members are resolved, followed
+ // by the bodies.
+ var literalDecl = (LiteralModuleDecl)decl;
+ var m = (literalDecl).ModuleDef;
+ //rewriter.PreResolve(m);
+ ModuleSignature refinedSig = null;
+ if (m.RefinementBaseRoot != null) {
+ if (ResolvePath(m.RefinementBaseRoot, m.RefinementBaseName, out refinedSig)) {
+ if (refinedSig.ModuleDef != null) {
+ m.RefinementBase = refinedSig.ModuleDef;
+ refinementTransformer.PreResolve(m);
+ } else {
+ Error(m.RefinementBaseName[0], "module ({0}) named as refinement base is not a literal module or simple reference to a literal module", Util.Comma(".", m.RefinementBaseName, x => x.val));
+ }
+ } else {
+ Error(m.RefinementBaseName[0], "module ({0}) named as refinement base does not exist", Util.Comma(".", m.RefinementBaseName, x => x.val));
+ }
+ }
+ literalDecl.Signature = RegisterTopLevelDecls(m);
+ literalDecl.Signature.Refines = refinedSig;
+ // set up environment
+ moduleInfo = MergeSignature(literalDecl.Signature, systemNameInfo);
+ // resolve
+ var datatypeDependencies = new Graph<IndDatatypeDecl>();
+ int prevErrorCount = ErrorCount;
+ ResolveTopLevelDecls_Signatures(m.TopLevelDecls, datatypeDependencies);
+ if (ErrorCount == prevErrorCount)
ResolveTopLevelDecls_Meat(m.TopLevelDecls, datatypeDependencies);
- }
- // tear down
- classes = null;
- allDatatypeCtors = null;
- // give rewriters a chance to do processing
- rewriters.Iter(r => r.PostResolve(m));
- }
+ refinementTransformer.PostResolve(m);
+ // give rewriter a chance to do processing
+ //rewriter.PostResolve(m);
+ } else if (decl is AliasModuleDecl) {
+ var alias = (AliasModuleDecl)decl;
+ // resolve the path
+ ModuleSignature p;
+ if (ResolvePath(alias.Root, alias.Path, out p)) {
+ alias.Signature = p;
+ } else {
+ alias.Signature = new ModuleSignature(); // there was an error, give it a valid but empty signature
+ }
+ } else if (decl is AbstractModuleDecl) {
+ var abs = (AbstractModuleDecl)decl;
+ ModuleSignature p; ModuleDefinition mod;
+ if (ResolvePath(abs.Root, abs.Path, out p)) {
+ abs.Signature = MakeAbstractSignature(p, abs.Name, abs.Height, out mod);
+ abs.OriginalSignature = p;
+ moduleInfo = MergeSignature(abs.Signature, systemNameInfo);
+ // resolve
+ var datatypeDependencies = new Graph<IndDatatypeDecl>();
+ ResolveTopLevelDecls_Signatures(mod.TopLevelDecls, datatypeDependencies);
+ ResolveTopLevelDecls_Meat(mod.TopLevelDecls, datatypeDependencies);
+ prog.Modules.Add(mod);
+ } else {
+ abs.Signature = new ModuleSignature(); // there was an error, give it a valid but empty signature
+ }
+ } else { Contract.Assert(false); }
+ Contract.Assert(decl.Signature != null);
+ }
// compute IsRecursive bit for mutually recursive functions
- foreach (ModuleDecl m in mm) {
+ foreach (ModuleDefinition m in prog.Modules) {
foreach (TopLevelDecl decl in m.TopLevelDecls) {
ClassDecl cl = decl as ClassDecl;
if (cl != null) {
@@ -219,72 +228,159 @@ namespace Microsoft.Dafny {
}
}
}
+
}
- class ModuleNameInformation
- {
- public readonly Dictionary<string, TopLevelDecl> Classes = new Dictionary<string, TopLevelDecl>();
- public readonly Dictionary<string, Tuple<DatatypeCtor, bool>> Ctors = new Dictionary<string,Tuple<DatatypeCtor,bool>>();
-
- public static ModuleNameInformation Merge(ModuleDecl m, ModuleNameInformation system, ModuleNameInformation[] modules) {
- var info = new ModuleNameInformation();
- // add the system-declared information, among which we know there are no duplicates
- foreach (var kv in system.Classes) {
- info.Classes.Add(kv.Key, kv.Value);
- }
- foreach (var kv in system.Ctors) {
- info.Ctors.Add(kv.Key, kv.Value);
- }
- // for each imported module, add its information, noting any duplicates
- foreach (var im in m.Imports) {
- Contract.Assume(0 <= im.Height && im.Height < m.Height);
- var import = modules[im.Height];
- // classes:
- foreach (var kv in import.Classes) {
- TopLevelDecl d;
- if (info.Classes.TryGetValue(kv.Key, out d)) {
- info.Classes[kv.Key] = new AmbiguousTopLevelDecl(m, d, kv.Value);
- } else {
- info.Classes.Add(kv.Key, kv.Value);
- }
+
+ public class ModuleBindings {
+ private ModuleBindings parent;
+ private Dictionary<string, ModuleDecl> modules;
+ private Dictionary<string, ModuleBindings> bindings;
+
+ public ModuleBindings(ModuleBindings p) {
+ parent = p;
+ modules = new Dictionary<string, ModuleDecl>();
+ bindings = new Dictionary<string, ModuleBindings>();
+ }
+ public bool BindName(string name, ModuleDecl subModule, ModuleBindings b) {
+ if (modules.ContainsKey(name)) {
+ return false;
+ } else {
+ modules.Add(name, subModule);
+ bindings.Add(name, b);
+ return true;
+ }
+ }
+ public bool TryLookup(IToken name, out ModuleDecl m) {
+ Contract.Requires(name != null);
+ if (modules.TryGetValue(name.val, out m)) {
+ return true;
+ } else if (parent != null) {
+ return parent.TryLookup(name, out m);
+ } else return false;
+ }
+ public bool TryLookupLocal(IToken name, out ModuleDecl m) {
+ Contract.Requires(name != null);
+ if (modules.TryGetValue(name.val, out m)) {
+ return true;
+ } else return false;
+ }
+ public IEnumerable<ModuleDecl> ModuleList {
+ get { return modules.Values; }
+ }
+ public ModuleBindings SubBindings(string name) {
+ ModuleBindings v = null;
+ bindings.TryGetValue(name, out v);
+ return v;
+ }
+ }
+ private ModuleBindings BindModuleNames(ModuleDefinition moduleDecl, ModuleBindings parentBindings) {
+ var bindings = new ModuleBindings(parentBindings);
+
+ foreach (var tld in moduleDecl.TopLevelDecls) {
+ if (tld is LiteralModuleDecl) {
+ var subdecl = (LiteralModuleDecl)tld;
+ var subBindings = BindModuleNames(subdecl.ModuleDef, bindings);
+ if (!bindings.BindName(subdecl.Name, subdecl, subBindings)) {
+ Error(subdecl.Module, "Duplicate module name: {0}", subdecl.Name);
}
- // constructors:
- foreach (var kv in import.Ctors) {
- Tuple<DatatypeCtor, bool> pair;
- if (info.Ctors.TryGetValue(kv.Key, out pair)) {
- // mark it as a duplicate
- info.Ctors[kv.Key] = new Tuple<DatatypeCtor, bool>(pair.Item1, true);
- } else {
- // add new
- info.Ctors.Add(kv.Key, kv.Value);
- }
+ } else if (tld is AbstractModuleDecl) {
+ var subdecl = (AbstractModuleDecl)tld;
+ if (!bindings.BindName(subdecl.Name, subdecl, null)) {
+ Error(subdecl.Module, "Duplicate module name: {0}", subdecl.Name);
+ }
+ } else if (tld is AliasModuleDecl) {
+ var subdecl = (AliasModuleDecl)tld;
+ if (!bindings.BindName(subdecl.Name, subdecl, null)) {
+ Error(subdecl.Module, "Duplicate module name: {0}", subdecl.Name);
}
}
- // finally, for the module itself, let its information override whatever is imported
- foreach (var kv in modules[m.Height].Classes) {
- info.Classes[kv.Key] = kv.Value;
+ }
+ return bindings;
+ }
+
+ private void ProcessDependenciesDefinition(ModuleDecl decl, ModuleDefinition m, ModuleBindings bindings, Graph<ModuleDecl> dependencies) {
+ if (m.RefinementBaseName != null) {
+ ModuleDecl other;
+ if (!bindings.TryLookup(m.RefinementBaseName[0], out other)) {
+ Error(m, "module {0} named as refinement base does not exist", m.RefinementBaseName[0].val);
+ } else if (other is LiteralModuleDecl && ((LiteralModuleDecl)other).ModuleDef == m) {
+ Error(m, "module cannot refine itself: {0}", m.RefinementBaseName[0].val);
+ } else {
+ Contract.Assert(other != null); // follows from postcondition of TryGetValue
+ dependencies.AddEdge(decl, other);
+ m.RefinementBaseRoot = other;
+ }
+ }
+ foreach (var toplevel in m.TopLevelDecls) {
+ if (toplevel is ModuleDecl) {
+ var d = (ModuleDecl)toplevel;
+ dependencies.AddEdge(decl, d);
+ var subbindings = bindings.SubBindings(d.Name);
+ ProcessDependencies(d, subbindings ?? bindings, dependencies);
}
- foreach (var kv in modules[m.Height].Ctors) {
- info.Ctors[kv.Key] = kv.Value;
+ }
+ }
+ private void ProcessDependencies(ModuleDecl moduleDecl, ModuleBindings bindings, Graph<ModuleDecl> dependencies) {
+ dependencies.AddVertex(moduleDecl);
+ if (moduleDecl is LiteralModuleDecl) {
+ ProcessDependenciesDefinition(moduleDecl, ((LiteralModuleDecl)moduleDecl).ModuleDef, bindings, dependencies);
+ } else if (moduleDecl is AliasModuleDecl) {
+ var alias = moduleDecl as AliasModuleDecl;
+ ModuleDecl root;
+ if (!bindings.TryLookup(alias.Path[0], out root))
+ Error(alias.tok, "module {0} does not exist", Util.Comma(".", alias.Path, x => x.val));
+ else {
+ dependencies.AddEdge(moduleDecl, root);
+ alias.Root = root;
+ }
+ } else if (moduleDecl is AbstractModuleDecl) {
+ var abs = moduleDecl as AbstractModuleDecl;
+ ModuleDecl root;
+ if (!bindings.TryLookup(abs.Path[0], out root))
+ Error(abs.tok, "module {0} does not exist", Util.Comma(".", abs.Path, x => x.val));
+ else {
+ dependencies.AddEdge(moduleDecl, root);
+ abs.Root = root;
}
- return info;
}
}
- ModuleNameInformation RegisterTopLevelDecls(List<TopLevelDecl> declarations) {
- Contract.Requires(declarations != null);
- var info = new ModuleNameInformation();
+ public static ModuleSignature MergeSignature(ModuleSignature m, ModuleSignature system) {
+ var info = new ModuleSignature();
+ // add the system-declared information, among which we know there are no duplicates
+ foreach (var kv in system.TopLevels) {
+ info.TopLevels.Add(kv.Key, kv.Value);
+ }
+ foreach (var kv in system.Ctors) {
+ info.Ctors.Add(kv.Key, kv.Value);
+ }
+ // add for the module itself
+ foreach (var kv in m.TopLevels) {
+ info.TopLevels[kv.Key] = kv.Value;
+ }
+ foreach (var kv in m.Ctors) {
+ info.Ctors[kv.Key] = kv.Value;
+ }
+ return info;
+ }
+ ModuleSignature RegisterTopLevelDecls(ModuleDefinition moduleDef) {
+ Contract.Requires(moduleDef != null);
+ var sig = new ModuleSignature();
+ sig.ModuleDef = moduleDef;
+ List<TopLevelDecl> declarations = moduleDef.TopLevelDecls;
foreach (TopLevelDecl d in declarations) {
Contract.Assert(d != null);
- // register the class/datatype name
- if (info.Classes.ContainsKey(d.Name)) {
+ // register the class/datatype/module name
+ if (sig.TopLevels.ContainsKey(d.Name)) {
Error(d, "Duplicate name of top-level declaration: {0}", d.Name);
} else {
- info.Classes.Add(d.Name, d);
+ sig.TopLevels.Add(d.Name, d);
}
-
- if (d is ArbitraryTypeDecl) {
+ if (d is ModuleDecl) {
+ // nothing to do
+ } else if (d is ArbitraryTypeDecl) {
// nothing more to register
} else if (d is ClassDecl) {
@@ -334,12 +430,12 @@ namespace Microsoft.Dafny {
// also register the constructor name globally
Tuple<DatatypeCtor, bool> pair;
- if (info.Ctors.TryGetValue(ctor.Name, out pair)) {
+ if (sig.Ctors.TryGetValue(ctor.Name, out pair)) {
// mark it as a duplicate
- info.Ctors[ctor.Name] = new Tuple<DatatypeCtor, bool>(pair.Item1, true);
+ sig.Ctors[ctor.Name] = new Tuple<DatatypeCtor, bool>(pair.Item1, true);
} else {
// add new
- info.Ctors.Add(ctor.Name, new Tuple<DatatypeCtor, bool>(ctor, false));
+ sig.Ctors.Add(ctor.Name, new Tuple<DatatypeCtor, bool>(ctor, false));
}
}
}
@@ -361,9 +457,333 @@ namespace Microsoft.Dafny {
}
}
}
- return info;
+ return sig;
+ }
+
+ private ModuleSignature MakeAbstractSignature(ModuleSignature p, string Name, int Height, out ModuleDefinition mod) {
+ mod = new ModuleDefinition(Token.NoToken, Name+".Abs", true, true, null, null);
+ mod.Height = Height;
+ foreach (var kv in p.TopLevels) {
+ mod.TopLevelDecls.Add(CloneDeclaration(kv.Value, mod));
+ }
+ var sig = RegisterTopLevelDecls(mod);
+ sig.Refines = p.Refines;
+ return sig;
+ }
+ TopLevelDecl CloneDeclaration(TopLevelDecl d, ModuleDefinition m) {
+ Contract.Requires(d != null);
+ Contract.Requires(m != null);
+
+ if (d is ArbitraryTypeDecl) {
+ var dd = (ArbitraryTypeDecl)d;
+ return new ArbitraryTypeDecl(dd.tok, dd.Name, m, dd.EqualitySupport, null);
+ } else if (d is IndDatatypeDecl) {
+ var dd = (IndDatatypeDecl)d;
+ var tps = dd.TypeArgs.ConvertAll(CloneTypeParam);
+ var ctors = dd.Ctors.ConvertAll(CloneCtor);
+ var dt = new IndDatatypeDecl(dd.tok, dd.Name, m, tps, ctors, null);
+ return dt;
+ } else if (d is CoDatatypeDecl) {
+ var dd = (CoDatatypeDecl)d;
+ var tps = dd.TypeArgs.ConvertAll(CloneTypeParam);
+ var ctors = dd.Ctors.ConvertAll(CloneCtor);
+ var dt = new CoDatatypeDecl(dd.tok, dd.Name, m, tps, ctors, null);
+ return dt;
+ } else if (d is ClassDecl) {
+ var dd = (ClassDecl)d;
+ var tps = dd.TypeArgs.ConvertAll(CloneTypeParam);
+ var mm = dd.Members.ConvertAll(CloneMember);
+ var cl = new ClassDecl(dd.tok, dd.Name, m, tps, mm, null);
+ return cl;
+ } else if (d is ModuleDecl) {
+ if (d is LiteralModuleDecl) {
+ return new LiteralModuleDecl(((LiteralModuleDecl)d).ModuleDef, m);
+ } else if (d is AliasModuleDecl) {
+ var a = (AliasModuleDecl)d;
+ var alias = new AliasModuleDecl(a.Path, a.tok, m);
+ alias.ModuleReference = a.ModuleReference;
+ alias.Signature = a.Signature;
+ return alias;
+ }
+ Contract.Assert(false); // unexpected declaration
+ return null; // to please compiler
+ } else {
+ Contract.Assert(false); // unexpected declaration
+ return null; // to please compiler
+ }
+ }
+ MemberDecl CloneMember(MemberDecl member) {
+ if (member is Field) {
+ var f = (Field)member;
+ return new Field(f.tok, f.Name, f.IsGhost, f.IsMutable, CloneType(f.Type), null);
+ } else if (member is Function) {
+ var f = (Function)member;
+ return CloneFunction(f.tok, f, f.IsGhost);
+ } else {
+ var m = (Method)member;
+ return CloneMethod(m);
+ }
+ }
+ TypeParameter CloneTypeParam(TypeParameter tp) {
+ return new TypeParameter(tp.tok, tp.Name);
+ }
+
+ DatatypeCtor CloneCtor(DatatypeCtor ct) {
+ return new DatatypeCtor(ct.tok, ct.Name, ct.Formals.ConvertAll(CloneFormal), null);
+ }
+ Formal CloneFormal(Formal formal) {
+ return new Formal(formal.tok, formal.Name, CloneType(formal.Type), formal.InParam, formal.IsGhost);
+ }
+ Type CloneType(Type t) {
+ if (t is BasicType) {
+ return t;
+ } else if (t is SetType) {
+ var tt = (SetType)t;
+ return new SetType(CloneType(tt.Arg));
+ } else if (t is SeqType) {
+ var tt = (SeqType)t;
+ return new SeqType(CloneType(tt.Arg));
+ } else if (t is MultiSetType) {
+ var tt = (MultiSetType)t;
+ return new MultiSetType(CloneType(tt.Arg));
+ } else if (t is MapType) {
+ var tt = (MapType)t;
+ return new MapType(CloneType(tt.Domain), CloneType(tt.Range));
+ } else if (t is UserDefinedType) {
+ var tt = (UserDefinedType)t;
+ return new UserDefinedType(tt.tok, tt.Name, tt.TypeArgs.ConvertAll(CloneType), tt.ModuleName == null ? null : tt.ModuleName);
+ } else if (t is InferredTypeProxy) {
+ return new InferredTypeProxy();
+ } else {
+ Contract.Assert(false); // unexpected type (e.g., no other type proxies are expected at this time)
+ return null; // to please compiler
+ }
+ }
+ Function CloneFunction(IToken tok, Function f, bool isGhost) {
+
+ var tps = f.TypeArgs.ConvertAll(CloneTypeParam);
+ var formals = f.Formals.ConvertAll(CloneFormal);
+ var req = f.Req.ConvertAll(CloneExpr);
+ var reads = f.Reads.ConvertAll(CloneFrameExpr);
+ var decreases = CloneSpecExpr(f.Decreases);
+
+ var ens = f.Ens.ConvertAll(CloneExpr);
+
+ Expression body = CloneExpr(f.Body);
+
+ if (f is Predicate) {
+ return new Predicate(tok, f.Name, f.IsStatic, isGhost, tps, f.OpenParen, formals,
+ req, reads, ens, decreases, body, false, null, false);
+ } else {
+ return new Function(tok, f.Name, f.IsStatic, isGhost, tps, f.OpenParen, formals, CloneType(f.ResultType),
+ req, reads, ens, decreases, body, null, false);
+ }
+ }
+ Method CloneMethod(Method m) {
+ Contract.Requires(m != null);
+
+ var tps = m.TypeArgs.ConvertAll(CloneTypeParam);
+ var ins = m.Ins.ConvertAll(CloneFormal);
+ var req = m.Req.ConvertAll(CloneMayBeFreeExpr);
+ var mod = CloneSpecFrameExpr(m.Mod);
+ var decreases = CloneSpecExpr(m.Decreases);
+
+ var ens = m.Ens.ConvertAll(CloneMayBeFreeExpr);
+
+ if (m is Constructor) {
+ return new Constructor(m.tok, m.Name, tps, ins,
+ req, mod, ens, decreases, null, null, false);
+ } else {
+ return new Method(m.tok, m.Name, m.IsStatic, m.IsGhost, tps, ins, m.Outs.ConvertAll(CloneFormal),
+ req, mod, ens, decreases, null, null, false);
+ }
+ }
+ Specification<Expression> CloneSpecExpr(Specification<Expression> spec) {
+ var ee = spec.Expressions == null ? null : spec.Expressions.ConvertAll(CloneExpr);
+ return new Specification<Expression>(ee, null);
+ }
+ Specification<FrameExpression> CloneSpecFrameExpr(Specification<FrameExpression> frame) {
+ var ee = frame.Expressions == null ? null : frame.Expressions.ConvertAll(CloneFrameExpr);
+ return new Specification<FrameExpression>(ee, null);
+ }
+ FrameExpression CloneFrameExpr(FrameExpression frame) {
+ return new FrameExpression(CloneExpr(frame.E), frame.FieldName);
+ }
+ MaybeFreeExpression CloneMayBeFreeExpr(MaybeFreeExpression expr) {
+ return new MaybeFreeExpression(CloneExpr(expr.E), expr.IsFree);
}
+ BoundVar CloneBoundVar(BoundVar bv) {
+ return new BoundVar((bv.tok), bv.Name, CloneType(bv.Type));
+ }
+ Expression CloneExpr(Expression expr) {
+ if (expr == null) {
+ return null;
+ } else if (expr is LiteralExpr) {
+ var e = (LiteralExpr)expr;
+ if (e.Value == null) {
+ return new LiteralExpr((e.tok));
+ } else if (e.Value is bool) {
+ return new LiteralExpr((e.tok), (bool)e.Value);
+ } else {
+ return new LiteralExpr((e.tok), (BigInteger)e.Value);
+ }
+
+ } else if (expr is ThisExpr) {
+ if (expr is ImplicitThisExpr) {
+ return new ImplicitThisExpr((expr.tok));
+ } else {
+ return new ThisExpr((expr.tok));
+ }
+
+ } else if (expr is IdentifierExpr) {
+ var e = (IdentifierExpr)expr;
+ return new IdentifierExpr((e.tok), e.Name);
+
+ } else if (expr is DatatypeValue) {
+ var e = (DatatypeValue)expr;
+ return new DatatypeValue((e.tok), e.DatatypeName, e.MemberName, e.Arguments.ConvertAll(CloneExpr));
+
+ } else if (expr is DisplayExpression) {
+ DisplayExpression e = (DisplayExpression)expr;
+ if (expr is SetDisplayExpr) {
+ return new SetDisplayExpr((e.tok), e.Elements.ConvertAll(CloneExpr));
+ } else if (expr is MultiSetDisplayExpr) {
+ return new MultiSetDisplayExpr((e.tok), e.Elements.ConvertAll(CloneExpr));
+ } else {
+ Contract.Assert(expr is SeqDisplayExpr);
+ return new SeqDisplayExpr((e.tok), e.Elements.ConvertAll(CloneExpr));
+ }
+ } else if (expr is MapDisplayExpr) {
+ MapDisplayExpr e = (MapDisplayExpr)expr;
+ List<ExpressionPair> pp = new List<ExpressionPair>();
+ foreach (ExpressionPair p in e.Elements) {
+ pp.Add(new ExpressionPair(CloneExpr(p.A), CloneExpr(p.B)));
+ }
+ return new MapDisplayExpr((expr.tok), pp);
+ } else if (expr is ExprDotName) {
+ var e = (ExprDotName)expr;
+ return new ExprDotName((e.tok), CloneExpr(e.Obj), e.SuffixName);
+
+ } else if (expr is FieldSelectExpr) {
+ var e = (FieldSelectExpr)expr;
+ return new FieldSelectExpr((e.tok), CloneExpr(e.Obj), e.FieldName);
+
+ } else if (expr is SeqSelectExpr) {
+ var e = (SeqSelectExpr)expr;
+ return new SeqSelectExpr((e.tok), e.SelectOne, CloneExpr(e.Seq), CloneExpr(e.E0), CloneExpr(e.E1));
+
+ } else if (expr is MultiSelectExpr) {
+ var e = (MultiSelectExpr)expr;
+ return new MultiSelectExpr((e.tok), CloneExpr(e.Array), e.Indices.ConvertAll(CloneExpr));
+
+ } else if (expr is SeqUpdateExpr) {
+ var e = (SeqUpdateExpr)expr;
+ return new SeqUpdateExpr((e.tok), CloneExpr(e.Seq), CloneExpr(e.Index), CloneExpr(e.Value));
+
+ } else if (expr is FunctionCallExpr) {
+ var e = (FunctionCallExpr)expr;
+ return new FunctionCallExpr((e.tok), e.Name, CloneExpr(e.Receiver), e.OpenParen == null ? null : (e.OpenParen), e.Args.ConvertAll(CloneExpr));
+
+ } else if (expr is OldExpr) {
+ var e = (OldExpr)expr;
+ return new OldExpr((e.tok), CloneExpr(e.E));
+
+ } else if (expr is MultiSetFormingExpr) {
+ var e = (MultiSetFormingExpr)expr;
+ return new MultiSetFormingExpr((e.tok), CloneExpr(e.E));
+
+ } else if (expr is FreshExpr) {
+ var e = (FreshExpr)expr;
+ return new FreshExpr((e.tok), CloneExpr(e.E));
+
+ } else if (expr is AllocatedExpr) {
+ var e = (AllocatedExpr)expr;
+ return new AllocatedExpr((e.tok), CloneExpr(e.E));
+
+ } else if (expr is UnaryExpr) {
+ var e = (UnaryExpr)expr;
+ return new UnaryExpr((e.tok), e.Op, CloneExpr(e.E));
+
+ } else if (expr is BinaryExpr) {
+ var e = (BinaryExpr)expr;
+ return new BinaryExpr((e.tok), e.Op, CloneExpr(e.E0), CloneExpr(e.E1));
+
+ } else if (expr is ChainingExpression) {
+ var e = (ChainingExpression)expr;
+ return CloneExpr(e.E); // just clone the desugaring, since it's already available
+
+ } else if (expr is LetExpr) {
+ var e = (LetExpr)expr;
+ return new LetExpr((e.tok), e.Vars.ConvertAll(CloneBoundVar), e.RHSs.ConvertAll(CloneExpr), CloneExpr(e.Body));
+
+ } else if (expr is ComprehensionExpr) {
+ var e = (ComprehensionExpr)expr;
+ var tk = (e.tok);
+ var bvs = e.BoundVars.ConvertAll(CloneBoundVar);
+ var range = CloneExpr(e.Range);
+ var term = CloneExpr(e.Term);
+ if (e is ForallExpr) {
+ return new ForallExpr(tk, bvs, range, term, null);
+ } else if (e is ExistsExpr) {
+ return new ExistsExpr(tk, bvs, range, term, null);
+ } else if (e is MapComprehension) {
+ return new MapComprehension(tk, bvs, range, term);
+ } else {
+ Contract.Assert(e is SetComprehension);
+ return new SetComprehension(tk, bvs, range, term);
+ }
+
+ } else if (expr is WildcardExpr) {
+ return new WildcardExpr((expr.tok));
+
+ } else if (expr is PredicateExpr) {
+ var e = (PredicateExpr)expr;
+ if (e is AssertExpr) {
+ return new AssertExpr((e.tok), CloneExpr(e.Guard), CloneExpr(e.Body));
+ } else {
+ Contract.Assert(e is AssumeExpr);
+ return new AssumeExpr((e.tok), CloneExpr(e.Guard), CloneExpr(e.Body));
+ }
+
+ } else if (expr is ITEExpr) {
+ var e = (ITEExpr)expr;
+ return new ITEExpr((e.tok), CloneExpr(e.Test), CloneExpr(e.Thn), CloneExpr(e.Els));
+
+ } else if (expr is ParensExpression) {
+ var e = (ParensExpression)expr;
+ return CloneExpr(e.E); // skip the parentheses in the clone
+
+ } else if (expr is IdentifierSequence) {
+ var e = (IdentifierSequence)expr;
+ var aa = e.Arguments == null ? null : e.Arguments.ConvertAll(CloneExpr);
+ return new IdentifierSequence(e.Tokens.ConvertAll(tk => (tk)), e.OpenParen == null ? null : (e.OpenParen), aa);
+
+ } else if (expr is MatchExpr) {
+ var e = (MatchExpr)expr;
+ return new MatchExpr((e.tok), CloneExpr(e.Source),
+ e.Cases.ConvertAll(c => new MatchCaseExpr((c.tok), c.Id, c.Arguments.ConvertAll(CloneBoundVar), CloneExpr(c.Body))));
+
+ } else {
+ Contract.Assert(false); throw new cce.UnreachableException(); // unexpected expression
+ }
+ }
+
+ private bool ResolvePath(ModuleDecl root, List<IToken> Path, out ModuleSignature p) {
+ p = root.Signature;
+ int i = 1;
+ while (i < Path.Count) {
+ ModuleSignature pp;
+ if (p.FindSubmodule(Path[i].val, out pp)) {
+ p = pp;
+ i++;
+ } else {
+ Error(Path[i], "module {0} does not exist", Path[i].val);
+ break;
+ }
+ }
+ return i == Path.Count;
+ }
public void ResolveTopLevelDecls_Signatures(List<TopLevelDecl/*!*/>/*!*/ declarations, Graph<IndDatatypeDecl/*!*/>/*!*/ datatypeDependencies) {
Contract.Requires(declarations != null);
Contract.Requires(datatypeDependencies != null); // more expensive check: Contract.Requires(cce.NonNullElements(datatypeDependencies));
@@ -375,6 +795,8 @@ namespace Microsoft.Dafny {
// nothing to do
} else if (d is ClassDecl) {
ResolveClassMemberTypes((ClassDecl)d);
+ } else if (d is ModuleDecl) {
+ // TODO: what goes here?
} else {
ResolveCtorTypes((DatatypeDecl)d, datatypeDependencies);
}
@@ -831,6 +1253,7 @@ namespace Microsoft.Dafny {
Scope<Statement>/*!*/ labeledStatements = new Scope<Statement>();
List<Statement> loopStack = new List<Statement>(); // the enclosing loops (from which it is possible to break out)
readonly Dictionary<Statement, bool> inSpecOnlyContext = new Dictionary<Statement, bool>(); // invariant: domain contain union of the domains of "labeledStatements" and "loopStack"
+
/// <summary>
/// Assumes type parameters have already been pushed
@@ -1435,23 +1858,15 @@ namespace Microsoft.Dafny {
} else if (t.ResolvedClass == null) { // this test is because 'array' is already resolved; TODO: an alternative would be to pre-populate 'classes' with built-in references types like 'array' (and perhaps in the future 'string')
TopLevelDecl d = null;
if (t.ModuleName != null) {
- foreach (var imp in currentClass.Module.Imports) {
- if (imp.Name == t.ModuleName.val) {
- // now search among the types declared in module "imp"
- foreach (var tld in imp.TopLevelDecls) { // this search is slow, but oh well
- if (tld.Name == t.Name) {
- // found the class
- d = tld;
- goto DONE_WITH_QUALIFIED_NAME;
- }
- }
- Error(t.tok, "Undeclared class name {0} in module {1}", t.Name, t.ModuleName.val);
- goto DONE_WITH_QUALIFIED_NAME;
+ ModuleSignature sig;
+ if (moduleInfo.FindSubmodule(t.ModuleName.val, out sig)) {
+ if (!sig.TopLevels.TryGetValue(t.Name, out d)) {
+ Error(t.tok, "The name does not exist in the given module");
}
+ } else {
+ Error(t.ModuleName, "Undeclared module name: {0} (did you forget a module import?)", t.ModuleName.val);
}
- Error(t.ModuleName, "Undeclared module name: {0} (did you forget a module import?)", t.ModuleName.val);
- DONE_WITH_QUALIFIED_NAME: ;
- } else if (!classes.TryGetValue(t.Name, out d)) {
+ } else if (!moduleInfo.TopLevels.TryGetValue(t.Name, out d)) {
Error(t.tok, "Undeclared top-level type or type parameter: {0} (did you forget a module import?)", t.Name);
}
@@ -2627,13 +3042,14 @@ namespace Microsoft.Dafny {
// Resolution termination check
if (method.EnclosingClass != null && callee.EnclosingClass != null) {
- ModuleDecl callerModule = method.EnclosingClass.Module;
- ModuleDecl calleeModule = callee.EnclosingClass.Module;
+ ModuleDefinition callerModule = method.EnclosingClass.Module;
+ ModuleDefinition calleeModule = callee.EnclosingClass.Module;
if (callerModule == calleeModule) {
// intra-module call; this is allowed; add edge in module's call graph
callerModule.CallGraph.AddEdge(method, callee);
} else {
- Contract.Assert(importGraph.Reaches(callerModule, calleeModule));
+ //Contract.Assert(dependencies.Reaches(callerModule, calleeModule));
+ //
}
}
}
@@ -3067,7 +3483,7 @@ namespace Microsoft.Dafny {
} else if (expr is DatatypeValue) {
DatatypeValue dtv = (DatatypeValue)expr;
TopLevelDecl d;
- if (!classes.TryGetValue(dtv.DatatypeName, out d)) {
+ if (!moduleInfo.TopLevels.TryGetValue(dtv.DatatypeName, out d)) {
Error(expr.tok, "Undeclared datatype: {0}", dtv.DatatypeName);
} else if (d is AmbiguousTopLevelDecl) {
Error(expr.tok, "The name {0} ambiguously refers to a type in one of the modules {1}", dtv.DatatypeName, ((AmbiguousTopLevelDecl)d).ModuleNames());
@@ -3345,7 +3761,7 @@ namespace Microsoft.Dafny {
case BinaryExpr.Opcode.Eq:
case BinaryExpr.Opcode.Neq:
- if (!CouldPossiblyBeSameType(e.E0.Type, e.E1.Type)) {
+ if (!ComparableTypes(e.E0.Type, e.E1.Type)) {
if (!UnifyTypes(e.E0.Type, e.E1.Type)) {
Error(expr, "arguments must have the same type (got {0} and {1})", e.E0.Type, e.E1.Type);
}
@@ -3740,6 +4156,31 @@ namespace Microsoft.Dafny {
}
}
+ private bool ComparableTypes(Type A, Type B) {
+ if (A.IsArrayType && B.IsArrayType) {
+ Type a = UserDefinedType.ArrayElementType(A);
+ Type b = UserDefinedType.ArrayElementType(B);
+ return CouldPossiblyBeSameType(a, b);
+ } else
+ if (A is UserDefinedType && B is UserDefinedType) {
+ UserDefinedType a = (UserDefinedType)A;
+ UserDefinedType b = (UserDefinedType)B;
+ if (a.ResolvedClass != null && b.ResolvedClass != null && a.ResolvedClass.Name == b.ResolvedClass.Name) {
+ if (a.TypeArgs.Count != b.TypeArgs.Count) {
+ return false; // this probably doesn't happen if the classes are the same.
+ }
+ for (int i = 0; i < a.TypeArgs.Count; i++) {
+ if (!CouldPossiblyBeSameType(a.TypeArgs[i], b.TypeArgs[i]))
+ return false;
+ }
+ // all parameters could be the same
+ return true;
+ }
+ // either we don't know what class it is yet, or the classes mismatch
+ return false;
+ }
+ return false;
+ }
private bool CouldPossiblyBeSameType(Type A, Type B) {
if (A.IsTypeParameter || B.IsTypeParameter) {
return true;
@@ -3934,8 +4375,8 @@ namespace Microsoft.Dafny {
// Resolution termination check
if (currentFunction != null && currentFunction.EnclosingClass != null && function.EnclosingClass != null) {
- ModuleDecl callerModule = currentFunction.EnclosingClass.Module;
- ModuleDecl calleeModule = function.EnclosingClass.Module;
+ ModuleDefinition callerModule = currentFunction.EnclosingClass.Module;
+ ModuleDefinition calleeModule = function.EnclosingClass.Module;
if (callerModule == calleeModule) {
// intra-module call; this is allowed; add edge in module's call graph
callerModule.CallGraph.AddEdge(currentFunction, function);
@@ -3943,7 +4384,7 @@ namespace Microsoft.Dafny {
currentFunction.IsRecursive = true; // self recursion (mutual recursion is determined elsewhere)
}
} else {
- Contract.Assert(importGraph.Reaches(callerModule, calleeModule));
+ //Contract.Assert(dependencies.Reaches(callerModule, calleeModule));
}
}
}
@@ -3957,9 +4398,11 @@ namespace Microsoft.Dafny {
CallRhs ResolveIdentifierSequence(IdentifierSequence e, bool twoState, bool allowMethodCall) {
// Look up "id" as follows:
// - local variable, parameter, or bound variable (if this clashes with something of interest, one can always rename the local variable locally)
- // - unamibugous type name (class or datatype or arbitrary-type) (if two imported types have the same name, an error message is produced here)
+ // - unamibugous type/module name (class, datatype, sub-module (including submodules of imports) or arbitrary-type)
+ // (if two imported types have the same name, an error message is produced here)
// - unambiguous constructor name of a datatype (if two constructors have the same name, an error message is produced here)
- // - field name (with implicit receiver) (if the field is ocluded by anything above, one can use an explicit "this.")
+ // - imported module name
+ // - field name (with implicit receiver) (if the field is occluded by anything above, one can use an explicit "this.")
// Note, at present, modules do not give rise to new namespaces, which is something that should
// be changed in the language when modules are given more attention.
Expression r = null; // resolved version of e
@@ -3976,7 +4419,7 @@ namespace Microsoft.Dafny {
ResolveExpression(r, twoState);
r = ResolveSuffix(r, e, 1, twoState, allowMethodCall, out call);
- } else if (classes.TryGetValue(id.val, out decl)) {
+ } else if (moduleInfo.TopLevels.TryGetValue(id.val, out decl)) {
if (decl is AmbiguousTopLevelDecl) {
Error(id, "The name {0} ambiguously refers to a type in one of the modules {1}", id.val, ((AmbiguousTopLevelDecl)decl).ModuleNames());
} else if (e.Tokens.Count == 1 && e.Arguments == null) {
@@ -3992,6 +4435,12 @@ namespace Microsoft.Dafny {
var cd = (ClassDecl)decl;
r = ResolveSuffix(new StaticReceiverExpr(id, cd), e, 1, twoState, allowMethodCall, out call);
+ } else if (decl is ModuleDecl) {
+ // ----- root is a submodule
+ if (!(1 < e.Tokens.Count)) {
+ Error(e.tok, "module {0} cannot be used here", ((ModuleDecl)decl).Name);
+ }
+ call = ResolveIdentifierSequenceModuleScope(e, 1, ((ModuleDecl)decl).Signature, twoState, allowMethodCall);
} else {
// ----- root is a datatype
var dt = (DatatypeDecl)decl; // otherwise, unexpected TopLevelDecl
@@ -4003,7 +4452,7 @@ namespace Microsoft.Dafny {
}
}
- } else if (allDatatypeCtors.TryGetValue(id.val, out pair)) {
+ } else if (moduleInfo.Ctors.TryGetValue(id.val, out pair)) {
// ----- root is a datatype constructor
if (pair.Item2) {
// there is more than one constructor with this name
@@ -4049,6 +4498,59 @@ namespace Microsoft.Dafny {
return call;
}
+ CallRhs ResolveIdentifierSequenceModuleScope(IdentifierSequence e, int p, ModuleSignature info, bool twoState, bool allowMethodCall) {
+ // Look up "id" as follows:
+ // - unamibugous type/module name (class, datatype, sub-module (including submodules of imports) or arbitrary-type)
+ // (if two imported types have the same name, an error message is produced here)
+ // This is used to look up names that appear after a dot in a sequence identifier. For example, in X.M.*, M should be looked up in X, but
+ // should not consult the local scope. This distingushes this from the above, in that local scope, imported modules, etc. are ignored.
+ Contract.Requires(p < e.Tokens.Count);
+ Expression r = null; // resolved version of e
+ CallRhs call = null;
+
+ TopLevelDecl decl;
+ var id = e.Tokens[p];
+ if (info.TopLevels.TryGetValue(id.val, out decl)) {
+ if (decl is AmbiguousTopLevelDecl) {
+ Error(id, "The name {0} ambiguously refers to a something in one of the modules {1}", id.val, ((AmbiguousTopLevelDecl)decl).ModuleNames());
+ } else if (decl is ClassDecl) {
+ // ----- root is a class
+ var cd = (ClassDecl)decl;
+ r = ResolveSuffix(new StaticReceiverExpr(id, cd), e, p + 1, twoState, allowMethodCall, out call);
+
+ } else if (decl is ModuleDecl) {
+ // ----- root is a submodule
+ if (!(p + 1 < e.Tokens.Count)) {
+ Error(e.tok, "module {0} cannot be used here", ((ModuleDecl)decl).Name);
+ }
+ call = ResolveIdentifierSequenceModuleScope(e, p + 1, ((ModuleDecl)decl).Signature, twoState, allowMethodCall);
+ } else {
+ // ----- root is a datatype
+ var dt = (DatatypeDecl)decl; // otherwise, unexpected TopLevelDecl
+ var args = (e.Tokens.Count == p + 2 ? e.Arguments : null) ?? new List<Expression>();
+ r = new DatatypeValue(id, id.val, e.Tokens[p + 1].val, args);
+ ResolveExpression(r, twoState);
+ if (e.Tokens.Count != p + 2) {
+ r = ResolveSuffix(r, e, p + 2, twoState, allowMethodCall, out call);
+ }
+ }
+ } else {
+ Error(id, "unresolved identifier: {0}", id.val);
+ // resolve arguments, if any
+ if (e.Arguments != null) {
+ foreach (var arg in e.Arguments) {
+ ResolveExpression(arg, twoState);
+ }
+ }
+ }
+
+ if (r != null) {
+ e.ResolvedExpression = r;
+ e.Type = r.Type;
+ }
+ return call;
+ }
+
/// <summary>
/// Given resolved expression "r" and unresolved expressions e.Tokens[p..] and e.Arguments.
/// Returns a resolved version of the expression:
@@ -4837,7 +5339,7 @@ namespace Microsoft.Dafny {
class CoCallResolution
{
- readonly ModuleDecl currentModule;
+ readonly ModuleDefinition currentModule;
readonly Function currentFunction;
readonly bool dealsWithCodatatypes;
diff --git a/Source/Dafny/Rewriter.cs b/Source/Dafny/Rewriter.cs
index e04c5e9b..af41a679 100644
--- a/Source/Dafny/Rewriter.cs
+++ b/Source/Dafny/Rewriter.cs
@@ -7,16 +7,16 @@ namespace Microsoft.Dafny
[ContractClass(typeof(IRewriterContracts))]
public interface IRewriter
{
- void PreResolve(ModuleDecl m);
- void PostResolve(ModuleDecl m);
+ void PreResolve(ModuleDefinition m);
+ void PostResolve(ModuleDefinition m);
}
[ContractClassFor(typeof(IRewriter))]
abstract class IRewriterContracts : IRewriter
{
- public void PreResolve(ModuleDecl m) {
+ public void PreResolve(ModuleDefinition m) {
Contract.Requires(m != null);
}
- public void PostResolve(ModuleDecl m) {
+ public void PostResolve(ModuleDefinition m) {
Contract.Requires(m != null);
}
}
@@ -61,7 +61,7 @@ namespace Microsoft.Dafny
/// </summary>
public class AutoContractsRewriter : IRewriter
{
- public void PreResolve(ModuleDecl m) {
+ public void PreResolve(ModuleDefinition m) {
foreach (var d in m.TopLevelDecls) {
bool sayYes = true;
if (d is ClassDecl && Attributes.ContainsBool(d.Attributes, "autocontracts", ref sayYes) && sayYes) {
@@ -112,7 +112,7 @@ namespace Microsoft.Dafny
}
}
- public void PostResolve(ModuleDecl m) {
+ public void PostResolve(ModuleDefinition m) {
foreach (var d in m.TopLevelDecls) {
bool sayYes = true;
if (d is ClassDecl && Attributes.ContainsBool(d.Attributes, "autocontracts", ref sayYes) && sayYes) {
diff --git a/Source/Dafny/Scanner.cs b/Source/Dafny/Scanner.cs
index 7cb302fa..32c92a8b 100644
--- a/Source/Dafny/Scanner.cs
+++ b/Source/Dafny/Scanner.cs
@@ -262,14 +262,14 @@ public class Scanner {
start[123] = 10;
start[125] = 11;
start[61] = 57;
- start[124] = 58;
start[59] = 19;
+ start[46] = 58;
+ start[124] = 59;
start[44] = 20;
start[40] = 21;
start[41] = 22;
- start[60] = 59;
- start[62] = 60;
- start[46] = 61;
+ start[60] = 60;
+ start[62] = 61;
start[42] = 24;
start[96] = 25;
start[91] = 28;
@@ -491,29 +491,29 @@ public class Scanner {
case "ghost": t.kind = 8; break;
case "module": t.kind = 9; break;
case "refines": t.kind = 10; break;
- case "imports": t.kind = 11; break;
- case "class": t.kind = 12; break;
- case "static": t.kind = 13; break;
- case "datatype": t.kind = 14; break;
- case "codatatype": t.kind = 15; break;
- case "var": t.kind = 19; break;
- case "type": t.kind = 21; break;
- case "method": t.kind = 27; break;
- case "constructor": t.kind = 28; break;
- case "returns": t.kind = 29; break;
- case "modifies": t.kind = 31; break;
- case "free": t.kind = 32; break;
- case "requires": t.kind = 33; break;
- case "ensures": t.kind = 34; break;
- case "decreases": t.kind = 35; break;
- case "bool": t.kind = 36; break;
- case "nat": t.kind = 37; break;
- case "int": t.kind = 38; break;
- case "set": t.kind = 39; break;
- case "multiset": t.kind = 40; break;
- case "seq": t.kind = 41; break;
- case "map": t.kind = 42; break;
- case "object": t.kind = 43; break;
+ case "as": t.kind = 13; break;
+ case "class": t.kind = 15; break;
+ case "static": t.kind = 16; break;
+ case "datatype": t.kind = 17; break;
+ case "codatatype": t.kind = 18; break;
+ case "var": t.kind = 20; break;
+ case "type": t.kind = 22; break;
+ case "method": t.kind = 28; break;
+ case "constructor": t.kind = 29; break;
+ case "returns": t.kind = 30; break;
+ case "modifies": t.kind = 32; break;
+ case "free": t.kind = 33; break;
+ case "requires": t.kind = 34; break;
+ case "ensures": t.kind = 35; break;
+ case "decreases": t.kind = 36; break;
+ case "bool": t.kind = 37; break;
+ case "nat": t.kind = 38; break;
+ case "int": t.kind = 39; break;
+ case "set": t.kind = 40; break;
+ case "multiset": t.kind = 41; break;
+ case "seq": t.kind = 42; break;
+ case "map": t.kind = 43; break;
+ case "object": t.kind = 44; break;
case "function": t.kind = 45; break;
case "predicate": t.kind = 46; break;
case "reads": t.kind = 47; break;
@@ -648,15 +648,15 @@ public class Scanner {
else if (ch >= '0' && ch <= '9') {AddCh(); goto case 18;}
else {t.kind = 3; break;}
case 19:
- {t.kind = 18; break;}
+ {t.kind = 12; break;}
case 20:
- {t.kind = 20; break;}
+ {t.kind = 21; break;}
case 21:
- {t.kind = 22; break;}
+ {t.kind = 23; break;}
case 22:
- {t.kind = 24; break;}
+ {t.kind = 25; break;}
case 23:
- {t.kind = 30; break;}
+ {t.kind = 31; break;}
case 24:
{t.kind = 48; break;}
case 25:
@@ -730,43 +730,43 @@ public class Scanner {
else if (ch == ':') {AddCh(); goto case 54;}
else {t.kind = 5; break;}
case 57:
- recEnd = pos; recKind = 16;
+ recEnd = pos; recKind = 11;
if (ch == '=') {AddCh(); goto case 63;}
else if (ch == '>') {AddCh(); goto case 30;}
- else {t.kind = 16; break;}
+ else {t.kind = 11; break;}
case 58:
- recEnd = pos; recKind = 17;
- if (ch == '|') {AddCh(); goto case 39;}
- else {t.kind = 17; break;}
+ recEnd = pos; recKind = 14;
+ if (ch == '.') {AddCh(); goto case 64;}
+ else {t.kind = 14; break;}
case 59:
- recEnd = pos; recKind = 25;
- if (ch == '=') {AddCh(); goto case 64;}
- else {t.kind = 25; break;}
+ recEnd = pos; recKind = 19;
+ if (ch == '|') {AddCh(); goto case 39;}
+ else {t.kind = 19; break;}
case 60:
recEnd = pos; recKind = 26;
- if (ch == '=') {AddCh(); goto case 41;}
+ if (ch == '=') {AddCh(); goto case 65;}
else {t.kind = 26; break;}
case 61:
- recEnd = pos; recKind = 44;
- if (ch == '.') {AddCh(); goto case 65;}
- else {t.kind = 44; break;}
+ recEnd = pos; recKind = 27;
+ if (ch == '=') {AddCh(); goto case 41;}
+ else {t.kind = 27; break;}
case 62:
recEnd = pos; recKind = 83;
if (ch == '=') {AddCh(); goto case 42;}
else if (ch == '!') {AddCh(); goto case 43;}
else {t.kind = 83; break;}
case 63:
- recEnd = pos; recKind = 23;
+ recEnd = pos; recKind = 24;
if (ch == '>') {AddCh(); goto case 34;}
- else {t.kind = 23; break;}
+ else {t.kind = 24; break;}
case 64:
- recEnd = pos; recKind = 78;
- if (ch == '=') {AddCh(); goto case 31;}
- else {t.kind = 78; break;}
- case 65:
recEnd = pos; recKind = 100;
if (ch == '.') {AddCh(); goto case 23;}
else {t.kind = 100; break;}
+ case 65:
+ recEnd = pos; recKind = 78;
+ if (ch == '=') {AddCh(); goto case 31;}
+ else {t.kind = 78; break;}
}
t.val = new String(tval, 0, tlen);
diff --git a/Source/Dafny/Translator.cs b/Source/Dafny/Translator.cs
index 1290f3ad..75a1e174 100644
--- a/Source/Dafny/Translator.cs
+++ b/Source/Dafny/Translator.cs
@@ -26,6 +26,7 @@ namespace Microsoft.Dafny {
readonly Dictionary<TopLevelDecl/*!*/,Bpl.Constant/*!*/>/*!*/ classes = new Dictionary<TopLevelDecl/*!*/,Bpl.Constant/*!*/>();
readonly Dictionary<Field/*!*/,Bpl.Constant/*!*/>/*!*/ fields = new Dictionary<Field/*!*/,Bpl.Constant/*!*/>();
readonly Dictionary<Field/*!*/, Bpl.Function/*!*/>/*!*/ fieldFunctions = new Dictionary<Field/*!*/, Bpl.Function/*!*/>();
+ Program program;
[ContractInvariantMethod]
void ObjectInvariant()
@@ -306,9 +307,10 @@ namespace Microsoft.Dafny {
*/
}
- public Bpl.Program Translate(Program program) {
- Contract.Requires(program != null);
+ public Bpl.Program Translate(Program p) {
+ Contract.Requires(p != null);
Contract.Ensures(Contract.Result<Bpl.Program>() != null);
+ program = p;
if (sink == null || predef == null) {
// something went wrong during construction, which reads the prelude; an error has
@@ -325,14 +327,18 @@ namespace Microsoft.Dafny {
AddClassMembers((ClassDecl)d);
}
}
- foreach (ModuleDecl m in program.Modules) {
+ foreach (ModuleDefinition m in program.Modules) {
foreach (TopLevelDecl d in m.TopLevelDecls) {
if (d is ArbitraryTypeDecl) {
// nothing to do--this is treated just like a type parameter
} else if (d is DatatypeDecl) {
AddDatatype((DatatypeDecl)d);
- } else {
+ } else if (d is ClassDecl) {
AddClassMembers((ClassDecl)d);
+ } else if (d is ModuleDecl) {
+ // nop, sub-modules are handled in their own iteration.
+ } else {
+ Contract.Assert(false);
}
}
}
@@ -811,7 +817,7 @@ namespace Microsoft.Dafny {
}
// mh < ModuleContextHeight || (mh == ModuleContextHeight && (fh <= FunctionContextHeight || InMethodContext))
- ModuleDecl mod = f.EnclosingClass.Module;
+ ModuleDefinition mod = f.EnclosingClass.Module;
var activateForeign = Bpl.Expr.Lt(Bpl.Expr.Literal(mod.Height), etran.ModuleContextHeight());
var activateIntra =
Bpl.Expr.And(
@@ -1017,7 +1023,7 @@ namespace Microsoft.Dafny {
return Bpl.Expr.And(lower, upper);
}
- ModuleDecl currentModule = null; // the name of the module whose members are currently being translated
+ ModuleDefinition currentModule = null; // the name of the module whose members are currently being translated
Method currentMethod = null; // the method whose implementation is currently being translated
int loopHeapVarCount = 0;
int otherTmpVarCount = 0;
@@ -1554,7 +1560,7 @@ namespace Microsoft.Dafny {
// the procedure itself
Bpl.RequiresSeq req = new Bpl.RequiresSeq();
// free requires mh == ModuleContextHeight && fh == FunctionContextHeight;
- ModuleDecl mod = f.EnclosingClass.Module;
+ ModuleDefinition mod = f.EnclosingClass.Module;
Bpl.Expr context = Bpl.Expr.And(
Bpl.Expr.Eq(Bpl.Expr.Literal(mod.Height), etran.ModuleContextHeight()),
Bpl.Expr.Eq(Bpl.Expr.Literal(mod.CallGraph.GetSCCRepresentativeId(f)), etran.FunctionContextHeight()));
@@ -2372,7 +2378,7 @@ namespace Microsoft.Dafny {
if (options.Decr != null && e.CoCall != FunctionCallExpr.CoCallResolution.Yes) {
// check that the decreases measure goes down
- ModuleDecl module = cce.NonNull(e.Function.EnclosingClass).Module;
+ ModuleDefinition module = cce.NonNull(e.Function.EnclosingClass).Module;
if (module == cce.NonNull(options.Decr.EnclosingClass).Module) {
if (module.CallGraph.GetSCCRepresentative(e.Function) == module.CallGraph.GetSCCRepresentative(options.Decr)) {
bool contextDecrInferred, calleeDecrInferred;
@@ -2819,7 +2825,7 @@ namespace Microsoft.Dafny {
} else if (type is IntType) {
return new Bpl.IdentifierExpr(tok, "class._System.int", predef.ClassNameType);
} else if (type is ObjectType) {
- return new Bpl.IdentifierExpr(tok, "class._System.object", predef.ClassNameType);
+ return new Bpl.IdentifierExpr(tok, GetClass(program.BuiltIns.ObjectDecl));
} else if (type is CollectionType) {
CollectionType ct = (CollectionType)type;
Bpl.Expr a = GetTypeExpr(tok, ct.Arg);
@@ -4394,7 +4400,7 @@ namespace Microsoft.Dafny {
CheckFrameSubset(tok, method.Mod.Expressions, receiver, substMap, etran, builder, "call may violate context's modifies clause", null);
// Check termination
- ModuleDecl module = method.EnclosingClass.Module;
+ ModuleDefinition module = method.EnclosingClass.Module;
if (module == currentModule) {
if (module.CallGraph.GetSCCRepresentative(method) == module.CallGraph.GetSCCRepresentative(currentMethod)) {
bool contextDecrInferred, calleeDecrInferred;
@@ -5298,7 +5304,7 @@ namespace Microsoft.Dafny {
typeArgs.Add(tRhs.EType);
rightType = etran.GoodRef_Ref(tok, nw, new Bpl.IdentifierExpr(tok, "class._System." + BuiltIns.ArrayClassName(tRhs.ArrayDimensions.Count), predef.ClassNameType), typeArgs, true);
} else if (tRhs.EType is ObjectType) {
- rightType = etran.GoodRef_Ref(tok, nw, new Bpl.IdentifierExpr(tok, "class._System.object", predef.ClassNameType), new List<Type>(), true);
+ rightType = etran.GoodRef_Ref(tok, nw, new Bpl.IdentifierExpr(Token.NoToken,GetClass(program.BuiltIns.ObjectDecl)), new List<Type>(), true);
} else {
rightType = etran.GoodRef_Class(tok, nw, (UserDefinedType)tRhs.EType, true);
}
@@ -5714,7 +5720,7 @@ namespace Microsoft.Dafny {
}
string nm = FunctionName(e.Function, 1 + offsetToUse);
if (this.applyLimited_CurrentFunction != null && e.Function.IsRecursive) {
- ModuleDecl module = cce.NonNull(e.Function.EnclosingClass).Module;
+ ModuleDefinition module = cce.NonNull(e.Function.EnclosingClass).Module;
if (module == cce.NonNull(applyLimited_CurrentFunction.EnclosingClass).Module) {
if (module.CallGraph.GetSCCRepresentative(e.Function) == module.CallGraph.GetSCCRepresentative(applyLimited_CurrentFunction)) {
nm = FunctionName(e.Function, 0 + offsetToUse);
diff --git a/Source/Dafny/Util.cs b/Source/Dafny/Util.cs
new file mode 100644
index 00000000..e057727a
--- /dev/null
+++ b/Source/Dafny/Util.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Microsoft.Dafny {
+ class Util
+ {
+ public delegate string ToString<T>(T t);
+ public static string Comma<T>(string comma, List<T> l, ToString<T> f) {
+ string res = "";
+ string c = "";
+ foreach(var t in l) {
+ res += c + f(t);
+ c = comma;
+ }
+ return res;
+ }
+ }
+}
diff --git a/Source/GPUVerify/RaceInstrumenter.cs b/Source/GPUVerify/RaceInstrumenter.cs
deleted file mode 100644
index 620f7d1a..00000000
--- a/Source/GPUVerify/RaceInstrumenter.cs
+++ /dev/null
@@ -1,1042 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
-using Microsoft.Boogie;
-using Microsoft.Basetypes;
-
-namespace GPUVerify
-{
- class RaceInstrumenter : IRaceInstrumenter
- {
- protected GPUVerifier verifier;
-
- public INonLocalState NonLocalStateToCheck;
-
- public int onlyLog1;
- public int onlyLog2;
- public bool failedToFindSecondAccess;
- public bool addedLogWrite;
- private int logAddCount;
-
- private Dictionary<string, Procedure> logAccessProcedures = new Dictionary<string, Procedure>();
-
- public RaceInstrumenter()
- {
- onlyLog1 = -1;
- onlyLog2 = -1;
- failedToFindSecondAccess = false;
- addedLogWrite = false;
- logAddCount = 0;
- }
-
- public void setVerifier(GPUVerifier verifier)
- {
- this.verifier = verifier;
- NonLocalStateToCheck = new NonLocalStateLists();
- foreach(Variable v in verifier.NonLocalState.getGlobalVariables())
- {
- NonLocalStateToCheck.getGlobalVariables().Add(v);
- }
- foreach(Variable v in verifier.NonLocalState.getGroupSharedVariables())
- {
- NonLocalStateToCheck.getGroupSharedVariables().Add(v);
- }
- }
-
- private void AddNoReadOrWriteCandidateInvariants(IRegion region, Variable v)
- {
- // Reasoning: if READ_HAS_OCCURRED_v is not in the modifies set for the
- // loop then there is no point adding an invariant
- //
- // If READ_HAS_OCCURRED_v is in the modifies set, but the loop does not
- // contain a barrier, then it is almost certain that a read CAN be
- // pending at the loop head, so the invariant will not hold
- //
- // If there is a barrier in the loop body then READ_HAS_OCCURRED_v will
- // be in the modifies set, but there may not be a live read at the loop
- // head, so it is worth adding the loop invariant candidate.
- //
- // The same reasoning applies for WRITE
-
- if (verifier.ContainsBarrierCall(region))
- {
- if (verifier.ContainsNamedVariable(
- LoopInvariantGenerator.GetModifiedVariables(region), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "READ")))
- {
- AddNoReadOrWriteCandidateInvariant(region, v, "READ");
- }
-
- if (verifier.ContainsNamedVariable(
- LoopInvariantGenerator.GetModifiedVariables(region), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "WRITE")))
- {
- AddNoReadOrWriteCandidateInvariant(region, v, "WRITE");
- }
- }
- }
-
- private void AddNoReadOrWriteCandidateRequires(Procedure Proc, Variable v)
- {
- AddNoReadOrWriteCandidateRequires(Proc, v, "READ", "1");
- AddNoReadOrWriteCandidateRequires(Proc, v, "WRITE", "1");
- }
-
- private void AddNoReadOrWriteCandidateEnsures(Procedure Proc, Variable v)
- {
- AddNoReadOrWriteCandidateEnsures(Proc, v, "READ", "1");
- AddNoReadOrWriteCandidateEnsures(Proc, v, "WRITE", "1");
- }
-
- private void AddNoReadOrWriteCandidateInvariant(IRegion region, Variable v, string ReadOrWrite)
- {
- Expr candidate = NoReadOrWriteExpr(v, ReadOrWrite, "1");
- verifier.AddCandidateInvariant(region, candidate, "no " + ReadOrWrite.ToLower());
- }
-
- public void AddRaceCheckingCandidateInvariants(Implementation impl, IRegion region)
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddNoReadOrWriteCandidateInvariants(region, v);
- AddReadOrWrittenOffsetIsThreadIdCandidateInvariants(impl, region, v, "READ");
- AddReadOrWrittenOffsetIsThreadIdCandidateInvariants(impl, region, v, "WRITE");
- AddOffsetsSatisfyPredicatesCandidateInvariant(region, v, "READ", CollectOffsetPredicates(impl, region, v, "READ"));
- AddOffsetsSatisfyPredicatesCandidateInvariant(region, v, "WRITE", CollectOffsetPredicates(impl, region, v, "WRITE"));
- }
- }
-
- private void AddAccessRelatedCandidateInvariant(IRegion region, string accessKind, Expr candidateInvariantExpr, string procName, string tag)
- {
- Expr candidate = new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(candidateInvariantExpr.Clone() as Expr);
- verifier.AddCandidateInvariant(region, candidate, tag);
- }
-
- private bool DoesNotReferTo(Expr expr, string v)
- {
- FindReferencesToNamedVariableVisitor visitor = new FindReferencesToNamedVariableVisitor(v);
- visitor.VisitExpr(expr);
- return !visitor.found;
- }
-
- private List<Expr> CollectOffsetPredicates(Implementation impl, IRegion region, Variable v, string accessType)
- {
- var offsetVar = new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, accessType));
- var offsetExpr = new IdentifierExpr(Token.NoToken, offsetVar);
- var offsetPreds = new List<Expr>();
-
- foreach (var offset in GetOffsetsAccessed(region, v, accessType))
- {
- bool isConstant;
- var def = verifier.varDefAnalyses[impl].SubstDefinitions(offset, impl.Name, out isConstant);
- if (def == null)
- continue;
-
- if (isConstant)
- {
- offsetPreds.Add(Expr.Eq(offsetExpr, def));
- }
- else
- {
- var sc = StrideConstraint.FromExpr(verifier, impl, def);
- var pred = sc.MaybeBuildPredicate(verifier, offsetExpr);
- if (pred != null)
- offsetPreds.Add(pred);
- }
- }
-
- return offsetPreds;
- }
-
- private void AddReadOrWrittenOffsetIsThreadIdCandidateInvariants(Implementation impl, IRegion region, Variable v, string accessType)
- {
- KeyValuePair<IdentifierExpr, Expr> iLessThanC = GetILessThanC(region.Guard());
- if (iLessThanC.Key != null)
- {
- foreach (Expr e in GetOffsetsAccessed(region, v, accessType))
- {
- if(HasFormIPlusLocalIdTimesC(e, iLessThanC, impl))
- {
- AddAccessedOffsetInRangeCTimesLocalIdToCTimesLocalIdPlusC(region, v, iLessThanC.Value, accessType);
- break;
- }
- }
-
- foreach (Expr e in GetOffsetsAccessed(region, v, accessType))
- {
- if (HasFormIPlusGlobalIdTimesC(e, iLessThanC, impl))
- {
- AddAccessedOffsetInRangeCTimesGlobalIdToCTimesGlobalIdPlusC(region, v, iLessThanC.Value, accessType);
- break;
- }
- }
-
- }
-
-
- }
-
- private bool HasFormIPlusLocalIdTimesC(Expr e, KeyValuePair<IdentifierExpr, Expr> iLessThanC, Implementation impl)
- {
- if (!(e is NAryExpr))
- {
- return false;
- }
-
- NAryExpr nary = e as NAryExpr;
-
- if (!nary.Fun.FunctionName.Equals("BV32_ADD"))
- {
- return false;
- }
-
- return (SameIdentifierExpression(nary.Args[0], iLessThanC.Key) &&
- IsLocalIdTimesConstant(nary.Args[1], iLessThanC.Value, impl)) ||
- (SameIdentifierExpression(nary.Args[1], iLessThanC.Key) &&
- IsLocalIdTimesConstant(nary.Args[0], iLessThanC.Value, impl));
- }
-
- private bool IsLocalIdTimesConstant(Expr maybeLocalIdTimesConstant, Expr constant, Implementation impl)
- {
- if (!(maybeLocalIdTimesConstant is NAryExpr))
- {
- return false;
- }
- NAryExpr nary = maybeLocalIdTimesConstant as NAryExpr;
- if(!nary.Fun.FunctionName.Equals("BV32_MUL"))
- {
- return false;
- }
-
- return
- (SameConstant(nary.Args[0], constant) && verifier.IsLocalId(nary.Args[1], 0, impl)) ||
- (SameConstant(nary.Args[1], constant) && verifier.IsLocalId(nary.Args[0], 0, impl));
- }
-
-
- private bool HasFormIPlusGlobalIdTimesC(Expr e, KeyValuePair<IdentifierExpr, Expr> iLessThanC, Implementation impl)
- {
- if (!(e is NAryExpr))
- {
- return false;
- }
-
- NAryExpr nary = e as NAryExpr;
-
- if (!nary.Fun.FunctionName.Equals("BV32_ADD"))
- {
- return false;
- }
-
- return (SameIdentifierExpression(nary.Args[0], iLessThanC.Key) &&
- IsGlobalIdTimesConstant(nary.Args[1], iLessThanC.Value, impl)) ||
- (SameIdentifierExpression(nary.Args[1], iLessThanC.Key) &&
- IsGlobalIdTimesConstant(nary.Args[0], iLessThanC.Value, impl));
- }
-
- private bool IsGlobalIdTimesConstant(Expr maybeGlobalIdTimesConstant, Expr constant, Implementation impl)
- {
- if (!(maybeGlobalIdTimesConstant is NAryExpr))
- {
- return false;
- }
- NAryExpr nary = maybeGlobalIdTimesConstant as NAryExpr;
- if (!nary.Fun.FunctionName.Equals("BV32_MUL"))
- {
- return false;
- }
-
- return
- (SameConstant(nary.Args[0], constant) && verifier.IsGlobalId(nary.Args[1], 0, impl)) ||
- (SameConstant(nary.Args[1], constant) && verifier.IsGlobalId(nary.Args[0], 0, impl));
- }
-
-
- private bool SameConstant(Expr expr, Expr constant)
- {
- if (constant is IdentifierExpr)
- {
- IdentifierExpr identifierExpr = constant as IdentifierExpr;
- Debug.Assert(identifierExpr.Decl is Constant);
- return expr is IdentifierExpr && (expr as IdentifierExpr).Decl is Constant && (expr as IdentifierExpr).Decl.Name.Equals(identifierExpr.Decl.Name);
- }
- else
- {
- Debug.Assert(constant is LiteralExpr);
- LiteralExpr literalExpr = constant as LiteralExpr;
- if (!(expr is LiteralExpr))
- {
- return false;
- }
- if (!(literalExpr.Val is BvConst) || !((expr as LiteralExpr).Val is BvConst))
- {
- return false;
- }
-
- return (literalExpr.Val as BvConst).Value.ToInt == ((expr as LiteralExpr).Val as BvConst).Value.ToInt;
- }
- }
-
- private bool SameIdentifierExpression(Expr expr, IdentifierExpr identifierExpr)
- {
- if (!(expr is IdentifierExpr))
- {
- return false;
- }
- return (expr as IdentifierExpr).Decl.Name.Equals(identifierExpr.Name);
- }
-
- private KeyValuePair<IdentifierExpr, Expr> GetILessThanC(Expr expr)
- {
-
- if (expr is NAryExpr && (expr as NAryExpr).Fun.FunctionName.Equals("bv32_to_bool"))
- {
- expr = (expr as NAryExpr).Args[0];
- }
-
- if (!(expr is NAryExpr))
- {
- return new KeyValuePair<IdentifierExpr, Expr>(null, null);
- }
-
- NAryExpr nary = expr as NAryExpr;
-
- if (!(nary.Fun.FunctionName.Equals("BV32_C_LT") || nary.Fun.FunctionName.Equals("BV32_LT")))
- {
- return new KeyValuePair<IdentifierExpr, Expr>(null, null);
- }
-
- if (!(nary.Args[0] is IdentifierExpr))
- {
- return new KeyValuePair<IdentifierExpr, Expr>(null, null);
- }
-
- if (!IsConstant(nary.Args[1]))
- {
- return new KeyValuePair<IdentifierExpr, Expr>(null, null);
- }
-
- return new KeyValuePair<IdentifierExpr, Expr>(nary.Args[0] as IdentifierExpr, nary.Args[1]);
-
- }
-
- private static bool IsConstant(Expr e)
- {
- return ((e is IdentifierExpr && (e as IdentifierExpr).Decl is Constant) || e is LiteralExpr);
- }
-
- private void AddReadOrWrittenOffsetIsThreadIdCandidateRequires(Procedure Proc, Variable v)
- {
- AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "WRITE", 1);
- AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "READ", 1);
- }
-
- private void AddReadOrWrittenOffsetIsThreadIdCandidateEnsures(Procedure Proc, Variable v)
- {
- AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "WRITE", 1);
- AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "READ", 1);
- }
-
- public void AddKernelPrecondition()
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddRequiresNoPendingAccess(v);
-
- if (!verifier.ArrayModelledAdversarially(v))
- {
- IdentifierExpr v1 = new IdentifierExpr(Token.NoToken, new VariableDualiser(1, null, null).VisitVariable(v.Clone() as Variable));
- IdentifierExpr v2 = new IdentifierExpr(Token.NoToken, new VariableDualiser(2, null, null).VisitVariable(v.Clone() as Variable));
- verifier.KernelProcedure.Requires.Add(new Requires(false, Expr.Eq(v1, v2)));
- }
- }
- }
-
- public bool AddRaceCheckingInstrumentation()
- {
-
- if (onlyLog1 != -1)
- {
- addedLogWrite = false;
- failedToFindSecondAccess = true;
- }
- else
- {
- addedLogWrite = true;
- failedToFindSecondAccess = false;
- }
-
- foreach (Declaration d in verifier.Program.TopLevelDeclarations)
- {
- if (d is Implementation)
- {
- AddRaceCheckCalls(d as Implementation);
- }
- }
-
- if (failedToFindSecondAccess || !addedLogWrite)
- return false;
-
- return true;
-
- }
-
- private void AddRaceCheckingDecsAndProcsForVar(Variable v)
- {
- AddLogRaceDeclarations(v, "READ");
- AddLogRaceDeclarations(v, "WRITE");
- AddLogAccessProcedure(v, "READ");
- AddLogAccessProcedure(v, "WRITE");
-
- }
-
- private StmtList AddRaceCheckCalls(StmtList stmtList)
- {
- Contract.Requires(stmtList != null);
-
- StmtList result = new StmtList(new List<BigBlock>(), stmtList.EndCurly);
-
- foreach (BigBlock bodyBlock in stmtList.BigBlocks)
- {
- result.BigBlocks.Add(AddRaceCheckCalls(bodyBlock));
- }
- return result;
- }
-
- private Block AddRaceCheckCalls(Block b)
- {
- b.Cmds = AddRaceCheckCalls(b.Cmds);
- return b;
- }
-
- private void AddRaceCheckCalls(Implementation impl)
- {
- if (CommandLineOptions.Unstructured)
- impl.Blocks = impl.Blocks.Select(AddRaceCheckCalls).ToList();
- else
- impl.StructuredStmts = AddRaceCheckCalls(impl.StructuredStmts);
- }
-
- private bool shouldAddLogCallAndIncr()
- {
- Contract.Assert(onlyLog1 >= -1);
- int oldLogAddCount = logAddCount;
- ++logAddCount;
-
- if (onlyLog1 == -1)
- {
- return true;
- }
-
- if(onlyLog1 + onlyLog2 == oldLogAddCount)
- {
- failedToFindSecondAccess = false;
- return true;
- }
-
- if (onlyLog1 == oldLogAddCount)
- {
- return true;
- }
-
- return false;
- }
-
- private CmdSeq AddRaceCheckCalls(CmdSeq cs)
- {
- var result = new CmdSeq();
- foreach (Cmd c in cs)
- {
- result.Add(c);
- if (c is AssignCmd)
- {
- AssignCmd assign = c as AssignCmd;
-
- ReadCollector rc = new ReadCollector(NonLocalStateToCheck);
- foreach (var rhs in assign.Rhss)
- rc.Visit(rhs);
- if (rc.accesses.Count > 0)
- {
- foreach (AccessRecord ar in rc.accesses)
- {
- if (shouldAddLogCallAndIncr())
- {
-
- ExprSeq inParams = new ExprSeq();
- if (ar.IndexZ != null)
- {
- inParams.Add(ar.IndexZ);
- }
- if (ar.IndexY != null)
- {
- inParams.Add(ar.IndexY);
- }
- if (ar.IndexX != null)
- {
- inParams.Add(ar.IndexX);
- }
-
- Procedure logProcedure = GetLogAccessProcedure(c.tok, "_LOG_READ_" + ar.v.Name);
-
- CallCmd logAccessCallCmd = new CallCmd(c.tok, logProcedure.Name, inParams, new IdentifierExprSeq());
-
- logAccessCallCmd.Proc = logProcedure;
-
- result.Add(logAccessCallCmd);
-
- }
- }
- }
-
- foreach (var lhs in assign.Lhss)
- {
- WriteCollector wc = new WriteCollector(NonLocalStateToCheck);
- wc.Visit(lhs);
- if (wc.GetAccess() != null)
- {
- AccessRecord ar = wc.GetAccess();
-
- if (shouldAddLogCallAndIncr())
- {
-
- ExprSeq inParams = new ExprSeq();
- if (ar.IndexZ != null)
- {
- inParams.Add(ar.IndexZ);
- }
- if (ar.IndexY != null)
- {
- inParams.Add(ar.IndexY);
- }
- if (ar.IndexX != null)
- {
- inParams.Add(ar.IndexX);
- }
-
- Procedure logProcedure = GetLogAccessProcedure(c.tok, "_LOG_WRITE_" + ar.v.Name);
-
- CallCmd logAccessCallCmd = new CallCmd(c.tok, logProcedure.Name, inParams, new IdentifierExprSeq());
-
- logAccessCallCmd.Proc = logProcedure;
-
- result.Add(logAccessCallCmd);
-
- addedLogWrite = true;
-
- }
- }
- }
- }
- }
- return result;
- }
-
- private BigBlock AddRaceCheckCalls(BigBlock bb)
- {
- BigBlock result = new BigBlock(bb.tok, bb.LabelName, AddRaceCheckCalls(bb.simpleCmds), null, bb.tc);
-
- if (bb.ec is WhileCmd)
- {
- WhileCmd WhileCommand = bb.ec as WhileCmd;
- result.ec = new WhileCmd(WhileCommand.tok, WhileCommand.Guard,
- WhileCommand.Invariants, AddRaceCheckCalls(WhileCommand.Body));
- }
- else if (bb.ec is IfCmd)
- {
- IfCmd IfCommand = bb.ec as IfCmd;
- Debug.Assert(IfCommand.elseIf == null); // We don't handle else if yet
- result.ec = new IfCmd(IfCommand.tok, IfCommand.Guard, AddRaceCheckCalls(IfCommand.thn), IfCommand.elseIf, IfCommand.elseBlock != null ? AddRaceCheckCalls(IfCommand.elseBlock) : null);
- }
- else if (bb.ec is BreakCmd)
- {
- result.ec = bb.ec;
- }
- else
- {
- Debug.Assert(bb.ec == null);
- }
-
- return result;
- }
-
- private Procedure GetLogAccessProcedure(IToken tok, string name)
- {
- if (logAccessProcedures.ContainsKey(name))
- {
- return logAccessProcedures[name];
- }
- Procedure newProcedure = new Procedure(tok, name, new TypeVariableSeq(), new VariableSeq(), new VariableSeq(), new RequiresSeq(), new IdentifierExprSeq(), new EnsuresSeq());
- logAccessProcedures[name] = newProcedure;
- return newProcedure;
- }
-
-
- public BigBlock MakeResetReadWriteSetStatements(Variable v, int Thread)
- {
- BigBlock result = new BigBlock(Token.NoToken, null, new CmdSeq(), null, null);
- if (Thread == 2)
- {
- return result;
- }
-
- Expr ResetReadAssumeGuard = Expr.Not(new IdentifierExpr(Token.NoToken,
- new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ"))));
- Expr ResetWriteAssumeGuard = Expr.Not(new IdentifierExpr(Token.NoToken,
- new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE"))));
-
- if (CommandLineOptions.InterGroupRaceChecking && verifier.NonLocalState.getGlobalVariables().Contains(v))
- {
- ResetReadAssumeGuard = Expr.Imp(verifier.ThreadsInSameGroup(), ResetReadAssumeGuard);
- ResetWriteAssumeGuard = Expr.Imp(verifier.ThreadsInSameGroup(), ResetWriteAssumeGuard);
- }
-
- result.simpleCmds.Add(new AssumeCmd(Token.NoToken, ResetReadAssumeGuard));
- result.simpleCmds.Add(new AssumeCmd(Token.NoToken, ResetWriteAssumeGuard));
- return result;
- }
-
- protected Procedure MakeLogAccessProcedureHeader(Variable v, string ReadOrWrite)
- {
- VariableSeq inParams = new VariableSeq();
-
- Variable PredicateParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_P", Microsoft.Boogie.Type.Bool));
-
- Debug.Assert(v.TypedIdent.Type is MapType);
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
- Variable OffsetParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_offset", mt.Arguments[0]));
- Debug.Assert(!(mt.Result is MapType));
-
- inParams.Add(new VariableDualiser(1, null, null).VisitVariable(PredicateParameter.Clone() as Variable));
- inParams.Add(new VariableDualiser(1, null, null).VisitVariable(OffsetParameter.Clone() as Variable));
-
- inParams.Add(new VariableDualiser(2, null, null).VisitVariable(PredicateParameter.Clone() as Variable));
- inParams.Add(new VariableDualiser(2, null, null).VisitVariable(OffsetParameter.Clone() as Variable));
-
- string LogProcedureName = "_LOG_" + ReadOrWrite + "_" + v.Name;
-
- Procedure result = GetLogAccessProcedure(v.tok, LogProcedureName);
-
- result.InParams = inParams;
-
- result.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
-
- return result;
- }
-
- public void AddRaceCheckingCandidateRequires(Procedure Proc)
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddNoReadOrWriteCandidateRequires(Proc, v);
- AddReadOrWrittenOffsetIsThreadIdCandidateRequires(Proc, v);
- }
- }
-
- public void AddRaceCheckingCandidateEnsures(Procedure Proc)
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddNoReadOrWriteCandidateEnsures(Proc, v);
- AddReadOrWrittenOffsetIsThreadIdCandidateEnsures(Proc, v);
- }
- }
-
- private void AddNoReadOrWriteCandidateRequires(Procedure Proc, Variable v, string ReadOrWrite, string OneOrTwo)
- {
- verifier.AddCandidateRequires(Proc, NoReadOrWriteExpr(v, ReadOrWrite, OneOrTwo));
- }
-
- private void AddNoReadOrWriteCandidateEnsures(Procedure Proc, Variable v, string ReadOrWrite, string OneOrTwo)
- {
- verifier.AddCandidateEnsures(Proc, NoReadOrWriteExpr(v, ReadOrWrite, OneOrTwo));
- }
-
- private HashSet<Expr> GetOffsetsAccessed(IRegion region, Variable v, string AccessType)
- {
- HashSet<Expr> result = new HashSet<Expr>();
-
- foreach (Cmd c in region.Cmds())
- {
- if (c is CallCmd)
- {
- CallCmd call = c as CallCmd;
-
- if (call.callee == "_LOG_" + AccessType + "_" + v.Name)
- {
- // Ins[0] is thread 1's predicate,
- // Ins[1] is the offset to be read
- // If Ins[1] has the form BV32_ADD(offset#construct...(P), offset),
- // we are looking for the second parameter to this BV32_ADD
- Expr offset = call.Ins[1];
- if (offset is NAryExpr)
- {
- var nExpr = (NAryExpr)offset;
- if (nExpr.Fun.FunctionName == "BV32_ADD" &&
- nExpr.Args[0] is NAryExpr)
- {
- var n0Expr = (NAryExpr)nExpr.Args[0];
- if (n0Expr.Fun.FunctionName.StartsWith("offset#"))
- offset = nExpr.Args[1];
- }
- }
- result.Add(offset);
- }
-
- }
-
- }
-
- return result;
- }
-
- public void AddRaceCheckingDeclarations()
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddRaceCheckingDecsAndProcsForVar(v);
- }
- }
-
- protected void AddLogAccessProcedure(Variable v, string Access)
- {
- Procedure LogAccessProcedure = MakeLogAccessProcedureHeader(v, Access);
-
- Variable AccessHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, Access);
- Variable AccessOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, Access);
-
- Variable PredicateParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_P", Microsoft.Boogie.Type.Bool));
-
- Debug.Assert(v.TypedIdent.Type is MapType);
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
- Variable OffsetParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_offset", mt.Arguments[0]));
- Debug.Assert(!(mt.Result is MapType));
-
- VariableSeq locals = new VariableSeq();
- Variable TrackVariable = new LocalVariable(v.tok, new TypedIdent(v.tok, "track", Microsoft.Boogie.Type.Bool));
- locals.Add(TrackVariable);
-
- List<BigBlock> bigblocks = new List<BigBlock>();
-
- CmdSeq simpleCmds = new CmdSeq();
-
- simpleCmds.Add(new HavocCmd(v.tok, new IdentifierExprSeq(new IdentifierExpr[] { new IdentifierExpr(v.tok, TrackVariable) })));
-
- simpleCmds.Add(MakeConditionalAssignment(VariableForThread(1, AccessHasOccurredVariable),
- Expr.And(new IdentifierExpr(v.tok, VariableForThread(1, PredicateParameter)), new IdentifierExpr(v.tok, TrackVariable)), Expr.True));
- simpleCmds.Add(MakeConditionalAssignment(VariableForThread(1, AccessOffsetXVariable),
- Expr.And(new IdentifierExpr(v.tok, VariableForThread(1, PredicateParameter)), new IdentifierExpr(v.tok, TrackVariable)),
- new IdentifierExpr(v.tok, VariableForThread(1, OffsetParameter))));
-
- if (Access.Equals("READ"))
- {
- // Check read by thread 2 does not conflict with write by thread 1
- Variable WriteHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE");
- Variable WriteOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "WRITE");
- Expr WriteReadGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
- WriteReadGuard = Expr.And(WriteReadGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteHasOccurredVariable)));
- WriteReadGuard = Expr.And(WriteReadGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)),
- new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
- if (!verifier.ArrayModelledAdversarially(v))
- {
- WriteReadGuard = Expr.And(WriteReadGuard, Expr.Neq(
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)), 1, "WRITE"),
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "READ")
- ));
- }
-
- if (verifier.NonLocalState.getGroupSharedVariables().Contains(v) && CommandLineOptions.InterGroupRaceChecking)
- {
- WriteReadGuard = Expr.And(WriteReadGuard, verifier.ThreadsInSameGroup());
- }
-
- WriteReadGuard = Expr.Not(WriteReadGuard);
- simpleCmds.Add(new AssertCmd(Token.NoToken, WriteReadGuard));
- }
- else
- {
- Debug.Assert(Access.Equals("WRITE"));
-
- // Check write by thread 2 does not conflict with write by thread 1
- Variable WriteHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE");
- Variable WriteOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "WRITE");
-
- Expr WriteWriteGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
- WriteWriteGuard = Expr.And(WriteWriteGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteHasOccurredVariable)));
- WriteWriteGuard = Expr.And(WriteWriteGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)),
- new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
- if (!verifier.ArrayModelledAdversarially(v))
- {
- WriteWriteGuard = Expr.And(WriteWriteGuard, Expr.Neq(
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)), 1, "WRITE"),
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "WRITE")
- ));
- }
-
- if (verifier.NonLocalState.getGroupSharedVariables().Contains(v) && CommandLineOptions.InterGroupRaceChecking)
- {
- WriteWriteGuard = Expr.And(WriteWriteGuard, verifier.ThreadsInSameGroup());
- }
-
- WriteWriteGuard = Expr.Not(WriteWriteGuard);
- simpleCmds.Add(new AssertCmd(Token.NoToken, WriteWriteGuard));
-
- // Check write by thread 2 does not conflict with read by thread 1
- Variable ReadHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ");
- Variable ReadOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "READ");
-
- Expr ReadWriteGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
- ReadWriteGuard = Expr.And(ReadWriteGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadHasOccurredVariable)));
- ReadWriteGuard = Expr.And(ReadWriteGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadOffsetXVariable)),
- new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
- if (!verifier.ArrayModelledAdversarially(v))
- {
- ReadWriteGuard = Expr.And(ReadWriteGuard, Expr.Neq(
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadOffsetXVariable)), 1, "WRITE"),
- MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "READ")
- ));
- }
-
- if (verifier.NonLocalState.getGroupSharedVariables().Contains(v) && CommandLineOptions.InterGroupRaceChecking)
- {
- ReadWriteGuard = Expr.And(ReadWriteGuard, verifier.ThreadsInSameGroup());
- }
-
- ReadWriteGuard = Expr.Not(ReadWriteGuard);
- simpleCmds.Add(new AssertCmd(Token.NoToken, ReadWriteGuard));
-
- }
-
- bigblocks.Add(new BigBlock(v.tok, "_LOG_" + Access + "", simpleCmds, null, null));
-
- LogAccessProcedure.Modifies.Add(new IdentifierExpr(Token.NoToken, VariableForThread(1, AccessHasOccurredVariable)));
- LogAccessProcedure.Modifies.Add(new IdentifierExpr(Token.NoToken, VariableForThread(1, AccessOffsetXVariable)));
-
- Implementation LogAccessImplementation = new Implementation(v.tok, "_LOG_" + Access + "_" + v.Name, new TypeVariableSeq(), LogAccessProcedure.InParams, new VariableSeq(), locals, new StmtList(bigblocks, v.tok));
- LogAccessImplementation.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
-
- LogAccessImplementation.Proc = LogAccessProcedure;
-
- verifier.Program.TopLevelDeclarations.Add(LogAccessProcedure);
- verifier.Program.TopLevelDeclarations.Add(LogAccessImplementation);
- }
-
- private Variable VariableForThread(int thread, Variable v)
- {
- return new VariableDualiser(thread, null, null).VisitVariable(v.Clone() as Variable);
- }
-
- protected void AddLogRaceDeclarations(Variable v, String ReadOrWrite)
- {
- Variable AccessHasOccurred = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite);
-
- // Assumes full symmetry reduction
-
- verifier.Program.TopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable(AccessHasOccurred.Clone() as Variable));
-
- Debug.Assert(v.TypedIdent.Type is MapType);
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
-
- Variable AccessOffsetX = GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite);
- verifier.Program.TopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable(AccessOffsetX.Clone() as Variable));
-
- }
-
-
- private static AssignCmd MakeConditionalAssignment(Variable lhs, Expr condition, Expr rhs)
- {
- List<AssignLhs> lhss = new List<AssignLhs>();
- List<Expr> rhss = new List<Expr>();
- lhss.Add(new SimpleAssignLhs(lhs.tok, new IdentifierExpr(lhs.tok, lhs)));
- rhss.Add(new NAryExpr(rhs.tok, new IfThenElse(rhs.tok), new ExprSeq(new Expr[] { condition, rhs, new IdentifierExpr(lhs.tok, lhs) })));
- return new AssignCmd(lhs.tok, lhss, rhss);
- }
-
- private Expr MakeAccessedIndex(Variable v, Expr offsetExpr, int Thread, string AccessType)
- {
- Expr result = new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(v.Clone() as Variable));
- Debug.Assert(v.TypedIdent.Type is MapType);
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
-
- result = Expr.Select(result,
- new Expr[] { offsetExpr });
- Debug.Assert(!(mt.Result is MapType));
- return result;
- }
-
- protected void AddRequiresNoPendingAccess(Variable v)
- {
- IdentifierExpr ReadAccessOccurred1 = new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ")));
- IdentifierExpr WriteAccessOccurred1 = new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE")));
-
- verifier.KernelProcedure.Requires.Add(new Requires(false, Expr.And(Expr.Not(ReadAccessOccurred1), Expr.Not(WriteAccessOccurred1))));
- }
-
- protected Expr NoReadOrWriteExpr(Variable v, string ReadOrWrite, string OneOrTwo)
- {
- Variable ReadOrWriteHasOccurred = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite);
- ReadOrWriteHasOccurred.Name = ReadOrWriteHasOccurred.Name + "$" + OneOrTwo;
- ReadOrWriteHasOccurred.TypedIdent.Name = ReadOrWriteHasOccurred.TypedIdent.Name + "$" + OneOrTwo;
- Expr expr = Expr.Not(new IdentifierExpr(v.tok, ReadOrWriteHasOccurred));
- return expr;
- }
-
-
- protected void AddOffsetsSatisfyPredicatesCandidateInvariant(IRegion region, Variable v, string ReadOrWrite, List<Expr> preds)
- {
- if (preds.Count != 0)
- {
- Expr expr = AccessedOffsetsSatisfyPredicatesExpr(v, preds, ReadOrWrite, 1);
- verifier.AddCandidateInvariant(region, expr, "accessed offsets satisfy predicates");
- }
- }
-
- private Expr AccessedOffsetsSatisfyPredicatesExpr(Variable v, IEnumerable<Expr> offsets, string ReadOrWrite, int Thread) {
- return Expr.Imp(
- new IdentifierExpr(Token.NoToken, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite))),
- offsets.Aggregate(Expr.Or));
- }
-
- private Expr AccessedOffsetIsThreadLocalIdExpr(Variable v, string ReadOrWrite, int Thread)
- {
- Expr expr = null;
- if (GPUVerifier.HasXDimension(v) && GPUVerifier.IndexTypeOfXDimension(v).Equals(verifier.GetTypeOfIdX()))
- {
- expr = Expr.Imp(
- new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite))),
- Expr.Eq(new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite))), new IdentifierExpr(v.tok, verifier.MakeThreadId(v.tok, "X", Thread))));
- }
- return expr;
- }
-
- private Expr AccessedOffsetIsThreadGlobalIdExpr(Variable v, string ReadOrWrite, int Thread)
- {
- Expr expr = null;
- if (GPUVerifier.HasXDimension(v) && GPUVerifier.IndexTypeOfXDimension(v).Equals(verifier.GetTypeOfIdX()))
- {
- expr = Expr.Imp(
- new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite))),
- Expr.Eq(
- new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite))),
- GlobalIdExpr("X", Thread)
- )
- );
- }
- return expr;
- }
-
- private Expr GlobalIdExpr(string dimension, int Thread)
- {
- return new VariableDualiser(Thread, null, null).VisitExpr(verifier.GlobalIdExpr(dimension).Clone() as Expr);
- }
-
- protected void AddAccessedOffsetInRangeCTimesLocalIdToCTimesLocalIdPlusC(IRegion region, Variable v, Expr constant, string ReadOrWrite)
- {
- Expr expr = MakeCTimesLocalIdRangeExpression(v, constant, ReadOrWrite, 1);
- verifier.AddCandidateInvariant(region,
- expr, "accessed offset in range [ C*local_id, (C+1)*local_id )");
- }
-
- private Expr MakeCTimesLocalIdRangeExpression(Variable v, Expr constant, string ReadOrWrite, int Thread)
- {
- Expr CTimesLocalId = verifier.MakeBVMul(constant.Clone() as Expr,
- new IdentifierExpr(Token.NoToken, verifier.MakeThreadId(Token.NoToken, "X", Thread)));
-
- Expr CTimesLocalIdPlusC = verifier.MakeBVAdd(verifier.MakeBVMul(constant.Clone() as Expr,
- new IdentifierExpr(Token.NoToken, verifier.MakeThreadId(Token.NoToken, "X", Thread))), constant.Clone() as Expr);
-
- Expr CTimesLocalIdLeqAccessedOffset = GPUVerifier.MakeBitVectorBinaryBoolean("BV32_LEQ", CTimesLocalId, OffsetXExpr(v, ReadOrWrite, Thread));
-
- Expr AccessedOffsetLtCTimesLocalIdPlusC = verifier.MakeBVSlt(OffsetXExpr(v, ReadOrWrite, Thread), CTimesLocalIdPlusC);
-
- return Expr.Imp(
- AccessHasOccurred(v, ReadOrWrite, Thread),
- Expr.And(CTimesLocalIdLeqAccessedOffset, AccessedOffsetLtCTimesLocalIdPlusC));
- }
-
- private static IdentifierExpr AccessHasOccurred(Variable v, string ReadOrWrite, int Thread)
- {
- return new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite)));
- }
-
- private static IdentifierExpr OffsetXExpr(Variable v, string ReadOrWrite, int Thread)
- {
- return new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite)));
- }
-
- protected void AddAccessedOffsetInRangeCTimesGlobalIdToCTimesGlobalIdPlusC(IRegion region, Variable v, Expr constant, string ReadOrWrite)
- {
- Expr expr = MakeCTimesGloalIdRangeExpr(v, constant, ReadOrWrite, 1);
- verifier.AddCandidateInvariant(region,
- expr, "accessed offset in range [ C*global_id, (C+1)*global_id )");
- }
-
- private Expr MakeCTimesGloalIdRangeExpr(Variable v, Expr constant, string ReadOrWrite, int Thread)
- {
- Expr CTimesGlobalId = verifier.MakeBVMul(constant.Clone() as Expr,
- GlobalIdExpr("X", Thread));
-
- Expr CTimesGlobalIdPlusC = verifier.MakeBVAdd(verifier.MakeBVMul(constant.Clone() as Expr,
- GlobalIdExpr("X", Thread)), constant.Clone() as Expr);
-
- Expr CTimesGlobalIdLeqAccessedOffset = GPUVerifier.MakeBitVectorBinaryBoolean("BV32_LEQ", CTimesGlobalId, OffsetXExpr(v, ReadOrWrite, Thread));
-
- Expr AccessedOffsetLtCTimesGlobalIdPlusC = verifier.MakeBVSlt(OffsetXExpr(v, ReadOrWrite, Thread), CTimesGlobalIdPlusC);
-
- Expr implication = Expr.Imp(
- AccessHasOccurred(v, ReadOrWrite, Thread),
- Expr.And(CTimesGlobalIdLeqAccessedOffset, AccessedOffsetLtCTimesGlobalIdPlusC));
- return implication;
- }
-
- protected void AddAccessedOffsetIsThreadLocalIdCandidateRequires(Procedure Proc, Variable v, string ReadOrWrite, int Thread)
- {
- Expr expr = AccessedOffsetIsThreadLocalIdExpr(v, ReadOrWrite, Thread);
- if (expr != null)
- {
- verifier.AddCandidateRequires(Proc, expr);
- }
- }
-
- protected void AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Procedure Proc, Variable v, string ReadOrWrite, int Thread)
- {
- Expr expr = AccessedOffsetIsThreadLocalIdExpr(v, ReadOrWrite, Thread);
- if (expr != null)
- {
- verifier.AddCandidateEnsures(Proc, expr);
- }
- }
-
-
-
- }
-
-
-
- class FindReferencesToNamedVariableVisitor : StandardVisitor
- {
- internal bool found = false;
- private string name;
-
- internal FindReferencesToNamedVariableVisitor(string name)
- {
- this.name = name;
- }
-
- public override Variable VisitVariable(Variable node)
- {
- if (GPUVerifier.StripThreadIdentifier(node.Name).Equals(name))
- {
- found = true;
- }
- return base.VisitVariable(node);
- }
- }
-
-
-
-}
diff --git a/Source/GPUVerify/ReducedStrengthAnalysis.cs b/Source/GPUVerify/ReducedStrengthAnalysis.cs
deleted file mode 100644
index 0e58ff7d..00000000
--- a/Source/GPUVerify/ReducedStrengthAnalysis.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using Microsoft.Boogie;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace GPUVerify {
-
-class ReducedStrengthAnalysis {
-
- GPUVerifier verifier;
- Implementation impl;
- VariableDefinitionAnalysis varDefs;
-
- Dictionary<Variable, List<Tuple<object, Expr>>> multiDefMap = new Dictionary<Variable, List<Tuple<object, Expr>>>();
- Dictionary<string, ModStrideConstraint> strideConstraintMap = new Dictionary<string, ModStrideConstraint>();
- Dictionary<object, List<string>> loopCounterMap = new Dictionary<object, List<string>>();
-
- ReducedStrengthAnalysis(GPUVerifier v, Implementation i) {
- verifier = v;
- impl = i;
- varDefs = verifier.varDefAnalyses[impl];
- }
-
- void AddAssignment(object regionId, AssignLhs lhs, Expr rhs) {
- if (lhs is SimpleAssignLhs) {
- var sLhs = (SimpleAssignLhs)lhs;
- var theVar = sLhs.DeepAssignedVariable;
- List<Tuple<object, Expr>> defs;
- if (multiDefMap.ContainsKey(theVar))
- defs = multiDefMap[theVar];
- else
- defs = multiDefMap[theVar] = new List<Tuple<object, Expr>>();
- defs.Add(new Tuple<object, Expr>(regionId, rhs));
- }
- }
-
- void AnalyseRegion(IRegion region) {
- foreach (var c in region.CmdsChildRegions()) {
- var ac = c as AssignCmd;
- if (ac != null) {
- foreach (var a in ac.Lhss.Zip(ac.Rhss)) {
- AddAssignment(region.Identifier(), a.Item1, a.Item2);
- }
- }
- var child = c as IRegion;
- if (child != null)
- AnalyseRegion(child);
- }
- }
-
- void Analyse() {
- AnalyseRegion(verifier.RootRegion(impl));
- foreach (var v in multiDefMap.Keys) {
- var defs = multiDefMap[v];
- if (defs.Count != 2)
- continue;
- bool def0IsConst, def1IsConst;
- var def0 = varDefs.SubstDefinitions(defs[0].Item2, impl.Name, out def0IsConst);
- var def1 = varDefs.SubstDefinitions(defs[1].Item2, impl.Name, out def1IsConst);
- if (def0IsConst && !def1IsConst) {
- AddDefinitionPair(v, def0, def1, defs[1].Item1);
- } else if (!def0IsConst && def1IsConst) {
- AddDefinitionPair(v, def1, def0, defs[0].Item1);
- }
- }
- multiDefMap = null;
- }
-
- private class StrideForm {
- public StrideForm(Kind kind) { this.kind = kind; this.op = null; }
- public StrideForm(Kind kind, Expr op) { this.kind = kind; this.op = op; }
- public enum Kind { Bottom, Identity, Constant, Product, PowerMul, PowerDiv };
- public Kind kind;
- public Expr op;
- }
-
- private StrideForm ComputeStrideForm(Variable v, Expr e) {
- Expr lhs, rhs;
-
- if (e is LiteralExpr)
- return new StrideForm(StrideForm.Kind.Constant, e);
-
- var ie = e as IdentifierExpr;
- if (ie != null) {
- if (ie.Decl is Constant)
- return new StrideForm(StrideForm.Kind.Constant, e);
- if (ie.Decl == v)
- return new StrideForm(StrideForm.Kind.Identity, e);
- }
-
- if (GPUVerifier.IsBVAdd(e, out lhs, out rhs)) {
- var lhssf = ComputeStrideForm(v, lhs);
- var rhssf = ComputeStrideForm(v, rhs);
- if (lhssf.kind == StrideForm.Kind.Constant &&
- rhssf.kind == StrideForm.Kind.Constant)
- return new StrideForm(StrideForm.Kind.Constant, e);
- else if (lhssf.kind == StrideForm.Kind.Constant &&
- rhssf.kind == StrideForm.Kind.Identity)
- return new StrideForm(StrideForm.Kind.Product, lhs);
- else if (lhssf.kind == StrideForm.Kind.Identity &&
- rhssf.kind == StrideForm.Kind.Constant)
- return new StrideForm(StrideForm.Kind.Product, rhs);
- else if (lhssf.kind == StrideForm.Kind.Constant &&
- rhssf.kind == StrideForm.Kind.Product)
- return new StrideForm(StrideForm.Kind.Product, verifier.MakeBVAdd(lhs, rhssf.op));
- else if (lhssf.kind == StrideForm.Kind.Product &&
- rhssf.kind == StrideForm.Kind.Constant)
- return new StrideForm(StrideForm.Kind.Product, verifier.MakeBVAdd(lhssf.op, rhs));
- else
- return new StrideForm(StrideForm.Kind.Bottom);
- }
-
- var ne = e as NAryExpr;
- if (ne != null) {
- foreach (Expr op in ne.Args)
- if (ComputeStrideForm(v, op).kind != StrideForm.Kind.Constant)
- return new StrideForm(StrideForm.Kind.Bottom);
- return new StrideForm(StrideForm.Kind.Constant, e);
- }
-
- return new StrideForm(StrideForm.Kind.Bottom);
- }
-
- private void AddDefinitionPair(Variable v, Expr constDef, Expr nonConstDef, object nonConstId) {
- var sf = ComputeStrideForm(v, nonConstDef);
- if (sf.kind == StrideForm.Kind.Product) {
- var sc = new ModStrideConstraint(sf.op, constDef);
- if (!sc.IsBottom()) {
- strideConstraintMap[v.Name] = sc;
- List<string> lcs;
- if (loopCounterMap.ContainsKey(nonConstId))
- lcs = loopCounterMap[nonConstId];
- else
- lcs = loopCounterMap[nonConstId] = new List<string>();
- lcs.Add(v.Name);
- }
- }
- }
-
- public StrideConstraint GetStrideConstraint(string varName) {
- int id;
- var strippedVarName = GPUVerifier.StripThreadIdentifier(varName, out id);
- if (!strideConstraintMap.ContainsKey(strippedVarName))
- return null;
-
- var msc = strideConstraintMap[strippedVarName];
- if (id == 0)
- return msc;
- return new ModStrideConstraint(verifier.MaybeDualise(msc.mod, id, impl.Name),
- verifier.MaybeDualise(msc.modEq, id, impl.Name));
- }
-
- public IEnumerable<string> StridedLoopCounters(object loopId) {
- if (!loopCounterMap.ContainsKey(loopId))
- return Enumerable.Empty<string>();
- return loopCounterMap[loopId];
- }
-
- public static ReducedStrengthAnalysis Analyse(GPUVerifier verifier, Implementation impl) {
- var a = new ReducedStrengthAnalysis(verifier, impl);
- a.Analyse();
- return a;
- }
-}
-
-}
diff --git a/Source/GPUVerify/StrideConstraint.cs b/Source/GPUVerify/StrideConstraint.cs
deleted file mode 100755
index 948786b7..00000000
--- a/Source/GPUVerify/StrideConstraint.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Basetypes;
-using Microsoft.Boogie;
-
-namespace GPUVerify {
-
-class StrideConstraint {
-
- public static StrideConstraint Bottom(Expr e) {
- int width = e.Type.BvBits;
- return new ModStrideConstraint(new LiteralExpr(Token.NoToken, BigNum.FromInt(1), width),
- new LiteralExpr(Token.NoToken, BigNum.FromInt(0), width));
- }
-
- public bool IsBottom() {
- var msc = this as ModStrideConstraint;
- if (msc == null)
- return false;
-
- var le = msc.mod as LiteralExpr;
- if (le == null)
- return false;
-
- var bvc = le.Val as BvConst;
- if (bvc == null)
- return false;
-
- return bvc.Value.InInt32 && bvc.Value.ToInt == 1;
- }
-
- private Expr ExprModPow2(GPUVerifier verifier, Expr expr, Expr powerOfTwoExpr) {
- Expr Pow2Minus1 = verifier.MakeBVSub(powerOfTwoExpr,
- new LiteralExpr(Token.NoToken, BigNum.FromInt(1), 32));
-
- return verifier.MakeBVAnd(Pow2Minus1, expr);
- }
-
- public Expr MaybeBuildPredicate(GPUVerifier verifier, Expr e) {
- var msc = this as ModStrideConstraint;
- if (msc != null && !msc.IsBottom()) {
- Expr modEqExpr = Expr.Eq(ExprModPow2(verifier, e, msc.mod), ExprModPow2(verifier, msc.modEq, msc.mod));
- return modEqExpr;
- }
-
- return null;
- }
-
- private static StrideConstraint BuildAddStrideConstraint(GPUVerifier verifier, Expr e, StrideConstraint lhsc, StrideConstraint rhsc) {
- if (lhsc is EqStrideConstraint && rhsc is EqStrideConstraint) {
- return new EqStrideConstraint(e);
- }
-
- if (lhsc is EqStrideConstraint && rhsc is ModStrideConstraint)
- return BuildAddStrideConstraint(verifier, e, rhsc, lhsc);
-
- if (lhsc is ModStrideConstraint && rhsc is EqStrideConstraint) {
- var lhsmc = (ModStrideConstraint)lhsc;
- var rhsec = (EqStrideConstraint)rhsc;
-
- return new ModStrideConstraint(lhsmc.mod, verifier.MakeBVAdd(lhsmc.modEq, rhsec.eq));
- }
-
- if (lhsc is ModStrideConstraint && rhsc is ModStrideConstraint) {
- var lhsmc = (ModStrideConstraint)lhsc;
- var rhsmc = (ModStrideConstraint)rhsc;
-
- if (lhsmc.mod == rhsmc.mod)
- return new ModStrideConstraint(lhsmc.mod, verifier.MakeBVAdd(lhsmc.modEq, rhsmc.modEq));
- }
-
- return Bottom(e);
- }
-
- private static StrideConstraint BuildMulStrideConstraint(GPUVerifier verifier, Expr e, StrideConstraint lhsc, StrideConstraint rhsc) {
- if (lhsc is EqStrideConstraint && rhsc is EqStrideConstraint) {
- return new EqStrideConstraint(e);
- }
-
- if (lhsc is EqStrideConstraint && rhsc is ModStrideConstraint)
- return BuildMulStrideConstraint(verifier, e, rhsc, lhsc);
-
- if (lhsc is ModStrideConstraint && rhsc is EqStrideConstraint) {
- var lhsmc = (ModStrideConstraint)lhsc;
- var rhsec = (EqStrideConstraint)rhsc;
-
- return new ModStrideConstraint(verifier.MakeBVMul(lhsmc.mod, rhsec.eq),
- verifier.MakeBVMul(lhsmc.modEq, rhsec.eq));
- }
-
- return Bottom(e);
- }
-
- public static StrideConstraint FromExpr(GPUVerifier verifier, Implementation impl, Expr e) {
- if (e is LiteralExpr)
- return new EqStrideConstraint(e);
-
- var ie = e as IdentifierExpr;
- if (ie != null) {
- if (ie.Decl is Constant)
- return new EqStrideConstraint(e);
-
- var rsa = verifier.reducedStrengthAnalyses[impl];
- var sc = rsa.GetStrideConstraint(ie.Decl.Name);
- if (sc == null)
- return Bottom(e);
- return sc;
- }
-
- Expr lhs, rhs;
-
- if (GPUVerifier.IsBVAdd(e, out lhs, out rhs)) {
- var lhsc = FromExpr(verifier, impl, lhs);
- var rhsc = FromExpr(verifier, impl, rhs);
- return BuildAddStrideConstraint(verifier, e, lhsc, rhsc);
- }
-
- if (GPUVerifier.IsBVMul(e, out lhs, out rhs)) {
- var lhsc = FromExpr(verifier, impl, lhs);
- var rhsc = FromExpr(verifier, impl, rhs);
- return BuildMulStrideConstraint(verifier, e, lhsc, rhsc);
- }
-
- return Bottom(e);
- }
-
-}
-
-class EqStrideConstraint : StrideConstraint {
- public EqStrideConstraint(Expr eq) { this.eq = eq; }
- public Expr eq;
-}
-
-class ModStrideConstraint : StrideConstraint {
- public ModStrideConstraint(Expr mod, Expr modEq) { this.mod = mod; this.modEq = modEq; }
- public Expr mod, modEq;
-}
-
-}
diff --git a/Test/dafny0/Answer b/Test/dafny0/Answer
index 7510363a..85958099 100644
--- a/Test/dafny0/Answer
+++ b/Test/dafny0/Answer
@@ -703,8 +703,8 @@ Execution trace:
Dafny program verifier finished with 7 verified, 1 error
-------------------- ModulesCycle.dfy --------------------
-ModulesCycle.dfy(12,7): Error: module T named among imports does not exist
-ModulesCycle.dfy(23,7): Error: import graph contains a cycle: H -> I -> J -> G
+ModulesCycle.dfy(3,9): Error: module T does not exist
+ModulesCycle.dfy(6,7): Error: module definition contains a cycle (note: parent modules implicitly depend on submodules): A -> D -> C -> B
2 resolution/type errors detected in ModulesCycle.dfy
-------------------- Modules0.dfy --------------------
@@ -714,55 +714,47 @@ Modules0.dfy(7,7): Error: Duplicate name of top-level declaration: WazzupA
Modules0.dfy(10,7): Error: Duplicate name of top-level declaration: WazzupB
Modules0.dfy(11,8): Error: Duplicate name of top-level declaration: WazzupB
Modules0.dfy(12,11): Error: Duplicate name of top-level declaration: WazzupB
-Modules0.dfy(42,11): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(43,18): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(44,15): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(46,16): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(47,18): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(52,19): Error: The name T ambiguously refers to a type in one of the modules N, M (try qualifying the type name with the module name)
-Modules0.dfy(52,12): Error: new can be applied only to reference types (got T)
-Modules0.dfy(57,12): Error: Undeclared top-level type or type parameter: T (did you forget a module import?)
-Modules0.dfy(73,18): Error: Undeclared top-level type or type parameter: MyClass1 (did you forget a module import?)
-Modules0.dfy(74,18): Error: Undeclared top-level type or type parameter: MyClass2 (did you forget a module import?)
-Modules0.dfy(84,18): Error: Undeclared top-level type or type parameter: MyClass2 (did you forget a module import?)
-Modules0.dfy(108,16): Error: Undeclared top-level type or type parameter: ClassG (did you forget a module import?)
-Modules0.dfy(247,11): Error: Undeclared top-level type or type parameter: X (did you forget a module import?)
-Modules0.dfy(256,13): Error: unresolved identifier: X
-Modules0.dfy(257,15): Error: member DoesNotExist does not exist in class X
-Modules0.dfy(299,16): Error: member R does not exist in class B
-Modules0.dfy(299,6): Error: expected method call, found expression
-Modules0.dfy(322,18): Error: second argument to "in" must be a set or sequence with elements of type Q_Imp.Node, or a map with domain Q_Imp.Node (instead got set<Node>)
-Modules0.dfy(326,13): Error: arguments must have the same type (got Q_Imp.Node and Node)
-Modules0.dfy(327,11): Error: Undeclared module name: LongLostModule (did you forget a module import?)
-Modules0.dfy(328,11): Error: Undeclared module name: Wazzup (did you forget a module import?)
-Modules0.dfy(329,17): Error: Undeclared class name Edon in module Q_Imp
-Modules0.dfy(331,10): Error: new can be applied only to reference types (got Q_Imp.List<?>)
-Modules0.dfy(332,30): Error: member Create does not exist in class Klassy
-Modules0.dfy(143,11): Error: ghost variables are allowed only in specification contexts
-Modules0.dfy(157,11): Error: old expressions are allowed only in specification and ghost contexts
-Modules0.dfy(158,11): Error: fresh expressions are allowed only in specification and ghost contexts
-Modules0.dfy(159,11): Error: allocated expressions are allowed only in specification and ghost contexts
-Modules0.dfy(175,10): Error: match source expression 'tree' has already been used as a match source expression in this context
-Modules0.dfy(214,12): Error: match source expression 'l' has already been used as a match source expression in this context
-36 resolution/type errors detected in Modules0.dfy
+Modules0.dfy(53,18): Error: Undeclared top-level type or type parameter: MyClass1 (did you forget a module import?)
+Modules0.dfy(54,18): Error: Undeclared top-level type or type parameter: MyClass2 (did you forget a module import?)
+Modules0.dfy(65,18): Error: Undeclared top-level type or type parameter: MyClass2 (did you forget a module import?)
+Modules0.dfy(72,20): Error: Undeclared top-level type or type parameter: MyClass1 (did you forget a module import?)
+Modules0.dfy(72,34): Error: Undeclared top-level type or type parameter: MyClass0 (did you forget a module import?)
+Modules0.dfy(75,23): Error: Undeclared top-level type or type parameter: MyClass0 (did you forget a module import?)
+Modules0.dfy(80,24): Error: Undeclared top-level type or type parameter: MyClassY (did you forget a module import?)
+Modules0.dfy(89,16): Error: Undeclared top-level type or type parameter: ClassG (did you forget a module import?)
+Modules0.dfy(221,15): Error: Undeclared top-level type or type parameter: X (did you forget a module import?)
+Modules0.dfy(221,8): Error: new can be applied only to reference types (got X)
+Modules0.dfy(230,13): Error: The name does not exist in the given module
+Modules0.dfy(240,13): Error: unresolved identifier: X
+Modules0.dfy(241,15): Error: member DoesNotExist does not exist in class X
+Modules0.dfy(280,19): Error: Undeclared top-level type or type parameter: D (did you forget a module import?)
+Modules0.dfy(280,12): Error: new can be applied only to reference types (got D)
+Modules0.dfy(283,25): Error: type of the receiver is not fully determined at this program point
+Modules0.dfy(284,16): Error: type of the receiver is not fully determined at this program point
+Modules0.dfy(284,6): Error: expected method call, found expression
+Modules0.dfy(285,16): Error: type of the receiver is not fully determined at this program point
+Modules0.dfy(285,6): Error: expected method call, found expression
+Modules0.dfy(307,24): Error: Undeclared module name: Q_Imp (did you forget a module import?)
+Modules0.dfy(97,14): Error: Undeclared top-level type or type parameter: MyClassY (did you forget a module import?)
+28 resolution/type errors detected in Modules0.dfy
-------------------- Modules1.dfy --------------------
-Modules1.dfy(74,16): Error: assertion violation
+Modules1.dfy(75,16): Error: assertion violation
Execution trace:
(0,0): anon0
(0,0): anon3_Then
-Modules1.dfy(86,16): Error: assertion violation
+Modules1.dfy(88,16): Error: assertion violation
Execution trace:
(0,0): anon0
(0,0): anon3_Then
-Modules1.dfy(88,14): Error: assertion violation
+Modules1.dfy(90,14): Error: assertion violation
Execution trace:
(0,0): anon0
(0,0): anon3_Else
-Modules1.dfy(52,3): Error: decreases expression must be bounded below by 0
+Modules1.dfy(53,3): Error: decreases expression must be bounded below by 0
Execution trace:
(0,0): anon0
-Modules1.dfy(58,3): Error: failure to decrease termination measure
+Modules1.dfy(59,3): Error: failure to decrease termination measure
Execution trace:
(0,0): anon0
@@ -1441,19 +1433,19 @@ Refinement.dfy(93,3): Error BP5003: A postcondition might not hold on this retur
Refinement.dfy(74,15): Related location: This is the postcondition that might not hold.
Execution trace:
(0,0): anon0
-Refinement.dfy(179,5): Error BP5003: A postcondition might not hold on this return path.
+Refinement.dfy(180,5): Error BP5003: A postcondition might not hold on this return path.
Refinement.dfy(112,15): Related location: This is the postcondition that might not hold.
-Refinement.dfy(176,9): Related location: Related location
+Refinement.dfy(177,9): Related location: Related location
Execution trace:
(0,0): anon0
-Refinement.dfy(183,5): Error BP5003: A postcondition might not hold on this return path.
+Refinement.dfy(184,5): Error BP5003: A postcondition might not hold on this return path.
Refinement.dfy(120,15): Related location: This is the postcondition that might not hold.
-Refinement.dfy(176,9): Related location: Related location
+Refinement.dfy(177,9): Related location: Related location
Execution trace:
(0,0): anon0
(0,0): anon4_Then
(0,0): anon3
-Refinement.dfy(189,7): Error: assertion violation
+Refinement.dfy(190,7): Error: assertion violation
Refinement.dfy[IncorrectConcrete](128,24): Related location: Related location
Execution trace:
(0,0): anon0
@@ -1535,24 +1527,24 @@ Predicates.dfy[B](17,15): Related location: This is the postcondition that might
Predicates.dfy(28,9): Related location: Related location
Execution trace:
(0,0): anon0
-Predicates.dfy(84,16): Error: assertion violation
+Predicates.dfy(85,16): Error: assertion violation
Execution trace:
(0,0): anon0
-Predicates.dfy(88,14): Error: assertion violation
+Predicates.dfy(89,14): Error: assertion violation
Execution trace:
(0,0): anon0
-Predicates.dfy[Tricky_Full](121,5): Error BP5003: A postcondition might not hold on this return path.
-Predicates.dfy[Tricky_Full](120,15): Related location: This is the postcondition that might not hold.
-Predicates.dfy(131,7): Related location: Related location
-Predicates.dfy[Tricky_Full](111,9): Related location: Related location
+Predicates.dfy[Tricky_Full](123,5): Error BP5003: A postcondition might not hold on this return path.
+Predicates.dfy[Tricky_Full](122,15): Related location: This is the postcondition that might not hold.
+Predicates.dfy(133,7): Related location: Related location
+Predicates.dfy[Tricky_Full](113,9): Related location: Related location
Execution trace:
(0,0): anon0
-Predicates.dfy(159,5): Error BP5003: A postcondition might not hold on this return path.
-Predicates.dfy(158,15): Related location: This is the postcondition that might not hold.
+Predicates.dfy(161,5): Error BP5003: A postcondition might not hold on this return path.
+Predicates.dfy(160,15): Related location: This is the postcondition that might not hold.
Execution trace:
(0,0): anon0
-Predicates.dfy[Q1](149,5): Error BP5003: A postcondition might not hold on this return path.
-Predicates.dfy[Q1](148,15): Related location: This is the postcondition that might not hold.
+Predicates.dfy[Q1](151,5): Error BP5003: A postcondition might not hold on this return path.
+Predicates.dfy[Q1](150,15): Related location: This is the postcondition that might not hold.
Execution trace:
(0,0): anon0
@@ -1583,9 +1575,10 @@ Execution trace:
Dafny program verifier finished with 30 verified, 2 errors
-------------------- LiberalEquality.dfy --------------------
+LiberalEquality.dfy(18,14): Error: arguments must have the same type (got T and U)
LiberalEquality.dfy(37,14): Error: arguments must have the same type (got Weird<T,int,V> and Weird<T,bool,V>)
LiberalEquality.dfy(52,14): Error: arguments must have the same type (got array<int> and array<bool>)
-2 resolution/type errors detected in LiberalEquality.dfy
+3 resolution/type errors detected in LiberalEquality.dfy
-------------------- SmallTests.dfy --------------------
SmallTests.dfy(30,11): Error: index out of range
diff --git a/Test/dafny0/LiberalEquality.dfy b/Test/dafny0/LiberalEquality.dfy
index 3dc52c80..b9b4629b 100644
--- a/Test/dafny0/LiberalEquality.dfy
+++ b/Test/dafny0/LiberalEquality.dfy
@@ -15,7 +15,7 @@ class Test<T> {
}
method m1<T, U>(t: T, u: U)
- requires t != u;
+ requires t != u; // Cannot compare type parameters (can only compare reference types that could be the same)
{
}
diff --git a/Test/dafny0/Modules0.dfy b/Test/dafny0/Modules0.dfy
index 80ac7eef..273c88de 100644
--- a/Test/dafny0/Modules0.dfy
+++ b/Test/dafny0/Modules0.dfy
@@ -23,46 +23,26 @@ module N {
class T { }
}
-module U imports N { // fine, despite the fact that a class is called U,
- // since module names are in their own name space
+module U {
+ module NN = N;
}
-module UU imports N, U, N, N { // duplicates are allowed
-}
-
-module N_left imports N { }
-module N_right imports N { }
-module Diamond imports N_left, N_right { // this imports N.T twice, but that's okay
-}
-module A imports N, M { // Note, this has the effect of importing two different T's,
- // but that's okay as long as the module doesn't try to access
- // one of them
+module A { // Note, this has the effect of importing two different T's,
+ // but that's okay as long as the module doesn't try to access
+ // one of them
+ module MM = M;
+ module NN = N;
class X {
- var t: T; // error: use of the ambiguous name T
- function F(x: T): // error: use of the ambiguous name T
- T // error: use of the ambiguous name T
+ var t: MM.T; // error: use of the ambiguous name T
+ function F(x: MM.T): // error: use of the ambiguous name T
+ MM.T // error: use of the ambiguous name T
{ x }
- method M(x: T) // error: use of the ambiguous name T
- returns (y: T) // error: use of the ambiguous name T
+ method M(x: NN.T) // error: use of the ambiguous name T
+ returns (y: NN.T) // error: use of the ambiguous name T
}
}
-module A' imports N, M {
- method M()
- { var g := new T; } // error: use of the ambiguous name T
-}
-module B0 imports A {
- class BadUse {
- var b0: T; // error: T is not directly accessible
- }
-}
-
-module B1 imports A, N {
- class GoodUse {
- var b1: T; // fine
- }
-}
// --------------- calls
@@ -76,9 +56,10 @@ module X0 {
}
}
-module X1 imports X0 {
+module X1 {
+ module X0' = X0;
class MyClass1 {
- method Down(x0: MyClass0) {
+ method Down(x0: X0'.MyClass0) {
x0.Down();
}
method Up(x2: MyClass2) { // error: class MyClass2 is not in scope
@@ -86,7 +67,7 @@ module X1 imports X0 {
}
}
-module X2 imports X0, X1, YY {
+module X2 {
class MyClass2 {
method Down(x1: MyClass1, x0: MyClass0) {
x1.Down(x0);
@@ -231,9 +212,10 @@ module ATr {
}
}
-module BTr imports ATr {
+module BTr {
+ module A = ATr;
class Y {
- method N() returns (x: X)
+ method N() returns (x: A.X)
ensures x != null;
{
x := new X;
@@ -241,15 +223,17 @@ module BTr imports ATr {
}
}
-module CTr imports BTr {
+module CTr {
+ module B = BTr;
class Z {
- var b: Y; // fine
- var a: X; // error: imports don't reach name X explicitly
+ var b: B.Y; // fine
+ var a: B.X; // error: imports don't reach name X explicitly
}
}
-module CTs imports BTr {
+module CTs {
+ module B = BTr;
method P() {
- var y := new Y;
+ var y := new B.Y;
var x := y.N(); // this is allowed and will correctly infer the type of x to
// be X, but X could not have been mentioned explicitly
var q := x.M();
@@ -285,7 +269,9 @@ module NonLocalB {
}
}
-module Local imports NonLocalA, NonLocalB {
+module Local {
+ module AA = NonLocalA;
+ module BB = NonLocalB;
class MyClass {
method MyMethod()
{
@@ -317,7 +303,7 @@ module Q_Imp {
}
}
-module Q_M imports Q_Imp {
+module Q_M {
method MyMethod(root: Q_Imp.Node, S: set<Node>)
requires root in S; // error: the element type of S does not agree with the type of root
{
diff --git a/Test/dafny0/Modules1.dfy b/Test/dafny0/Modules1.dfy
index e8a88749..6fd8560e 100644
--- a/Test/dafny0/Modules1.dfy
+++ b/Test/dafny0/Modules1.dfy
@@ -1,6 +1,7 @@
-module A imports B {
+module A {
+ module B = Babble;
class X {
- function Fx(z: Z): int
+ function Fx(z: B.Z): int
requires z != null;
decreases 5, 4, 3;
{ z.G() } // fine; this goes to a different module
@@ -17,7 +18,7 @@ method MyMethod() { }
var MyField: int;
-module B {
+module Babble {
class Z {
method K() { }
function G(): int
@@ -78,14 +79,15 @@ module A_Visibility {
}
}
-module B_Visibility imports A_Visibility {
+module B_Visibility {
+ module A = A_Visibility;
method Main() {
var y;
- if (C.P(y)) {
+ if (A.C.P(y)) {
assert 0 <= y; // this much is known of C.P
assert 2 <= y; // error
} else {
- assert C.P(8); // error: C.P cannot be established outside the declaring module
+ assert A.C.P(8); // error: C.P cannot be established outside the declaring module
}
}
}
@@ -99,13 +101,14 @@ module Q_Imp {
}
}
-module Q_M imports Q_Imp {
- method MyMethod(root: Q_Imp.Node, S: set<Q_Imp.Node>)
+module Q_M {
+ module Q = Q_Imp;
+ method MyMethod(root: Q.Node, S: set<Q.Node>)
requires root in S;
{
- var i := new Q_Imp.Node;
- var j := new Node;
+ var i := new Q.Node;
+ var j := new Q.Node;
assert i != j; // fine
- var q := new Q_Imp.Klassy.Init();
+ var q := new Q.Klassy.Init();
}
}
diff --git a/Test/dafny0/ModulesCycle.dfy b/Test/dafny0/ModulesCycle.dfy
index a7f1caa2..15cad8e8 100644
--- a/Test/dafny0/ModulesCycle.dfy
+++ b/Test/dafny0/ModulesCycle.dfy
@@ -1,33 +1,12 @@
-module M {
- class T { }
- class U { }
-}
-
-module N {
-}
-
-module U imports N {
-}
-
-module V imports T { // error: T is not a module
-}
-module A imports B, M {
- class Y { }
+module V {
+ module t = T; // error: T is not visible (and isn't even a module)
}
-module B imports N, M {
- class X { }
+module A {
+ module B = C;
}
-module G imports A, M, A, H, B { // error: cycle in import graph
-}
-
-module H imports A, N, I {
-}
-
-module I imports J {
-}
-
-module J imports G, M {
-}
+module C {
+ module D = A;
+} \ No newline at end of file
diff --git a/Test/dafny0/Predicates.dfy b/Test/dafny0/Predicates.dfy
index 146129b5..8857482f 100644
--- a/Test/dafny0/Predicates.dfy
+++ b/Test/dafny0/Predicates.dfy
@@ -78,9 +78,10 @@ module Tight refines Loose {
}
}
-module UnawareClient imports Loose {
+module UnawareClient {
+ module L = Loose;
method Main0() {
- var n := new MyNumber.Init();
+ var n := new L.MyNumber.Init();
assert n.N == 0; // error: this is not known
n.Inc();
n.Inc();
@@ -89,9 +90,10 @@ module UnawareClient imports Loose {
}
}
-module AwareClient imports Tight {
+module AwareClient {
+ module T = Tight;
method Main1() {
- var n := new MyNumber.Init();
+ var n := new T.MyNumber.Init();
assert n.N == 0;
n.Inc();
n.Inc();
diff --git a/Test/dafny0/Refinement.dfy b/Test/dafny0/Refinement.dfy
index da7f0ac2..2c2fc52b 100644
--- a/Test/dafny0/Refinement.dfy
+++ b/Test/dafny0/Refinement.dfy
@@ -155,10 +155,11 @@ module Concrete refines Abstract {
}
}
-module Client imports Concrete {
+module Client {
+ module C = Concrete;
class TheClient {
method Main() {
- var n := new MyNumber.Init();
+ var n := new C.MyNumber.Init();
n.Inc();
n.Inc();
var k := n.Get();
diff --git a/Test/dafny1/Answer b/Test/dafny1/Answer
index 06cac03b..b2876948 100644
--- a/Test/dafny1/Answer
+++ b/Test/dafny1/Answer
@@ -11,10 +11,6 @@ Dafny program verifier finished with 24 verified, 0 errors
Dafny program verifier finished with 11 verified, 0 errors
--------------------- ExtensibleArrayAuto.dfy --------------------
-
-Dafny program verifier finished with 11 verified, 0 errors
-
-------------------- BinaryTree.dfy --------------------
Dafny program verifier finished with 24 verified, 0 errors
diff --git a/Test/dafny1/ListContents.dfy b/Test/dafny1/ListContents.dfy
index 594be748..a8b4861d 100644
--- a/Test/dafny1/ListContents.dfy
+++ b/Test/dafny1/ListContents.dfy
@@ -62,7 +62,7 @@ class Node<T> {
reverse.next := null;
reverse.footprint := {reverse};
reverse.list := [data];
-
+
while (current != null)
invariant reverse != null && reverse.Valid();
invariant reverse.footprint <= old(footprint);
@@ -71,8 +71,8 @@ class Node<T> {
current.Valid() &&
current in old(footprint) && current.footprint <= old(footprint) &&
current.footprint !! reverse.footprint &&
- |old(list)| == |reverse.list| + |current.list| &&
- (forall i :: 0 <= i && i < |current.list| ==> current.list[i] == old(list)[|reverse.list|+i]);
+ |old(list)| == |reverse.list| + |current.list|;
+ invariant current != null ==> current.list == old(list)[|reverse.list|..];
invariant
(forall i :: 0 <= i && i < |reverse.list| ==> old(list)[i] == reverse.list[|reverse.list|-1-i]);
decreases if current != null then |current.list| else -1;
@@ -86,13 +86,6 @@ class Node<T> {
reverse := current;
current := nx;
- // This makes the verification go faster.
- assert current != null ==>
- current.Valid() &&
- current in old(footprint) && current.footprint <= old(footprint) &&
- current.footprint !! reverse.footprint &&
- |old(list)| == |reverse.list| + |current.list| &&
- (forall i :: 0 <= i && i < |current.list| ==> current.list[i] == old(list)[|reverse.list|+i]);
}
}
}
diff --git a/Test/dafny1/runtest.bat b/Test/dafny1/runtest.bat
index fa7f7c70..22bef761 100644
--- a/Test/dafny1/runtest.bat
+++ b/Test/dafny1/runtest.bat
@@ -5,7 +5,7 @@ set BOOGIEDIR=..\..\Binaries
set DAFNY_EXE=%BOOGIEDIR%\Dafny.exe
for %%f in (Queue.dfy PriorityQueue.dfy
- ExtensibleArray.dfy ExtensibleArrayAuto.dfy
+ ExtensibleArray.dfy
BinaryTree.dfy
UnboundedStack.dfy
SeparationLogicList.dfy
diff --git a/Test/dafny2/Answer b/Test/dafny2/Answer
index 9c37549e..f359e416 100644
--- a/Test/dafny2/Answer
+++ b/Test/dafny2/Answer
@@ -39,10 +39,6 @@ Dafny program verifier finished with 3 verified, 0 errors
Dafny program verifier finished with 3 verified, 0 errors
--------------------- StoreAndRetrieve.dfy --------------------
-
-Dafny program verifier finished with 22 verified, 0 errors
-
-------------------- MajorityVote.dfy --------------------
Dafny program verifier finished with 11 verified, 0 errors
diff --git a/Test/dafny2/runtest.bat b/Test/dafny2/runtest.bat
index b68ba251..19b116d2 100644
--- a/Test/dafny2/runtest.bat
+++ b/Test/dafny2/runtest.bat
@@ -4,7 +4,7 @@ setlocal
set BOOGIEDIR=..\..\Binaries
set DAFNY_EXE=%BOOGIEDIR%\Dafny.exe
-REM soon again: SnapshotableTrees.dfy
+REM soon again: SnapshotableTrees.dfy StoreAndRetrieve.dfy
for %%f in (
Classics.dfy
TreeBarrier.dfy
@@ -14,7 +14,7 @@ for %%f in (
COST-verif-comp-2011-3-TwoDuplicates.dfy
COST-verif-comp-2011-4-FloydCycleDetect.dfy
Intervals.dfy TreeFill.dfy TuringFactorial.dfy
- StoreAndRetrieve.dfy MajorityVote.dfy SegmentSum.dfy
+ MajorityVote.dfy SegmentSum.dfy
) do (
echo.
echo -------------------- %%f --------------------
diff --git a/Test/test15/Answer b/Test/test15/Answer
index 04a94759..473af09b 100644
--- a/Test/test15/Answer
+++ b/Test/test15/Answer
@@ -1,14 +1,14 @@
-------------------- NullInModel --------------------
*** MODEL
-s -> T@U!val!0
-%lbl%+24 -> true
%lbl%@47 -> false
-refType -> T@T!val!2
-intType -> T@T!val!0
+%lbl%+24 -> true
%lbl%+37 -> true
boolType -> T@T!val!1
+intType -> T@T!val!0
null -> T@U!val!0
+refType -> T@T!val!2
+s -> T@U!val!0
tickleBool -> {
true -> true
false -> true
@@ -33,12 +33,12 @@ Boogie program verifier finished with 0 verified, 1 error
-------------------- IntInModel --------------------
*** MODEL
-intType -> T@T!val!0
-boolType -> T@T!val!1
-%lbl%+29 -> true
+%lbl%@39 -> false
%lbl%+23 -> true
+%lbl%+29 -> true
+boolType -> T@T!val!1
i -> 0
-%lbl%@39 -> false
+intType -> T@T!val!0
tickleBool -> {
true -> true
false -> true
@@ -58,18 +58,18 @@ Boogie program verifier finished with 0 verified, 1 error
-------------------- ModelTest --------------------
*** MODEL
-%lbl%+64 -> true
-s -> T@U!val!0
-j@2 -> 4
+%lbl%@182 -> false
%lbl%+119 -> true
+%lbl%+64 -> true
boolType -> T@T!val!1
-intType -> T@T!val!0
-refType -> T@T!val!2
-%lbl%@182 -> false
i@0 -> 1
+intType -> T@T!val!0
j@0 -> 2
j@1 -> 3
+j@2 -> 4
r -> T@U!val!1
+refType -> T@T!val!2
+s -> T@U!val!0
tickleBool -> {
true -> true
false -> true
@@ -114,27 +114,27 @@ Execution trace:
CaptureState.bpl(16,5): anon4_Then
CaptureState.bpl(24,5): anon3
*** MODEL
-m@3 -> -1
-this -> T@U!val!1
-intType -> T@T!val!0
+%lbl%@334 -> false
+%lbl%+110 -> true
%lbl%+112 -> true
-Heap -> T@U!val!0
%lbl%+116 -> true
-%lbl%+110 -> true
+%lbl%+189 -> true
+@MV_state_const -> 6
+boolType -> T@T!val!1
+F -> T@U!val!2
FieldNameType -> T@T!val!3
+Heap -> T@U!val!0
+intType -> T@T!val!0
+m -> **m
m@0 -> -2
m@2 -> -1
+m@3 -> -1
+r -> **r
r@0 -> -2
-boolType -> T@T!val!1
-%lbl%@334 -> false
-%lbl%+189 -> true
RefType -> T@T!val!2
-F -> T@U!val!2
-@MV_state_const -> 6
+this -> T@U!val!1
x@@4 -> 797
y@@1 -> **y@@1
-r -> **r
-m -> **m
tickleBool -> {
true -> true
false -> true
diff --git a/Test/vstte2012/Answer b/Test/vstte2012/Answer
index bca270c3..15a95de1 100644
--- a/Test/vstte2012/Answer
+++ b/Test/vstte2012/Answer
@@ -11,10 +11,6 @@ Dafny program verifier finished with 25 verified, 0 errors
Dafny program verifier finished with 13 verified, 0 errors
--------------------- RingBufferAuto.dfy --------------------
-
-Dafny program verifier finished with 13 verified, 0 errors
-
-------------------- Tree.dfy --------------------
Dafny program verifier finished with 15 verified, 0 errors
diff --git a/Test/vstte2012/runtest.bat b/Test/vstte2012/runtest.bat
index 7f7c9b9f..cda455fa 100644
--- a/Test/vstte2012/runtest.bat
+++ b/Test/vstte2012/runtest.bat
@@ -4,10 +4,11 @@ setlocal
set BOOGIEDIR=..\..\Binaries
set DAFNY_EXE=%BOOGIEDIR%\Dafny.exe
+REM removed for now: RingBufferAuto.dfy
for %%f in (
Two-Way-Sort.dfy
Combinators.dfy
- RingBuffer.dfy RingBufferAuto.dfy
+ RingBuffer.dfy
Tree.dfy
BreadthFirstSearch.dfy
) do (
diff --git a/Util/VS2010/Dafny/DafnyLanguageService/Grammar.cs b/Util/VS2010/Dafny/DafnyLanguageService/Grammar.cs
index 4244e817..627353bf 100644
--- a/Util/VS2010/Dafny/DafnyLanguageService/Grammar.cs
+++ b/Util/VS2010/Dafny/DafnyLanguageService/Grammar.cs
@@ -19,7 +19,7 @@ namespace Demo
this.MarkReservedWords( // NOTE: these keywords must also appear once more below
"class", "ghost", "static", "var", "method", "constructor", "datatype", "codatatype", "type",
"assert", "assume", "new", "this", "object", "refines",
- "module", "imports",
+ "module", "imports", "as",
"if", "then", "else", "while", "invariant",
"break", "label", "return", "parallel", "havoc", "print",
"returns", "requires", "ensures", "modifies", "reads", "decreases",
@@ -277,6 +277,7 @@ namespace Demo
| "refines"
| "module"
| "imports"
+ | "as"
| "if"
| "then"
| "else"
diff --git a/_admin/Boogie/aste/summary.log b/_admin/Boogie/aste/summary.log
index b8e43610..36f316ee 100644
--- a/_admin/Boogie/aste/summary.log
+++ b/_admin/Boogie/aste/summary.log
@@ -1,15 +1,15 @@
-# Aste started: 2012-06-28 07:00:02
+# Aste started: 2012-07-01 07:00:02
# Host id: Boogiebox
# Configuration: boogie.cfg
# Task: aste.tasks.boogie.FullBuild
-# [2012-06-28 07:01:12] SpecSharp revision: c5e115b716fb
-# [2012-06-28 07:01:12] SscBoogie revision: c5e115b716fb
-# [2012-06-28 07:02:11] Boogie revision: a813e78d9573
-[2012-06-28 07:03:59] C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com SpecSharp.sln /Project "Checkin Tests" /Build
+# [2012-07-01 07:01:03] SpecSharp revision: 5a36a96934ef
+# [2012-07-01 07:01:03] SscBoogie revision: 5a36a96934ef
+# [2012-07-01 07:02:11] Boogie revision: a31c96069547
+[2012-07-01 07:03:15] C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com SpecSharp.sln /Project "Checkin Tests" /Build
1>corflags : warning CF011: The specified file is strong name signed. Using /Force will invalidate the signature of this image and will require the assembly to be resigned.
warning CF011: The specified file is strong name signed. Using /Force will invalidate the signature of this image and will require the assembly to be resigned.
-[2012-06-28 07:05:29] C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com Boogie.sln /Rebuild Checked
+[2012-07-01 07:04:56] C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com Boogie.sln /Rebuild Checked
D:\Temp\aste\Boogie\Source\Core\AbsyType.cs(823,16): warning CS0659: 'Microsoft.Boogie.BasicType' overrides Object.Equals(object o) but does not override Object.GetHashCode()
D:\Temp\aste\Boogie\Source\Core\AbsyType.cs(2802,16): warning CS0659: 'Microsoft.Boogie.CtorType' overrides Object.Equals(object o) but does not override Object.GetHashCode()
@@ -41,6 +41,9 @@
warning CS0162: Unreachable code detected
warning CC1032: Method 'Microsoft.Boogie.Houdini.InlineRequiresVisitor.VisitCmdSeq(Microsoft.Boogie.CmdSeq)' overrides 'Microsoft.Boogie.StandardVisitor.VisitCmdSeq(Microsoft.Boogie.CmdSeq)', thus cannot add Requires.
warning CC1032: Method 'Microsoft.Boogie.Houdini.FreeRequiresVisitor.VisitAssertRequiresCmd(Microsoft.Boogie.AssertRequiresCmd)' overrides 'Microsoft.Boogie.StandardVisitor.VisitAssertRequiresCmd(Microsoft.Boogie.AssertRequiresCmd)', thus cannot add Requires.
-[2012-06-28 08:09:26] 1 out of 33 test(s) in D:\Temp\aste\Boogie\Test\alltests.txt failed
-['test15']
-# [2012-06-28 08:10:09] Released nightly of Boogie
+[2012-07-01 07:05:12] C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com Dafny.sln /Rebuild Checked
+
+ D:\Temp\aste\Boogie\Source\Dafny\RefinementTransformer.cs(65,7): warning CC1033: Method 'Microsoft.Dafny.RefinementTransformer.PreResolve(Microsoft.Dafny.ModuleDefinition)' implements interface method 'Microsoft.Dafny.IRewriter.PreResolve(Microsoft.Dafny.ModuleDefinition)', thus cannot add Requires.
+ warning CC1033: Method 'Microsoft.Dafny.RefinementTransformer.PreResolve(Microsoft.Dafny.ModuleDefinition)' implements interface method 'Microsoft.Dafny.IRewriter.PreResolve(Microsoft.Dafny.ModuleDefinition)', thus cannot add Requires.
+[2012-07-01 08:10:46] 0 out of 33 test(s) in D:\Temp\aste\Boogie\Test\alltests.txt failed
+# [2012-07-01 08:11:28] Released nightly of Boogie
diff --git a/_admin/Chalice/aste/summary.log b/_admin/Chalice/aste/summary.log
index 177c1fc2..4b7f68fc 100644
--- a/_admin/Chalice/aste/summary.log
+++ b/_admin/Chalice/aste/summary.log
@@ -1,9 +1,9 @@
-# Aste started: 2012-06-08 09:05:33
+# Aste started: 2012-06-30 07:04:21
# Host id: Boogiebox
# Configuration: chalice.cfg
# Task: aste.tasks.chalice.FullBuild
-# [2012-06-08 09:06:28] Chalice revision: 819624caaac6
-[2012-06-08 09:07:52] cmd /c "(set JAVA_OPTS=-Dsbt.ivy.home=D:\temp\.ivy2\) && (sbt.bat clean compile)"
+# [2012-06-30 07:05:08] Chalice revision: fd5b6c3b4c53
+[2012-06-30 07:06:35] cmd /c "(set JAVA_OPTS=-Dsbt.ivy.home=D:\temp\.ivy2\) && (sbt.bat clean compile)"
[warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:77: case class `class SeqClass' has case class ancestor `class Class'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
[warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:111: case class `class TokenClass' has case class ancestor `class Class'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
@@ -11,13 +11,5 @@
[warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:141: case class `class TokenType' has case class ancestor `class Type'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
[warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:168: case class `class SpecialField' has case class ancestor `class Field'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
[warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:227: case class `class SpecialVariable' has case class ancestor `class Variable'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
-[2012-06-08 09:42:23] 0 out of 85 test(s) failed
-[2012-06-08 09:43:39] cmd /c "(set JAVA_OPTS=-Dsbt.ivy.home=D:\temp\.ivy2\) && (create_release.bat)"
-
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:77: case class `class SeqClass' has case class ancestor `class Class'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:111: case class `class TokenClass' has case class ancestor `class Class'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:121: case class `class ChannelClass' has case class ancestor `class Class'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:141: case class `class TokenType' has case class ancestor `class Type'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:168: case class `class SpecialField' has case class ancestor `class Field'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
- [warn] D:\temp\aste\Boogie\Chalice\src\main\scala\Ast.scala:227: case class `class SpecialVariable' has case class ancestor `class Variable'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes.
-# [2012-06-08 09:44:16] Released nightly of Chalice
+[2012-06-30 07:40:25] 0 out of 85 test(s) failed
+# [2012-06-30 07:41:28] Released nightly of Chalice