Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve match before compile #2734

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
364 commits
Select commit Hold shift + click to select a range
7527220
Small fix
keyboardDrummer Oct 4, 2022
bbeb012
Run formatter
keyboardDrummer Oct 4, 2022
135fc5e
Refactor CompileNestedMatch
keyboardDrummer Oct 5, 2022
2e86af7
Refactor CompileNestedMatch take2
keyboardDrummer Oct 5, 2022
ed423c9
Further refactoring of CompileNestedMatch
keyboardDrummer Oct 5, 2022
1fdc9c9
Refactoring
keyboardDrummer Oct 5, 2022
9edf54d
Fix bugs related to nested match constructs
keyboardDrummer Oct 5, 2022
ff6e47a
Move unnested match AST
keyboardDrummer Oct 5, 2022
4127e8e
Override ToString for statements
keyboardDrummer Oct 5, 2022
7a41faf
Fix accidental Body reuse bug
keyboardDrummer Oct 5, 2022
58e711f
Printing changes
keyboardDrummer Oct 5, 2022
63de739
Allow cloning with resolved fields
keyboardDrummer Oct 5, 2022
619b238
PatternMatching.dfy passes
keyboardDrummer Oct 5, 2022
7a11b6b
Ran formatter
keyboardDrummer Oct 5, 2022
c9a59df
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Oct 5, 2022
6d89b73
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Oct 5, 2022
3eaa042
More cloning if resolved fields
keyboardDrummer Oct 12, 2022
373e422
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Oct 13, 2022
ae8b336
Tiny refac
keyboardDrummer Oct 13, 2022
4f32cec
Remove bad cast
keyboardDrummer Oct 13, 2022
e91b271
Ran formatter
keyboardDrummer Oct 13, 2022
83c9458
Bring back pre-resolve processing of explicit bound variable types
keyboardDrummer Oct 13, 2022
a437955
Ran formatter
keyboardDrummer Oct 13, 2022
5991bc6
Add missing type annotation
keyboardDrummer Oct 13, 2022
6977673
Update cloner for all inheritors of ConcreteSyntaxExpression
keyboardDrummer Oct 13, 2022
f76bd59
NameSegment creation improvement, refactoring, and test updates
keyboardDrummer Oct 14, 2022
40b5dfd
Let IdPattern use a BoundVar or LocalVariable depending on the contex…
keyboardDrummer Oct 14, 2022
3ee3856
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Oct 14, 2022
e2c2b71
Add missing clone
keyboardDrummer Oct 14, 2022
4ee1f58
Remove obsolete print statement
keyboardDrummer Oct 14, 2022
9afc71d
Various cloner and .Children fixes
keyboardDrummer Oct 14, 2022
92a772f
Improve .Children, run formatter
keyboardDrummer Oct 14, 2022
3f719e8
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Oct 14, 2022
6396e5b
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Oct 14, 2022
e06890a
Lambda related changes
keyboardDrummer Oct 14, 2022
a5a78af
Various fixes
keyboardDrummer Oct 18, 2022
5b2711c
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Oct 18, 2022
de2c3bb
Fix for CloneCallAndAddK
keyboardDrummer Oct 18, 2022
1d902ea
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Oct 18, 2022
429d26a
Cloner improvements for AutoGenExpr
keyboardDrummer Oct 18, 2022
d498ecd
Ran formatter
keyboardDrummer Oct 18, 2022
48372f0
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Oct 18, 2022
5748253
Fixes for CloneXAndAddK
keyboardDrummer Oct 18, 2022
80b04bb
Fixes
keyboardDrummer Oct 19, 2022
9aceefd
Commit formatting changes
keyboardDrummer Oct 19, 2022
88f74c7
Fix ChainingExpression
keyboardDrummer Oct 19, 2022
0126747
Various fixes for CoPrefix
keyboardDrummer Oct 19, 2022
9232cfb
ExtremeLemmaBodyCloner fix
keyboardDrummer Oct 26, 2022
cacb03c
Copy BoundVar.IsGhost when substituting
keyboardDrummer Oct 26, 2022
a3e83d7
Some IsGhost assignments that may be useful
keyboardDrummer Oct 26, 2022
2b57634
Pat resolve order change
keyboardDrummer Oct 26, 2022
2c7d126
Undo bug
keyboardDrummer Oct 27, 2022
ce10e4a
Fix children of Calc
keyboardDrummer Oct 27, 2022
c509ad8
Let cloner take into account reference and non-reference variables
keyboardDrummer Oct 31, 2022
2493e34
Refactoring
keyboardDrummer Oct 31, 2022
5bfffdd
Allow cloning resolved attributes
keyboardDrummer Oct 31, 2022
a430987
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Oct 31, 2022
e7b58af
Allocated1 passes after computing ghost interesting after compiling N…
keyboardDrummer Oct 31, 2022
788e907
CoPrefix passes
keyboardDrummer Oct 31, 2022
c432818
Add TODO
keyboardDrummer Oct 31, 2022
943420b
Added null checks to make cloner more robust, Datatypes passes now
keyboardDrummer Nov 1, 2022
d6cf02d
Fix NoTypeArgs test
keyboardDrummer Nov 1, 2022
962a39b
Fix CallStmt cloning
keyboardDrummer Nov 1, 2022
ffe829b
Move TailRecursion to separate class and add case for NestedMatch*
keyboardDrummer Nov 1, 2022
ed2b77b
Update BranchCoverage test expect tokens
keyboardDrummer Nov 1, 2022
3b83c46
Update Various expect file
keyboardDrummer Nov 1, 2022
a9047ae
Update ghostness checks in NestedMatchStmt
keyboardDrummer Nov 1, 2022
da460ff
Fix Abstemious check and ModuleExport expect file
keyboardDrummer Nov 1, 2022
19e23b5
Fix cloning of existsExpr
keyboardDrummer Nov 1, 2022
81d2243
Substitution.dfy passes
keyboardDrummer Nov 1, 2022
0c4f99e
Calculations passes
keyboardDrummer Nov 1, 2022
33fc142
Going over all FilledByResolution attributes to make sure the cloner …
keyboardDrummer Nov 2, 2022
72ffd01
More usages of ICloneable
keyboardDrummer Nov 2, 2022
d85c68c
Remove ConcreteSyntaxStatement since it's not used
keyboardDrummer Nov 2, 2022
50f20fe
All FilledInByResolution Statements and Expressions now inherit from …
keyboardDrummer Nov 2, 2022
ce443b8
Fix cloning bugs
keyboardDrummer Nov 2, 2022
11c24d8
Fix cloning bug in LetExpr
keyboardDrummer Nov 2, 2022
eafe06b
QuantifierExpr.SubExpressions 'fix', test update
keyboardDrummer Nov 2, 2022
efcf155
Update test
keyboardDrummer Nov 2, 2022
4535ea1
Remove redundancy warnings
keyboardDrummer Nov 2, 2022
11150be
Move illegal pattern check to resolution, away from nested match comp…
keyboardDrummer Nov 2, 2022
6ddd2fc
Revert "Move illegal pattern check to resolution, away from nested ma…
keyboardDrummer Nov 2, 2022
76aa52a
Less WOOP
keyboardDrummer Nov 2, 2022
dd11006
PatternMatchingErrors now passes
keyboardDrummer Nov 2, 2022
9ecf20e
Moved extremaLemmaCloner files
keyboardDrummer Nov 2, 2022
b3b1359
constructorCaseWithoutParentheses passes
keyboardDrummer Nov 2, 2022
84176d8
SimpleCompiler passes
keyboardDrummer Nov 2, 2022
9711944
Override contracts with an empty implementation
keyboardDrummer Nov 2, 2022
08ef2d8
Add contract class to overwrite contracts
keyboardDrummer Nov 2, 2022
16b490a
Fix Children traversal for ApplySuffix and ActualBindings
keyboardDrummer Nov 2, 2022
771f0a4
Fix trigger generation for NestedMatchExpr
keyboardDrummer Nov 3, 2022
3c8fa3c
Clone stmt in nested match compilation
keyboardDrummer Nov 3, 2022
335d711
Refactoring
keyboardDrummer Nov 3, 2022
1c555c4
Cleanup
keyboardDrummer Nov 3, 2022
6678b3b
Correctly clone Bounds, Wellfounded now passes
keyboardDrummer Nov 3, 2022
a1003d9
Ran formatter
keyboardDrummer Nov 4, 2022
b03409a
Fix refinement transformer
keyboardDrummer Nov 4, 2022
3f4d176
Small cloner fixes
keyboardDrummer Nov 4, 2022
6f3e5cb
Refactored out CheckTypeInferenceVisitor
keyboardDrummer Nov 4, 2022
0741daf
Fix unary minus lit pattern check, and update 889b test
keyboardDrummer Nov 4, 2022
ce333da
Ran formatter
keyboardDrummer Nov 4, 2022
c977c9a
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Nov 4, 2022
0a8c889
Add missing null check
keyboardDrummer Nov 6, 2022
47200f4
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Nov 6, 2022
13ff3dc
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Nov 23, 2022
70a3c69
Merge commit 'f65c111a' into resolveMatchBeforeCompile
keyboardDrummer Nov 25, 2022
d1a82d6
Merge commit '99d8ac3' into resolveMatchBeforeCompile
keyboardDrummer Nov 25, 2022
c7c99e7
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Nov 25, 2022
7727f33
Move more code to prep from resolveNestedMatch
keyboardDrummer Nov 25, 2022
6ce2bef
Capitalise first letter of some public members
keyboardDrummer Nov 25, 2022
a5f6baf
Remove WOOP files
keyboardDrummer Nov 25, 2022
593f6ae
Add case
keyboardDrummer Nov 25, 2022
4277427
No longer denest matches as part of resolution
keyboardDrummer Nov 25, 2022
169d55a
Fix call Stmt children
keyboardDrummer Nov 25, 2022
4897660
Add AST changes
keyboardDrummer Nov 25, 2022
368cfa6
Compiles now
keyboardDrummer Nov 25, 2022
74dfdb7
Most tests pass now, except the ones that fail because of StaticRecei…
keyboardDrummer Nov 25, 2022
b2aa68d
Run formatter
keyboardDrummer Nov 25, 2022
0be6b16
Weird static state crash only when running all DefinitionTest tests
keyboardDrummer Nov 28, 2022
4cdef82
Definition tests pass
keyboardDrummer Nov 28, 2022
7990148
Remove base.Children call in StaticRecExpr.Children
keyboardDrummer Nov 28, 2022
6c62dbd
Fixes for static receiver expr
keyboardDrummer Nov 28, 2022
ffbb783
Ran formatter
keyboardDrummer Nov 28, 2022
f785f46
Fix TODO
keyboardDrummer Nov 29, 2022
35b4f2a
Merge branch 'codeMoves2' into updateChildren
keyboardDrummer Nov 29, 2022
4e46577
Merge commit 'f2d1f5d5~1' into updateChildren
keyboardDrummer Nov 29, 2022
01ce3a4
Merge commit 'f2d1f5d5' into updateChildren
keyboardDrummer Nov 29, 2022
bd976a8
Merge remote-tracking branch 'origin/master' into updateChildren
keyboardDrummer Nov 29, 2022
1e3a028
Merge branch 'updateChildren' of github.com:keyboardDrummer/dafny int…
keyboardDrummer Nov 29, 2022
db6cd10
Delete StatementsOld
keyboardDrummer Nov 29, 2022
670b10e
Refactoring
keyboardDrummer Nov 29, 2022
3bafbe9
Merge remote-tracking branch 'origin/master' into updateChildren
keyboardDrummer Dec 15, 2022
4ea6b9d
Bring back some removed code
keyboardDrummer Dec 15, 2022
22a5ab6
Fix NRE in UpdateStmt
keyboardDrummer Dec 15, 2022
0d68478
Fix another UpdateStatement.ResolvedStatements bug
keyboardDrummer Dec 15, 2022
9544d76
Turn RangeToken computing into a method instead of a property
keyboardDrummer Dec 15, 2022
9959513
Turn RangeToken computing into a method instead of a property
keyboardDrummer Dec 15, 2022
2b415ba
Converted properties to method in attempt to fix debugging, but ToStr…
keyboardDrummer Dec 16, 2022
c60a9b8
Temporarily shorten test file
keyboardDrummer Dec 16, 2022
6edfaff
Make Token a class
keyboardDrummer Dec 16, 2022
5fb11a1
Ran formatter
keyboardDrummer Dec 16, 2022
522cbaf
Merge branch 'master' into fixDebugging
keyboardDrummer Dec 16, 2022
fb96dff
Repair accidentaly changed test file
keyboardDrummer Dec 19, 2022
ef2b371
Merge branch 'fixDebugging' into updateChildren
keyboardDrummer Dec 19, 2022
2997659
Fix QuantifierExpr.SubExpressions
keyboardDrummer Dec 19, 2022
2a20720
Fix ExtremeLemmaBodyCloner
keyboardDrummer Dec 19, 2022
fd0efc5
Merge remote-tracking branch 'origin/master' into updateChildren
keyboardDrummer Dec 19, 2022
c8c3858
Fix ForLoopStmt.Clone
keyboardDrummer Dec 19, 2022
9e97cff
Fix bug in MatchAst.Clone
keyboardDrummer Dec 19, 2022
d44fb20
Fix AutoGhostIdentifierExpr.Clone
keyboardDrummer Dec 19, 2022
9566329
Run formatter
keyboardDrummer Dec 19, 2022
5c1f966
Fix Tok and GetRangeToken of AttributedExpression
keyboardDrummer Dec 19, 2022
1bab8b3
Format and remove .Reverse
keyboardDrummer Dec 19, 2022
4007e69
Merge branch 'updateChildren' of github.com:keyboardDrummer/dafny int…
keyboardDrummer Dec 19, 2022
dcef971
Fix bug
keyboardDrummer Dec 20, 2022
8fe135d
Merge branch 'master' into updateChildren
keyboardDrummer Dec 20, 2022
2f68010
Delete ResolvedCloner
keyboardDrummer Dec 20, 2022
a4a58fd
Resolve comments
keyboardDrummer Dec 20, 2022
43c65ef
Merge branch 'updateChildren' of github.com:keyboardDrummer/dafny int…
keyboardDrummer Dec 20, 2022
5d53048
Merge remote-tracking branch 'origin/master' into updateChildren
keyboardDrummer Dec 20, 2022
066be92
Merge remote-tracking branch 'origin/master' into updateChildren
keyboardDrummer Dec 21, 2022
ce3edc5
Trigger CI
keyboardDrummer Dec 21, 2022
02e32ca
Merge branch 'updateChildren' into resolveMatchBeforeCompile
keyboardDrummer Dec 21, 2022
f5c154f
Merge commit '2d6d0e43cc6' into resolveMatchBeforeCompile
keyboardDrummer Dec 21, 2022
5af1720
Merge commit '051c71b76d94' into resolveMatchBeforeCompile
keyboardDrummer Dec 21, 2022
e448083
Add ghost interest computation for NestedMatch
keyboardDrummer Dec 22, 2022
cae57df
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Dec 22, 2022
f96bf92
Undo unintentional change
keyboardDrummer Dec 22, 2022
3af00f7
Move ExtendedPatterns to separate files, and move illegal subpatterns…
keyboardDrummer Dec 22, 2022
e1328b0
Bring back .Reverse()
keyboardDrummer Dec 22, 2022
16f59ba
Fix denesting during translation to properly visit all modules
keyboardDrummer Dec 22, 2022
4e1fc38
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Dec 22, 2022
ac41345
Fix handling in tuples in match cases
keyboardDrummer Dec 23, 2022
ea29cdd
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Dec 23, 2022
cf97258
Fill in some missing nestedMatchExpr cases
keyboardDrummer Dec 23, 2022
8ba8e41
Moved classes, many inside Rewriter.cs, into separate files
keyboardDrummer Dec 23, 2022
edfaaf5
Move infer decreases clauses code into a separate file
keyboardDrummer Dec 23, 2022
9e1a5a0
Prevent NRE in GhostInterestVisitor when calling ExpressionTester
keyboardDrummer Dec 23, 2022
0de2347
Fix NRE in cloning constructor of OneBodyLoopStmt
keyboardDrummer Dec 23, 2022
4ec6cfc
Fix cloner issue related to Statement.Labels and BreakStmt.TargetStmt
keyboardDrummer Dec 23, 2022
582b8a0
Let tail recursion detection work for nested match expressions
keyboardDrummer Dec 23, 2022
d0c7d04
Tiny refactoring
keyboardDrummer Dec 23, 2022
e683701
Temp fix for MatchDenester traversal
keyboardDrummer Dec 23, 2022
80209f2
Fix expect file
keyboardDrummer Dec 23, 2022
cc38782
Make denester part of resolution, but store the result in a separate …
keyboardDrummer Dec 25, 2022
95615c4
Various .Denested fixes
keyboardDrummer Dec 25, 2022
ff96f44
032 runs without crashing
keyboardDrummer Dec 25, 2022
ee0701d
032 passes
keyboardDrummer Dec 25, 2022
8626ee4
FStarQuicksort passes
keyboardDrummer Dec 25, 2022
9b97497
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Dec 27, 2022
5f4ace4
Fix SimpleCoinduction.dfy
keyboardDrummer Dec 27, 2022
7eb6723
Fix for literally nested match constructs
keyboardDrummer Dec 27, 2022
73238a0
Fix bug in match wellformedness check
keyboardDrummer Dec 28, 2022
ca1bad5
Add missing NestedMatchExpr case
keyboardDrummer Dec 28, 2022
909ad0d
Fix NRE in ForallStmt
keyboardDrummer Dec 28, 2022
1aa94de
Fix 503
keyboardDrummer Dec 28, 2022
0429ae1
Fix 133
keyboardDrummer Dec 28, 2022
cf29536
Fix 686 test
keyboardDrummer Dec 28, 2022
498dcf9
Fix ComprehensionExpr clone so Calculations.dfy passes
keyboardDrummer Dec 28, 2022
8b03ac7
Fix 686 expect file
keyboardDrummer Dec 29, 2022
b127542
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Dec 29, 2022
a457420
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Dec 29, 2022
c748421
Fix 1665 expect file
keyboardDrummer Dec 29, 2022
af69bfa
Fix nested patterns expect
keyboardDrummer Dec 29, 2022
f7d23db
Fix printer to handle Denested well
keyboardDrummer Dec 29, 2022
f455011
Fix tail recursion code, so BranchCoverage passes
keyboardDrummer Dec 29, 2022
62c46a4
Ran formatter
keyboardDrummer Dec 29, 2022
41c00dc
Fix 1665 expect file
keyboardDrummer Dec 29, 2022
a3f6883
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Dec 29, 2022
542182e
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Dec 30, 2022
9ef0a73
Fix 686 expect file
keyboardDrummer Dec 30, 2022
0328ec3
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Dec 30, 2022
cf0237b
Refactoring
keyboardDrummer Dec 30, 2022
1e14501
Delete StatementsOld.cs
keyboardDrummer Dec 30, 2022
f38dd2f
Update 1665 expect file
keyboardDrummer Dec 30, 2022
7ca28c5
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Jan 2, 2023
0f7202b
Merge commit '2b23d2ed' into resolveMatchBeforeCompile
keyboardDrummer Jan 2, 2023
31eaf85
Merge commit '185282eff' into resolveMatchBeforeCompile
keyboardDrummer Jan 2, 2023
a72bf13
Merge remote-tracking branch 'origin/master' into resolveMatchBeforeC…
keyboardDrummer Jan 2, 2023
59faebf
Renamed folder
keyboardDrummer Jan 2, 2023
629bf63
Refactoring
keyboardDrummer Jan 2, 2023
6284aaa
Remove match debug code
keyboardDrummer Jan 2, 2023
38ce8b1
Move the first half of the nested match resolve code out of Resolver.cs
keyboardDrummer Jan 2, 2023
79439d0
Rename
keyboardDrummer Jan 2, 2023
93fccb5
Rename denested to flattened
keyboardDrummer Jan 2, 2023
1220b94
Cleanup and renames
keyboardDrummer Jan 2, 2023
5c253a7
Undo Body->Term inline
keyboardDrummer Jan 2, 2023
eb7f315
Fix comp errors
keyboardDrummer Jan 2, 2023
ccf0b91
Reduce code duplication
keyboardDrummer Jan 2, 2023
837039d
Small refactoring
keyboardDrummer Jan 2, 2023
bc91c60
Delete resolve code for simple matches
keyboardDrummer Jan 2, 2023
24fe226
Remove OrigUnresolved
keyboardDrummer Jan 2, 2023
fbaf092
Refactor and fix bug
keyboardDrummer Jan 2, 2023
0abef8d
Remove obsolete argument
keyboardDrummer Jan 2, 2023
c97e7d3
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Jan 3, 2023
07c6cd4
Fix print expect file
keyboardDrummer Jan 3, 2023
ed72062
Run formatter
keyboardDrummer Jan 3, 2023
55ae49f
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Jan 3, 2023
3059618
Fix comp error
keyboardDrummer Jan 3, 2023
ba64de2
Code review
keyboardDrummer Jan 4, 2023
0e850be
Apply TODO
keyboardDrummer Jan 4, 2023
5ecb444
Merge branch 'master' into resolveMatchBeforeCompile
keyboardDrummer Jan 4, 2023
2ed841c
Merge branch 'resolveMatchBeforeCompile' of github.com:keyboardDrumme…
keyboardDrummer Jan 4, 2023
2040d73
Move SinglyLinkedList
keyboardDrummer Jan 4, 2023
74e7ecd
Resolve TODO that removes SyntaxContainer
keyboardDrummer Jan 4, 2023
4589aed
Remove TODO
keyboardDrummer Jan 4, 2023
b319033
Remove .Reverse call
keyboardDrummer Jan 4, 2023
513fe70
Fix
keyboardDrummer Jan 4, 2023
97d3fb3
Refactor
keyboardDrummer Jan 4, 2023
6644b8c
Fix NRE
keyboardDrummer Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/DafnyCore/AST/AstVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ protected virtual void VisitExpression(Expression expr, VisitorContext context)
VisitUserProvidedType(v.Type, context);
}
}
} else if (expr is NestedMatchExpr nestedMatchExpr) {
foreach (IdPattern mc in nestedMatchExpr.Cases.SelectMany(c => c.Pat.DescendantsAndSelf).OfType<IdPattern>()
.Where(id => id.BoundVar != null)) {
VisitUserProvidedType(mc.BoundVar.Type, context);
}
}

