-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce support for closures (#479)
* Extend parser with closure literal * Temporary * Type checking for function literals * Internal Program object * Use correct substitutions within function literals * Within desugaring, replace captured variables with their reference * Fix Ghostless printer * Fix warnings, finish implementation of desugarer * Implement encoding of function literals, including encoding of closure domain, satisfies functions, default getter * Small refactorings * Implement parsing and type checking of closure spec instances and implements expressions * Implement desugaring and encoding of spec instance literals and implements assertion * Add support for treating method members as closures * Implement encoding of closure calls * Implement parsing and type checking of closure implementation proofs * Introduce desugaring and encoding of spec proof statements * In spec implementation proofs, introduce an alias for the closure to avoid access permissions problems * Fixes * Introduce closure objects, fix ghostness of function and method constants * Add ghost erasure tests * Try to support importing packages * Add fixes to support closures when importing packages * Extend type checking to make sure that closure names are not use improperly * Refactor name resolution * Fix ghostness checks for closure calls and spec implementation proofs * Fix warnings * Fix errors if spec name not found * Fix error, improve how the encoding deals with pure functions or literals * Fix bugs, add examples * add closure import tests * Fix bugs * Add comments * Fix bug * Add comments, fix parser * Rename some files/classes * Fix Goification, add copyright headers to all new files * Fix test * Fix custom error condition * Remove blank line * Fix bug causing violation * Encode function nil, fix error message for closure calls * Add test examples, fix bug causing crash while type checking * More test cases (including examples with call descriptions) * Fix encoding of captured variables as domain functions (allowing types different from Ref) * Remove changes made for debugging and left there by mistake * Make ClosureImplements a ghost expression (instead of an assertion), allow shareable closure arguments * Address some comments (mainly refactorings) * Remove PClosureNamedDecl * Address typing comments (name resolution in proofs, closure spec used as operand) * Delete PClosureSpecParameter, use PKeyedElement instead; regenerate ANTLR sources * Solve bug caused by merge * Remove PCallWithSpec and internal.CallWithSpec, use PInvoke and method, function calls instead * Change one of the test examples to make it shorter * Fix bug causing crash (wrong value passed to error message) * Introduce ClosureCall and PureClosureCall * Fix termination-related problems with proof and function/method objects * Fix bug * Improve documentation of the encoding * Change a word in a comment * Remove default value for info parameter in Desugar, other minor changes * Change proof loop so that it actually terminates * Simplify genConversion function in MethodObjectEncoder * Fix ambiguity resolution between ClosureCall and FunctionCall, remove termination measures when unnecessary * Turn closureImplements$... functions into domain functions * Simplify preconditions for closureCall$ of closure obtained from function literal * Refactor following advice in the comments, fix error message for closure calls * Implement suggestions * Add comment from suggestion Co-authored-by: Felix Wolf <[email protected]> * Add suggested `Experimental feature` warning Co-authored-by: Felix Wolf <[email protected]> * Ensure that the Closure domain is only generated if there are closures Co-authored-by: Stefano Milizia <[email protected]> Co-authored-by: Felix Wolf <[email protected]>
- Loading branch information
1 parent
3619330
commit 7294137
Showing
81 changed files
with
7,475 additions
and
3,390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,285 changes: 645 additions & 640 deletions
1,285
src/main/java/viper/gobra/frontend/GobraLexer.java
Large diffs are not rendered by default.
Oops, something went wrong.
4,484 changes: 2,465 additions & 2,019 deletions
4,484
src/main/java/viper/gobra/frontend/GobraParser.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.