-
Notifications
You must be signed in to change notification settings - Fork 261
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
Feat: Rust operators and immutable collections #5081
Merged
Merged
Changes from 40 commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
0628309
Added initial tests to support allocation
MikaelMayer 7649600
Implemented codatatypes
MikaelMayer 06c65ba
Sequences now defined. Only need to define more methods
MikaelMayer 5fc5bf4
Support for traits and mutable variables without dynamic dispatch(?)
MikaelMayer b72cec9
Arguments always borrowed, deallocation more general now
MikaelMayer c2f8b24
Conversion to/from Rust strings, better handling of is_string
MikaelMayer bed8f90
Got rid of DafnyClone
MikaelMayer 79f1503
Immutable lazy maps
MikaelMayer 4b0fae7
Support to subtype testing
MikaelMayer 754022c
Make sure StreamReaders are closed after use
MikaelMayer 22a2897
Formatting fix 2
MikaelMayer ae3081c
Needed to updated GeneratedFromDafny apparently
MikaelMayer 705b1ca
Aligning with existing runtime
MikaelMayer 13defc6
More idiomatic rust identifiers, started to deal with indentation
MikaelMayer ded93a3
Allow dead code + finished all trivial impl
MikaelMayer 70e1dcf
Added standard library
MikaelMayer 6c6236a
Support for subset of standard libraries
MikaelMayer aa3e84a
much better Rust output
MikaelMayer eccae5e
Proof that ID encoding is bijective so that there is no collision
MikaelMayer 5ba5c93
Constant initialization for datatypes and tests with closures
MikaelMayer c7fb7c0
Merge branch 'master' into feat-rust
MikaelMayer 770da14
Fixed the merge build
MikaelMayer 70732a7
Set and print
MikaelMayer b09c1a0
Ongoing work
MikaelMayer 21a0074
Ensure we don't mess up with the system
MikaelMayer a2ef3f8
Fixed the build
MikaelMayer 9704661
Better reporting
MikaelMayer 58229de
Simplified a bit
MikaelMayer 43c60ae
Removed useless interfaces in lib.rs
MikaelMayer ec7188a
Newtype decls now fully erase, support for 128 bit operations
MikaelMayer 136b368
Many map and set operations implemented
MikaelMayer 3cacd1f
Removed mod.rs
MikaelMayer eaad5be
Operators working till maps
MikaelMayer 71f2a08
Support for set and set operations
MikaelMayer 2c1e7ee
Merge branch 'master' into feat-rust
MikaelMayer 42f3bd3
Comprehensive tests
MikaelMayer 7e4457c
Operators file updated
MikaelMayer 541d9fe
Merge branch 'master' into feat-rust-operators
MikaelMayer bc6ef02
Fixed the rust test
MikaelMayer 70d95d5
Fix the CI build
MikaelMayer e715090
Started to add checks to multibackends using Rust
MikaelMayer 2ede243
Merge branch 'master' into feat-rust
MikaelMayer 6d825fb
Merge branch 'master' into feat-rust-operators
MikaelMayer a4bbd0e
Review comments
MikaelMayer dca95f9
Extract branch here: A check file for every rust test that does not pass
MikaelMayer 1a0c3f5
Merge branch 'feat-rust-test-monitor' into feat-rust-operators
MikaelMayer 31c4a31
Review comments
MikaelMayer ab90d9d
Merge branch 'master' into feat-rust-operators
MikaelMayer a85a31c
Fixed the merge
MikaelMayer b361f98
Merge branch 'master' into feat-rust-operators
MikaelMayer 84a280c
Review comments
MikaelMayer bce6df2
Merge branch 'master' into feat-rust-operators
MikaelMayer 79d9767
Fixed the merge commit
MikaelMayer ec471f7
Added new option to set of options not needing a check for the doo file
MikaelMayer 805628d
Fixed CI tests
MikaelMayer f204d29
Fixed CI Tests
MikaelMayer 6af66d2
Merge branch 'master' into feat-rust-operators
MikaelMayer fc489c7
whitespace
MikaelMayer 450c34c
Updated Options.txt
MikaelMayer 5b47e79
Added release helper
MikaelMayer 2c734f4
Refactoring to reduce brittleness
MikaelMayer 0de8444
Fixed CI tests
MikaelMayer 084fd8f
Formatted dfy code
MikaelMayer fca0a64
Ensure tests works for ResolvedDesugaredExecutableDafnyBackend
MikaelMayer 48bb366
Ensure feature descriptions are still accurate
MikaelMayer 231b877
Merge branch 'master' into feat-rust-operators
MikaelMayer a667a51
Fixed a name
MikaelMayer 2f2a34a
Ensured tests on unsupported code behave the same
MikaelMayer 77d6fc0
Merge branch 'master' into feat-rust-operators
MikaelMayer 8dd3e91
Added unsupported feature
MikaelMayer 591a108
Added one more unsupported feature
MikaelMayer 7df7a43
Fixed one more CI test
MikaelMayer ab8713f
Fixed a few test cases
MikaelMayer 5c507ee
Updated hopefully last tests
MikaelMayer 9d84841
Fixed the last test
MikaelMayer e06ba55
Increased code coverage
MikaelMayer 974a622
Merge branch 'master' into feat-rust-operators
MikaelMayer 978de94
Ensure we generate code that is not specific to Windows
MikaelMayer 494ec95
GeneratedFromDafny now splits files in different namespaces.
MikaelMayer 6185aea
Restored formatting
MikaelMayer 7262e2e
Formatted Dafny file
MikaelMayer 2388a16
Increased coverage and refactored coverage to another dafny file
MikaelMayer 2ba549f
Moved coverage code to DafnyCore.Test
MikaelMayer 927e0ce
formatting
MikaelMayer b8fa9be
Fixed generation
MikaelMayer ae9c6a5
formatting
MikaelMayer 8fa13f8
reverted wrong formatting
MikaelMayer 9fa45e9
Merge branch 'master' into feat-rust-operators
MikaelMayer b08160e
Update docs/DafnyRef/integration- rust/IntegrationRust.md
MikaelMayer 7a1112b
Review comments
MikaelMayer 428edc1
Merge branch 'master' into feat-rust-operators
MikaelMayer ff40edc
formatting
MikaelMayer 628f55b
Revert "formatting"
MikaelMayer dc3e8eb
Fixed the format command.
MikaelMayer bd632f5
Fixed CI Tests
MikaelMayer 04f055e
Merge branch 'master' into feat-rust-operators
MikaelMayer 1adb784
emitUncompilableCode using the new CLI option format
MikaelMayer 4b9323e
Merge branch 'feat-rust-operators' of https://github.com/dafny-lang/d…
MikaelMayer 0787071
Merge branch 'master' into feat-rust-operators
MikaelMayer d160b19
Merge branch 'master' into feat-rust-operators
MikaelMayer 94060a0
Merge branch 'master' into feat-rust-operators
MikaelMayer ea057e3
Addressing CI failures
MikaelMayer 71f9e96
Missing check files
MikaelMayer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: dotnet-format | ||
name: dotnet-format | ||
language: system | ||
entry: dotnet format whitespace Source/Dafny.sln --include | ||
types_or: ["c#"] | ||
# hooks: | ||
# - id: dotnet-format | ||
# name: dotnet-format | ||
# language: system | ||
# entry: dotnet format whitespace Source/Dafny.sln -v:d --exclude Source/DafnyCore/GeneratedFromDafny.cs --include | ||
# types_or: ["c#"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ string UniqueName { | |
string SanitizedName { | ||
get; | ||
} | ||
string SanitizedNameShadowable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth a comment what this is for |
||
get; | ||
} | ||
string CompileName { | ||
get; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,22 @@ | ||||||||||||||||||||||||||||||
module {:extern "DAST.Format"} DAST.Format | ||||||||||||||||||||||||||||||
/* Cues about how to format different AST elements if necessary, | ||||||||||||||||||||||||||||||
e.g. to generate idiomatic code when needed. */ | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
// Dafny AST compilation tenets: | ||||||||||||||||||||||||||||||
// - The Compiled Dafny AST should be minimal | ||||||||||||||||||||||||||||||
// - The generated code should look idiomatic and close to the original Dafny file if possible | ||||||||||||||||||||||||||||||
// Since the two might conflict, the second one is taken care of by adding formatting information | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype UnOpFormat = | ||||||||||||||||||||||||||||||
NoFormat() | ||||||||||||||||||||||||||||||
| CombineNotInner() | ||||||||||||||||||||||||||||||
datatype BinOpFormat = | ||||||||||||||||||||||||||||||
NoFormat() | ||||||||||||||||||||||||||||||
| ImpliesFormat() | ||||||||||||||||||||||||||||||
| Equivalence() | ||||||||||||||||||||||||||||||
| ReverseOperands() | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(minor style nit, feel free to debate :) |
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
module {:extern "DAST"} DAST { | ||||||||||||||||||||||||||||||
import opened Std.Wrappers | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -19,13 +38,22 @@ module {:extern "DAST"} DAST { | |||||||||||||||||||||||||||||
Set(element: Type) | | ||||||||||||||||||||||||||||||
Multiset(element: Type) | | ||||||||||||||||||||||||||||||
Map(key: Type, value: Type) | | ||||||||||||||||||||||||||||||
SetBuilder(element: Type) | | ||||||||||||||||||||||||||||||
MapBuilder(key: Type, value: Type) | | ||||||||||||||||||||||||||||||
Arrow(args: seq<Type>, result: Type) | | ||||||||||||||||||||||||||||||
Primitive(Primitive) | Passthrough(string) | | ||||||||||||||||||||||||||||||
TypeArg(Ident) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype Primitive = Int | Real | String | Bool | Char | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype ResolvedType = Datatype(path: seq<Ident>) | Trait(path: seq<Ident>) | Newtype(Type) | ||||||||||||||||||||||||||||||
datatype NewtypeRange = | ||||||||||||||||||||||||||||||
| U8 | I8 | U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128 | BigInt | ||||||||||||||||||||||||||||||
| NoRange | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype ResolvedType = | ||||||||||||||||||||||||||||||
| Datatype(path: seq<Ident>) | ||||||||||||||||||||||||||||||
| Trait(path: seq<Ident>) | ||||||||||||||||||||||||||||||
| Newtype(baseType: Type, range: NewtypeRange, erase: bool) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype Ident = Ident(id: string) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -37,7 +65,7 @@ module {:extern "DAST"} DAST { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype DatatypeCtor = DatatypeCtor(name: string, args: seq<Formal>, hasAnyArgs: bool /* includes ghost */) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype Newtype = Newtype(name: string, typeParams: seq<Type>, base: Type, witnessStmts: seq<Statement>, witnessExpr: Option<Expression>) | ||||||||||||||||||||||||||||||
datatype Newtype = Newtype(name: string, typeParams: seq<Type>, base: Type, range: NewtypeRange, witnessStmts: seq<Statement>, witnessExpr: Option<Expression>) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype ClassItem = Method(Method) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -47,14 +75,18 @@ module {:extern "DAST"} DAST { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype Method = Method(isStatic: bool, hasBody: bool, overridingPath: Option<seq<Ident>>, name: string, typeParams: seq<Type>, params: seq<Formal>, body: seq<Statement>, outTypes: seq<Type>, outVars: Option<seq<Ident>>) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype CallName = | ||||||||||||||||||||||||||||||
Name(name: string) | | ||||||||||||||||||||||||||||||
MapBuilderAdd | MapBuilderBuild | SetBuilderAdd | SetBuilderBuild | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype Statement = | ||||||||||||||||||||||||||||||
DeclareVar(name: string, typ: Type, maybeValue: Option<Expression>) | | ||||||||||||||||||||||||||||||
Assign(lhs: AssignLhs, value: Expression) | | ||||||||||||||||||||||||||||||
If(cond: Expression, thn: seq<Statement>, els: seq<Statement>) | | ||||||||||||||||||||||||||||||
Labeled(lbl: string, body: seq<Statement>) | | ||||||||||||||||||||||||||||||
While(cond: Expression, body: seq<Statement>) | | ||||||||||||||||||||||||||||||
Foreach(boundName: string, boundType: Type, over: Expression, body: seq<Statement>) | | ||||||||||||||||||||||||||||||
Call(on: Expression, name: string, typeArgs: seq<Type>, args: seq<Expression>, outs: Option<seq<Ident>>) | | ||||||||||||||||||||||||||||||
Call(on: Expression, callName: CallName, typeArgs: seq<Type>, args: seq<Expression>, outs: Option<seq<Ident>>) | | ||||||||||||||||||||||||||||||
Return(expr: Expression) | | ||||||||||||||||||||||||||||||
EarlyReturn() | | ||||||||||||||||||||||||||||||
Break(toLabel: Option<string>) | | ||||||||||||||||||||||||||||||
|
@@ -72,13 +104,21 @@ module {:extern "DAST"} DAST { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
datatype BinOp = | ||||||||||||||||||||||||||||||
Eq(referential: bool, nullable: bool) | | ||||||||||||||||||||||||||||||
Neq(referential: bool, nullable: bool) | | ||||||||||||||||||||||||||||||
Div() | EuclidianDiv() | | ||||||||||||||||||||||||||||||
Mod() | EuclidianMod() | | ||||||||||||||||||||||||||||||
Implies() | // TODO: REplace by Not Or | ||||||||||||||||||||||||||||||
Lt() | // a <= b is !(b < a) | ||||||||||||||||||||||||||||||
LtChar() | | ||||||||||||||||||||||||||||||
Plus() | Minus() | Times() | | ||||||||||||||||||||||||||||||
BitwiseAnd() | BitwiseOr() | BitwiseXor() | | ||||||||||||||||||||||||||||||
BitwiseShiftRight() | BitwiseShiftLeft() | | ||||||||||||||||||||||||||||||
And() | Or() | | ||||||||||||||||||||||||||||||
In() | | ||||||||||||||||||||||||||||||
NotIn() | // TODO: Replace by Not In | ||||||||||||||||||||||||||||||
SetDifference() | | ||||||||||||||||||||||||||||||
SeqProperPrefix() | SeqPrefix() | | ||||||||||||||||||||||||||||||
SetMerge() | SetSubtraction() | SetIntersection() | | ||||||||||||||||||||||||||||||
Subset() | ProperSubset() | SetDisjoint() | | ||||||||||||||||||||||||||||||
MapMerge() | MapSubtraction() | | ||||||||||||||||||||||||||||||
MultisetMerge() | MultisetSubtraction() | MultisetIntersection() | | ||||||||||||||||||||||||||||||
Submultiset() | ProperSubmultiset() | MultisetDisjoint() | | ||||||||||||||||||||||||||||||
Concat() | | ||||||||||||||||||||||||||||||
Passthrough(string) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -94,18 +134,26 @@ module {:extern "DAST"} DAST { | |||||||||||||||||||||||||||||
SeqConstruct(length: Expression, elem: Expression) | | ||||||||||||||||||||||||||||||
SeqValue(elements: seq<Expression>, typ: Type) | | ||||||||||||||||||||||||||||||
SetValue(elements: seq<Expression>) | | ||||||||||||||||||||||||||||||
MultisetValue(elements: seq<Expression>) | | ||||||||||||||||||||||||||||||
MapValue(mapElems: seq<(Expression, Expression)>) | | ||||||||||||||||||||||||||||||
MapBuilder(keyType: Type, valueType: Type) | | ||||||||||||||||||||||||||||||
SeqUpdate(expr: Expression, indexExpr: Expression, value: Expression) | | ||||||||||||||||||||||||||||||
MapUpdate(expr: Expression, indexExpr: Expression, value: Expression) | | ||||||||||||||||||||||||||||||
SetBuilder(elemType: Type) | | ||||||||||||||||||||||||||||||
ToMultiset(Expression) | | ||||||||||||||||||||||||||||||
This() | | ||||||||||||||||||||||||||||||
Ite(cond: Expression, thn: Expression, els: Expression) | | ||||||||||||||||||||||||||||||
UnOp(unOp: UnaryOp, expr: Expression) | | ||||||||||||||||||||||||||||||
BinOp(op: BinOp, left: Expression, right: Expression) | | ||||||||||||||||||||||||||||||
UnOp(unOp: UnaryOp, expr: Expression, format1: Format.UnOpFormat) | | ||||||||||||||||||||||||||||||
BinOp(op: BinOp, left: Expression, right: Expression, format2: Format.BinOpFormat) | | ||||||||||||||||||||||||||||||
ArrayLen(expr: Expression, dim: nat) | | ||||||||||||||||||||||||||||||
MapKeys(expr: Expression) | | ||||||||||||||||||||||||||||||
MapValues(expr: Expression) | | ||||||||||||||||||||||||||||||
Select(expr: Expression, field: string, isConstant: bool, onDatatype: bool) | | ||||||||||||||||||||||||||||||
SelectFn(expr: Expression, field: string, onDatatype: bool, isStatic: bool, arity: nat) | | ||||||||||||||||||||||||||||||
Index(expr: Expression, collKind: CollKind, indices: seq<Expression>) | | ||||||||||||||||||||||||||||||
IndexRange(expr: Expression, isArray: bool, low: Option<Expression>, high: Option<Expression>) | | ||||||||||||||||||||||||||||||
TupleSelect(expr: Expression, index: nat) | | ||||||||||||||||||||||||||||||
Call(on: Expression, name: Ident, typeArgs: seq<Type>, args: seq<Expression>) | | ||||||||||||||||||||||||||||||
Call(on: Expression, callName: CallName, typeArgs: seq<Type>, args: seq<Expression>) | | ||||||||||||||||||||||||||||||
Lambda(params: seq<Formal>, retType: Type, body: seq<Statement>) | | ||||||||||||||||||||||||||||||
BetaRedex(values: seq<(Formal, Expression)>, retType: Type, expr: Expression) | | ||||||||||||||||||||||||||||||
IIFE(name: Ident, typ: Type, value: Expression, iifeBody: Expression) | | ||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary or do you mean to disable it? If the latter we should delete the file entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get this command to exclude GeneratedFromDafny.cs. It's the only generated file, and formatting it every time way too much time. So I would happily keep this pre-commit if we found a way to remove GeneratedFromDafny, but I haven't found any yet. In need for help here.