// Visit substatements
Expand Down
44 changes: 14 additions & 30 deletions Source/DafnyCore/AST/Cloner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ interface ICloneable<out T> {

public class Cloner {
public bool CloneResolvedFields { get; }
private readonly Dictionary<Statement, Statement> statementClones = new();
private readonly Dictionary<IVariable, IVariable> clones = new();
private readonly Dictionary<MemberDecl, MemberDecl> memberClones = new();

public void AddStatementClone(Statement original, Statement clone) {
statementClones.Add(original, clone);
}

public Cloner(bool cloneResolvedFields = false) {
this.CloneResolvedFields = cloneResolvedFields;
}
Expand Down Expand Up @@ -409,7 +414,6 @@ private Expression CloneExprInner(Expression expr) {
} else if (expr is TernaryExpr) {
var e = (TernaryExpr)expr;
return new TernaryExpr(Tok(e.tok), e.Op, CloneExpr(e.E0), CloneExpr(e.E1), CloneExpr(e.E2));

} else if (expr is WildcardExpr) {
return new WildcardExpr(Tok(expr.tok));
} else if (expr is StmtExpr) {
Expand All @@ -421,14 +425,6 @@ private Expression CloneExprInner(Expression expr) {
} else if (expr is ParensExpression) {
var e = (ParensExpression)expr;
return CloneExpr(e.E); // skip the parentheses in the clone
} else if (expr is NestedMatchExpr) {
var e = (NestedMatchExpr)expr;
return new NestedMatchExpr(Tok(e.tok), CloneExpr(e.Source), e.Cases.ConvertAll(CloneNestedMatchCaseExpr),
e.UsesOptionalBraces);
} else if (expr is MatchExpr) {
var e = (MatchExpr)expr;
return new MatchExpr(Tok(e.tok), CloneExpr(e.Source), e.Cases.ConvertAll(CloneMatchCaseExpr),
e.UsesOptionalBraces);
}
if (expr is Resolver_IdentifierExpr resolverIdentifierExpr) {
return new Resolver_IdentifierExpr(Tok(resolverIdentifierExpr.tok), resolverIdentifierExpr.Decl, resolverIdentifierExpr.TypeArgs);
Expand Down Expand Up @@ -461,25 +457,17 @@ public virtual NameSegment CloneNameSegment(Expression expr) {

public virtual AssignmentRhs CloneRHS(AssignmentRhs rhs) {
AssignmentRhs c;
if (rhs is ICloneable<AssignmentRhs> cloneable) {
return cloneable.Clone(this);
}

if (rhs is ExprRhs) {
var r = (ExprRhs)rhs;
c = new ExprRhs(CloneExpr(r.Expr), CloneAttributes(rhs.Attributes));
} else if (rhs is HavocRhs) {
c = new HavocRhs(Tok(rhs.Tok));
} else {
var r = (TypeRhs)rhs;
if (r.ArrayDimensions != null) {
if (r.InitDisplay != null) {
Contract.Assert(r.ArrayDimensions.Count == 1);
c = new TypeRhs(Tok(r.Tok), CloneType(r.EType), CloneExpr(r.ArrayDimensions[0]), r.InitDisplay.ConvertAll(CloneExpr));
} else {
c = new TypeRhs(Tok(r.Tok), CloneType(r.EType), r.ArrayDimensions.ConvertAll(CloneExpr), CloneExpr(r.ElementInit));
}
} else if (r.Bindings == null) {
c = new TypeRhs(Tok(r.Tok), CloneType(r.EType));
} else {
c = new TypeRhs(Tok(r.Tok), CloneType(r.Path), r.Bindings.ArgumentBindings.ConvertAll(CloneActualBinding));
}
throw new cce.UnreachableException();
}
return c;
}
Expand All @@ -506,6 +494,10 @@ public virtual Statement CloneStmt(Statement stmt) {
return null;
}

if (statementClones.TryGetValue(stmt, out var cachedResult)) {
return cachedResult;
}

if (stmt is ICloneable<Statement> cloneable) {
var r = cloneable.Clone(this);
// add labels to the cloned statement
Expand Down Expand Up @@ -924,14 +916,6 @@ public override Expression CloneExpr(Expression expr) {
return base.CloneExpr(expr);
}

public override Statement CloneStmt(Statement stmt) {
var s = stmt as MatchStmt;
if (s != null && s.OrigUnresolved != null) {
return CloneStmt(s.OrigUnresolved);
}
return base.CloneStmt(stmt);
}

public ModuleSignature CloneModuleSignature(ModuleSignature org, ModuleSignature newSig) {
var sig = new ModuleSignature();
sig.ModuleDef = newSig.ModuleDef;
Expand Down
15 changes: 11 additions & 4 deletions Source/DafnyCore/AST/DafnyAst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public ISet<INode> Visit(Func<INode, bool> beforeChildren = null, Action<INode>
afterChildren ??= node => { };

var visited = new HashSet<INode>();
var toVisit = new Stack<INode>();
toVisit.Push(this);
var toVisit = new LinkedList<INode>();
toVisit.AddFirst(this);
while (toVisit.Any()) {
var current = toVisit.Pop();
var current = toVisit.First();
toVisit.RemoveFirst();
if (!visited.Add(current)) {
continue;
}
Expand All @@ -58,11 +59,17 @@ public ISet<INode> Visit(Func<INode, bool> beforeChildren = null, Action<INode>
continue;
}

var nodeAfterChildren = toVisit.First;
foreach (var child in current.Children) {
if (child == null) {
throw new InvalidOperationException($"Object of type {current.GetType()} has null child");
}
toVisit.Push(child);

if (nodeAfterChildren == null) {
toVisit.AddLast(child);
} else {
toVisit.AddBefore(nodeAfterChildren, child);
}
}

afterChildren(current);
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Expressions/ComprehensionExpr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ protected ComprehensionExpr(Cloner cloner, ComprehensionExpr original) : base(cl
Term = cloner.CloneExpr(original.Term);

if (cloner.CloneResolvedFields) {
Bounds = original.Bounds?.Select(b => b.Clone(cloner)).ToList();
Bounds = original.Bounds?.Select(b => b?.Clone(cloner)).ToList();
}
}
public override IEnumerable<INode> Children => (Attributes != null ? new List<INode> { Attributes } : Enumerable.Empty<INode>()).Concat(SubExpressions);
Expand Down
18 changes: 18 additions & 0 deletions Source/DafnyCore/AST/Expressions/DisjunctivePattern.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

namespace Microsoft.Dafny;

Expand All @@ -11,4 +12,21 @@ public DisjunctivePattern(IToken tok, List<ExtendedPattern> alternatives, bool i
}

public override IEnumerable<INode> Children => Alternatives;
public override void Resolve(Resolver resolver, ResolutionContext resolutionContext,
Type sourceType, bool isGhost, bool mutable,
bool inPattern, bool inDisjunctivePattern) {

if (inPattern) {
resolver.reporter.Error(MessageSource.Resolver, Tok, "Disjunctive patterns are not allowed inside other patterns");
}

foreach (var alternative in Alternatives) {
alternative.Resolve(resolver, resolutionContext, sourceType, isGhost, mutable, true, true);
}
}

public override IEnumerable<(BoundVar var, Expression usage)> ReplaceTypesWithBoundVariables(Resolver resolver,
ResolutionContext resolutionContext) {
return Enumerable.Empty<(BoundVar var, Expression usage)>();
}
}
56 changes: 6 additions & 50 deletions Source/DafnyCore/AST/Expressions/Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,8 @@ public FunctionCallExpr(Cloner cloner, FunctionCallExpr original) : base(cloner,
TypeApplication_JustFunction = original.TypeApplication_JustFunction;
IsByMethodCall = original.IsByMethodCall;
Function = original.Function;
CoCall = original.CoCall;
CoCallHint = original.CoCallHint;
}
}

Expand Down Expand Up @@ -2455,6 +2457,8 @@ public class CasePattern<VT> : INode
where VT : class, IVariable {
public readonly string Id;
// After successful resolution, exactly one of the following two fields is non-null.

[FilledInDuringResolution]
public DatatypeCtor Ctor; // finalized by resolution (null if the pattern is a bound variable)
public VT Var; // finalized by resolution (null if the pattern is a constructor) Invariant: Var != null ==> Arguments == null
public List<CasePattern<VT>> Arguments;
Expand All @@ -2474,6 +2478,7 @@ public CasePattern(Cloner cloner, CasePattern<VT> original) {

if (cloner.CloneResolvedFields) {
Expr = cloner.CloneExpr(original.Expr);
Ctor = original.Ctor;
}

if (original.Arguments != null) {
Expand Down Expand Up @@ -2535,24 +2540,6 @@ public IEnumerable<VT> Vars {
public override IEnumerable<INode> Children => Arguments ?? Enumerable.Empty<INode>();
}

/*
ExtendedPattern is either:
1 - A LitPattern of a LiteralExpr, representing a constant pattern
2 - An IdPattern of a string and a list of ExtendedPattern, representing either
a bound variable or a constructor applied to n arguments or a symbolic constant
*/

public abstract class NestedMatchCase : INode {
public readonly ExtendedPattern Pat;

public NestedMatchCase(IToken tok, ExtendedPattern pat) {
Contract.Requires(tok != null);
Contract.Requires(pat != null);
this.Tok = tok;
this.Pat = pat;
}
}

public class BoxingCastExpr : Expression { // a BoxingCastExpr is used only as a temporary placeholding during translation
public readonly Expression E;
public readonly Type FromType;
Expand Down Expand Up @@ -2704,14 +2691,12 @@ public IEnumerable<IDeclarationOrUsage> GetResolvedDeclarations() {
/// it gets "replaced" by the expression in "ResolvedExpression".
/// </summary>
public abstract class ConcreteSyntaxExpression : Expression {

// [FilledInDuringResolution] public Expression ResolvedExpression; // after resolution, manipulation of "this" should proceed as with manipulating "this.ResolvedExpression"

protected ConcreteSyntaxExpression(Cloner cloner, ConcreteSyntaxExpression original) : base(cloner, original) {
if (cloner.CloneResolvedFields && original.ResolvedExpression != null) {
ResolvedExpression = cloner.CloneExpr(original.ResolvedExpression);
}
}

[FilledInDuringResolution]
private Expression resolvedExpression;

Expand Down Expand Up @@ -2740,35 +2725,6 @@ public override IEnumerable<Expression> SubExpressions {
public override IEnumerable<Type> ComponentTypes => ResolvedExpression.ComponentTypes;
}

/// <summary>
/// This class represents a piece of concrete syntax in the parse tree. During resolution,
/// it gets "replaced" by the statement in "ResolvedStatement".
/// Adapted from ConcreteSyntaxStatement
/// </summary>
public abstract class ConcreteSyntaxStatement : Statement {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to see this go away!

Copy link
Member Author

@keyboardDrummer keyboardDrummer Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but NestedMatchStmt.Flattened came in its place so I'm not sure if it's an improvement 😅 I considered changing ConcreteSyntaxStatement and ConcreteSyntaxExpression so they would have not only a resolvedX but also a compiledX field, instead of the current Flattened property. That would reduce the code added to Translator.cs and SinglePassCompiler.cs, and add opportunities for other post resolution compilation passes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. But one advantage to NestedMatchStmt.Flattened is that it's clear that it's used for one thing, whereas ConcreteSyntaxStatement sounds like it could cover many instances of concrete syntax, even if it didn't, in practice.

[FilledInDuringResolution] public Statement ResolvedStatement; // after resolution, manipulation of "this" should proceed as with manipulating "this.ResolvedExpression"

public override IEnumerable<INode> Children =>
ResolvedStatement == null ? base.Children : new[] { ResolvedStatement };

public ConcreteSyntaxStatement(Cloner cloner, ConcreteSyntaxStatement original) : base(cloner, original) {
if (cloner.CloneResolvedFields) {
ResolvedStatement = cloner.CloneStmt(original.ResolvedStatement);
}
}

public ConcreteSyntaxStatement(IToken tok, IToken endtok)
: base(tok, endtok) {
}
public ConcreteSyntaxStatement(IToken tok, IToken endtok, Attributes attrs)
: base(tok, endtok, attrs) {
}
public override IEnumerable<Statement> SubStatements {
get {
yield return ResolvedStatement;
}
}
}
public class ParensExpression : ConcreteSyntaxExpression {
public readonly Expression E;
public ParensExpression(IToken tok, Expression e)
Expand Down
Loading