diff --git a/.github/actions/build_dafny_from_source/action.yml b/.github/actions/build_dafny_from_source/action.yml new file mode 100644 index 000000000..5e530533a --- /dev/null +++ b/.github/actions/build_dafny_from_source/action.yml @@ -0,0 +1,55 @@ +# +# This local action builds Dafny from source +# rather than using the setup-dafny-action. +# Currently it's only used to test Rust support +# against a feature branch of Dafny. +# + +name: "Build Dafny from source" +description: "Drop-in replacement for setup-dafny-action that builds the given branch of Dafny from source" +inputs: + dafny: + description: "The Dafny branch to use" + required: true + type: string +runs: + using: "composite" + steps: + - name: Checkout Dafny + uses: actions/checkout@v4 + with: + repository: dafny-lang/dafny + path: dafny + ref: ${{ inputs.dafny }} + + - name: Load Z3 + shell: bash + run: | + sudo apt-get install -qq libarchive-tools + mkdir -p dafny/Binaries/z3/bin + wget -qO- https://github.com/dafny-lang/solver-builds/releases/download/snapshot-2023-08-02/z3-4.12.1-x64-ubuntu-20.04-bin.zip | bsdtar -xf - + mv z3-4.12.1 dafny/Binaries/z3/bin/ + chmod +x dafny/Binaries/z3/bin/z3-4.12.1 + mkdir -p unzippedRelease/dafny/z3/bin + ln dafny/Binaries/z3/bin/z3-4.12.1 unzippedRelease/dafny/z3/bin/z3-4.12.1 + + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.0.x + + - name: Build Dafny + shell: bash + run: | + dotnet build dafny/Source/Dafny.sln + + - name: Add dafny to PATH + shell: bash + run: | + echo ${{ github.workspace }}/dafny/Scripts >> $GITHUB_PATH + + # Hard-coding this for now since it's a pain to extract from an arbitrary branch + - name: Export DAFNY_VERSION + shell: bash + run: | + echo "DAFNY_VERSION=4.7.0" >> $GITHUB_ENV diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index da19e3181..56051218a 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -47,10 +47,9 @@ jobs: fail-fast: false matrix: # Rust code generation is under development and depends on pending changes to the - # Dafny Rust code generation, so we only test on a relatively recent prerelease instead. - # This can be updated as needed when new features/fixes land in Dafny master. + # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - nightly-2024-05-14-8da3ddd + - 00fe7ff70d3858d67d69a2b897a65c7f9d209e0a uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 96772df90..fa76acd86 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -49,10 +49,9 @@ jobs: fail-fast: false matrix: # Rust code generation is under development and depends on pending changes to the - # Dafny Rust code generation, so we only test on a relatively recent prerelease instead. - # This can be updated as needed when new features/fixes land in Dafny master. + # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - nightly-2024-05-14-8da3ddd + - 00fe7ff70d3858d67d69a2b897a65c7f9d209e0a uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} diff --git a/.github/workflows/test_models_rust_tests.yml b/.github/workflows/test_models_rust_tests.yml index 7f95dec04..eac02275a 100644 --- a/.github/workflows/test_models_rust_tests.yml +++ b/.github/workflows/test_models_rust_tests.yml @@ -69,16 +69,17 @@ jobs: - uses: actions/checkout@v3 - - name: Setup Dafny - uses: dafny-lang/setup-dafny-action@v1.7.0 + - name: Setup Dafny (build from source) + uses: ./.github/actions/build_dafny_from_source with: - dafny-version: ${{ inputs.dafny }} + dafny: ${{ inputs.dafny }} - name: Set up Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: "1.74.1" rustflags: "" + components: rustfmt - name: Generate Polymorph Dafny working-directory: ./${{ matrix.library }} diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index 197ea2554..3046c74ba 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -194,6 +194,7 @@ transpile_implementation: -functionSyntax:3 \ -useRuntimeLib \ -out $(OUT) \ + $(DAFNY_OPTIONS) \ $(if $(strip $(STD_LIBRARY)) , -library:$(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy, ) \ $(TRANSPILE_DEPENDENCIES) @@ -505,12 +506,18 @@ transpile_rust: | transpile_implementation_rust transpile_dependencies_rust transpile_implementation_rust: TARGET=rs transpile_implementation_rust: OUT=implementation_from_dafny transpile_implementation_rust: SRC_INDEX=$(RUST_SRC_INDEX) +# The Dafny Rust code generator is not complete yet, +# so we want to emit code even if there are unsupported features in the input. +transpile_implementation_rust: DAFNY_OPTIONS=-emitUncompilableCode transpile_implementation_rust: _transpile_implementation_all _mv_implementation_rust transpile_test_rust: TARGET=rs transpile_test_rust: OUT=tests_from_dafny transpile_test_rust: SRC_INDEX=$(RUST_SRC_INDEX) transpile_test_rust: TEST_INDEX=$(RUST_TEST_INDEX) +# The Dafny Rust code generator is not complete yet, +# so we want to emit code even if there are unsupported features in the input. +transpile_test_rust: DAFNY_OPTIONS=-emitUncompilableCode transpile_test_rust: _transpile_test_all _mv_test_rust transpile_dependencies_rust: LANG=rust @@ -519,12 +526,16 @@ transpile_dependencies_rust: transpile_dependencies _mv_implementation_rust: rm -rf runtimes/rust/dafny_impl/src mkdir -p runtimes/rust/dafny_impl/src - mv implementation_from_dafny-rust/src/implementation_from_dafny.rs runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +# TODO: Currently need to insert an import of the the StandardLibrary. + python -c "import sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data.replace(b'\npub mod', b'\npub use dafny_standard_library::implementation_from_dafny::*;\n\npub mod', 1) if b'\npub mod' in data else data)" \ + < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/dafny_impl/src/implementation_from_dafny.rs + rustfmt runtimes/rust/dafny_impl/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: rm -rf runtimes/rust/dafny_impl/tests mkdir -p runtimes/rust/dafny_impl/tests mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/dafny_impl/tests/tests_from_dafny.rs + rustfmt runtimes/rust/dafny_impl/tests/tests_from_dafny.rs rm -rf tests_from_dafny-rust build_rust: diff --git a/TestModels/SharedMakefile.mk b/TestModels/SharedMakefile.mk index 37b65ecfd..65650e4ef 100644 --- a/TestModels/SharedMakefile.mk +++ b/TestModels/SharedMakefile.mk @@ -65,5 +65,3 @@ _polymorph_dotnet: _polymorph _polymorph_dotnet: OUTPUT_DOTNET_WRAPPED=\ $(if $(DIR_STRUCTURE_V2), --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped/$(SERVICE)/, --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped) _polymorph_dotnet: _polymorph_wrapped - - diff --git a/TestModels/SimpleTypes/SimpleBlob/Makefile b/TestModels/SimpleTypes/SimpleBlob/Makefile index 1c02cda52..d48c80281 100644 --- a/TestModels/SimpleTypes/SimpleBlob/Makefile +++ b/TestModels/SimpleTypes/SimpleBlob/Makefile @@ -18,5 +18,3 @@ SMITHY_DEPS=dafny-dependencies/Model/traits.smithy # This project has no dependencies # DEPENDENT-MODELS:= - -RUST_SRC_INDEX=src_for_rust diff --git a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch index a50784e96..ed5018dc5 100644 --- a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch @@ -1,649 +1,9 @@ -diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index ba5de6ff..8aa39b59 100644 ---- b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -1,89 +1,549 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] --extern crate dafny_runtime; --mod _System { -- #[derive(Clone, PartialEq)] -- #[repr(transparent)] -- pub struct nat(pub ::dafny_runtime::DafnyInt); -- impl ::std::default::Default for nat { -- fn default() -> Self { -- nat(::std::default::Default::default()) -- } -- } -- impl ::dafny_runtime::DafnyPrint for nat { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -- ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -- } -- } -- impl ::std::ops::Deref for nat { -- type Target = ::dafny_runtime::DafnyInt; -- fn deref(&self) -> &Self::Target { -- &self.0 -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple2 { -- _T2 { _0: T0, _1: T1 }, -- _PhantomVariant(::std::marker::PhantomData::, ::std::marker::PhantomData::) -- } -- impl Tuple2 { -- pub fn _0(&self) -> &T0 { -- match self { -- Tuple2::_T2 { _0, _1, } => _0, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- pub fn _1(&self) -> &T1 { -- match self { -- Tuple2::_T2 { _0, _1, } => _1, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- } -- impl ::dafny_runtime::DafnyPrint for Tuple2 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple2::_T2 { _0, _1, } => { -- write!(_formatter, "_System.Tuple2._T2(")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_0, _formatter, false)?; -- write!(_formatter, ", ")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_1, _formatter, false)?; -- write!(_formatter, ")")?; -- Ok(()) -+pub use dafny_runtime; -+pub use dafny_standard_library; -+pub use dafny_standard_library::implementation_from_dafny::*; -+ -+pub mod r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes { -+ /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ -+ #[derive(Clone)] -+ pub struct DafnyCallEvent { -+ input: I, -+ output: O, -+ } -+ impl ::core::fmt::Debug -+ for DafnyCallEvent -+ { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("DafnyCallEvent") -+ .field("input", &self.input) -+ .field("output", &self.output) -+ .finish() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint -+ for DafnyCallEvent -+ { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyblob.internaldafny.types.DafnyCallEvent(" -+ )?; -+ self.input.fmt_print(f, false)?; -+ write!(f, ",")?; -+ self.output.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl -+ PartialEq> for DafnyCallEvent -+ { -+ fn eq(&self, other: &DafnyCallEvent) -> bool { -+ self.input == other.input && self.output == other.output -+ } -+ } -+ impl Eq for DafnyCallEvent {} -+ impl ::core::hash::Hash -+ for DafnyCallEvent -+ { -+ fn hash(&self, state: &mut H) { -+ self.input.hash(state); -+ self.output.hash(state); -+ } -+ } -+ -+ /* -+ datatype GetBlobInput = | GetBlobInput ( -+ nameonly value: Option := Option.None -+ ) -+ */ -+ #[derive(Clone)] -+ pub enum GetBlobInput { -+ GetBlobInput { -+ value: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ >, -+ }, -+ } -+ impl ::std::convert::AsRef for &GetBlobInput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl GetBlobInput { -+ pub fn value( -+ &self, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ > { -+ match self { -+ GetBlobInput::GetBlobInput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::core::fmt::Debug for GetBlobInput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetBlobInput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyblob.internaldafny.types.GetBlobInput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetBlobInput { -+ fn eq(&self, other: &GetBlobInput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetBlobInput {} -+ impl ::core::hash::Hash for GetBlobInput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype GetBlobOutput = | GetBlobOutput ( -+ nameonly value: Option := Option.None -+ ) */ -+ #[derive(Clone)] -+ pub enum GetBlobOutput { -+ GetBlobOutput { -+ value: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ >, - }, -- Tuple2::_PhantomVariant(..) => {panic!()} -- } -- } -- } -- impl ::std::default::Default for Tuple2 { -- fn default() -> Self { -- Tuple2::_T2 { -- _0: ::std::default::Default::default(), -- _1: ::std::default::Default::default() -- } -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple0 { -- _T0 {} -- } -- impl Tuple0 {} -- impl ::dafny_runtime::DafnyPrint for Tuple0 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple0::_T0 { } => { -- write!(_formatter, "_System.Tuple0._T0")?; -- Ok(()) -- } -- } -- } -- } -- impl ::std::default::Default for Tuple0 { -- fn default() -> Self { -- Tuple0::_T0 {} -- } -- } -+ } -+ impl GetBlobOutput { -+ pub fn value( -+ &self, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ > { -+ match self { -+ GetBlobOutput::GetBlobOutput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::std::convert::AsRef for &GetBlobOutput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl ::core::fmt::Debug for GetBlobOutput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetBlobOutput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyblob.internaldafny.types.GetBlobOutput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetBlobOutput { -+ fn eq(&self, other: &GetBlobOutput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetBlobOutput {} -+ impl ::core::hash::Hash for GetBlobOutput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype SimpleBlobConfig = | SimpleBlobConfig ( -+ ) */ -+ #[derive(Clone)] -+ pub enum SimpleBlobConfig { -+ SimpleBlobConfig {}, -+ } -+ -+ impl ::std::convert::AsRef for &SimpleBlobConfig { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ impl ::core::fmt::Debug for SimpleBlobConfig { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("SimpleBlobConfig").finish() -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for SimpleBlobConfig { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyblob.internaldafny.types.SimpleBlobConfig()" -+ ) -+ } -+ } -+ impl PartialEq for SimpleBlobConfig { -+ fn eq(&self, other: &SimpleBlobConfig) -> bool { -+ true -+ } -+ } -+ impl Eq for SimpleBlobConfig {} -+ -+ impl ::core::hash::Hash for SimpleBlobConfig { -+ fn hash(&self, state: &mut H) {} -+ } -+ -+ pub struct ISimpleTypesBlobClientCallHistory {} -+ impl ISimpleTypesBlobClientCallHistory { -+ fn ctor(this: *mut ISimpleTypesBlobClientCallHistory) {} -+ } -+ pub trait ISimpleTypesBlobClient { -+ fn GetBlob( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ >; -+ } -+ /* -+ datatype Error = -+ | CollectionOfErrors(list: seq, nameonly message: blob) -+ | Opaque(obj: object) -+ */ -+ #[derive(Clone)] -+ pub enum Error { -+ CollectionOfErrors { -+ list: ::dafny_runtime::Sequence, -+ message: bool, -+ }, -+ Opaque { -+ obj: *mut dyn ::std::any::Any, -+ }, -+ } -+ impl ::core::fmt::Debug for Error { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => f -+ .debug_struct("Error::CollectionOfErrors") -+ .field("list", list) -+ .field("message", message) -+ .finish(), -+ Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), -+ } -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Error { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ write!(f, "Error::CollectionOfErrors(list := ")?; -+ list.fmt_print(f, false)?; -+ write!(f, ", message := ")?; -+ message.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ Error::Opaque { obj } => { -+ write!(f, "Error::Opaque(obj := ")?; -+ obj.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ } -+ } -+ impl PartialEq for Error { -+ fn eq(&self, other: &Error) -> bool { -+ match self { -+ Error::CollectionOfErrors { list, message } => match other { -+ Error::CollectionOfErrors { -+ list: other_list, -+ message: other_message, -+ } => list == other_list && message == other_message, -+ _ => false, -+ }, -+ Error::Opaque { obj } => match other { -+ Error::Opaque { obj: other_obj } => obj == other_obj, -+ _ => false, -+ }, -+ } -+ } -+ } -+ impl Eq for Error {} -+ impl ::core::hash::Hash for Error { -+ fn hash(&self, state: &mut H) { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ list.hash(state); -+ message.hash(state); -+ } -+ Error::Opaque { obj } => obj.hash(state), -+ } -+ } -+ } -+ -+ pub type OpaqueError = Error; -+} -+ -+mod r#_SimpleBlobImpl_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ -+ pub fn GetBlob( -+ config: &::std::rc::Rc, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); -+ let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { -+ value: input.value().clone() -+ }); -+ res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { -+ value: input.value().clone() -+ }); -+ output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( -+ super::r#_Wrappers_Compile::Result::< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, -+ >, -+ ::std::rc::Rc, -+ >::Success { -+ value: res.clone(), -+ }, -+ )); -+ return output.read(); -+ return output.read(); -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "SimpleBlobImpl_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Config { -+ Config {}, -+ } -+ impl Config {} -+ -+ impl ::dafny_runtime::DafnyPrint for Config { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Config::Config {} => { -+ write!(_formatter, "SimpleBlobImpl_Compile.Config.Config")?; -+ Ok(()) -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default for Config { -+ fn default() -> Config { -+ Config::Config {} -+ } -+ } -+ -+ impl ::std::convert::AsRef for &Config { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+// SimpleBlob -+pub mod r#_simple_dtypes_dsmithyblob_dinternaldafny { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ -+ pub fn DefaultSimpleBlobConfig( -+ ) -> super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::SimpleBlobConfig { -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig{} -+ } -+ -+ /*method SimpleBlob(config: SimpleBlobConfig) -+ returns (res: Result) { -+ var client := new SimpleBlobClient(Operations.Config); -+ return Success(client); -+ } */ -+ pub fn SimpleBlob(config: &::std::rc::Rc) -+ -> ::std::rc::Rc>>{ -+ let client: *mut SimpleBlobClient = ::dafny_runtime::allocate::(); -+ SimpleBlobClient::_ctor( -+ client, -+ &::std::rc::Rc::new(super::r#_SimpleBlobImpl_Compile::Config::Config {}), -+ ); -+ let v = client as *mut dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient; -+ // build a success -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, ::std::rc::Rc>::Success{ -+ value: v -+ }) -+ } -+ } -+ -+ struct SimpleBlobClient { -+ r#_i_config: ::std::rc::Rc, -+ } -+ -+ impl SimpleBlobClient { -+ fn _ctor( -+ this: *mut SimpleBlobClient, -+ config: &::std::rc::Rc, -+ ) { -+ let mut _i_set_config = false; -+ ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); -+ } -+ fn config(&self) -> ::std::rc::Rc { -+ self.r#_i_config.clone() -+ } -+ } -+ -+ impl super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient -+ for SimpleBlobClient -+ { -+ fn GetBlob( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ super::r#_SimpleBlobImpl_Compile::_default::GetBlob(&self.config(), input) -+ } -+ } -+ ::dafny_runtime::UpcastTo!( -+ SimpleBlobClient, -+ dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient -+ ); -+} -+ -+mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ -+ impl WrappersInterop { -+ pub fn new() -> Self { -+ WrappersInterop {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn CreateStringSome( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Some { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::None {}) -+ } -+ pub fn CreateBlobSome( -+ b: ::dafny_runtime::Sequence<::std::primitive::u8>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::std::primitive::u8>, -+ >::Some { -+ value: b, -+ }) -+ } -+ pub fn CreateBlobNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::std::primitive::u8>, -+ >::None {}) -+ } -+ } -+ -+ impl ::std::default::Default for WrappersInterop { -+ fn default() -> Self { -+ WrappersInterop::new() -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for WrappersInterop { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") -+ } -+ } -+ -+ impl ::std::cmp::PartialEq for WrappersInterop { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } - } --mod _module { -- --} -\ No newline at end of file -+mod _module {} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..ee9432a0 +index 00000000..cff0634e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs -@@ -0,0 +1,65 @@ +@@ -0,0 +1,56 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. + +use aws_smithy_types::error::operation::BuildError; @@ -651,7 +11,7 @@ index 00000000..ee9432a0 +#[derive(Debug)] +pub(crate) struct Handle { + pub(crate) conf: crate::Config, -+ pub(crate) inner: *mut dyn ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient ++ pub(crate) inner: ::dafny_runtime::Object +} + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -666,9 +26,9 @@ index 00000000..ee9432a0 + // If this service had any configuration properties, + // they would need converting here too. + let inner_config = ::std::rc::Rc::new( -+ ::simple_blob_dafny::_simple_dtypes_dsmithyblob_dinternaldafny::_default::DefaultSimpleBlobConfig()); ++ ::simple_blob_dafny::_simple_dtypes_dblob_dinternaldafny::_default::DefaultSimpleBlobConfig()); + let inner = -+ ::simple_blob_dafny::_simple_dtypes_dsmithyblob_dinternaldafny::_default::SimpleBlob( ++ ::simple_blob_dafny::_simple_dtypes_dblob_dinternaldafny::_default::SimpleBlob( + &inner_config, + ); + if matches!( @@ -684,7 +44,7 @@ index 00000000..ee9432a0 + } + let handle = Handle { + conf: conf.clone(), -+ inner: inner.Extract(), ++ inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + }; + Ok(Self { + handle: ::std::sync::Arc::new(handle), @@ -697,15 +57,6 @@ index 00000000..ee9432a0 + } +} + -+impl Drop for Handle { -+ fn drop(&mut self) { -+ // Ensure the Dafny values we created by calling SimpleBlob are deallocated. -+ unsafe { -+ drop(Box::from_raw(self.inner)); -+ } -+ } -+} -+ +mod get_blob; + +mod get_blob_known_value; @@ -897,7 +248,7 @@ index 00000000..c36bf85b +pub mod get_blob_known_value; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs new file mode 100644 -index 00000000..20a8f14c +index 00000000..9ff5a903 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -0,0 +1,32 @@ @@ -908,21 +259,21 @@ index 00000000..20a8f14c +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_blob::GetBlobError, -+) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error> { ++) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_blob::GetBlobError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_blob::GetBlobError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -935,7 +286,7 @@ index 00000000..20a8f14c +pub mod _get_blob_output; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs new file mode 100644 -index 00000000..d1a66e32 +index 00000000..7dfd3d6d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs @@ -0,0 +1,43 @@ @@ -944,7 +295,7 @@ index 00000000..d1a66e32 +pub fn to_dafny( + value: crate::operation::get_blob::GetBlobInput, +) -> ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, +> { + let dafny_value = match value.value { + Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -952,7 +303,7 @@ index 00000000..d1a66e32 + }, + None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -960,7 +311,7 @@ index 00000000..d1a66e32 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + >, +) -> crate::operation::get_blob::GetBlobInput { + let value = if matches!( @@ -984,7 +335,7 @@ index 00000000..d1a66e32 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs new file mode 100644 -index 00000000..7fbf9fc5 +index 00000000..ab3eb510 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs @@ -0,0 +1,44 @@ @@ -993,7 +344,7 @@ index 00000000..7fbf9fc5 +pub fn to_dafny( + value: crate::operation::get_blob::GetBlobOutput, +) -> ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, +> { + let dafny_value = match value.value { + Some(b) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -1001,7 +352,7 @@ index 00000000..7fbf9fc5 + }, + None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -1009,7 +360,7 @@ index 00000000..7fbf9fc5 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, +) -> crate::operation::get_blob::GetBlobOutput { + let value = if matches!( @@ -1034,7 +385,7 @@ index 00000000..7fbf9fc5 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs new file mode 100644 -index 00000000..644cb23a +index 00000000..489f2341 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -0,0 +1,32 @@ @@ -1045,21 +396,21 @@ index 00000000..644cb23a +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_blob_known_value::GetBlobKnownValueError, -+) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error> { ++) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_blob_known_value::GetBlobKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -1072,7 +423,7 @@ index 00000000..644cb23a +pub mod _get_blob_known_value_output; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs new file mode 100644 -index 00000000..8b38beeb +index 00000000..d6507fa2 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs @@ -0,0 +1,42 @@ @@ -1081,7 +432,7 @@ index 00000000..8b38beeb +pub fn to_dafny( + value: crate::operation::get_blob_known_value::GetBlobKnownValueInput, +) -> ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, +> { + let dafny_value = match value.value { + Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -1089,7 +440,7 @@ index 00000000..8b38beeb + }, + None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -1097,7 +448,7 @@ index 00000000..8b38beeb +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueInput { + let value = if matches!( @@ -1120,7 +471,7 @@ index 00000000..8b38beeb +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs new file mode 100644 -index 00000000..dc482621 +index 00000000..5ab5b54f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs @@ -0,0 +1,44 @@ @@ -1129,7 +480,7 @@ index 00000000..dc482621 +pub fn to_dafny( + value: crate::operation::get_blob_known_value::GetBlobKnownValueOutput, +) -> ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, +> { + let dafny_value = match value.value { + Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -1137,7 +488,7 @@ index 00000000..dc482621 + }, + None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { ++ ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -1145,7 +496,7 @@ index 00000000..dc482621 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, ++ ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, +) -> crate::operation::get_blob_known_value::GetBlobKnownValueOutput { + let value = if matches!( @@ -1258,7 +609,7 @@ index 00000000..a72267ed +pub mod get_blob_known_value; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs new file mode 100644 -index 00000000..0618c678 +index 00000000..ec28d2be --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs @@ -0,0 +1,143 @@ @@ -1281,7 +632,7 @@ index 00000000..0618c678 + > { + let inner_input = crate::conversions::get_blob::_get_blob_input::to_dafny(input); + let inner_result = -+ ::simple_blob_dafny::dafny_runtime::read!(handle.inner).GetBlob(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetBlob(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_blob_dafny::r#_Wrappers_Compile::Result::Success { .. } @@ -1646,7 +997,7 @@ index 00000000..2f67a4f7 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs new file mode 100644 -index 00000000..8da7c6b0 +index 00000000..c2e3e803 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs @@ -0,0 +1,146 @@ @@ -1670,7 +1021,7 @@ index 00000000..8da7c6b0 + let inner_input = + crate::conversions::get_blob_known_value::_get_blob_known_value_input::to_dafny(input); + let inner_result = -+ ::simple_blob_dafny::dafny_runtime::read!(handle.inner).GetBlob(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetBlob(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_blob_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs index 8aa39b591..a683be1b7 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs @@ -1,341 +1,562 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -pub use dafny_runtime; -pub use dafny_standard_library; pub use dafny_standard_library::implementation_from_dafny::*; -pub mod r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes { - /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ - #[derive(Clone)] - pub struct DafnyCallEvent { - input: I, - output: O, +pub mod r#_simple_dtypes_dblob_dinternaldafny_dtypes { + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent { + DafnyCallEvent { input: I, output: O }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), } - impl ::core::fmt::Debug + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug for DafnyCallEvent { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DafnyCallEvent") - .field("input", &self.input) - .field("output", &self.output) - .finish() + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for DafnyCallEvent { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyblob.internaldafny.types.DafnyCallEvent(" - )?; - self.input.fmt_print(f, false)?; - write!(f, ",")?; - self.output.fmt_print(f, false)?; - write!(f, ")") - } - } - impl - PartialEq> for DafnyCallEvent - { - fn eq(&self, other: &DafnyCallEvent) -> bool { - self.input == other.input && self.output == other.output + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "r#_simple_dtypes_dblob_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } } } - impl Eq for DafnyCallEvent {} - impl ::core::hash::Hash + + impl Eq for DafnyCallEvent { - fn hash(&self, state: &mut H) { - self.input.hash(state); - self.output.hash(state); + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::hash::Hash, + O: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + input.hash(_state); + output.hash(_state) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } } } - /* - datatype GetBlobInput = | GetBlobInput ( - nameonly value: Option := Option.None - ) - */ - #[derive(Clone)] - pub enum GetBlobInput { - GetBlobInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, - >, - }, + impl< + I: ::dafny_runtime::DafnyType + ::std::default::Default, + O: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } } - impl ::std::convert::AsRef for &GetBlobInput { + + impl + ::std::convert::AsRef> for &DafnyCallEvent + { fn as_ref(&self) -> Self { self } } + + #[derive(PartialEq, Clone)] + pub enum GetBlobInput { + GetBlobInput { + value: ::std::rc::Rc>>, + }, + } + impl GetBlobInput { pub fn value( &self, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, - > { + ) -> &::std::rc::Rc>> + { match self { - GetBlobInput::GetBlobInput { value } => value.clone(), + GetBlobInput::GetBlobInput { value } => value, } } } - impl ::core::fmt::Debug for GetBlobInput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::std::fmt::Debug for GetBlobInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for GetBlobInput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyblob.internaldafny.types.GetBlobInput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBlobInput::GetBlobInput { value } => { + write!( + _formatter, + "r#_simple_dtypes_dblob_dinternaldafny_dtypes.GetBlobInput.GetBlobInput(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl PartialEq for GetBlobInput { - fn eq(&self, other: &GetBlobInput) -> bool { - self.value() == other.value() + + impl Eq for GetBlobInput {} + + impl ::std::hash::Hash for GetBlobInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBlobInput::GetBlobInput { value } => value.hash(_state), + } } } - impl Eq for GetBlobInput {} - impl ::core::hash::Hash for GetBlobInput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::default::Default for GetBlobInput { + fn default() -> GetBlobInput { + GetBlobInput::GetBlobInput { + value: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetBlobInput { + fn as_ref(&self) -> Self { + self } } - /* - datatype GetBlobOutput = | GetBlobOutput ( - nameonly value: Option := Option.None - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum GetBlobOutput { GetBlobOutput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, - >, + value: ::std::rc::Rc>>, }, } + impl GetBlobOutput { pub fn value( &self, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, - > { + ) -> &::std::rc::Rc>> + { match self { - GetBlobOutput::GetBlobOutput { value } => value.clone(), + GetBlobOutput::GetBlobOutput { value } => value, } } } - impl ::std::convert::AsRef for &GetBlobOutput { - fn as_ref(&self) -> Self { - self + + impl ::std::fmt::Debug for GetBlobOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for GetBlobOutput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::dafny_runtime::DafnyPrint for GetBlobOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBlobOutput::GetBlobOutput { value } => { + write!( + _formatter, + "r#_simple_dtypes_dblob_dinternaldafny_dtypes.GetBlobOutput.GetBlobOutput(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for GetBlobOutput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyblob.internaldafny.types.GetBlobOutput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + + impl Eq for GetBlobOutput {} + + impl ::std::hash::Hash for GetBlobOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBlobOutput::GetBlobOutput { value } => value.hash(_state), + } } } - impl PartialEq for GetBlobOutput { - fn eq(&self, other: &GetBlobOutput) -> bool { - self.value() == other.value() + + impl ::std::default::Default for GetBlobOutput { + fn default() -> GetBlobOutput { + GetBlobOutput::GetBlobOutput { + value: ::std::default::Default::default(), + } } } - impl Eq for GetBlobOutput {} - impl ::core::hash::Hash for GetBlobOutput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::convert::AsRef for &GetBlobOutput { + fn as_ref(&self) -> Self { + self } } - /* - datatype SimpleBlobConfig = | SimpleBlobConfig ( - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum SimpleBlobConfig { SimpleBlobConfig {}, } - impl ::std::convert::AsRef for &SimpleBlobConfig { - fn as_ref(&self) -> Self { - self + impl SimpleBlobConfig {} + + impl ::std::fmt::Debug for SimpleBlobConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for SimpleBlobConfig { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("SimpleBlobConfig").finish() + impl ::dafny_runtime::DafnyPrint for SimpleBlobConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleBlobConfig::SimpleBlobConfig {} => { + write!(_formatter, "r#_simple_dtypes_dblob_dinternaldafny_dtypes.SimpleBlobConfig.SimpleBlobConfig")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for SimpleBlobConfig { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyblob.internaldafny.types.SimpleBlobConfig()" - ) + impl Eq for SimpleBlobConfig {} + + impl ::std::hash::Hash for SimpleBlobConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleBlobConfig::SimpleBlobConfig {} => {} + } } } - impl PartialEq for SimpleBlobConfig { - fn eq(&self, other: &SimpleBlobConfig) -> bool { - true + + impl ::std::default::Default for SimpleBlobConfig { + fn default() -> SimpleBlobConfig { + SimpleBlobConfig::SimpleBlobConfig {} } } - impl Eq for SimpleBlobConfig {} - impl ::core::hash::Hash for SimpleBlobConfig { - fn hash(&self, state: &mut H) {} + impl ::std::convert::AsRef for &SimpleBlobConfig { + fn as_ref(&self) -> Self { + self + } } pub struct ISimpleTypesBlobClientCallHistory {} + impl ISimpleTypesBlobClientCallHistory { - fn ctor(this: *mut ISimpleTypesBlobClientCallHistory) {} + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } } + pub trait ISimpleTypesBlobClient { fn GetBlob( - self: &Self, + &mut self, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, + ::std::rc::Rc, + ::std::rc::Rc, + >, + >; + fn GetBlobKnownValueTest( + &mut self, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, >, >; } - /* - datatype Error = - | CollectionOfErrors(list: seq, nameonly message: blob) - | Opaque(obj: object) - */ - #[derive(Clone)] + + #[derive(PartialEq, Clone)] pub enum Error { CollectionOfErrors { - list: ::dafny_runtime::Sequence, - message: bool, + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, }, Opaque { - obj: *mut dyn ::std::any::Any, + obj: ::dafny_runtime::Object, }, } - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { match self { - Error::CollectionOfErrors { list, message } => f - .debug_struct("Error::CollectionOfErrors") - .field("list", list) - .field("message", message) - .finish(), - Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), } } - } - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { + pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { match self { Error::CollectionOfErrors { list, message } => { - write!(f, "Error::CollectionOfErrors(list := ")?; - list.fmt_print(f, false)?; - write!(f, ", message := ")?; - message.fmt_print(f, false)?; - write!(f, ")") - } - Error::Opaque { obj } => { - write!(f, "Error::Opaque(obj := ")?; - obj.fmt_print(f, false)?; - write!(f, ")") + panic!("field does not exist on this variant") } + Error::Opaque { obj } => obj, } } } - impl PartialEq for Error { - fn eq(&self, other: &Error) -> bool { + + impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { match self { - Error::CollectionOfErrors { list, message } => match other { - Error::CollectionOfErrors { - list: other_list, - message: other_message, - } => list == other_list && message == other_message, - _ => false, - }, - Error::Opaque { obj } => match other { - Error::Opaque { obj: other_obj } => obj == other_obj, - _ => false, - }, + Error::CollectionOfErrors { list, message } => { + write!( + _formatter, + "r#_simple_dtypes_dblob_dinternaldafny_dtypes.Error.CollectionOfErrors(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "r#_simple_dtypes_dblob_dinternaldafny_dtypes.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } } } } + impl Eq for Error {} - impl ::core::hash::Hash for Error { - fn hash(&self, state: &mut H) { + + impl ::std::hash::Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { match self { Error::CollectionOfErrors { list, message } => { - list.hash(state); - message.hash(state); + list.hash(_state); + message.hash(_state) } - Error::Opaque { obj } => obj.hash(state), + Error::Opaque { obj } => obj.hash(_state), } } } - pub type OpaqueError = Error; -} - -mod r#_SimpleBlobImpl_Compile { - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} + impl ::std::default::Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } } + } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() + impl ::std::convert::AsRef for &Error { + fn as_ref(&self) -> Self { + self } + } + + pub type OpaqueError = + ::std::rc::Rc; +} +pub mod r#_SimpleBlobImpl_Compile { + pub struct _default {} + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } pub fn GetBlob( config: &::std::rc::Rc, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::< ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, >, - ::std::rc::Rc, + >::new(); + if !matches!( + input.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); + let mut res: ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + > = ::std::rc::Rc::new( + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + res = ::std::rc::Rc::new( + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + if !matches!( + res.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); + if !(res.value().value().clone() == input.value().value().clone()) { + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + return output.read(); + } + pub fn GetBlobKnownValueTest( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, >, > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone() - }); + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + if !matches!( + input.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); + if !(input.value().value().clone() == ::dafny_runtime::seq![0, 2, 4]) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + > = ::std::rc::Rc::new( + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + res = ::std::rc::Rc::new( + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + value: input.value().clone(), + }, + ); + if !matches!( + res.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); + if !(res.value().value().clone() == input.value().value().clone()) { + panic!("Halt") + }; output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( super::r#_Wrappers_Compile::Result::< ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, >, - ::std::rc::Rc, + ::std::rc::Rc, >::Success { value: res.clone(), }, @@ -343,32 +564,35 @@ mod r#_SimpleBlobImpl_Compile { return output.read(); return output.read(); } - } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "SimpleBlobImpl_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + pub fn ValidateBlobType(input: &::dafny_runtime::Sequence) -> () { + if !(input.cardinality() >= ::dafny_runtime::int!(0)) { + panic!("Halt") + }; + let mut _hi0: ::dafny_runtime::DafnyInt = input.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + let mut inputElement: u8 = input.get(&i); + inputElement = input.get(&i); + if !(inputElement >= 0) { + panic!("Halt") + } + } + return (); } } + #[derive(PartialEq, Clone)] pub enum Config { Config {}, } + impl Config {} + impl ::std::fmt::Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + impl ::dafny_runtime::DafnyPrint for Config { fn fmt_print( &self, @@ -377,13 +601,23 @@ mod r#_SimpleBlobImpl_Compile { ) -> std::fmt::Result { match self { Config::Config {} => { - write!(_formatter, "SimpleBlobImpl_Compile.Config.Config")?; + write!(_formatter, "r#_SimpleBlobImpl_Compile.Config.Config")?; Ok(()) } } } } + impl Eq for Config {} + + impl ::std::hash::Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + impl ::std::default::Default for Config { fn default() -> Config { Config::Config {} @@ -396,154 +630,214 @@ mod r#_SimpleBlobImpl_Compile { } } } -// SimpleBlob -pub mod r#_simple_dtypes_dsmithyblob_dinternaldafny { +pub mod r#_simple_dtypes_dblob_dinternaldafny { pub struct _default {} impl _default { - pub fn new() -> Self { - _default {} + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() } - pub fn DefaultSimpleBlobConfig( - ) -> super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::SimpleBlobConfig { - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig{} - } - - /*method SimpleBlob(config: SimpleBlobConfig) - returns (res: Result) { - var client := new SimpleBlobClient(Operations.Config); - return Success(client); - } */ - pub fn SimpleBlob(config: &::std::rc::Rc) - -> ::std::rc::Rc>>{ - let client: *mut SimpleBlobClient = ::dafny_runtime::allocate::(); - SimpleBlobClient::_ctor( - client, + ) -> ::std::rc::Rc + { + ::std::rc::Rc::new(super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig {}) + } + pub fn SimpleBlob( + config: &::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, + >, + >::new(); + let mut _nw0: ::dafny_runtime::Object< + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, + > = super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient::_allocate_rcmut(); + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient::_ctor( + &_nw0, &::std::rc::Rc::new(super::r#_SimpleBlobImpl_Compile::Config::Config {}), ); - let v = client as *mut dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient; - // build a success - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, ::std::rc::Rc>::Success{ - value: v - }) + client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + return res.read(); + } + pub fn CreateSuccessOfClient( + client: &::dafny_runtime::Object< + dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, + >, + ::std::rc::Rc, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, + >, + ::std::rc::Rc, + >::Success { + value: client.clone(), + }) + } + pub fn CreateFailureOfError( + error: &::std::rc::Rc, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, + >, + ::std::rc::Rc, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, + >, + ::std::rc::Rc, + >::Failure { + error: error.clone(), + }) } } - struct SimpleBlobClient { - r#_i_config: ::std::rc::Rc, + pub struct SimpleBlobClient { + pub r#__i_config: ::std::rc::Rc, } impl SimpleBlobClient { - fn _ctor( - this: *mut SimpleBlobClient, + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn _ctor( + this: &::dafny_runtime::Object, config: &::std::rc::Rc, - ) { - let mut _i_set_config = false; - ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_rcmut!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); } - fn config(&self) -> ::std::rc::Rc { - self.r#_i_config.clone() + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() } } - impl super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient - for SimpleBlobClient + impl super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient + for super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient { fn GetBlob( - self: &Self, + &mut self, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - > { - super::r#_SimpleBlobImpl_Compile::_default::GetBlob(&self.config(), input) - } - } - ::dafny_runtime::UpcastTo!( - SimpleBlobClient, - dyn super::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient - ); -} - -mod r#_StandardLibraryInterop_Compile { - pub struct WrappersInterop {} - - impl WrappersInterop { - pub fn new() -> Self { - WrappersInterop {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn CreateStringSome( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::std::rc::Rc, + ::std::rc::Rc, >, > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: s.clone(), - }) + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleBlobImpl_Compile::_default::GetBlob(&self.config(), input), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); } - pub fn CreateStringNone() -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + fn GetBlobKnownValueTest( + &mut self, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::None {}) - } - pub fn CreateBlobSome( - b: ::dafny_runtime::Sequence<::std::primitive::u8>, ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::std::primitive::u8>, - >::Some { - value: b, - }) - } - pub fn CreateBlobNone() -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::Sequence<::std::primitive::u8>>, + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc, + ::std::rc::Rc, + >, > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::std::primitive::u8>, - >::None {}) - } - } - - impl ::std::default::Default for WrappersInterop { - fn default() -> Self { - WrappersInterop::new() - } - } - - impl ::dafny_runtime::DafnyPrint for WrappersInterop { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") - } - } - - impl ::std::cmp::PartialEq for WrappersInterop { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + let mut output = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, + >, + ::std::rc::Rc, + >, + >, + >::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleBlobImpl_Compile::_default::GetBlobKnownValueTest( + &self.config(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); } } } -mod _module {} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs index ee9432a00..cff0634ee 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs @@ -5,7 +5,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(Debug)] pub(crate) struct Handle { pub(crate) conf: crate::Config, - pub(crate) inner: *mut dyn ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::ISimpleTypesBlobClient + pub(crate) inner: ::dafny_runtime::Object } #[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -20,9 +20,9 @@ impl Client { // If this service had any configuration properties, // they would need converting here too. let inner_config = ::std::rc::Rc::new( - ::simple_blob_dafny::_simple_dtypes_dsmithyblob_dinternaldafny::_default::DefaultSimpleBlobConfig()); + ::simple_blob_dafny::_simple_dtypes_dblob_dinternaldafny::_default::DefaultSimpleBlobConfig()); let inner = - ::simple_blob_dafny::_simple_dtypes_dsmithyblob_dinternaldafny::_default::SimpleBlob( + ::simple_blob_dafny::_simple_dtypes_dblob_dinternaldafny::_default::SimpleBlob( &inner_config, ); if matches!( @@ -38,7 +38,7 @@ impl Client { } let handle = Handle { conf: conf.clone(), - inner: inner.Extract(), + inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), }; Ok(Self { handle: ::std::sync::Arc::new(handle), @@ -51,15 +51,6 @@ impl Client { } } -impl Drop for Handle { - fn drop(&mut self) { - // Ensure the Dafny values we created by calling SimpleBlob are deallocated. - unsafe { - drop(Box::from_raw(self.inner)); - } - } -} - mod get_blob; mod get_blob_known_value; diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs index 20a8f14c6..9ff5a903d 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_blob::GetBlobError, -) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error> { +) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error> { match value { crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_blob::GetBlobError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_blob::GetBlobError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs index d1a66e32f..7dfd3d6d1 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_input.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_blob::GetBlobInput, ) -> ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, > { let dafny_value = match value.value { Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -11,7 +11,7 @@ pub fn to_dafny( }, None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,7 +19,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, ) -> crate::operation::get_blob::GetBlobInput { let value = if matches!( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs index 7fbf9fc5e..ab3eb510b 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob/_get_blob_output.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_blob::GetBlobOutput, ) -> ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, > { let dafny_value = match value.value { Some(b) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -11,7 +11,7 @@ pub fn to_dafny( }, None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,7 +19,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, >, ) -> crate::operation::get_blob::GetBlobOutput { let value = if matches!( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs index 644cb23a8..489f2341d 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_blob_known_value::GetBlobKnownValueError, -) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error> { +) -> ::std::rc::Rc<::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error> { match value { crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_blob_known_value::GetBlobKnownValueError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs index 8b38beeb4..d6507fa2a 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_input.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_blob_known_value::GetBlobKnownValueInput, ) -> ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, > { let dafny_value = match value.value { Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -11,7 +11,7 @@ pub fn to_dafny( }, None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput::GetBlobInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,7 +19,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobInput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueInput { let value = if matches!( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs index dc4826211..5ab5b54f6 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value/_get_blob_known_value_output.rs @@ -3,7 +3,7 @@ pub fn to_dafny( value: crate::operation::get_blob_known_value::GetBlobKnownValueOutput, ) -> ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, > { let dafny_value = match value.value { Some(v) => ::simple_blob_dafny::_Wrappers_Compile::Option::Some { @@ -11,7 +11,7 @@ pub fn to_dafny( }, None => ::simple_blob_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { + ::std::rc::Rc::new(::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -19,7 +19,7 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_blob_dafny::r#_simple_dtypes_dsmithyblob_dinternaldafny_dtypes::GetBlobOutput, + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, >, ) -> crate::operation::get_blob_known_value::GetBlobKnownValueOutput { let value = if matches!( diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs index 0618c678c..ec28d2be2 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob.rs @@ -17,7 +17,7 @@ impl GetBlob { > { let inner_input = crate::conversions::get_blob::_get_blob_input::to_dafny(input); let inner_result = - ::simple_blob_dafny::dafny_runtime::read!(handle.inner).GetBlob(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetBlob(&inner_input); if matches!( inner_result.as_ref(), ::simple_blob_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs index 8da7c6b0a..c2e3e803a 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/operation/get_blob_known_value.rs @@ -18,7 +18,7 @@ impl GetBlobKnownValue { let inner_input = crate::conversions::get_blob_known_value::_get_blob_known_value_input::to_dafny(input); let inner_result = - ::simple_blob_dafny::dafny_runtime::read!(handle.inner).GetBlob(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetBlob(&inner_input); if matches!( inner_result.as_ref(), ::simple_blob_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleBlob/src_for_rust/Index.dfy b/TestModels/SimpleTypes/SimpleBlob/src_for_rust/Index.dfy deleted file mode 100644 index 673804f32..000000000 --- a/TestModels/SimpleTypes/SimpleBlob/src_for_rust/Index.dfy +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Not attempting to actually compile any code yet, -// just 100% patching. diff --git a/TestModels/SimpleTypes/SimpleBoolean/Makefile b/TestModels/SimpleTypes/SimpleBoolean/Makefile index 9cc6f1bcc..7fe35f6fa 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/Makefile +++ b/TestModels/SimpleTypes/SimpleBoolean/Makefile @@ -21,5 +21,3 @@ SMITHY_DEPS=dafny-dependencies/Model/traits.smithy # This project has no dependencies # DEPENDENT-MODELS:= - -RUST_SRC_INDEX=src_for_rust diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index d8a9a0b66..b57178258 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,622 +1,31 @@ diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index ba5de6ff..dd0ece8a 100644 +index c2850c0e..06c0c0ea 100644 --- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -1,89 +1,522 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] --extern crate dafny_runtime; --mod _System { -- #[derive(Clone, PartialEq)] -- #[repr(transparent)] -- pub struct nat(pub ::dafny_runtime::DafnyInt); -- impl ::std::default::Default for nat { -- fn default() -> Self { -- nat(::std::default::Default::default()) -- } -- } -- impl ::dafny_runtime::DafnyPrint for nat { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -- ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -- } -- } -- impl ::std::ops::Deref for nat { -- type Target = ::dafny_runtime::DafnyInt; -- fn deref(&self) -> &Self::Target { -- &self.0 -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple2 { -- _T2 { _0: T0, _1: T1 }, -- _PhantomVariant(::std::marker::PhantomData::, ::std::marker::PhantomData::) -- } -- impl Tuple2 { -- pub fn _0(&self) -> &T0 { -- match self { -- Tuple2::_T2 { _0, _1, } => _0, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- pub fn _1(&self) -> &T1 { -- match self { -- Tuple2::_T2 { _0, _1, } => _1, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- } -- impl ::dafny_runtime::DafnyPrint for Tuple2 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple2::_T2 { _0, _1, } => { -- write!(_formatter, "_System.Tuple2._T2(")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_0, _formatter, false)?; -- write!(_formatter, ", ")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_1, _formatter, false)?; -- write!(_formatter, ")")?; -- Ok(()) -+pub use dafny_runtime; -+pub use dafny_standard_library; -+pub use dafny_standard_library::implementation_from_dafny::*; -+ -+pub mod r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes { -+ /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ -+ #[derive(Clone)] -+ pub struct DafnyCallEvent { -+ input: I, -+ output: O, -+ } -+ impl ::core::fmt::Debug -+ for DafnyCallEvent -+ { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("DafnyCallEvent") -+ .field("input", &self.input) -+ .field("output", &self.output) -+ .finish() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint -+ for DafnyCallEvent -+ { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyboolean.internaldafny.types.DafnyCallEvent(" -+ )?; -+ self.input.fmt_print(f, false)?; -+ write!(f, ",")?; -+ self.output.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl -+ PartialEq> for DafnyCallEvent -+ { -+ fn eq(&self, other: &DafnyCallEvent) -> bool { -+ self.input == other.input && self.output == other.output -+ } -+ } -+ impl Eq for DafnyCallEvent {} -+ impl ::core::hash::Hash -+ for DafnyCallEvent -+ { -+ fn hash(&self, state: &mut H) { -+ self.input.hash(state); -+ self.output.hash(state); -+ } -+ } -+ -+ /* -+ datatype GetBooleanInput = | GetBooleanInput ( -+ nameonly value: Option := Option.None -+ ) -+ */ -+ #[derive(Clone)] -+ pub enum GetBooleanInput { -+ GetBooleanInput { -+ value: ::std::rc::Rc>, -+ }, -+ } -+ impl ::std::convert::AsRef for &GetBooleanInput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl GetBooleanInput { -+ pub fn value(&self) -> ::std::rc::Rc> { -+ match self { -+ GetBooleanInput::GetBooleanInput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::core::fmt::Debug for GetBooleanInput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetBooleanInput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyboolean.internaldafny.types.GetBooleanInput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetBooleanInput { -+ fn eq(&self, other: &GetBooleanInput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetBooleanInput {} -+ impl ::core::hash::Hash for GetBooleanInput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype GetBooleanOutput = | GetBooleanOutput ( -+ nameonly value: Option := Option.None -+ ) */ -+ #[derive(Clone)] -+ pub enum GetBooleanOutput { -+ GetBooleanOutput { -+ value: ::std::rc::Rc>, - }, -- Tuple2::_PhantomVariant(..) => {panic!()} -- } -- } -- } -- impl ::std::default::Default for Tuple2 { -- fn default() -> Self { -- Tuple2::_T2 { -- _0: ::std::default::Default::default(), -- _1: ::std::default::Default::default() -- } -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple0 { -- _T0 {} -- } -- impl Tuple0 {} -- impl ::dafny_runtime::DafnyPrint for Tuple0 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple0::_T0 { } => { -- write!(_formatter, "_System.Tuple0._T0")?; -- Ok(()) -- } -- } -- } -- } -- impl ::std::default::Default for Tuple0 { -- fn default() -> Self { -- Tuple0::_T0 {} -- } -- } -+ } -+ impl GetBooleanOutput { -+ pub fn value(&self) -> ::std::rc::Rc> { -+ match self { -+ GetBooleanOutput::GetBooleanOutput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::std::convert::AsRef for &GetBooleanOutput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl ::core::fmt::Debug for GetBooleanOutput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyboolean.internaldafny.types.GetBooleanOutput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetBooleanOutput { -+ fn eq(&self, other: &GetBooleanOutput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetBooleanOutput {} -+ impl ::core::hash::Hash for GetBooleanOutput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype SimpleBooleanConfig = | SimpleBooleanConfig ( -+ ) */ -+ #[derive(Clone)] -+ pub enum SimpleBooleanConfig { -+ SimpleBooleanConfig {}, -+ } -+ -+ impl ::std::convert::AsRef for &SimpleBooleanConfig { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ impl ::core::fmt::Debug for SimpleBooleanConfig { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("SimpleBooleanConfig").finish() -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithyboolean.internaldafny.types.SimpleBooleanConfig()" -+ ) -+ } -+ } -+ impl PartialEq for SimpleBooleanConfig { -+ fn eq(&self, other: &SimpleBooleanConfig) -> bool { -+ true -+ } -+ } -+ impl Eq for SimpleBooleanConfig {} -+ -+ impl ::core::hash::Hash for SimpleBooleanConfig { -+ fn hash(&self, state: &mut H) {} -+ } -+ -+ pub struct ISimpleTypesBooleanClientCallHistory {} -+ impl ISimpleTypesBooleanClientCallHistory { -+ fn ctor(this: *mut ISimpleTypesBooleanClientCallHistory) {} -+ } -+ pub trait ISimpleTypesBooleanClient { -+ fn GetBoolean( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ >; -+ } -+ /* -+ datatype Error = -+ | CollectionOfErrors(list: seq, nameonly message: boolean) -+ | Opaque(obj: object) -+ */ -+ #[derive(Clone)] -+ pub enum Error { -+ CollectionOfErrors { -+ list: ::dafny_runtime::Sequence, -+ message: bool, -+ }, -+ Opaque { -+ obj: *mut dyn ::std::any::Any, -+ }, -+ } -+ impl ::core::fmt::Debug for Error { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => f -+ .debug_struct("Error::CollectionOfErrors") -+ .field("list", list) -+ .field("message", message) -+ .finish(), -+ Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), -+ } -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Error { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ write!(f, "Error::CollectionOfErrors(list := ")?; -+ list.fmt_print(f, false)?; -+ write!(f, ", message := ")?; -+ message.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ Error::Opaque { obj } => { -+ write!(f, "Error::Opaque(obj := ")?; -+ obj.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ } -+ } -+ impl PartialEq for Error { -+ fn eq(&self, other: &Error) -> bool { -+ match self { -+ Error::CollectionOfErrors { list, message } => match other { -+ Error::CollectionOfErrors { -+ list: other_list, -+ message: other_message, -+ } => list == other_list && message == other_message, -+ _ => false, -+ }, -+ Error::Opaque { obj } => match other { -+ Error::Opaque { obj: other_obj } => obj == other_obj, -+ _ => false, -+ }, -+ } -+ } -+ } -+ impl Eq for Error {} -+ impl ::core::hash::Hash for Error { -+ fn hash(&self, state: &mut H) { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ list.hash(state); -+ message.hash(state); -+ } -+ Error::Opaque { obj } => obj.hash(state), -+ } -+ } -+ } -+ -+ pub type OpaqueError = Error; -+} -+ -+mod r#_SimpleBooleanImpl_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ -+ pub fn GetBoolean( -+ config: &::std::rc::Rc, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); -+ let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { -+ value: input.value().clone() -+ }); -+ res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { -+ value: input.value().clone() -+ }); -+ output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { -+ value: res.clone() -+ })); -+ return output.read(); -+ return output.read(); -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "SimpleBooleanImpl_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Config { -+ Config {}, -+ } -+ impl Config {} -+ -+ impl ::dafny_runtime::DafnyPrint for Config { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Config::Config {} => { -+ write!(_formatter, "SimpleBooleanImpl_Compile.Config.Config")?; -+ Ok(()) -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default for Config { -+ fn default() -> Config { -+ Config::Config {} -+ } -+ } -+ -+ impl ::std::convert::AsRef for &Config { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+// SimpleBoolean -+pub mod r#_simple_dtypes_dsmithyboolean_dinternaldafny { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ -+ pub fn DefaultSimpleBooleanConfig( -+ ) -> super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::SimpleBooleanConfig -+ { -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig{} -+ } -+ -+ /*method SimpleBoolean(config: SimpleBooleanConfig) -+ returns (res: Result) { -+ var client := new SimpleBooleanClient(Operations.Config); -+ return Success(client); -+ } */ -+ pub fn SimpleBoolean(config: &::std::rc::Rc) -+ -> ::std::rc::Rc>>{ -+ let client: *mut SimpleBooleanClient = -+ ::dafny_runtime::allocate::(); -+ SimpleBooleanClient::_ctor( -+ client, -+ &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), -+ ); -+ let v = client as *mut dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient; -+ // build a success -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient, ::std::rc::Rc>::Success{ -+ value: v -+ }) -+ } -+ } -+ -+ struct SimpleBooleanClient { -+ r#_i_config: ::std::rc::Rc, -+ } -+ -+ impl SimpleBooleanClient { -+ fn _ctor( -+ this: *mut SimpleBooleanClient, -+ config: &::std::rc::Rc, -+ ) { -+ let mut _i_set_config = false; -+ ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); -+ } -+ fn config(&self) -> ::std::rc::Rc { -+ self.r#_i_config.clone() -+ } -+ } -+ -+ impl super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient -+ for SimpleBooleanClient -+ { -+ fn GetBoolean( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input) -+ } -+ } -+ ::dafny_runtime::UpcastTo!( -+ SimpleBooleanClient, -+ dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient -+ ); -+} -+ -+mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ -+ impl WrappersInterop { -+ pub fn new() -> Self { -+ WrappersInterop {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn CreateStringSome( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Some { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::None {}) -+ } -+ pub fn CreateBooleanSome( -+ b: bool, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) -+ } -+ pub fn CreateBooleanNone() -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+ -+ impl ::std::default::Default for WrappersInterop { -+ fn default() -> Self { -+ WrappersInterop::new() -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for WrappersInterop { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") -+ } -+ } -+ -+ impl ::std::cmp::PartialEq for WrappersInterop { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } - } --mod _module { -- --} -\ No newline at end of file -+mod _module {} +@@ -434,7 +434,7 @@ pub mod r#_SimpleBooleanImpl_Compile { + ) { + panic!("Halt") + }; +- if !(input.value().value() == true || input.value().value() == false) { ++ if !(*input.value().value() == true || *input.value().value() == false) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { +@@ -443,7 +443,7 @@ pub mod r#_SimpleBooleanImpl_Compile { + res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: input.value().clone() + }); +- if !(res.value().value() == true || res.value().value() == false) { ++ if !(*res.value().value() == true || *res.value().value() == false) { + panic!("Halt") + }; + if !(input.value().value() == res.value().value()) { diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..7d63747e +index 00000000..cc741930 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs -@@ -0,0 +1,61 @@ +@@ -0,0 +1,52 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. + +use aws_smithy_types::error::operation::BuildError; @@ -624,7 +33,7 @@ index 00000000..7d63747e +#[derive(Debug)] +pub(crate) struct Handle { + pub(crate) conf: crate::Config, -+ pub(crate) inner: *mut dyn ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient ++ pub(crate) inner: ::dafny_runtime::Object +} + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -639,9 +48,9 @@ index 00000000..7d63747e + // If this service had any configuration properties, + // they would need converting here too. + let inner_config = ::std::rc::Rc::new( -+ ::simple_boolean_dafny::_simple_dtypes_dsmithyboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig()); ++ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig()); + let inner = -+ ::simple_boolean_dafny::_simple_dtypes_dsmithyboolean_dinternaldafny::_default::SimpleBoolean(&inner_config); ++ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&inner_config); + if matches!( + inner.as_ref(), + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } @@ -655,7 +64,7 @@ index 00000000..7d63747e + } + let handle = Handle { + conf: conf.clone(), -+ inner: inner.Extract(), ++ inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + }; + Ok(Self { + handle: ::std::sync::Arc::new(handle), @@ -668,15 +77,6 @@ index 00000000..7d63747e + } +} + -+impl Drop for Handle { -+ fn drop(&mut self) { -+ // Ensure the Dafny values we created by calling SimpleBoolean are deallocated. -+ unsafe { -+ drop(Box::from_raw(self.inner)); -+ } -+ } -+} -+ +mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client/get_boolean.rs new file mode 100644 @@ -841,7 +241,7 @@ index 00000000..180cd865 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..b85f5565 +index 00000000..3594bb56 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,34 @@ @@ -853,22 +253,22 @@ index 00000000..b85f5565 +pub fn to_dafny_error( + value: crate::operation::get_boolean::GetBooleanError, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, +> { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -881,7 +281,7 @@ index 00000000..b85f5565 +pub mod _get_boolean_output; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs new file mode 100644 -index 00000000..023d5082 +index 00000000..1f8987e8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -0,0 +1,35 @@ @@ -890,20 +290,20 @@ index 00000000..023d5082 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanInput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, +> { + let dafny_value = match value.value { + Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput>, ++ dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput>, +) -> crate::operation::get_boolean::GetBooleanInput { + let value = if matches!( + dafny_value.value().as_ref(), @@ -922,7 +322,7 @@ index 00000000..023d5082 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs new file mode 100644 -index 00000000..f95d177d +index 00000000..024d6db9 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -0,0 +1,35 @@ @@ -931,20 +331,20 @@ index 00000000..f95d177d +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanOutput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, +> { + let dafny_value = match value.value { + Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} + +#[allow(dead_code)] +pub fn from_dafny( -+ dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput>, ++ dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput>, +) -> crate::operation::get_boolean::GetBooleanOutput { + let value = if matches!( + dafny_value.value().as_ref(), @@ -1048,7 +448,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..5f4d9bf0 +index 00000000..b8374820 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -1071,7 +471,7 @@ index 00000000..5f4d9bf0 + > { + let inner_input = crate::conversions::get_boolean::_get_boolean_input::to_dafny(input); + let inner_result = -+ ::simple_boolean_dafny::dafny_runtime::read!(handle.inner).GetBoolean(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetBoolean(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs index dd0ece8ab..06c0c0eab 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs @@ -1,355 +1,482 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -pub use dafny_runtime; -pub use dafny_standard_library; pub use dafny_standard_library::implementation_from_dafny::*; -pub mod r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes { - /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ - #[derive(Clone)] - pub struct DafnyCallEvent { - input: I, - output: O, +pub mod r#_simple_dtypes_dboolean_dinternaldafny_dtypes { + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent { + DafnyCallEvent { input: I, output: O }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } } - impl ::core::fmt::Debug + + impl ::std::fmt::Debug for DafnyCallEvent { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DafnyCallEvent") - .field("input", &self.input) - .field("output", &self.output) - .finish() + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for DafnyCallEvent { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyboolean.internaldafny.types.DafnyCallEvent(" - )?; - self.input.fmt_print(f, false)?; - write!(f, ",")?; - self.output.fmt_print(f, false)?; - write!(f, ")") - } - } - impl - PartialEq> for DafnyCallEvent - { - fn eq(&self, other: &DafnyCallEvent) -> bool { - self.input == other.input && self.output == other.output + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } } } - impl Eq for DafnyCallEvent {} - impl ::core::hash::Hash + + impl Eq for DafnyCallEvent { - fn hash(&self, state: &mut H) { - self.input.hash(state); - self.output.hash(state); + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::hash::Hash, + O: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + input.hash(_state); + output.hash(_state) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } } } - /* - datatype GetBooleanInput = | GetBooleanInput ( - nameonly value: Option := Option.None - ) - */ - #[derive(Clone)] - pub enum GetBooleanInput { - GetBooleanInput { - value: ::std::rc::Rc>, - }, + impl< + I: ::dafny_runtime::DafnyType + ::std::default::Default, + O: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } } - impl ::std::convert::AsRef for &GetBooleanInput { + + impl + ::std::convert::AsRef> for &DafnyCallEvent + { fn as_ref(&self) -> Self { self } } + + #[derive(PartialEq, Clone)] + pub enum GetBooleanInput { + GetBooleanInput { + value: ::std::rc::Rc>, + }, + } + impl GetBooleanInput { - pub fn value(&self) -> ::std::rc::Rc> { + pub fn value(&self) -> &::std::rc::Rc> { match self { - GetBooleanInput::GetBooleanInput { value } => value.clone(), + GetBooleanInput::GetBooleanInput { value } => value, } } } - impl ::core::fmt::Debug for GetBooleanInput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::std::fmt::Debug for GetBooleanInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for GetBooleanInput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyboolean.internaldafny.types.GetBooleanInput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanInput::GetBooleanInput { value } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanInput.GetBooleanInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl PartialEq for GetBooleanInput { - fn eq(&self, other: &GetBooleanInput) -> bool { - self.value() == other.value() + + impl Eq for GetBooleanInput {} + + impl ::std::hash::Hash for GetBooleanInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanInput::GetBooleanInput { value } => value.hash(_state), + } } } - impl Eq for GetBooleanInput {} - impl ::core::hash::Hash for GetBooleanInput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::default::Default for GetBooleanInput { + fn default() -> GetBooleanInput { + GetBooleanInput::GetBooleanInput { + value: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetBooleanInput { + fn as_ref(&self) -> Self { + self } } - /* - datatype GetBooleanOutput = | GetBooleanOutput ( - nameonly value: Option := Option.None - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum GetBooleanOutput { GetBooleanOutput { value: ::std::rc::Rc>, }, } + impl GetBooleanOutput { - pub fn value(&self) -> ::std::rc::Rc> { + pub fn value(&self) -> &::std::rc::Rc> { match self { - GetBooleanOutput::GetBooleanOutput { value } => value.clone(), + GetBooleanOutput::GetBooleanOutput { value } => value, } } } - impl ::std::convert::AsRef for &GetBooleanOutput { - fn as_ref(&self) -> Self { - self + + impl ::std::fmt::Debug for GetBooleanOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for GetBooleanOutput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanOutput::GetBooleanOutput { value } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanOutput.GetBooleanOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyboolean.internaldafny.types.GetBooleanOutput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + + impl Eq for GetBooleanOutput {} + + impl ::std::hash::Hash for GetBooleanOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanOutput::GetBooleanOutput { value } => value.hash(_state), + } } } - impl PartialEq for GetBooleanOutput { - fn eq(&self, other: &GetBooleanOutput) -> bool { - self.value() == other.value() + + impl ::std::default::Default for GetBooleanOutput { + fn default() -> GetBooleanOutput { + GetBooleanOutput::GetBooleanOutput { + value: ::std::default::Default::default(), + } } } - impl Eq for GetBooleanOutput {} - impl ::core::hash::Hash for GetBooleanOutput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::convert::AsRef for &GetBooleanOutput { + fn as_ref(&self) -> Self { + self } } - /* - datatype SimpleBooleanConfig = | SimpleBooleanConfig ( - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum SimpleBooleanConfig { SimpleBooleanConfig {}, } - impl ::std::convert::AsRef for &SimpleBooleanConfig { - fn as_ref(&self) -> Self { - self + impl SimpleBooleanConfig {} + + impl ::std::fmt::Debug for SimpleBooleanConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for SimpleBooleanConfig { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("SimpleBooleanConfig").finish() + impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.SimpleBooleanConfig.SimpleBooleanConfig")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithyboolean.internaldafny.types.SimpleBooleanConfig()" - ) + impl Eq for SimpleBooleanConfig {} + + impl ::std::hash::Hash for SimpleBooleanConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => {} + } } } - impl PartialEq for SimpleBooleanConfig { - fn eq(&self, other: &SimpleBooleanConfig) -> bool { - true + + impl ::std::default::Default for SimpleBooleanConfig { + fn default() -> SimpleBooleanConfig { + SimpleBooleanConfig::SimpleBooleanConfig {} } } - impl Eq for SimpleBooleanConfig {} - impl ::core::hash::Hash for SimpleBooleanConfig { - fn hash(&self, state: &mut H) {} + impl ::std::convert::AsRef for &SimpleBooleanConfig { + fn as_ref(&self) -> Self { + self + } } pub struct ISimpleTypesBooleanClientCallHistory {} + impl ISimpleTypesBooleanClientCallHistory { - fn ctor(this: *mut ISimpleTypesBooleanClientCallHistory) {} + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } } + pub trait ISimpleTypesBooleanClient { fn GetBoolean( - self: &Self, + &mut self, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, - ::std::rc::Rc, + ::std::rc::Rc, >, >; } - /* - datatype Error = - | CollectionOfErrors(list: seq, nameonly message: boolean) - | Opaque(obj: object) - */ - #[derive(Clone)] + + #[derive(PartialEq, Clone)] pub enum Error { CollectionOfErrors { - list: ::dafny_runtime::Sequence, - message: bool, + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, }, Opaque { - obj: *mut dyn ::std::any::Any, + obj: ::dafny_runtime::Object, }, } - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { match self { - Error::CollectionOfErrors { list, message } => f - .debug_struct("Error::CollectionOfErrors") - .field("list", list) - .field("message", message) - .finish(), - Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), } } - } - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { + pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { match self { Error::CollectionOfErrors { list, message } => { - write!(f, "Error::CollectionOfErrors(list := ")?; - list.fmt_print(f, false)?; - write!(f, ", message := ")?; - message.fmt_print(f, false)?; - write!(f, ")") - } - Error::Opaque { obj } => { - write!(f, "Error::Opaque(obj := ")?; - obj.fmt_print(f, false)?; - write!(f, ")") + panic!("field does not exist on this variant") } + Error::Opaque { obj } => obj, } } } - impl PartialEq for Error { - fn eq(&self, other: &Error) -> bool { + + impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { match self { - Error::CollectionOfErrors { list, message } => match other { - Error::CollectionOfErrors { - list: other_list, - message: other_message, - } => list == other_list && message == other_message, - _ => false, - }, - Error::Opaque { obj } => match other { - Error::Opaque { obj: other_obj } => obj == other_obj, - _ => false, - }, + Error::CollectionOfErrors { list, message } => { + write!( + _formatter, + "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.CollectionOfErrors(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } } } } + impl Eq for Error {} - impl ::core::hash::Hash for Error { - fn hash(&self, state: &mut H) { + + impl ::std::hash::Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { match self { Error::CollectionOfErrors { list, message } => { - list.hash(state); - message.hash(state); + list.hash(_state); + message.hash(_state) } - Error::Opaque { obj } => obj.hash(state), + Error::Opaque { obj } => obj.hash(_state), } } } - pub type OpaqueError = Error; -} - -mod r#_SimpleBooleanImpl_Compile { - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} + impl ::std::default::Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } } + } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() + impl ::std::convert::AsRef for &Error { + fn as_ref(&self) -> Self { + self } + } + + pub type OpaqueError = + ::std::rc::Rc; +} +pub mod r#_SimpleBooleanImpl_Compile { + pub struct _default {} + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } pub fn GetBoolean( config: &::std::rc::Rc, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, - ::std::rc::Rc, + ::std::rc::Rc, >, > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + if !matches!( + input.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !(*input.value().value() == true || *input.value().value() == false) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { value: input.value().clone() }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { value: input.value().clone() }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: res.clone() - })); + if !(*res.value().value() == true || *res.value().value() == false) { + panic!("Halt") + }; + if !(input.value().value() == res.value().value()) { + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); return output.read(); return output.read(); } } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "SimpleBooleanImpl_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) - } - } + #[derive(PartialEq, Clone)] pub enum Config { Config {}, } + impl Config {} + impl ::std::fmt::Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + impl ::dafny_runtime::DafnyPrint for Config { fn fmt_print( &self, @@ -358,13 +485,23 @@ mod r#_SimpleBooleanImpl_Compile { ) -> std::fmt::Result { match self { Config::Config {} => { - write!(_formatter, "SimpleBooleanImpl_Compile.Config.Config")?; + write!(_formatter, "r#_SimpleBooleanImpl_Compile.Config.Config")?; Ok(()) } } } } + impl Eq for Config {} + + impl ::std::hash::Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + impl ::std::default::Default for Config { fn default() -> Config { Config::Config {} @@ -377,146 +514,128 @@ mod r#_SimpleBooleanImpl_Compile { } } } -// SimpleBoolean -pub mod r#_simple_dtypes_dsmithyboolean_dinternaldafny { +pub mod r#_simple_dtypes_dboolean_dinternaldafny { pub struct _default {} impl _default { - pub fn new() -> Self { - _default {} - } - - pub fn DefaultSimpleBooleanConfig( - ) -> super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::SimpleBooleanConfig - { - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig{} - } - - /*method SimpleBoolean(config: SimpleBooleanConfig) - returns (res: Result) { - var client := new SimpleBooleanClient(Operations.Config); - return Success(client); - } */ - pub fn SimpleBoolean(config: &::std::rc::Rc) - -> ::std::rc::Rc>>{ - let client: *mut SimpleBooleanClient = - ::dafny_runtime::allocate::(); - SimpleBooleanClient::_ctor( - client, + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + > { + ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + pub fn SimpleBoolean( + config: &::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + >::new(); + let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_allocate_rcmut(); + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_ctor( + &_nw0, &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), ); - let v = client as *mut dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient; - // build a success - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient, ::std::rc::Rc>::Success{ - value: v - }) + client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) } } - struct SimpleBooleanClient { - r#_i_config: ::std::rc::Rc, + pub struct SimpleBooleanClient { + pub r#__i_config: ::std::rc::Rc, } impl SimpleBooleanClient { - fn _ctor( - this: *mut SimpleBooleanClient, + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn _ctor( + this: &::dafny_runtime::Object, config: &::std::rc::Rc, - ) { - let mut _i_set_config = false; - ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_rcmut!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); } - fn config(&self) -> ::std::rc::Rc { - self.r#_i_config.clone() + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() } } - impl super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - for SimpleBooleanClient + impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient + for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient { fn GetBoolean( - self: &Self, + &mut self, input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> ::std::rc::Rc< super::r#_Wrappers_Compile::Result< ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, - ::std::rc::Rc, - >, - > { - super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input) - } - } - ::dafny_runtime::UpcastTo!( - SimpleBooleanClient, - dyn super::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - ); -} - -mod r#_StandardLibraryInterop_Compile { - pub struct WrappersInterop {} - - impl WrappersInterop { - pub fn new() -> Self { - WrappersInterop {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn CreateStringSome( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: s.clone(), - }) - } - pub fn CreateStringNone() -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::std::rc::Rc, >, > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::None {}) - } - pub fn CreateBooleanSome( - b: bool, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) - } - pub fn CreateBooleanNone() -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } - } - - impl ::std::default::Default for WrappersInterop { - fn default() -> Self { - WrappersInterop::new() - } - } - - impl ::dafny_runtime::DafnyPrint for WrappersInterop { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") - } - } - - impl ::std::cmp::PartialEq for WrappersInterop { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); } } } -mod _module {} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 7d63747ee..cc741930f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -5,7 +5,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(Debug)] pub(crate) struct Handle { pub(crate) conf: crate::Config, - pub(crate) inner: *mut dyn ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient + pub(crate) inner: ::dafny_runtime::Object } #[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -20,9 +20,9 @@ impl Client { // If this service had any configuration properties, // they would need converting here too. let inner_config = ::std::rc::Rc::new( - ::simple_boolean_dafny::_simple_dtypes_dsmithyboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig()); + ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig()); let inner = - ::simple_boolean_dafny::_simple_dtypes_dsmithyboolean_dinternaldafny::_default::SimpleBoolean(&inner_config); + ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&inner_config); if matches!( inner.as_ref(), ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } @@ -36,7 +36,7 @@ impl Client { } let handle = Handle { conf: conf.clone(), - inner: inner.Extract(), + inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), }; Ok(Self { handle: ::std::sync::Arc::new(handle), @@ -49,13 +49,4 @@ impl Client { } } -impl Drop for Handle { - fn drop(&mut self) { - // Ensure the Dafny values we created by calling SimpleBoolean are deallocated. - unsafe { - drop(Box::from_raw(self.inner)); - } - } -} - mod get_boolean; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index b85f55659..3594bb56d 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -6,22 +6,22 @@ use std::any::Any; pub fn to_dafny_error( value: crate::operation::get_boolean::GetBooleanError, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, > { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs index 023d5082a..1f8987e8a 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -3,20 +3,20 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, > { let dafny_value = match value.value { Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(dafny_value) }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanInput>, + dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput>, ) -> crate::operation::get_boolean::GetBooleanInput { let value = if matches!( dafny_value.value().as_ref(), diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs index f95d177d6..024d6db9b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -3,20 +3,20 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanOutput, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, > { let dafny_value = match value.value { Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { value: ::std::rc::Rc::new(dafny_value) }) } #[allow(dead_code)] pub fn from_dafny( - dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dsmithyboolean_dinternaldafny_dtypes::GetBooleanOutput>, + dafny_value: ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput>, ) -> crate::operation::get_boolean::GetBooleanOutput { let value = if matches!( dafny_value.value().as_ref(), diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 5f4d9bf02..b83748200 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -17,7 +17,7 @@ impl GetBoolean { > { let inner_input = crate::conversions::get_boolean::_get_boolean_input::to_dafny(input); let inner_result = - ::simple_boolean_dafny::dafny_runtime::read!(handle.inner).GetBoolean(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetBoolean(&inner_input); if matches!( inner_result.as_ref(), ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleBoolean/src_for_rust/Index.dfy b/TestModels/SimpleTypes/SimpleBoolean/src_for_rust/Index.dfy deleted file mode 100644 index 673804f32..000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/src_for_rust/Index.dfy +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Not attempting to actually compile any code yet, -// just 100% patching. diff --git a/TestModels/SimpleTypes/SimpleString/Makefile b/TestModels/SimpleTypes/SimpleString/Makefile index 3a00b6af4..6db609ced 100644 --- a/TestModels/SimpleTypes/SimpleString/Makefile +++ b/TestModels/SimpleTypes/SimpleString/Makefile @@ -18,5 +18,3 @@ SMITHY_DEPS=dafny-dependencies/Model/traits.smithy # This project has no dependencies # DEPENDENT-MODELS:= - -RUST_SRC_INDEX=src_for_rust diff --git a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch index 340c7cacb..e42b7dc42 100644 --- a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch @@ -1,737 +1,9 @@ -diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index ba5de6ff..469a527f 100644 ---- b/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -1,89 +1,637 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] --extern crate dafny_runtime; --mod _System { -- #[derive(Clone, PartialEq)] -- #[repr(transparent)] -- pub struct nat(pub ::dafny_runtime::DafnyInt); -- impl ::std::default::Default for nat { -- fn default() -> Self { -- nat(::std::default::Default::default()) -- } -- } -- impl ::dafny_runtime::DafnyPrint for nat { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -- ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -- } -- } -- impl ::std::ops::Deref for nat { -- type Target = ::dafny_runtime::DafnyInt; -- fn deref(&self) -> &Self::Target { -- &self.0 -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple2 { -- _T2 { _0: T0, _1: T1 }, -- _PhantomVariant(::std::marker::PhantomData::, ::std::marker::PhantomData::) -- } -- impl Tuple2 { -- pub fn _0(&self) -> &T0 { -- match self { -- Tuple2::_T2 { _0, _1, } => _0, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- pub fn _1(&self) -> &T1 { -- match self { -- Tuple2::_T2 { _0, _1, } => _1, -- Tuple2::_PhantomVariant(..) => panic!() -- } -- } -- } -- impl ::dafny_runtime::DafnyPrint for Tuple2 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple2::_T2 { _0, _1, } => { -- write!(_formatter, "_System.Tuple2._T2(")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_0, _formatter, false)?; -- write!(_formatter, ", ")?; -- ::dafny_runtime::DafnyPrint::fmt_print(_1, _formatter, false)?; -- write!(_formatter, ")")?; -- Ok(()) -+pub extern crate dafny_runtime; -+pub extern crate dafny_standard_library; -+pub use dafny_standard_library::implementation_from_dafny::*; -+ -+pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { -+ /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ -+ #[derive(Clone)] -+ pub struct DafnyCallEvent { -+ input: I, -+ output: O, -+ } -+ impl ::core::fmt::Debug -+ for DafnyCallEvent -+ { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("DafnyCallEvent") -+ .field("input", &self.input) -+ .field("output", &self.output) -+ .finish() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint -+ for DafnyCallEvent -+ { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithystring.internaldafny.types.DafnyCallEvent(" -+ )?; -+ self.input.fmt_print(f, false)?; -+ write!(f, ",")?; -+ self.output.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl -+ PartialEq> for DafnyCallEvent -+ { -+ fn eq(&self, other: &DafnyCallEvent) -> bool { -+ self.input == other.input && self.output == other.output -+ } -+ } -+ impl Eq for DafnyCallEvent {} -+ impl ::core::hash::Hash -+ for DafnyCallEvent -+ { -+ fn hash(&self, state: &mut H) { -+ self.input.hash(state); -+ self.output.hash(state); -+ } -+ } -+ -+ /* -+ datatype GetStringInput = | GetStringInput ( -+ nameonly value: Option := Option.None -+ ) -+ */ -+ #[derive(Clone)] -+ pub enum GetStringInput { -+ GetStringInput { -+ value: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::DafnyStringUTF16>, -+ >, - }, -- Tuple2::_PhantomVariant(..) => {panic!()} -- } -- } -- } -- impl ::std::default::Default for Tuple2 { -- fn default() -> Self { -- Tuple2::_T2 { -- _0: ::std::default::Default::default(), -- _1: ::std::default::Default::default() -- } -- } -- } -- #[derive(PartialEq)] -- pub enum Tuple0 { -- _T0 {} -- } -- impl Tuple0 {} -- impl ::dafny_runtime::DafnyPrint for Tuple0 { -- fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -- match self { -- Tuple0::_T0 { } => { -- write!(_formatter, "_System.Tuple0._T0")?; -- Ok(()) -- } -- } -- } -- } -- impl ::std::default::Default for Tuple0 { -- fn default() -> Self { -- Tuple0::_T0 {} -- } -- } -+ } -+ impl ::std::convert::AsRef for &GetStringInput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl GetStringInput { -+ pub fn value( -+ &self, -+ ) -> ::std::rc::Rc> -+ { -+ match self { -+ GetStringInput::GetStringInput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::core::fmt::Debug for GetStringInput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetStringInput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithystring.internaldafny.types.GetStringInput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetStringInput { -+ fn eq(&self, other: &GetStringInput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetStringInput {} -+ impl ::core::hash::Hash for GetStringInput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype GetStringOutput = | GetStringOutput ( -+ nameonly value: Option := Option.None -+ ) */ -+ #[derive(Clone)] -+ pub enum GetStringOutput { -+ GetStringOutput { -+ value: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::DafnyStringUTF16>, -+ >, -+ }, -+ } -+ impl GetStringOutput { -+ pub fn value( -+ &self, -+ ) -> ::std::rc::Rc> -+ { -+ match self { -+ GetStringOutput::GetStringOutput { value } => value.clone(), -+ } -+ } -+ } -+ impl ::std::convert::AsRef for &GetStringOutput { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl ::core::fmt::Debug for GetStringOutput { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for GetStringOutput { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithystring.internaldafny.types.GetStringOutput(value := " -+ )?; -+ self.value().fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ impl PartialEq for GetStringOutput { -+ fn eq(&self, other: &GetStringOutput) -> bool { -+ self.value() == other.value() -+ } -+ } -+ impl Eq for GetStringOutput {} -+ impl ::core::hash::Hash for GetStringOutput { -+ fn hash(&self, state: &mut H) { -+ self.value().hash(state); -+ } -+ } -+ -+ /* -+ datatype SimpleStringConfig = | SimpleStringConfig ( -+ ) */ -+ #[derive(Clone)] -+ pub enum SimpleStringConfig { -+ SimpleStringConfig {}, -+ } -+ impl ::std::convert::AsRef for &SimpleStringConfig { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ impl ::core::fmt::Debug for SimpleStringConfig { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ f.debug_struct("SimpleStringConfig").finish() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for SimpleStringConfig { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ write!( -+ f, -+ "simple.types.smithystring.internaldafny.types.SimpleStringConfig()" -+ ) -+ } -+ } -+ impl PartialEq for SimpleStringConfig { -+ fn eq(&self, other: &SimpleStringConfig) -> bool { -+ true -+ } -+ } -+ impl Eq for SimpleStringConfig {} -+ impl ::core::hash::Hash for SimpleStringConfig { -+ fn hash(&self, state: &mut H) {} -+ } -+ -+ pub struct ISimpleTypesStringClientCallHistory {} -+ impl ISimpleTypesStringClientCallHistory { -+ fn ctor(this: *mut ISimpleTypesStringClientCallHistory) {} -+ } -+ pub trait ISimpleTypesStringClient { -+ fn GetString( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ >; -+ fn GetStringKnownValue( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ >; -+ fn GetStringUTF8( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ >; -+ } -+ /* -+ datatype Error = -+ | CollectionOfErrors(list: seq, nameonly message: string) -+ | Opaque(obj: object) -+ */ -+ #[derive(Clone)] -+ pub enum Error { -+ CollectionOfErrors { -+ list: ::dafny_runtime::Sequence, -+ message: ::dafny_runtime::DafnyStringUTF16, -+ }, -+ Opaque { -+ obj: *mut dyn ::std::any::Any, -+ }, -+ } -+ impl ::core::fmt::Debug for Error { -+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => f -+ .debug_struct("Error::CollectionOfErrors") -+ .field("list", list) -+ .field("message", message) -+ .finish(), -+ Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), -+ } -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Error { -+ fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ write!(f, "Error::CollectionOfErrors(list := ")?; -+ list.fmt_print(f, false)?; -+ write!(f, ", message := ")?; -+ message.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ Error::Opaque { obj } => { -+ write!(f, "Error::Opaque(obj := ")?; -+ obj.fmt_print(f, false)?; -+ write!(f, ")") -+ } -+ } -+ } -+ } -+ impl PartialEq for Error { -+ fn eq(&self, other: &Error) -> bool { -+ match self { -+ Error::CollectionOfErrors { list, message } => match other { -+ Error::CollectionOfErrors { -+ list: other_list, -+ message: other_message, -+ } => list == other_list && message == other_message, -+ _ => false, -+ }, -+ Error::Opaque { obj } => match other { -+ Error::Opaque { obj: other_obj } => obj == other_obj, -+ _ => false, -+ }, -+ } -+ } -+ } -+ impl Eq for Error {} -+ impl ::core::hash::Hash for Error { -+ fn hash(&self, state: &mut H) { -+ match self { -+ Error::CollectionOfErrors { list, message } => { -+ list.hash(state); -+ message.hash(state); -+ } -+ Error::Opaque { obj } => obj.hash(state), -+ } -+ } -+ } -+ -+ pub type OpaqueError = Error; -+} -+mod r#_SimpleStringImpl_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn GetString( -+ config: &::std::rc::Rc, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); -+ let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { -+ value: res.clone() -+ })); -+ return output.read(); -+ return output.read(); -+ } -+ pub fn GetStringKnownValue( -+ config: &::std::rc::Rc, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); -+ if !matches!( -+ input.value().as_ref(), -+ super::r#_Wrappers_Compile::Option::Some { .. } -+ ) { -+ panic!("Halt") -+ }; -+ if !(input.value().value().clone() -+ == ::dafny_runtime::string_utf16_of("TEST_SIMPLE_STRING_KNOWN_VALUE")) -+ { -+ panic!("Halt") -+ }; -+ let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { -+ value: res.clone() -+ })); -+ return output.read(); -+ return output.read(); -+ } -+ pub fn GetStringUTF8( -+ config: &::std::rc::Rc, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); -+ if !matches!( -+ input.value().as_ref(), -+ super::r#_Wrappers_Compile::Option::Some { .. } -+ ) { -+ panic!("Halt") -+ }; -+ let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { -+ value: input.value().clone() -+ }); -+ output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { -+ value: res.clone() -+ })); -+ return output.read(); -+ return output.read(); -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "SimpleStringImpl_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Config { -+ Config {}, -+ } -+ impl Config {} -+ impl ::dafny_runtime::DafnyPrint for Config { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Config::Config {} => { -+ write!(_formatter, "SimpleStringImpl_Compile.Config.Config")?; -+ Ok(()) -+ } -+ } -+ } -+ } -+ impl ::std::default::Default for Config { -+ fn default() -> Config { -+ Config::Config {} -+ } -+ } -+ impl ::std::convert::AsRef for &Config { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+// SimpleString -+pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn DefaultSimpleStringConfig( -+ ) -> super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig -+ { -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig{} -+ } -+ /*method SimpleString(config: SimpleStringConfig) -+ returns (res: Result) { -+ var client := new SimpleStringClient(Operations.Config); -+ return Success(client); -+ } */ -+ pub fn SimpleString(config: &::std::rc::Rc) -+ -> ::std::rc::Rc>>{ -+ let client: *mut SimpleStringClient = ::dafny_runtime::allocate::(); -+ SimpleStringClient::_ctor( -+ client, -+ &::std::rc::Rc::new(super::r#_SimpleStringImpl_Compile::Config::Config {}), -+ ); -+ let v = client as *mut dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient; -+ // build a success -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient, ::std::rc::Rc>::Success{ -+ value: v -+ }) -+ } -+ } -+ -+ struct SimpleStringClient { -+ r#_i_config: ::std::rc::Rc, -+ } -+ -+ impl SimpleStringClient { -+ fn _ctor( -+ this: *mut SimpleStringClient, -+ config: &::std::rc::Rc, -+ ) { -+ let mut _i_set_config = false; -+ ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); -+ } -+ fn config(&self) -> ::std::rc::Rc { -+ self.r#_i_config.clone() -+ } -+ } -+ impl super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient -+ for SimpleStringClient -+ { -+ fn GetString( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ super::r#_SimpleStringImpl_Compile::_default::GetString(&self.config(), input) -+ } -+ fn GetStringKnownValue( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ super::r#_SimpleStringImpl_Compile::_default::GetStringKnownValue(&self.config(), input) -+ } -+ fn GetStringUTF8( -+ self: &Self, -+ input: &::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, -+ >, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::std::rc::Rc< -+ super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, -+ >, -+ ::std::rc::Rc, -+ >, -+ > { -+ super::r#_SimpleStringImpl_Compile::_default::GetStringUTF8(&self.config(), input) -+ } -+ } -+ ::dafny_runtime::UpcastTo!( -+ SimpleStringClient, -+ dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient -+ ); -+} -+mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ impl WrappersInterop { -+ pub fn new() -> Self { -+ WrappersInterop {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn CreateStringSome( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Some { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::None {}) -+ } -+ pub fn CreateBooleanSome( -+ b: bool, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) -+ } -+ pub fn CreateBooleanNone() -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+ impl ::std::default::Default for WrappersInterop { -+ fn default() -> Self { -+ WrappersInterop::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for WrappersInterop { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") -+ } -+ } -+ impl ::std::cmp::PartialEq for WrappersInterop { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } - } --mod _module { -- --} -\ No newline at end of file -+mod _module {} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..0b44b7d5 +index 00000000..e085b5cf --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs -@@ -0,0 +1,65 @@ +@@ -0,0 +1,66 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. + +use aws_smithy_types::error::operation::BuildError; @@ -739,7 +11,7 @@ index 00000000..0b44b7d5 +#[derive(Debug)] +pub(crate) struct Handle { + pub(crate) conf: crate::Config, -+ pub(crate) inner: *mut dyn ::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient ++ pub(crate) inner: ::dafny_runtime::Object +} + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -770,7 +42,7 @@ index 00000000..0b44b7d5 + } + let handle = Handle { + conf: conf.clone(), -+ inner: inner.Extract(), ++ inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + }; + Ok(Self { + handle: ::std::sync::Arc::new(handle), @@ -786,9 +58,10 @@ index 00000000..0b44b7d5 +impl Drop for Handle { + fn drop(&mut self) { + // Ensure the Dafny values we created by calling SimpleString are deallocated. -+ unsafe { -+ drop(Box::from_raw(self.inner)); -+ } ++ // Useful only for raw references ++ //unsafe { ++ // drop(Box::from_raw(self.inner)); ++ //} + } +} + @@ -1033,7 +306,7 @@ index 00000000..25e072d2 +pub mod get_string_utf8; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs new file mode 100644 -index 00000000..ed44841a +index 00000000..337142c0 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -0,0 +1,33 @@ @@ -1048,7 +321,7 @@ index 00000000..ed44841a +{ + match value { + crate::operation::get_string::GetStringError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -1168,7 +441,7 @@ index 00000000..d658997a +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs new file mode 100644 -index 00000000..2a70d89f +index 00000000..33d5010e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -0,0 +1,33 @@ @@ -1183,7 +456,7 @@ index 00000000..2a70d89f +{ + match value { + crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -1303,7 +576,7 @@ index 00000000..dce554ae +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs new file mode 100644 -index 00000000..db5ecd27 +index 00000000..972bf501 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -0,0 +1,33 @@ @@ -1318,7 +591,7 @@ index 00000000..db5ecd27 +{ + match value { + crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -1529,7 +802,7 @@ index 00000000..af6d5f9c +pub mod get_string_utf8; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs new file mode 100644 -index 00000000..f369da68 +index 00000000..beee8893 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs @@ -0,0 +1,145 @@ @@ -1552,7 +825,7 @@ index 00000000..f369da68 + > { + let inner_input = crate::conversions::get_string::_get_string_input::to_dafny(input); + let inner_result = -+ ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetString(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetString(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } @@ -1899,7 +1172,7 @@ index 00000000..6db3795e +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs new file mode 100644 -index 00000000..c3276c35 +index 00000000..f3d04510 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs @@ -0,0 +1,146 @@ @@ -1925,7 +1198,7 @@ index 00000000..c3276c35 + input, + ); + let inner_result = -+ ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetStringUTF8(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetStringUTF8(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } @@ -2282,7 +1555,7 @@ index 00000000..ddd6dbfb +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs new file mode 100644 -index 00000000..a8d2a18d +index 00000000..b7d5ad2a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs @@ -0,0 +1,146 @@ @@ -2306,7 +1579,7 @@ index 00000000..a8d2a18d + let inner_input = + crate::conversions::get_string_utf8::_get_string_utf8_input::to_dafny(input); + let inner_result = -+ ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetStringUTF8(&inner_input); ++ ::dafny_runtime::md!(handle.inner.clone()).GetStringUTF8(&inner_input); + if matches!( + inner_result.as_ref(), + ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs index 469a527f9..a0d75180d 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs @@ -1,208 +1,310 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -pub extern crate dafny_runtime; -pub extern crate dafny_standard_library; pub use dafny_standard_library::implementation_from_dafny::*; pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { - /* datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O) */ - #[derive(Clone)] - pub struct DafnyCallEvent { - input: I, - output: O, + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent { + DafnyCallEvent { input: I, output: O }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } } - impl ::core::fmt::Debug + + impl ::std::fmt::Debug for DafnyCallEvent { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DafnyCallEvent") - .field("input", &self.input) - .field("output", &self.output) - .finish() + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for DafnyCallEvent { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithystring.internaldafny.types.DafnyCallEvent(" - )?; - self.input.fmt_print(f, false)?; - write!(f, ",")?; - self.output.fmt_print(f, false)?; - write!(f, ")") - } - } - impl - PartialEq> for DafnyCallEvent - { - fn eq(&self, other: &DafnyCallEvent) -> bool { - self.input == other.input && self.output == other.output + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } } } - impl Eq for DafnyCallEvent {} - impl ::core::hash::Hash + + impl Eq for DafnyCallEvent { - fn hash(&self, state: &mut H) { - self.input.hash(state); - self.output.hash(state); + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::hash::Hash, + O: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + input.hash(_state); + output.hash(_state) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::default::Default, + O: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } } } - /* - datatype GetStringInput = | GetStringInput ( - nameonly value: Option := Option.None - ) - */ - #[derive(Clone)] + impl + ::std::convert::AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] pub enum GetStringInput { GetStringInput { value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::DafnyStringUTF16>, + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, >, }, } - impl ::std::convert::AsRef for &GetStringInput { - fn as_ref(&self) -> Self { - self - } - } + impl GetStringInput { pub fn value( &self, - ) -> ::std::rc::Rc> - { + ) -> &::std::rc::Rc< + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { match self { - GetStringInput::GetStringInput { value } => value.clone(), + GetStringInput::GetStringInput { value } => value, } } } - impl ::core::fmt::Debug for GetStringInput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::std::fmt::Debug for GetStringInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } + impl ::dafny_runtime::DafnyPrint for GetStringInput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithystring.internaldafny.types.GetStringInput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetStringInput::GetStringInput { value } => { + write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.GetStringInput.GetStringInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl PartialEq for GetStringInput { - fn eq(&self, other: &GetStringInput) -> bool { - self.value() == other.value() + + impl Eq for GetStringInput {} + + impl ::std::hash::Hash for GetStringInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetStringInput::GetStringInput { value } => value.hash(_state), + } } } - impl Eq for GetStringInput {} - impl ::core::hash::Hash for GetStringInput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::default::Default for GetStringInput { + fn default() -> GetStringInput { + GetStringInput::GetStringInput { + value: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetStringInput { + fn as_ref(&self) -> Self { + self } } - /* - datatype GetStringOutput = | GetStringOutput ( - nameonly value: Option := Option.None - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum GetStringOutput { GetStringOutput { value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::DafnyStringUTF16>, + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, >, }, } + impl GetStringOutput { pub fn value( &self, - ) -> ::std::rc::Rc> - { + ) -> &::std::rc::Rc< + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { match self { - GetStringOutput::GetStringOutput { value } => value.clone(), + GetStringOutput::GetStringOutput { value } => value, } } } - impl ::std::convert::AsRef for &GetStringOutput { - fn as_ref(&self) -> Self { - self + + impl ::std::fmt::Debug for GetStringOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for GetStringOutput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, false) + + impl ::dafny_runtime::DafnyPrint for GetStringOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetStringOutput::GetStringOutput { value } => { + write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.GetStringOutput.GetStringOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for GetStringOutput { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithystring.internaldafny.types.GetStringOutput(value := " - )?; - self.value().fmt_print(f, false)?; - write!(f, ")") + + impl Eq for GetStringOutput {} + + impl ::std::hash::Hash for GetStringOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetStringOutput::GetStringOutput { value } => value.hash(_state), + } } } - impl PartialEq for GetStringOutput { - fn eq(&self, other: &GetStringOutput) -> bool { - self.value() == other.value() + + impl ::std::default::Default for GetStringOutput { + fn default() -> GetStringOutput { + GetStringOutput::GetStringOutput { + value: ::std::default::Default::default(), + } } } - impl Eq for GetStringOutput {} - impl ::core::hash::Hash for GetStringOutput { - fn hash(&self, state: &mut H) { - self.value().hash(state); + + impl ::std::convert::AsRef for &GetStringOutput { + fn as_ref(&self) -> Self { + self } } - /* - datatype SimpleStringConfig = | SimpleStringConfig ( - ) */ - #[derive(Clone)] + #[derive(PartialEq, Clone)] pub enum SimpleStringConfig { SimpleStringConfig {}, } - impl ::std::convert::AsRef for &SimpleStringConfig { - fn as_ref(&self) -> Self { - self + + impl SimpleStringConfig {} + + impl ::std::fmt::Debug for SimpleStringConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) } } - impl ::core::fmt::Debug for SimpleStringConfig { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("SimpleStringConfig").finish() + + impl ::dafny_runtime::DafnyPrint for SimpleStringConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleStringConfig::SimpleStringConfig {} => { + write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.SimpleStringConfig.SimpleStringConfig")?; + Ok(()) + } + } } } - impl ::dafny_runtime::DafnyPrint for SimpleStringConfig { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { - write!( - f, - "simple.types.smithystring.internaldafny.types.SimpleStringConfig()" - ) + + impl Eq for SimpleStringConfig {} + + impl ::std::hash::Hash for SimpleStringConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleStringConfig::SimpleStringConfig {} => {} + } } } - impl PartialEq for SimpleStringConfig { - fn eq(&self, other: &SimpleStringConfig) -> bool { - true + + impl ::std::default::Default for SimpleStringConfig { + fn default() -> SimpleStringConfig { + SimpleStringConfig::SimpleStringConfig {} } } - impl Eq for SimpleStringConfig {} - impl ::core::hash::Hash for SimpleStringConfig { - fn hash(&self, state: &mut H) {} + + impl ::std::convert::AsRef for &SimpleStringConfig { + fn as_ref(&self) -> Self { + self + } } pub struct ISimpleTypesStringClientCallHistory {} + impl ISimpleTypesStringClientCallHistory { - fn ctor(this: *mut ISimpleTypesStringClientCallHistory) {} + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } } + pub trait ISimpleTypesStringClient { fn GetString( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -215,7 +317,7 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { >, >; fn GetStringKnownValue( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -228,7 +330,7 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { >, >; fn GetStringUTF8( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -241,91 +343,119 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { >, >; } - /* - datatype Error = - | CollectionOfErrors(list: seq, nameonly message: string) - | Opaque(obj: object) - */ - #[derive(Clone)] + + #[derive(PartialEq, Clone)] pub enum Error { CollectionOfErrors { - list: ::dafny_runtime::Sequence, - message: ::dafny_runtime::DafnyStringUTF16, + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, }, Opaque { - obj: *mut dyn ::std::any::Any, + obj: ::dafny_runtime::Object, }, } - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { match self { - Error::CollectionOfErrors { list, message } => f - .debug_struct("Error::CollectionOfErrors") - .field("list", list) - .field("message", message) - .finish(), - Error::Opaque { obj } => f.debug_struct("Error::Opaque").field("obj", obj).finish(), + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), } } - } - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print(&self, f: &mut std::fmt::Formatter<'_>, in_seq: bool) -> std::fmt::Result { + pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { match self { Error::CollectionOfErrors { list, message } => { - write!(f, "Error::CollectionOfErrors(list := ")?; - list.fmt_print(f, false)?; - write!(f, ", message := ")?; - message.fmt_print(f, false)?; - write!(f, ")") - } - Error::Opaque { obj } => { - write!(f, "Error::Opaque(obj := ")?; - obj.fmt_print(f, false)?; - write!(f, ")") + panic!("field does not exist on this variant") } + Error::Opaque { obj } => obj, } } } - impl PartialEq for Error { - fn eq(&self, other: &Error) -> bool { + + impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { match self { - Error::CollectionOfErrors { list, message } => match other { - Error::CollectionOfErrors { - list: other_list, - message: other_message, - } => list == other_list && message == other_message, - _ => false, - }, - Error::Opaque { obj } => match other { - Error::Opaque { obj: other_obj } => obj == other_obj, - _ => false, - }, + Error::CollectionOfErrors { list, message } => { + write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } } } } + impl Eq for Error {} - impl ::core::hash::Hash for Error { - fn hash(&self, state: &mut H) { + + impl ::std::hash::Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { match self { Error::CollectionOfErrors { list, message } => { - list.hash(state); - message.hash(state); + list.hash(_state); + message.hash(_state) } - Error::Opaque { obj } => obj.hash(state), + Error::Opaque { obj } => obj.hash(_state), } } } - pub type OpaqueError = Error; + impl ::std::default::Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; } -mod r#_SimpleStringImpl_Compile { +pub mod r#_SimpleStringImpl_Compile { pub struct _default {} + impl _default { - pub fn new() -> Self { - _default {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() } pub fn GetString( config: &::std::rc::Rc, @@ -423,30 +553,20 @@ mod r#_SimpleStringImpl_Compile { return output.read(); } } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "SimpleStringImpl_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) - } - } + #[derive(PartialEq, Clone)] pub enum Config { Config {}, } + impl Config {} + + impl ::std::fmt::Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + impl ::dafny_runtime::DafnyPrint for Config { fn fmt_print( &self, @@ -455,76 +575,129 @@ mod r#_SimpleStringImpl_Compile { ) -> std::fmt::Result { match self { Config::Config {} => { - write!(_formatter, "SimpleStringImpl_Compile.Config.Config")?; + write!(_formatter, "r#_SimpleStringImpl_Compile.Config.Config")?; Ok(()) } } } } + + impl Eq for Config {} + + impl ::std::hash::Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + impl ::std::default::Default for Config { fn default() -> Config { Config::Config {} } } + impl ::std::convert::AsRef for &Config { fn as_ref(&self) -> Self { self } } } -// SimpleString pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { pub struct _default {} + impl _default { - pub fn new() -> Self { - _default {} - } - pub fn DefaultSimpleStringConfig( - ) -> super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig - { - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig{} - } - /*method SimpleString(config: SimpleStringConfig) - returns (res: Result) { - var client := new SimpleStringClient(Operations.Config); - return Success(client); - } */ - pub fn SimpleString(config: &::std::rc::Rc) - -> ::std::rc::Rc>>{ - let client: *mut SimpleStringClient = ::dafny_runtime::allocate::(); - SimpleStringClient::_ctor( - client, + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn DefaultSimpleStringConfig() -> ::std::rc::Rc< + super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, + > { + ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig {}) + } + pub fn SimpleString( + config: &::std::rc::Rc< + super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, + >, + >::new(); + let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient::_allocate_rcmut(); + super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient::_ctor( + &_nw0, &::std::rc::Rc::new(super::r#_SimpleStringImpl_Compile::Config::Config {}), ); - let v = client as *mut dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient; - // build a success - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<*mut dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient, ::std::rc::Rc>::Success{ - value: v - }) + client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, + >, + >::Success { + value: client.read(), + }, + )); + return res.read(); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) } } - struct SimpleStringClient { - r#_i_config: ::std::rc::Rc, + pub struct SimpleStringClient { + pub r#__i_config: ::std::rc::Rc, } impl SimpleStringClient { - fn _ctor( - this: *mut SimpleStringClient, + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn _ctor( + this: &::dafny_runtime::Object, config: &::std::rc::Rc, - ) { - let mut _i_set_config = false; - ::dafny_runtime::update_field_uninit!(this, r#_i_config, _i_set_config, config.clone()); + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_rcmut!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); } - fn config(&self) -> ::std::rc::Rc { - self.r#_i_config.clone() + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() } } + impl super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient - for SimpleStringClient + for super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient { fn GetString( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -536,10 +709,16 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { ::std::rc::Rc, >, > { - super::r#_SimpleStringImpl_Compile::_default::GetString(&self.config(), input) + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleStringImpl_Compile::_default::GetString(&self.config(), input), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); } fn GetStringKnownValue( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -551,10 +730,19 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { ::std::rc::Rc, >, > { - super::r#_SimpleStringImpl_Compile::_default::GetStringKnownValue(&self.config(), input) + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleStringImpl_Compile::_default::GetStringKnownValue( + &self.config(), + input, + ), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + return output.read(); } fn GetStringUTF8( - self: &Self, + &mut self, input: &::std::rc::Rc< super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, >, @@ -566,72 +754,14 @@ pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { ::std::rc::Rc, >, > { - super::r#_SimpleStringImpl_Compile::_default::GetStringUTF8(&self.config(), input) - } - } - ::dafny_runtime::UpcastTo!( - SimpleStringClient, - dyn super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient - ); -} -mod r#_StandardLibraryInterop_Compile { - pub struct WrappersInterop {} - impl WrappersInterop { - pub fn new() -> Self { - WrappersInterop {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn CreateStringSome( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: s.clone(), - }) - } - pub fn CreateStringNone() -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::None {}) - } - pub fn CreateBooleanSome( - b: bool, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) - } - pub fn CreateBooleanNone() -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } - } - impl ::std::default::Default for WrappersInterop { - fn default() -> Self { - WrappersInterop::new() - } - } - impl ::dafny_runtime::DafnyPrint for WrappersInterop { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") - } - } - impl ::std::cmp::PartialEq for WrappersInterop { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleStringImpl_Compile::_default::GetStringUTF8(&self.config(), input), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + return output.read(); } } } -mod _module {} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs index 0b44b7d58..e085b5cfd 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs @@ -5,7 +5,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(Debug)] pub(crate) struct Handle { pub(crate) conf: crate::Config, - pub(crate) inner: *mut dyn ::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient + pub(crate) inner: ::dafny_runtime::Object } #[derive(::std::clone::Clone, ::std::fmt::Debug)] @@ -36,7 +36,7 @@ impl Client { } let handle = Handle { conf: conf.clone(), - inner: inner.Extract(), + inner: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), }; Ok(Self { handle: ::std::sync::Arc::new(handle), @@ -52,9 +52,10 @@ impl Client { impl Drop for Handle { fn drop(&mut self) { // Ensure the Dafny values we created by calling SimpleString are deallocated. - unsafe { - drop(Box::from_raw(self.inner)); - } + // Useful only for raw references + //unsafe { + // drop(Box::from_raw(self.inner)); + //} } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs index ed44841ab..337142c06 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string::GetStringError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs index 2a70d89ff..33d5010eb 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs index db5ecd27e..972bf5010 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: Box::into_raw(Box::new(unhandled) as Box) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs index f369da68d..beee88931 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string.rs @@ -17,7 +17,7 @@ impl GetString { > { let inner_input = crate::conversions::get_string::_get_string_input::to_dafny(input); let inner_result = - ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetString(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetString(&inner_input); if matches!( inner_result.as_ref(), ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs index c3276c357..f3d04510c 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_known_value.rs @@ -20,7 +20,7 @@ impl GetStringKnownValue { input, ); let inner_result = - ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetStringUTF8(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetStringUTF8(&inner_input); if matches!( inner_result.as_ref(), ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs index a8d2a18d9..b7d5ad2a5 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/operation/get_string_utf8.rs @@ -18,7 +18,7 @@ impl GetStringUTF8 { let inner_input = crate::conversions::get_string_utf8::_get_string_utf8_input::to_dafny(input); let inner_result = - ::simple_string_dafny::dafny_runtime::read!(handle.inner).GetStringUTF8(&inner_input); + ::dafny_runtime::md!(handle.inner.clone()).GetStringUTF8(&inner_input); if matches!( inner_result.as_ref(), ::simple_string_dafny::r#_Wrappers_Compile::Result::Success { .. } diff --git a/TestModels/SimpleTypes/SimpleString/src_for_rust/Index.dfy b/TestModels/SimpleTypes/SimpleString/src_for_rust/Index.dfy deleted file mode 100644 index 224b20c34..000000000 --- a/TestModels/SimpleTypes/SimpleString/src_for_rust/Index.dfy +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Not attempting to actually compile any code yet, -// just 100% patching. \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/Makefile b/TestModels/dafny-dependencies/StandardLibrary/Makefile index 6a36dd006..3dcd26f9c 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/Makefile +++ b/TestModels/dafny-dependencies/StandardLibrary/Makefile @@ -67,20 +67,18 @@ transpile_java: | transpile_implementation_java transpile_test_java # StandardLibrary as a dependency transpile_rust: | transpile_implementation_rust -RUST_SRC_INDEX=src_for_rust RUST_TEST_INDEX=test_for_rust # Override the targets to relocate translated Rust code directly into the main crate, # instead of the dafny_impl sub-crate. +# We also don't want to delete the src directory since we have an extern in there too. _mv_implementation_rust: - rm -rf runtimes/rust/src - mkdir -p runtimes/rust/src mv implementation_from_dafny-rust/src/implementation_from_dafny.rs runtimes/rust/src/implementation_from_dafny.rs + rustfmt runtimes/rust/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: - rm -rf runtimes/rust/dafny_impl/tests - mkdir -p runtimes/rust/dafny_impl/tests mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny.rs + rustfmt runtimes/rust/tests/tests_from_dafny.rs rm -rf tests_from_dafny-rust transpile_dependencies: @@ -101,6 +99,7 @@ transpile_implementation: -unicodeChar:0 \ -functionSyntax:3 \ -useRuntimeLib \ + $(DAFNY_OPTIONS) \ -out $(OUT) # Override SharedMakefile's build_java to not install @@ -113,3 +112,22 @@ build_java: transpile_java mvn_local_deploy: @echo "${RED}Warning!!${YELLOW} Installing TestModel's STD to Maven Local replaces ESDK's STD!\n$(RESET)" >&2 gradle -p runtimes/java publishToMavenLocal + +dafny_benerate: DAFNY_RUST_OUTPUT=\ + runtimes/rust/implementation_from_dafny +dafny_benerate: DAFNY_RUST_OUTPUT_FOLDER=\ + $(DAFNY_RUST_OUTPUT)-rust/src +dafny_benerate: DAFNY_RUST_OUTPUT_RS=\ + $(DAFNY_RUST_OUTPUT_FOLDER)/implementation_from_dafny.rs +dafny_benerate: DAFNY_RUST_OUTPUT_RS_DTR=\ + $(DAFNY_RUST_OUTPUT_FOLDER)/implementation_from_dafny-rs.dtr +dafny_benerate: DAFNY_RUST_IMPL=\ + runtimes/rust/src/implementation_from_dafny.rs +dafny_benerate: + $(DAFNY) translate rs src/Index.dfy --emit-uncompilable-code --no-verify --optimize-erasable-datatype-wrapper false --include-runtime --compile-suffix true --unicode-char false --function-syntax 3 --allow-warnings --output $(DAFNY_RUST_OUTPUT) + rustfmt $(DAFNY_RUST_OUTPUT_RS) + # echo "Diffs remaining till code generation works:" + # diff -u $(DAFNY_RUST_OUTPUT_RS) $(DAFNY_RUST_IMPL) | wc -l + mv $(DAFNY_RUST_OUTPUT_RS) $(DAFNY_RUST_IMPL) + rm $(DAFNY_RUST_OUTPUT_RS_DTR); + rm -r $(DAFNY_RUST_OUTPUT_FOLDER); \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index 0b273a1f8..bb3c2cc0f 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -1,69 +1,72 @@ diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs new file mode 100644 -index 00000000..1b9158e9 +index 00000000..fb5e7bf9 --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs -@@ -0,0 +1,64 @@ +@@ -0,0 +1,67 @@ + +// Annotation to ignore the case of this module +#[allow(non_snake_case)] +pub mod UTF8 { + use crate::implementation_from_dafny::r#_Wrappers_Compile; -+ use crate::implementation_from_dafny::r#_UTF8_Compile; -+ -+ pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { -+ let v = s.to_array(); -+ let mut _accumulator: Vec = vec![]; -+ // Use of .encode_utf8 method. -+ let mut surrogate: Option = None; -+ for c in v.iter() { -+ let s = -+ if let Some(s) = surrogate { -+ String::from_utf16(&[s, c.0]) -+ } else { -+ String::from_utf16(&[c.0]) -+ }; -+ surrogate = None; -+ match s { -+ Ok(value) => { -+ _accumulator.extend(value.as_bytes()); -+ continue; -+ }, -+ Err(e) => { -+ if 0xD800 <= c.0 && c.0 <= 0xDFFF { -+ surrogate = Some(c.0); ++ use crate::implementation_from_dafny::UTF8; ++ ++ ++ impl crate::implementation_from_dafny::UTF8::_default { ++ pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { ++ let v = s.to_array(); ++ let mut _accumulator: Vec = vec![]; ++ // Use of .encode_utf8 method. ++ let mut surrogate: Option = None; ++ for c in v.iter() { ++ let s = ++ if let Some(s) = surrogate { ++ String::from_utf16(&[s, c.0]) ++ } else { ++ String::from_utf16(&[c.0]) ++ }; ++ surrogate = None; ++ match s { ++ Ok(value) => { ++ _accumulator.extend(value.as_bytes()); + continue; -+ } -+ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { -+ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( -+ &e.to_string()) -+ }); ++ }, ++ Err(e) => { ++ if 0xD800 <= c.0 && c.0 <= 0xDFFF { ++ surrogate = Some(c.0); ++ continue; ++ } ++ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { ++ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( ++ &e.to_string()) ++ }); ++ } + } + } -+ } -+ if let Some(s) = surrogate { -+ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { -+ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( -+ &format!("Surrogate pair missing: 0x{:04x}", s)) -+ }); -+ } -+ ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) -+ } -+ pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { -+ let b = String::from_utf8(b.to_array().as_ref().clone()); -+ match b { -+ Ok(s) => { -+ ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { -+ value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) -+ }) -+ }, -+ Err(e) => { -+ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { -+ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( -+ &e.to_string()) ++ if let Some(s) = surrogate { ++ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { ++ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( ++ &format!("Surrogate pair missing: 0x{:04x}", s)) ++ }); ++ } ++ ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) ++ } ++ pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { ++ let b = String::from_utf8(b.to_array().as_ref().clone()); ++ match b { ++ Ok(s) => { ++ ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { ++ value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) + }) ++ }, ++ Err(e) => { ++ return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { ++ error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( ++ &e.to_string()) ++ }) ++ } + } + } + } @@ -71,1085 +74,1353 @@ index 00000000..1b9158e9 \ No newline at end of file diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 -index 00000000..a67da67c +index 00000000..20cb9f07 --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs -@@ -0,0 +1,1071 @@ +@@ -0,0 +1,1340 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] -+extern crate dafny_runtime; -+pub mod _System { -+ pub type nat = ::dafny_runtime::DafnyInt; -+ #[derive(PartialEq, Clone)] -+ pub enum Tuple2 { -+ _T2 { _0: T0, _1: T1 }, -+ _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData) -+ } -+ impl Tuple2 { -+ pub fn _0(&self) -> &T0 { -+ match self { -+ Tuple2::_T2 { _0, _1, } => _0, -+ Tuple2::_PhantomVariant(..) => panic!() -+ } -+ } -+ pub fn _1(&self) -> &T1 { -+ match self { -+ Tuple2::_T2 { _0, _1, } => _1, -+ Tuple2::_PhantomVariant(..) => panic!() -+ } -+ } -+ } -+ impl ::std::fmt::Debug for Tuple2 { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Tuple2 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ match self { -+ Tuple2::_T2 { _0, _1, } => { -+ write!(_formatter, "_System.Tuple2._T2(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(_0, _formatter, false)?; -+ write!(_formatter, ", ")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(_1, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ }, -+ Tuple2::_PhantomVariant(..) => {panic!()} -+ } -+ } -+ } -+ impl Eq for Tuple2 {} -+ impl ::std::hash::Hash for Tuple2 { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Tuple2::_T2 { _0, _1, } => { -+ _0.hash(_state); -+ _1.hash(_state) -+ }, -+ Tuple2::_PhantomVariant(..) => {panic!()} -+ } -+ } -+ } -+ impl ::std::default::Default for Tuple2 { -+ fn default() -> Tuple2 { -+ Tuple2::_T2 { -+ _0: ::std::default::Default::default(), -+ _1: ::std::default::Default::default() -+ } -+ } -+ } -+ impl ::std::convert::AsRef> for &Tuple2 { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Tuple0 { -+ _T0 {} -+ } -+ impl Tuple0 {} -+ impl ::std::fmt::Debug for Tuple0 { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Tuple0 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ match self { -+ Tuple0::_T0 { } => { -+ write!(_formatter, "_System.Tuple0._T0")?; -+ Ok(()) ++pub mod r#_Wrappers_Compile { ++ pub struct _default {} ++ ++ impl _default { ++ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_rcmut::() + } -+ } -+ } -+ } -+ impl Eq for Tuple0 {} -+ impl ::std::hash::Hash for Tuple0 { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Tuple0::_T0 { } => { -+ ++ pub fn Need<_E: ::dafny_runtime::DafnyType>( ++ condition: bool, ++ error: &_E, ++ ) -> ::std::rc::Rc> { ++ if condition { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) ++ } else { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { ++ error: error.clone(), ++ }) ++ } + } -+ } -+ } -+ } -+ impl ::std::default::Default for Tuple0 { -+ fn default() -> Tuple0 { -+ Tuple0::_T0 {} -+ } -+ } -+ impl ::std::convert::AsRef for &Tuple0 { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+pub mod r#_Wrappers_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn Need<_E: ::dafny_runtime::DafnyType>(condition: bool, error: &_E) -> ::std::rc::Rc> { -+ if condition { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) -+ } else { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { -+ error: error.clone() -+ }) -+ } -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() + } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ write!(_formatter, "Wrappers_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Option { -+ None {}, -+ Some { value: T }, -+ _PhantomVariant(::std::marker::PhantomData) -+ } -+ impl Option { -+ pub fn ToResult(self: &::std::rc::Rc) -> ::std::rc::Rc>> { -+ let mut _source0: ::std::rc::Rc> = self.clone(); -+ if matches!((&_source0).as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Failure { -+ error: ::dafny_runtime::string_utf16_of("Option is None") -+ }) -+ } else { -+ let mut r#___mcc_h0: T = _source0.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Success { -+ value: v.clone() -+ }) -+ } -+ } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source1: ::std::rc::Rc> = self.clone(); -+ if matches!((&_source1).as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) { -+ default.clone() -+ } else { -+ let mut r#___mcc_h0: T = _source1.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ v.clone() -+ } -+ } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!(self.as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) -+ } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() -+ } -+ pub fn value(&self) -> &T { -+ match self { -+ Option::None { } => panic!("field does not exist on this variant"), -+ Option::Some { value, } => value, -+ Option::_PhantomVariant(..) => panic!() -+ } -+ } -+ } -+ impl ::std::fmt::Debug for Option { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for Option { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ match self { -+ Option::None { } => { -+ write!(_formatter, "Wrappers_Compile.Option.None")?; -+ Ok(()) -+ }, -+ Option::Some { value, } => { -+ write!(_formatter, "Wrappers_Compile.Option.Some(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ }, -+ Option::_PhantomVariant(..) => {panic!()} -+ } -+ } -+ } -+ impl Eq for Option {} -+ impl ::std::hash::Hash for Option { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Option::None { } => { -+ -+ }, -+ Option::Some { value, } => { -+ value.hash(_state) -+ }, -+ Option::_PhantomVariant(..) => {panic!()} -+ } -+ } -+ } -+ impl ::std::default::Default for Option { -+ fn default() -> Option { -+ Option::None {} -+ } -+ } -+ impl ::std::convert::AsRef> for &Option { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Result { -+ Success { value: T }, -+ Failure { error: R }, -+ _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData) -+ } -+ impl Result { -+ pub fn ToOption(self: &::std::rc::Rc) -> ::std::rc::Rc> { -+ let mut _source2: ::std::rc::Rc> = self.clone(); -+ if matches!((&_source2).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { -+ let mut r#___mcc_h0: T = _source2.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { -+ value: s.clone() -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source2.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } ++ ++ #[derive(PartialEq, Clone)] ++ pub enum Option { ++ None {}, ++ Some { value: T }, ++ _PhantomVariant(::std::marker::PhantomData), + } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source3: ::std::rc::Rc> = self.clone(); -+ if matches!((&_source3).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { -+ let mut r#___mcc_h0: T = _source3.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ s.clone() -+ } else { -+ let mut r#___mcc_h1: R = _source3.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ default.clone() -+ } ++ ++ impl Option { ++ pub fn ToResult( ++ self: &::std::rc::Rc, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Result< ++ T, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ let mut _source0: ::std::rc::Rc> = self.clone(); ++ if matches!( ++ (&_source0).as_ref(), ++ super::r#_Wrappers_Compile::Option::None { .. } ++ ) { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ T, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Failure { ++ error: ::dafny_runtime::string_utf16_of("Option is None"), ++ }) ++ } else { ++ let mut r#___mcc_h0: T = _source0.value().clone(); ++ let mut v: T = r#___mcc_h0.clone(); ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ T, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Success { ++ value: v.clone(), ++ }) ++ } ++ } ++ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { ++ let mut _source1: ::std::rc::Rc> = self.clone(); ++ if matches!( ++ (&_source1).as_ref(), ++ super::r#_Wrappers_Compile::Option::None { .. } ++ ) { ++ default.clone() ++ } else { ++ let mut r#___mcc_h0: T = _source1.value().clone(); ++ let mut v: T = r#___mcc_h0.clone(); ++ v.clone() ++ } ++ } ++ pub fn IsFailure(self: &::std::rc::Rc) -> bool { ++ matches!( ++ self.as_ref(), ++ super::r#_Wrappers_Compile::Option::None { .. } ++ ) ++ } ++ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( ++ self: &::std::rc::Rc, ++ ) -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) ++ } ++ pub fn Extract(self: &::std::rc::Rc) -> T { ++ self.value().clone() ++ } ++ pub fn value(&self) -> &T { ++ match self { ++ Option::None {} => panic!("field does not exist on this variant"), ++ Option::Some { value } => value, ++ Option::_PhantomVariant(..) => panic!(), ++ } ++ } + } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!(self.as_ref(), super::r#_Wrappers_Compile::Result::Failure{ .. }) ++ ++ impl ::std::fmt::Debug for Option { ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) ++ } + } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { -+ error: self.error().clone() -+ }) ++ ++ impl ::dafny_runtime::DafnyPrint for Option { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ _in_seq: bool, ++ ) -> std::fmt::Result { ++ match self { ++ Option::None {} => { ++ write!(_formatter, "r#_Wrappers_Compile.Option.None")?; ++ Ok(()) ++ } ++ Option::Some { value } => { ++ write!(_formatter, "r#_Wrappers_Compile.Option.Some(")?; ++ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; ++ write!(_formatter, ")")?; ++ Ok(()) ++ } ++ Option::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc, reWrap: &::std::rc::Rc _NewR>) -> ::std::rc::Rc> { -+ let mut _source4: ::std::rc::Rc> = self.clone(); -+ if matches!((&_source4).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { -+ let mut r#___mcc_h0: T = _source4.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { -+ value: s.clone() -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source4.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { -+ error: reWrap(&e) -+ }) -+ } ++ ++ impl Eq for Option {} ++ ++ impl ::std::hash::Hash for Option { ++ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { ++ match self { ++ Option::None {} => {} ++ Option::Some { value } => value.hash(_state), ++ Option::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() ++ ++ impl ::std::default::Default ++ for Option ++ { ++ fn default() -> Option { ++ Option::None {} ++ } + } -+ pub fn value(&self) -> &T { -+ match self { -+ Result::Success { value, } => value, -+ Result::Failure { error, } => panic!("field does not exist on this variant"), -+ Result::_PhantomVariant(..) => panic!() -+ } ++ ++ impl ::std::convert::AsRef> for &Option { ++ fn as_ref(&self) -> Self { ++ self ++ } + } -+ pub fn error(&self) -> &R { -+ match self { -+ Result::Success { value, } => panic!("field does not exist on this variant"), -+ Result::Failure { error, } => error, -+ Result::_PhantomVariant(..) => panic!() -+ } ++ ++ #[derive(PartialEq, Clone)] ++ pub enum Result { ++ Success { value: T }, ++ Failure { error: R }, ++ _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), + } -+ } -+ impl ::std::fmt::Debug for Result { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) ++ ++ impl Result { ++ pub fn ToOption( ++ self: &::std::rc::Rc, ++ ) -> ::std::rc::Rc> { ++ let mut _source2: ::std::rc::Rc> = ++ self.clone(); ++ if matches!( ++ (&_source2).as_ref(), ++ super::r#_Wrappers_Compile::Result::Success { .. } ++ ) { ++ let mut r#___mcc_h0: T = _source2.value().clone(); ++ let mut s: T = r#___mcc_h0.clone(); ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { ++ value: s.clone(), ++ }) ++ } else { ++ let mut r#___mcc_h1: R = _source2.error().clone(); ++ let mut e: R = r#___mcc_h1.clone(); ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) ++ } ++ } ++ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { ++ let mut _source3: ::std::rc::Rc> = ++ self.clone(); ++ if matches!( ++ (&_source3).as_ref(), ++ super::r#_Wrappers_Compile::Result::Success { .. } ++ ) { ++ let mut r#___mcc_h0: T = _source3.value().clone(); ++ let mut s: T = r#___mcc_h0.clone(); ++ s.clone() ++ } else { ++ let mut r#___mcc_h1: R = _source3.error().clone(); ++ let mut e: R = r#___mcc_h1.clone(); ++ default.clone() ++ } ++ } ++ pub fn IsFailure(self: &::std::rc::Rc) -> bool { ++ matches!( ++ self.as_ref(), ++ super::r#_Wrappers_Compile::Result::Failure { .. } ++ ) ++ } ++ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( ++ self: &::std::rc::Rc, ++ ) -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { ++ error: self.error().clone(), ++ }) ++ } ++ pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( ++ self: &::std::rc::Rc, ++ reWrap: &::std::rc::Rc _NewR>, ++ ) -> ::std::rc::Rc> { ++ let mut _source4: ::std::rc::Rc> = ++ self.clone(); ++ if matches!( ++ (&_source4).as_ref(), ++ super::r#_Wrappers_Compile::Result::Success { .. } ++ ) { ++ let mut r#___mcc_h0: T = _source4.value().clone(); ++ let mut s: T = r#___mcc_h0.clone(); ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { ++ value: s.clone(), ++ }) ++ } else { ++ let mut r#___mcc_h1: R = _source4.error().clone(); ++ let mut e: R = r#___mcc_h1.clone(); ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { ++ error: reWrap(&e), ++ }) ++ } ++ } ++ pub fn Extract(self: &::std::rc::Rc) -> T { ++ self.value().clone() ++ } ++ pub fn value(&self) -> &T { ++ match self { ++ Result::Success { value } => value, ++ Result::Failure { error } => panic!("field does not exist on this variant"), ++ Result::_PhantomVariant(..) => panic!(), ++ } ++ } ++ pub fn error(&self) -> &R { ++ match self { ++ Result::Success { value } => panic!("field does not exist on this variant"), ++ Result::Failure { error } => error, ++ Result::_PhantomVariant(..) => panic!(), ++ } ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for Result { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ match self { -+ Result::Success { value, } => { -+ write!(_formatter, "Wrappers_Compile.Result.Success(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ }, -+ Result::Failure { error, } => { -+ write!(_formatter, "Wrappers_Compile.Result.Failure(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ }, -+ Result::_PhantomVariant(..) => {panic!()} -+ } ++ ++ impl ::std::fmt::Debug ++ for Result ++ { ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) ++ } + } -+ } -+ impl Eq for Result {} -+ impl ::std::hash::Hash for Result { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Result::Success { value, } => { -+ value.hash(_state) -+ }, -+ Result::Failure { error, } => { -+ error.hash(_state) -+ }, -+ Result::_PhantomVariant(..) => {panic!()} -+ } ++ ++ impl ::dafny_runtime::DafnyPrint ++ for Result ++ { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ _in_seq: bool, ++ ) -> std::fmt::Result { ++ match self { ++ Result::Success { value } => { ++ write!(_formatter, "r#_Wrappers_Compile.Result.Success(")?; ++ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; ++ write!(_formatter, ")")?; ++ Ok(()) ++ } ++ Result::Failure { error } => { ++ write!(_formatter, "r#_Wrappers_Compile.Result.Failure(")?; ++ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; ++ write!(_formatter, ")")?; ++ Ok(()) ++ } ++ Result::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ } -+ impl ::std::default::Default for Result { -+ fn default() -> Result { -+ Result::Success { -+ value: ::std::default::Default::default() -+ } ++ ++ impl Eq for Result {} ++ ++ impl< ++ T: ::dafny_runtime::DafnyType + ::std::hash::Hash, ++ R: ::dafny_runtime::DafnyType + ::std::hash::Hash, ++ > ::std::hash::Hash for Result ++ { ++ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { ++ match self { ++ Result::Success { value } => value.hash(_state), ++ Result::Failure { error } => error.hash(_state), ++ Result::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ } -+ impl ::std::convert::AsRef> for &Result { -+ fn as_ref(&self) -> Self { -+ self ++ ++ impl< ++ T: ::dafny_runtime::DafnyType + ::std::default::Default, ++ R: ::dafny_runtime::DafnyType + ::std::default::Default, ++ > ::std::default::Default for Result ++ { ++ fn default() -> Result { ++ Result::Success { ++ value: ::std::default::Default::default(), ++ } ++ } + } -+ } -+ #[derive(PartialEq, Clone)] -+ pub enum Outcome { -+ Pass {}, -+ Fail { error: E }, -+ _PhantomVariant(::std::marker::PhantomData) -+ } -+ impl Outcome { -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!(self.as_ref(), super::r#_Wrappers_Compile::Outcome::Fail{ .. }) ++ ++ impl ++ ::std::convert::AsRef> for &Result ++ { ++ fn as_ref(&self) -> Self { ++ self ++ } + } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { -+ error: self.error().clone() -+ }) ++ ++ #[derive(PartialEq, Clone)] ++ pub enum Outcome { ++ Pass {}, ++ Fail { error: E }, ++ _PhantomVariant(::std::marker::PhantomData), + } -+ pub fn error(&self) -> &E { -+ match self { -+ Outcome::Pass { } => panic!("field does not exist on this variant"), -+ Outcome::Fail { error, } => error, -+ Outcome::_PhantomVariant(..) => panic!() -+ } ++ ++ impl Outcome { ++ pub fn IsFailure(self: &::std::rc::Rc) -> bool { ++ matches!( ++ self.as_ref(), ++ super::r#_Wrappers_Compile::Outcome::Fail { .. } ++ ) ++ } ++ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( ++ self: &::std::rc::Rc, ++ ) -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { ++ error: self.error().clone(), ++ }) ++ } ++ pub fn error(&self) -> &E { ++ match self { ++ Outcome::Pass {} => panic!("field does not exist on this variant"), ++ Outcome::Fail { error } => error, ++ Outcome::_PhantomVariant(..) => panic!(), ++ } ++ } + } -+ } -+ impl ::std::fmt::Debug for Outcome { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) ++ ++ impl ::std::fmt::Debug for Outcome { ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for Outcome { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ match self { -+ Outcome::Pass { } => { -+ write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; -+ Ok(()) -+ }, -+ Outcome::Fail { error, } => { -+ write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ }, -+ Outcome::_PhantomVariant(..) => {panic!()} -+ } ++ ++ impl ::dafny_runtime::DafnyPrint for Outcome { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ _in_seq: bool, ++ ) -> std::fmt::Result { ++ match self { ++ Outcome::Pass {} => { ++ write!(_formatter, "r#_Wrappers_Compile.Outcome.Pass")?; ++ Ok(()) ++ } ++ Outcome::Fail { error } => { ++ write!(_formatter, "r#_Wrappers_Compile.Outcome.Fail(")?; ++ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; ++ write!(_formatter, ")")?; ++ Ok(()) ++ } ++ Outcome::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ } -+ impl Eq for Outcome {} -+ impl ::std::hash::Hash for Outcome { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Outcome::Pass { } => { -+ -+ }, -+ Outcome::Fail { error, } => { -+ error.hash(_state) -+ }, -+ Outcome::_PhantomVariant(..) => {panic!()} -+ } ++ ++ impl Eq for Outcome {} ++ ++ impl ::std::hash::Hash for Outcome { ++ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { ++ match self { ++ Outcome::Pass {} => {} ++ Outcome::Fail { error } => error.hash(_state), ++ Outcome::_PhantomVariant(..) => { ++ panic!() ++ } ++ } ++ } + } -+ } -+ impl ::std::default::Default for Outcome { -+ fn default() -> Outcome { -+ Outcome::Pass {} ++ ++ impl ::std::default::Default ++ for Outcome ++ { ++ fn default() -> Outcome { ++ Outcome::Pass {} ++ } + } -+ } -+ impl ::std::convert::AsRef> for &Outcome { -+ fn as_ref(&self) -> Self { -+ self ++ ++ impl ::std::convert::AsRef> for &Outcome { ++ fn as_ref(&self) -> Self { ++ self ++ } + } -+ } +} +pub mod r#_StandardLibrary_Compile_dUInt_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn UInt8Less(a: u8, b: u8) -> bool { -+ a < b -+ } -+ pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { -+ s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() -+ } -+ pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { -+ s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() -+ } -+ pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { -+ s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() -+ } -+ pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 256) as u8; -+ let mut b1: u8 = (x % 256) as u8; -+ ::dafny_runtime::seq![b0, b1] -+ } -+ pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { -+ let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; -+ x0 + s.get(&::dafny_runtime::int!(1)) as u16 -+ } -+ pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 16777216) as u8; -+ let mut x0: u32 = x - b0 as u32 * 16777216; -+ let mut b1: u8 = (x0 / 65536) as u8; -+ let mut x1: u32 = x0 - b1 as u32 * 65536; -+ let mut b2: u8 = (x1 / 256) as u8; -+ let mut b3: u8 = (x1 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3] -+ } -+ pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { -+ let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; -+ let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; -+ let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; -+ x2 + s.get(&::dafny_runtime::int!(3)) as u32 -+ } -+ pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 72057594037927936) as u8; -+ let mut x0: u64 = x - b0 as u64 * 72057594037927936; -+ let mut b1: u8 = (x0 / 281474976710656) as u8; -+ let mut x1: u64 = x0 - b1 as u64 * 281474976710656; -+ let mut b2: u8 = (x1 / 1099511627776) as u8; -+ let mut x2: u64 = x1 - b2 as u64 * 1099511627776; -+ let mut b3: u8 = (x2 / 4294967296) as u8; -+ let mut x3: u64 = x2 - b3 as u64 * 4294967296; -+ let mut b4: u8 = (x3 / 16777216) as u8; -+ let mut x4: u64 = x3 - b4 as u64 * 16777216; -+ let mut b5: u8 = (x4 / 65536) as u8; -+ let mut x5: u64 = x4 - b5 as u64 * 65536; -+ let mut b6: u8 = (x5 / 256) as u8; -+ let mut b7: u8 = (x5 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] -+ } -+ pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { -+ let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; -+ let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; -+ let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; -+ let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; -+ let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; -+ let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; -+ let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; -+ let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; -+ x -+ } -+ pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"65536") -+ } -+ pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"4294967296") -+ } -+ pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"18446744073709551616") -+ } -+ pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"2147483648") -+ } -+ pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"9223372036854775808") -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ write!(_formatter, "StandardLibrary_Compile.UInt_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) ++ pub struct _default {} ++ ++ impl _default { ++ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_rcmut::() ++ } ++ pub fn UInt8Less(a: u8, b: u8) -> bool { ++ a < b ++ } ++ pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ ) -> bool { ++ s.cardinality() ++ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() ++ } ++ pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ ) -> bool { ++ s.cardinality() ++ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() ++ } ++ pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ ) -> bool { ++ s.cardinality() ++ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() ++ } ++ pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { ++ let mut b0: u8 = (x / 256) as u8; ++ let mut b1: u8 = (x % 256) as u8; ++ ::dafny_runtime::seq![b0, b1] ++ } ++ pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { ++ let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; ++ x0 + s.get(&::dafny_runtime::int!(1)) as u16 ++ } ++ pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { ++ let mut b0: u8 = (x / 16777216) as u8; ++ let mut x0: u32 = x - b0 as u32 * 16777216; ++ let mut b1: u8 = (x0 / 65536) as u8; ++ let mut x1: u32 = x0 - b1 as u32 * 65536; ++ let mut b2: u8 = (x1 / 256) as u8; ++ let mut b3: u8 = (x1 % 256) as u8; ++ ::dafny_runtime::seq![b0, b1, b2, b3] ++ } ++ pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { ++ let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; ++ let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; ++ let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; ++ x2 + s.get(&::dafny_runtime::int!(3)) as u32 ++ } ++ pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { ++ let mut b0: u8 = (x / 72057594037927936) as u8; ++ let mut x0: u64 = x - b0 as u64 * 72057594037927936; ++ let mut b1: u8 = (x0 / 281474976710656) as u8; ++ let mut x1: u64 = x0 - b1 as u64 * 281474976710656; ++ let mut b2: u8 = (x1 / 1099511627776) as u8; ++ let mut x2: u64 = x1 - b2 as u64 * 1099511627776; ++ let mut b3: u8 = (x2 / 4294967296) as u8; ++ let mut x3: u64 = x2 - b3 as u64 * 4294967296; ++ let mut b4: u8 = (x3 / 16777216) as u8; ++ let mut x4: u64 = x3 - b4 as u64 * 16777216; ++ let mut b5: u8 = (x4 / 65536) as u8; ++ let mut x5: u64 = x4 - b5 as u64 * 65536; ++ let mut b6: u8 = (x5 / 256) as u8; ++ let mut b7: u8 = (x5 % 256) as u8; ++ ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] ++ } ++ pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { ++ let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; ++ let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; ++ let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; ++ let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; ++ let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; ++ let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; ++ let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; ++ let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; ++ x ++ } ++ pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { ++ ::dafny_runtime::int!(b"65536") ++ } ++ pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { ++ ::dafny_runtime::int!(b"4294967296") ++ } ++ pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { ++ ::dafny_runtime::int!(b"18446744073709551616") ++ } ++ pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { ++ ::dafny_runtime::int!(b"2147483648") ++ } ++ pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { ++ ::dafny_runtime::int!(b"9223372036854775808") ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint8(pub u8); -+ impl ::std::default::Default for uint8 { -+ fn default() -> Self { -+ uint8(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct uint8(pub u8); ++ ++ impl ::std::default::Default for uint8 { ++ fn default() -> Self { ++ uint8(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for uint8 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for uint8 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for uint8 { -+ type Target = u8; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for uint8 { ++ type Target = u8; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint16(pub u16); -+ impl ::std::default::Default for uint16 { -+ fn default() -> Self { -+ uint16(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct uint16(pub u16); ++ ++ impl ::std::default::Default for uint16 { ++ fn default() -> Self { ++ uint16(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for uint16 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for uint16 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for uint16 { -+ type Target = u16; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for uint16 { ++ type Target = u16; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint32(pub u32); -+ impl ::std::default::Default for uint32 { -+ fn default() -> Self { -+ uint32(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct uint32(pub u32); ++ ++ impl ::std::default::Default for uint32 { ++ fn default() -> Self { ++ uint32(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for uint32 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for uint32 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for uint32 { -+ type Target = u32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for uint32 { ++ type Target = u32; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint64(pub u64); -+ impl ::std::default::Default for uint64 { -+ fn default() -> Self { -+ uint64(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct uint64(pub u64); ++ ++ impl ::std::default::Default for uint64 { ++ fn default() -> Self { ++ uint64(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for uint64 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for uint64 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for uint64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for uint64 { ++ type Target = u64; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int32(pub i32); -+ impl ::std::default::Default for int32 { -+ fn default() -> Self { -+ int32(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct int32(pub i32); ++ ++ impl ::std::default::Default for int32 { ++ fn default() -> Self { ++ int32(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for int32 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for int32 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for int32 { -+ type Target = i32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for int32 { ++ type Target = i32; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int64(pub i64); -+ impl ::std::default::Default for int64 { -+ fn default() -> Self { -+ int64(::std::default::Default::default()) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct int64(pub i64); ++ ++ impl ::std::default::Default for int64 { ++ fn default() -> Self { ++ int64(::std::default::Default::default()) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for int64 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for int64 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for int64 { -+ type Target = i64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for int64 { ++ type Target = i64; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct posInt64(pub u64); -+ impl ::std::default::Default for posInt64 { -+ fn default() -> Self { -+ posInt64(1) ++ ++ #[derive(Clone, PartialEq)] ++ #[repr(transparent)] ++ pub struct posInt64(pub u64); ++ ++ impl ::std::default::Default for posInt64 { ++ fn default() -> Self { ++ posInt64(1) ++ } + } -+ } -+ impl ::dafny_runtime::DafnyPrint for posInt64 { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ ++ impl ::dafny_runtime::DafnyPrint for posInt64 { ++ fn fmt_print( ++ &self, ++ _formatter: &mut ::std::fmt::Formatter, ++ in_seq: bool, ++ ) -> ::std::fmt::Result { ++ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) ++ } + } -+ } -+ impl ::std::ops::Deref for posInt64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 ++ ++ impl ::std::ops::Deref for posInt64 { ++ type Target = u64; ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } + } -+ } -+ pub type seq16 = ::dafny_runtime::Sequence; -+ pub type seq32 = ::dafny_runtime::Sequence; -+ pub type seq64 = ::dafny_runtime::Sequence; ++ ++ pub type seq16 = ::dafny_runtime::Sequence; ++ ++ pub type seq32 = ::dafny_runtime::Sequence; ++ ++ pub type seq64 = ::dafny_runtime::Sequence; +} +pub mod r#_StandardLibrary_Compile { -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn Join<_T: ::dafny_runtime::DafnyType>(ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, joiner: &::dafny_runtime::Sequence<_T>) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut ss = ss.clone(); -+ let mut joiner = joiner.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if ss.cardinality() == ::dafny_runtime::int!(1) { -+ return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); -+ } else { -+ _accumulator = _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); -+ let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ss.drop(&::dafny_runtime::int!(1)); -+ let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); -+ ss = _in0.clone(); -+ joiner = _in1.clone(); -+ continue 'TAIL_CALL_START; ++ pub struct _default {} ++ ++ impl _default { ++ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_rcmut::() + } -+ } -+ } -+ pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut delim = delim.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ let mut i: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(&s, &delim, &::dafny_runtime::int!(0)); -+ if matches!((&i).as_ref(), super::r#_Wrappers_Compile::Option::Some{ .. }) { -+ _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); -+ let mut _in2: ::dafny_runtime::Sequence<_T> = s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); -+ let mut _in3: _T = delim.clone(); -+ s = _in2.clone(); -+ delim = _in3.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); ++ pub fn Join<_T: ::dafny_runtime::DafnyType>( ++ ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, ++ joiner: &::dafny_runtime::Sequence<_T>, ++ ) -> ::dafny_runtime::Sequence<_T> { ++ let mut _accumulator: ::dafny_runtime::Sequence<_T> = ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; ++ let mut ss = ss.clone(); ++ let mut joiner = joiner.clone(); ++ let mut _accumulator = _accumulator.clone(); ++ 'TAIL_CALL_START: loop { ++ if ss.cardinality() == ::dafny_runtime::int!(1) { ++ return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); ++ } else { ++ _accumulator = ++ _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); ++ let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ++ ss.drop(&::dafny_runtime::int!(1)); ++ let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); ++ ss = _in0.clone(); ++ joiner = _in1.clone(); ++ continue 'TAIL_CALL_START; ++ } ++ } + } -+ } -+ } -+ pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { -+ let mut i: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(s, delim, &::dafny_runtime::int!(0)); -+ (s.take(i.value()), s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))),) -+ } -+ pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> { -+ let mut valueOrError0: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(s, delim, &::dafny_runtime::int!(0)); -+ if valueOrError0.IsFailure() { -+ (valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>()/* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */) -+ } else { -+ let mut i: super::_System::nat = (valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>::Some { -+ value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1))),) -+ }) -+ } -+ } -+ pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, c: &_T, i: &super::_System::nat) -> ::std::rc::Rc> { -+ super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>(s, { -+ let c: _T = c.clone(); -+ &({ -+ let mut c = c.clone(); -+ ::std::rc::Rc::new(move |x: &_T| -> bool { -+ x.clone() == c.clone() -+ }) ++ pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( ++ s: &::dafny_runtime::Sequence<_T>, ++ delim: &_T, ++ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { ++ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; ++ let mut s = s.clone(); ++ let mut delim = delim.clone(); ++ let mut _accumulator = _accumulator.clone(); ++ 'TAIL_CALL_START: loop { ++ let mut i: ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, ++ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( ++ &s, ++ &delim, ++ &::dafny_runtime::int!(0), ++ ); ++ if matches!( ++ (&i).as_ref(), ++ super::r#_Wrappers_Compile::Option::Some { .. } ++ ) { ++ _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); ++ let mut _in2: ::dafny_runtime::Sequence<_T> = ++ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); ++ let mut _in3: _T = delim.clone(); ++ s = _in2.clone(); ++ delim = _in3.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); ++ } ++ } ++ } ++ pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( ++ s: &::dafny_runtime::Sequence<_T>, ++ delim: &_T, ++ ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { ++ let mut i: ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, ++ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( ++ s, ++ delim, ++ &::dafny_runtime::int!(0), ++ ); ++ ( ++ s.take(i.value()), ++ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), ++ ) ++ } ++ pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( ++ s: &::dafny_runtime::Sequence<_T>, ++ delim: &_T, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option<( ++ ::dafny_runtime::Sequence<_T>, ++ ::dafny_runtime::Sequence<_T>, ++ )>, ++ > { ++ let mut valueOrError0: ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, ++ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( ++ s, ++ delim, ++ &::dafny_runtime::int!(0), ++ ); ++ if valueOrError0.IsFailure() { ++ valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() ++ /* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */ ++ } else { ++ let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */; ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<( ++ ::dafny_runtime::Sequence<_T>, ++ ::dafny_runtime::Sequence<_T>, ++ )>::Some { ++ value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), + }) -+ }, i) -+ } -+ pub fn FindIndex<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>, f: &::std::rc::Rc bool>, i: &super::_System::nat) -> ::std::rc::Rc> { -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut i = i.clone(); -+ 'TAIL_CALL_START: loop { -+ if i.clone() == s.cardinality() { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}); -+ } else { -+ if (&f)(&s.get(&i)) { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { -+ value: i.clone() -+ }); -+ } else { -+ let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); -+ let mut _in5: ::std::rc::Rc bool> = f.clone(); -+ let mut _in6: ::dafny_runtime::DafnyInt = i.clone() + ::dafny_runtime::int!(1); -+ s = _in4.clone(); -+ f = _in5.clone(); -+ i = _in6.clone(); -+ continue 'TAIL_CALL_START; -+ } ++ } + } -+ } -+ } -+ pub fn Filter<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>, f: &::std::rc::Rc bool>) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::int!(0) { -+ return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); -+ } else { -+ if (&f)(&s.get(&::dafny_runtime::int!(0))) { -+ _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); -+ let mut _in7: ::dafny_runtime::Sequence<_T> = s.drop(&::dafny_runtime::int!(1)); -+ let mut _in8: ::std::rc::Rc bool> = f.clone(); -+ s = _in7.clone(); -+ f = _in8.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ let mut _in9: ::dafny_runtime::Sequence<_T> = s.drop(&::dafny_runtime::int!(1)); -+ let mut _in10: ::std::rc::Rc bool> = f.clone(); -+ s = _in9.clone(); -+ f = _in10.clone(); -+ continue 'TAIL_CALL_START; -+ } ++ pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( ++ s: &::dafny_runtime::Sequence<_T>, ++ c: &_T, ++ i: &::dafny_runtime::_System::nat, ++ ) -> ::std::rc::Rc> ++ { ++ super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( ++ s, ++ { ++ let c: _T = c.clone(); ++ &({ ++ let mut c = c.clone(); ++ ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) ++ }) ++ }, ++ i, ++ ) + } -+ } -+ } -+ pub fn Min(a: &::dafny_runtime::DafnyInt, b: &::dafny_runtime::DafnyInt) -> ::dafny_runtime::DafnyInt { -+ if a.clone() < b.clone() { -+ a.clone() -+ } else { -+ b.clone() -+ } -+ } -+ pub fn Fill<_T: ::dafny_runtime::DafnyType>(value: &_T, n: &super::_System::nat) -> ::dafny_runtime::Sequence<_T> { -+ { -+ let _initializer = { -+ let value: _T = value.clone(); -+ { -+ let mut value = value.clone(); -+ ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { -+ value.clone() -+ }) ++ pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ f: &::std::rc::Rc bool>, ++ i: &::dafny_runtime::_System::nat, ++ ) -> ::std::rc::Rc> ++ { ++ let mut s = s.clone(); ++ let mut f = f.clone(); ++ let mut i = i.clone(); ++ 'TAIL_CALL_START: loop { ++ if i.clone() == s.cardinality() { ++ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::_System::nat, ++ >::None {}); ++ } else { ++ if (&f)(&s.get(&i)) { ++ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::_System::nat, ++ >::Some { ++ value: i.clone(), ++ }); ++ } else { ++ let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); ++ let mut _in5: ::std::rc::Rc bool> = f.clone(); ++ let mut _in6: ::dafny_runtime::DafnyInt = ++ i.clone() + ::dafny_runtime::int!(1); ++ s = _in4.clone(); ++ f = _in5.clone(); ++ i = _in6.clone(); ++ continue 'TAIL_CALL_START; + } -+ }; -+ ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()).map(|i| _initializer(&i)).collect::<::dafny_runtime::Sequence<_>>() ++ } ++ } + } -+ } -+ pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> *mut [_T] { -+ let mut _init0: ::std::rc::Rc _T> = { -+ let s: ::dafny_runtime::Sequence<_T> = s.clone(); -+ ({ -+ let s = s.clone(); -+ ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { -+ s.get(i) -+ })}) -+ }; -+ ::dafny_runtime::array::initialize(&s.cardinality(), _init0) -+ } -+ pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, b: &::dafny_runtime::Sequence<_T>, less: &::std::rc::Rc bool>) -> bool { -+ Self::LexicographicLessOrEqualAux(a, b, less, &::dafny_runtime::int!(0)) -+ } -+ pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, b: &::dafny_runtime::Sequence<_T>, less: &::std::rc::Rc bool>, lengthOfCommonPrefix: &super::_System::nat) -> bool { -+ lengthOfCommonPrefix.clone() <= b.cardinality() && ::dafny_runtime::Forall::forall(&::dafny_runtime::Range(::dafny_runtime::int!(0), lengthOfCommonPrefix.clone()), { -+ let a = a.clone(); -+ let b = b.clone(); -+ ::std::rc::Rc::new(move |i| a.get(i) == b.get(i))}) && (lengthOfCommonPrefix.clone() == a.cardinality() || lengthOfCommonPrefix.clone() < b.cardinality() && ((less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))))) -+ } -+ pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, less: &::std::rc::Rc bool>) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.clone() == ::dafny_runtime::set!{} { -+ return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>)); -+ } else { -+ return (&({ -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { ++ pub fn Filter<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ f: &::std::rc::Rc bool>, ++ ) -> ::dafny_runtime::Sequence<_T> { ++ let mut _accumulator: ::dafny_runtime::Sequence<_T> = ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; ++ let mut s = s.clone(); ++ let mut f = f.clone(); ++ let mut _accumulator = _accumulator.clone(); ++ 'TAIL_CALL_START: loop { ++ if s.cardinality() == ::dafny_runtime::int!(0) { ++ return _accumulator ++ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); ++ } else { ++ if (&f)(&s.get(&::dafny_runtime::int!(0))) { ++ _accumulator = _accumulator ++ .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); ++ let mut _in7: ::dafny_runtime::Sequence<_T> = ++ s.drop(&::dafny_runtime::int!(1)); ++ let mut _in8: ::std::rc::Rc bool> = f.clone(); ++ s = _in7.clone(); ++ f = _in8.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ let mut _in9: ::dafny_runtime::Sequence<_T> = ++ s.drop(&::dafny_runtime::int!(1)); ++ let mut _in10: ::std::rc::Rc bool> = f.clone(); ++ s = _in9.clone(); ++ f = _in10.clone(); ++ continue 'TAIL_CALL_START; ++ } ++ } ++ } ++ } ++ pub fn Min( ++ a: &::dafny_runtime::DafnyInt, ++ b: &::dafny_runtime::DafnyInt, ++ ) -> ::dafny_runtime::DafnyInt { ++ if a.clone() < b.clone() { ++ a.clone() ++ } else { ++ b.clone() ++ } ++ } ++ pub fn Fill<_T: ::dafny_runtime::DafnyType>( ++ value: &_T, ++ n: &::dafny_runtime::_System::nat, ++ ) -> ::dafny_runtime::Sequence<_T> { ++ { ++ let _initializer = { ++ let value: _T = value.clone(); ++ { ++ let mut value = value.clone(); ++ ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { ++ value.clone() ++ }) ++ } ++ }; ++ ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) ++ .map(|i| _initializer(&i)) ++ .collect::<::dafny_runtime::Sequence<_>>() ++ } ++ } ++ pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( ++ s: &::dafny_runtime::Sequence<_T>, ++ ) -> ::dafny_runtime::Object<[_T]> { ++ let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); ++ let mut _init0: ::std::rc::Rc _T> = { ++ let s: ::dafny_runtime::Sequence<_T> = s.clone(); ++ { ++ let mut s = s.clone(); ++ ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) ++ } ++ }; ++ let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = ++ ::dafny_runtime::array::placebos_usize_rcmut::<_T>(s.cardinality().as_usize()); ++ for r#__i0_0 in ++ ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) ++ { ++ { ++ let __idx0 = ++ ::from(r#__i0_0.clone()).unwrap(); ++ ::dafny_runtime::md!(_nw0.clone())[__idx0] = ::std::mem::MaybeUninit::new( ++ (&_init0)(&::dafny_runtime::int!(r#__i0_0.clone())), ++ ); ++ } ++ } ++ a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_rcmut( ++ _nw0.clone(), ++ )); ++ return a.read(); ++ } ++ pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( ++ a: &::dafny_runtime::Sequence<_T>, ++ b: &::dafny_runtime::Sequence<_T>, ++ less: &::std::rc::Rc bool>, ++ ) -> bool { ++ ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ ++ let mut a = a.clone(); ++ let mut b = b.clone(); ++ let mut less = less.clone(); ++ ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool { ++ let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); ++ ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) ++ }) ++ }).as_ref()) ++ } ++ pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( ++ a: &::dafny_runtime::Sequence<_T>, ++ b: &::dafny_runtime::Sequence<_T>, ++ less: &::std::rc::Rc bool>, ++ lengthOfCommonPrefix: &::dafny_runtime::_System::nat, ++ ) -> bool { ++ lengthOfCommonPrefix.clone() <= b.cardinality() ++ && ::dafny_runtime::integer_range( ++ ::dafny_runtime::int!(0), ++ lengthOfCommonPrefix.clone(), ++ ) ++ .all( ++ ({ ++ let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); ++ let mut a = a.clone(); ++ let mut b = b.clone(); ++ ::std::rc::Rc::new( ++ move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { ++ let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); ++ !(::dafny_runtime::int!(0) <= i.clone() ++ && i.clone() < lengthOfCommonPrefix.clone()) ++ || a.get(&i) == b.get(&i) ++ }, ++ ) ++ }) ++ .as_ref(), ++ ) ++ && (lengthOfCommonPrefix.clone() == a.cardinality() ++ || lengthOfCommonPrefix.clone() < b.cardinality() ++ && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) ++ } ++ pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( ++ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, ++ less: &::std::rc::Rc bool>, ++ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { ++ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; ++ let mut s = s.clone(); ++ let mut less = less.clone(); ++ let mut _accumulator = _accumulator.clone(); ++ 'TAIL_CALL_START: loop { ++ if s.clone() == ::dafny_runtime::set! {} { ++ return _accumulator.concat( ++ &(::dafny_runtime::seq![] ++ as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), ++ ); ++ } else { ++ return (&({ ++ let mut s = s.clone(); ++ let mut less = less.clone(); ++ ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); + 'label_goto__ASSIGN_SUCH_THAT_0: loop { -+ for r#__assign_such_that_0 in (&s).iter() { ++ for r#__assign_such_that_0 in (&s).iter().cloned() { + a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); + if s.contains(&a.read()) && super::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { + break 'label_goto__ASSIGN_SUCH_THAT_0; + } -+ }; ++ } + panic!("Halt"); + break; + }; + ::dafny_runtime::seq![a.read()].concat(&super::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) + }) -+ }))(&::dafny_runtime::int!(0)); ++ }))(&::dafny_runtime::int!(0)); ++ } ++ } ++ } ++ pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( ++ a: &::dafny_runtime::Sequence<_T>, ++ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, ++ less: &::std::rc::Rc bool>, ++ ) -> bool { ++ s.contains(a) && s.iter().cloned().all(({ ++ let mut a = a.clone(); ++ let mut s = s.clone(); ++ let mut less = less.clone(); ++ ::std::rc::Rc::new(move |r#__forall_var_1: ::dafny_runtime::Sequence<_T>| -> bool { ++ let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); ++ !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) ++ }) ++ }).as_ref()) + } -+ } -+ } -+ pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, less: &::std::rc::Rc bool>) -> bool { -+ s.contains(a) && -+ ::dafny_runtime::Forall::forall(s, { -+ let a = a.clone(); -+ let less = less.clone(); -+ ::std::rc::Rc::new(move |z| Self::LexicographicLessOrEqual(&a, z, &less)) -+ }) -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ write!(_formatter, "StandardLibrary_Compile.__default") -+ } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) + } -+ } +} ++pub mod UTF8 { ++ pub struct _default {} + -+pub mod r#_UTF8_Compile { -+ use dafny_runtime::dafny_runtime_conversions; -+ use dafny_runtime::ToPrimitive; -+ use dafny_runtime::BigInt; -+ use crate::UTF8; -+ pub struct _default {} -+ impl _default { -+ pub fn new() -> Self { -+ _default {} -+ } -+ pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { -+ UTF8::UTF8::Encode(s) -+ } -+ pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { -+ UTF8::UTF8::Decode(b) -+ } -+ -+ pub fn CreateEncodeSuccess(bytes: &super::r#_UTF8_Compile::ValidUTF8Bytes) -> ::std::rc::Rc>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Success {value: (bytes.clone()) }) -+ } -+ pub fn CreateEncodeFailure(error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Failure {error: (error.clone()) }) -+ } -+ pub fn CreateDecodeSuccess(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success {value: (s.clone()) }) -+ } -+ pub fn CreateDecodeFailure(error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure {error: (error.clone()) }) -+ } -+ pub fn IsASCIIString(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> bool { -+ true -+ } -+ pub fn EncodeAscii(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> super::r#_UTF8_Compile::ValidUTF8Bytes { -+ let mut _accumulator: super::r#_UTF8_Compile::ValidUTF8Bytes = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; -+ let mut s = s.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::DafnyInt::from(0) { -+ return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); -+ } else { -+ let mut x: ::dafny_runtime::Sequence = ::dafny_runtime::seq![0 as u8]; -+ _accumulator = _accumulator.concat(&x); -+ let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = s.drop(&::dafny_runtime::DafnyInt::from(1)); -+ s = _in0.clone(); -+ continue 'TAIL_CALL_START; ++ impl _default { ++ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_rcmut::() + } -+ } -+ } -+ pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { -+ (/*optimized*/0) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/127) -+ } -+ pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ (/*optimized*/194) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/223) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) -+ } -+ pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/224) && ((/*optimized*/160) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || (/*optimized*/225) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/236) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/237) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/159)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || (/*optimized*/238) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/239) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) -+ } -+ pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/240) && ((/*optimized*/144) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) || (/*optimized*/241) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/243) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) || s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/244) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/143)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) -+ } -+ pub fn ValidUTF8Range(a: &::dafny_runtime::Sequence, lo: &super::_System::nat, hi: &super::_System::nat) -> bool { -+ let mut a = a.clone(); -+ let mut lo = lo.clone(); -+ let mut hi = hi.clone(); -+ 'TAIL_CALL_START: loop { -+ if lo.clone() == hi.clone() { -+ return true; -+ } else { -+ let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); -+ if <(super::r#_UTF8_Compile::_default)>::Uses1Byte(&r) { -+ let mut _in1: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in2: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(1); -+ let mut _in3: super::_System::nat = hi.clone(); -+ a = _in1.clone(); -+ lo = _in2.clone(); -+ hi = _in3.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::DafnyInt::from(2) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses2Bytes(&r) { -+ let mut _in4: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in5: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(2); -+ let mut _in6: super::_System::nat = hi.clone(); -+ a = _in4.clone(); -+ lo = _in5.clone(); -+ hi = _in6.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::DafnyInt::from(3) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses3Bytes(&r) { -+ let mut _in7: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in8: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(3); -+ let mut _in9: super::_System::nat = hi.clone(); -+ a = _in7.clone(); -+ lo = _in8.clone(); -+ hi = _in9.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::DafnyInt::from(4) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses4Bytes(&r) { -+ let mut _in10: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in11: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(4); -+ let mut _in12: super::_System::nat = hi.clone(); -+ a = _in10.clone(); -+ lo = _in11.clone(); -+ hi = _in12.clone(); -+ continue 'TAIL_CALL_START; ++ pub fn CreateEncodeSuccess( ++ bytes: &super::UTF8::ValidUTF8Bytes, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Result< ++ super::UTF8::ValidUTF8Bytes, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ super::UTF8::ValidUTF8Bytes, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Success { ++ value: bytes.clone(), ++ }) ++ } ++ pub fn CreateEncodeFailure( ++ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Result< ++ super::UTF8::ValidUTF8Bytes, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ super::UTF8::ValidUTF8Bytes, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Failure { ++ error: error.clone(), ++ }) ++ } ++ pub fn CreateDecodeSuccess( ++ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Result< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Success { ++ value: s.clone(), ++ }) ++ } ++ pub fn CreateDecodeFailure( ++ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Result< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Failure { ++ error: error.clone(), ++ }) ++ } ++ pub fn IsASCIIString( ++ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> bool { ++ let mut _hresult: bool = ::default(); ++ let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); ++ for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { ++ if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { ++ _hresult = false; ++ return _hresult; ++ } ++ } ++ _hresult = true; ++ return _hresult; ++ return _hresult; ++ } ++ pub fn EncodeAscii( ++ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> super::UTF8::ValidUTF8Bytes { ++ let mut _accumulator: super::UTF8::ValidUTF8Bytes = ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; ++ let mut s = s.clone(); ++ let mut _accumulator = _accumulator.clone(); ++ 'TAIL_CALL_START: loop { ++ if s.cardinality() == ::dafny_runtime::int!(0) { ++ return _accumulator ++ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); + } else { -+ return false; ++ let mut x: ::dafny_runtime::Sequence = ++ ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; ++ _accumulator = _accumulator.concat(&x); ++ let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ++ s.drop(&::dafny_runtime::int!(1)); ++ s = _in11.clone(); ++ continue 'TAIL_CALL_START; + } -+ } + } -+ } + } -+ } -+ } -+ pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { -+ <(super::r#_UTF8_Compile::_default)>::ValidUTF8Range(s, &::dafny_runtime::DafnyInt::from(0), &s.cardinality()) -+ } -+ } -+ impl ::std::default::Default for _default { -+ fn default() -> Self { -+ _default::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for _default { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ write!(_formatter, "UTF8_Compile.__default") ++ pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { ++ 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 ++ } ++ pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { ++ 194 <= s.get(&::dafny_runtime::int!(0)) ++ && s.get(&::dafny_runtime::int!(0)) <= 223 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ } ++ pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { ++ s.get(&::dafny_runtime::int!(0)) == 224 ++ && (160 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ || 225 <= s.get(&::dafny_runtime::int!(0)) ++ && s.get(&::dafny_runtime::int!(0)) <= 236 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ || s.get(&::dafny_runtime::int!(0)) == 237 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 159) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ || 238 <= s.get(&::dafny_runtime::int!(0)) ++ && s.get(&::dafny_runtime::int!(0)) <= 239 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ } ++ pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { ++ s.get(&::dafny_runtime::int!(0)) == 240 ++ && (144 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(3)) ++ && s.get(&::dafny_runtime::int!(3)) <= 191) ++ || 241 <= s.get(&::dafny_runtime::int!(0)) ++ && s.get(&::dafny_runtime::int!(0)) <= 243 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(3)) ++ && s.get(&::dafny_runtime::int!(3)) <= 191) ++ || s.get(&::dafny_runtime::int!(0)) == 244 ++ && (128 <= s.get(&::dafny_runtime::int!(1)) ++ && s.get(&::dafny_runtime::int!(1)) <= 143) ++ && (128 <= s.get(&::dafny_runtime::int!(2)) ++ && s.get(&::dafny_runtime::int!(2)) <= 191) ++ && (128 <= s.get(&::dafny_runtime::int!(3)) ++ && s.get(&::dafny_runtime::int!(3)) <= 191) ++ } ++ pub fn ValidUTF8Range( ++ a: &::dafny_runtime::Sequence, ++ lo: &::dafny_runtime::_System::nat, ++ hi: &::dafny_runtime::_System::nat, ++ ) -> bool { ++ let mut a = a.clone(); ++ let mut lo = lo.clone(); ++ let mut hi = hi.clone(); ++ 'TAIL_CALL_START: loop { ++ if lo.clone() == hi.clone() { ++ return true; ++ } else { ++ let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); ++ if super::UTF8::_default::Uses1Byte(&r) { ++ let mut _in12: ::dafny_runtime::Sequence = a.clone(); ++ let mut _in13: ::dafny_runtime::DafnyInt = ++ lo.clone() + ::dafny_runtime::int!(1); ++ let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); ++ a = _in12.clone(); ++ lo = _in13.clone(); ++ hi = _in14.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ if ::dafny_runtime::int!(2) <= r.cardinality() ++ && super::UTF8::_default::Uses2Bytes(&r) ++ { ++ let mut _in15: ::dafny_runtime::Sequence = a.clone(); ++ let mut _in16: ::dafny_runtime::DafnyInt = ++ lo.clone() + ::dafny_runtime::int!(2); ++ let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); ++ a = _in15.clone(); ++ lo = _in16.clone(); ++ hi = _in17.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ if ::dafny_runtime::int!(3) <= r.cardinality() ++ && super::UTF8::_default::Uses3Bytes(&r) ++ { ++ let mut _in18: ::dafny_runtime::Sequence = a.clone(); ++ let mut _in19: ::dafny_runtime::DafnyInt = ++ lo.clone() + ::dafny_runtime::int!(3); ++ let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); ++ a = _in18.clone(); ++ lo = _in19.clone(); ++ hi = _in20.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ if ::dafny_runtime::int!(4) <= r.cardinality() ++ && super::UTF8::_default::Uses4Bytes(&r) ++ { ++ let mut _in21: ::dafny_runtime::Sequence = a.clone(); ++ let mut _in22: ::dafny_runtime::DafnyInt = ++ lo.clone() + ::dafny_runtime::int!(4); ++ let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); ++ a = _in21.clone(); ++ lo = _in22.clone(); ++ hi = _in23.clone(); ++ continue 'TAIL_CALL_START; ++ } else { ++ return false; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { ++ super::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) ++ } + } -+ } -+ impl ::std::cmp::PartialEq for _default { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) ++ ++ pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; ++ ++ pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { ++ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence + } -+ } -+ pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; +} +pub mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ impl WrappersInterop { -+ pub fn new() -> Self { -+ WrappersInterop {} -+ } -+ pub fn _allocated() -> *mut Self { -+ ::dafny_runtime::allocate::() -+ } -+ pub fn CreateStringSome(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { -+ value: s.clone() -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc>> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::None {}) -+ } -+ pub fn CreateBooleanSome(b: bool) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { -+ value: b -+ }) -+ } -+ pub fn CreateBooleanNone() -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+ impl ::std::default::Default for WrappersInterop { -+ fn default() -> Self { -+ WrappersInterop::new() -+ } -+ } -+ impl ::dafny_runtime::DafnyPrint for WrappersInterop { -+ fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { -+ write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") -+ } -+ } -+ impl ::std::cmp::PartialEq for WrappersInterop { -+ fn eq(&self, other: &Self) -> bool { -+ ::std::ptr::eq(self, other) ++ pub struct WrappersInterop {} ++ ++ impl WrappersInterop { ++ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { ++ ::dafny_runtime::allocate_rcmut::() ++ } ++ pub fn CreateStringSome( ++ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ ) -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::Some { ++ value: s.clone(), ++ }) ++ } ++ pub fn CreateStringNone() -> ::std::rc::Rc< ++ super::r#_Wrappers_Compile::Option< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >, ++ > { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< ++ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ++ >::None {}) ++ } ++ pub fn CreateBooleanSome( ++ b: bool, ++ ) -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) ++ } ++ pub fn CreateBooleanNone() -> ::std::rc::Rc> { ++ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) ++ } + } -+ } +} -+pub mod _module { -+ -+} -\ No newline at end of file ++pub mod _module {} diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..8ba31f25 +index 00000000..789b96b0 --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs @@ -0,0 +1,297 @@ @@ -1166,7 +1437,7 @@ index 00000000..8ba31f25 + let unicodeString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); + let expectedBytes = + dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; -+ let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&unicodeString); ++ let _r = implementation_from_dafny::UTF8::_default::Encode(&unicodeString); + if _r.IsFailure() { + panic!("Encode failed"); + } @@ -1182,7 +1453,7 @@ index 00000000..8ba31f25 + ::dafny_runtime::DafnyCharUTF16('c' as u16), + ::dafny_runtime::DafnyCharUTF16(0xD800) + ]; -+ let encoded = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&invalidUnicode); ++ let encoded = implementation_from_dafny::UTF8::_default::Encode(&invalidUnicode); + assert!(encoded.IsFailure()); + } + @@ -1191,7 +1462,7 @@ index 00000000..8ba31f25 + let unicodeBytes = + ::dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; + assert!( -+ implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes( ++ implementation_from_dafny::UTF8::_default::Uses2Bytes( + &::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8] + ) + ); @@ -1200,21 +1471,21 @@ index 00000000..8ba31f25 + unicodeBytes.slice(&::dafny_runtime::int!(5), &::dafny_runtime::int!(9)) + ); + assert!( -+ implementation_from_dafny::r#_UTF8_Compile::_default::ValidUTF8Range( ++ implementation_from_dafny::UTF8::_default::ValidUTF8Range( + &unicodeBytes, + &::dafny_runtime::int!(7), + &::dafny_runtime::int!(9) + ) + ); + assert!( -+ implementation_from_dafny::r#_UTF8_Compile::_default::ValidUTF8Range( ++ implementation_from_dafny::UTF8::_default::ValidUTF8Range( + &unicodeBytes, + &::dafny_runtime::int!(0), + &::dafny_runtime::int!(9) + ) + ); + let expectedString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); -+ let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&unicodeBytes); ++ let _r = implementation_from_dafny::UTF8::_default::Decode(&unicodeBytes); + if _r.IsFailure() { + panic!("Decode failed"); + } @@ -1227,7 +1498,7 @@ index 00000000..8ba31f25 + let invalidUnicode = ::dafny_runtime::seq![ + 0x61 as u8, 0x62 as u8, 0x63 as u8, 0xED as u8, 0xA0 as u8, 0x80 as u8 + ]; -+ let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&invalidUnicode); ++ let _r = implementation_from_dafny::UTF8::_default::Decode(&invalidUnicode); + assert!(_r.IsFailure()); + } + @@ -1235,66 +1506,66 @@ index 00000000..8ba31f25 + fn Test1Byte() { + // Null + let mut decoded = ::dafny_runtime::string_utf16_of("\u{0000}"); -+ let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + let mut encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x00 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + let mut redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + + // Space + decoded = ::dafny_runtime::string_utf16_of(" "); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x20 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + + decoded = ::dafny_runtime::string_utf16_of("$"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x24 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + + decoded = ::dafny_runtime::string_utf16_of("0"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x30 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("A"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x41 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("a"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0x61 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); @@ -1303,42 +1574,42 @@ index 00000000..8ba31f25 + #[test] + fn Test2Bytes() { + let mut decoded = ::dafny_runtime::string_utf16_of("\u{00A3}"); -+ let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + let mut encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA3 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); ++ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + let mut redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{00A9}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA9 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{00AE}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xAE as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{03C0}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!(::dafny_runtime::seq![0xCF as u8, 0x80 as u8], encoded); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); @@ -1347,67 +1618,67 @@ index 00000000..8ba31f25 + #[test] + fn Test3Bytes() { + let mut decoded = ::dafny_runtime::string_utf16_of("\u{2386}"); -+ let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + let mut encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x86 as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); ++ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + let mut redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{2387}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x87 as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{231B}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xE2 as u8, 0x8C as u8, 0x9B as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{1D78}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xE1 as u8, 0xB5 as u8, 0xB8 as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{732B}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xE7 as u8, 0x8C as u8, 0xAB as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); @@ -1419,7 +1690,7 @@ index 00000000..8ba31f25 + ::dafny_runtime::DafnyCharUTF16(0xD808), + ::dafny_runtime::DafnyCharUTF16(0xDC00) + ]; -+ let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + println!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&_r.as_ref().clone()) @@ -1430,21 +1701,21 @@ index 00000000..8ba31f25 + ::dafny_runtime::seq![0xF0 as u8, 0x92 as u8, 0x80 as u8, 0x80 as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses4Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); ++ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + let mut redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); + decoded = ::dafny_runtime::string_utf16_of("\u{1D7C1}"); -+ _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); ++ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); + assert!(!_r.IsFailure()); + encoded = _r.Extract(); + assert_eq!( + ::dafny_runtime::seq![0xF0 as u8, 0x9D as u8, 0x9F as u8, 0x81 as u8], + encoded + ); -+ assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses4Bytes(&encoded)); -+ _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); ++ assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); ++ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); + assert!(!_r2.IsFailure()); + redecoded = _r2.Extract(); + assert_eq!(decoded, redecoded); diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs index 1b9158e98..fb5e7bf90 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/UTF8.rs @@ -3,61 +3,64 @@ #[allow(non_snake_case)] pub mod UTF8 { use crate::implementation_from_dafny::r#_Wrappers_Compile; - use crate::implementation_from_dafny::r#_UTF8_Compile; + use crate::implementation_from_dafny::UTF8; - pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { - let v = s.to_array(); - let mut _accumulator: Vec = vec![]; - // Use of .encode_utf8 method. - let mut surrogate: Option = None; - for c in v.iter() { - let s = - if let Some(s) = surrogate { - String::from_utf16(&[s, c.0]) - } else { - String::from_utf16(&[c.0]) - }; - surrogate = None; - match s { - Ok(value) => { - _accumulator.extend(value.as_bytes()); - continue; - }, - Err(e) => { - if 0xD800 <= c.0 && c.0 <= 0xDFFF { - surrogate = Some(c.0); + + impl crate::implementation_from_dafny::UTF8::_default { + pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { + let v = s.to_array(); + let mut _accumulator: Vec = vec![]; + // Use of .encode_utf8 method. + let mut surrogate: Option = None; + for c in v.iter() { + let s = + if let Some(s) = surrogate { + String::from_utf16(&[s, c.0]) + } else { + String::from_utf16(&[c.0]) + }; + surrogate = None; + match s { + Ok(value) => { + _accumulator.extend(value.as_bytes()); continue; - } - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) - }); + }, + Err(e) => { + if 0xD800 <= c.0 && c.0 <= 0xDFFF { + surrogate = Some(c.0); + continue; + } + return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { + error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( + &e.to_string()) + }); + } } } + if let Some(s) = surrogate { + return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { + error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( + &format!("Surrogate pair missing: 0x{:04x}", s)) + }); + } + ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) } - if let Some(s) = surrogate { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &format!("Surrogate pair missing: 0x{:04x}", s)) - }); - } - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::>::Success { value: ::dafny_runtime::Sequence::from_array_owned(_accumulator) }) - } - pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { - let b = String::from_utf8(b.to_array().as_ref().clone()); - match b { - Ok(s) => { - ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { - value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) - }) - }, - Err(e) => { - return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { - error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( - &e.to_string()) + pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { + let b = String::from_utf8(b.to_array().as_ref().clone()); + match b { + Ok(s) => { + ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success { + value: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&s) }) + }, + Err(e) => { + return ::std::rc::Rc::new(r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure { + error: ::dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string( + &e.to_string()) + }) + } } } } diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs index a67da67c4..20cb9f072 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs @@ -1,1071 +1,1340 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -extern crate dafny_runtime; -pub mod _System { - pub type nat = ::dafny_runtime::DafnyInt; - #[derive(PartialEq, Clone)] - pub enum Tuple2 { - _T2 { _0: T0, _1: T1 }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData) - } - impl Tuple2 { - pub fn _0(&self) -> &T0 { - match self { - Tuple2::_T2 { _0, _1, } => _0, - Tuple2::_PhantomVariant(..) => panic!() - } - } - pub fn _1(&self) -> &T1 { - match self { - Tuple2::_T2 { _0, _1, } => _1, - Tuple2::_PhantomVariant(..) => panic!() - } - } - } - impl ::std::fmt::Debug for Tuple2 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - impl ::dafny_runtime::DafnyPrint for Tuple2 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - match self { - Tuple2::_T2 { _0, _1, } => { - write!(_formatter, "_System.Tuple2._T2(")?; - ::dafny_runtime::DafnyPrint::fmt_print(_0, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(_1, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - }, - Tuple2::_PhantomVariant(..) => {panic!()} - } - } - } - impl Eq for Tuple2 {} - impl ::std::hash::Hash for Tuple2 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Tuple2::_T2 { _0, _1, } => { - _0.hash(_state); - _1.hash(_state) - }, - Tuple2::_PhantomVariant(..) => {panic!()} - } - } - } - impl ::std::default::Default for Tuple2 { - fn default() -> Tuple2 { - Tuple2::_T2 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default() - } - } - } - impl ::std::convert::AsRef> for &Tuple2 { - fn as_ref(&self) -> Self { - self - } - } - #[derive(PartialEq, Clone)] - pub enum Tuple0 { - _T0 {} - } - impl Tuple0 {} - impl ::std::fmt::Debug for Tuple0 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - impl ::dafny_runtime::DafnyPrint for Tuple0 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - match self { - Tuple0::_T0 { } => { - write!(_formatter, "_System.Tuple0._T0")?; - Ok(()) - } - } - } - } - impl Eq for Tuple0 {} - impl ::std::hash::Hash for Tuple0 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Tuple0::_T0 { } => { - - } - } - } - } - impl ::std::default::Default for Tuple0 { - fn default() -> Tuple0 { - Tuple0::_T0 {} - } - } - impl ::std::convert::AsRef for &Tuple0 { - fn as_ref(&self) -> Self { - self - } - } -} pub mod r#_Wrappers_Compile { - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn Need<_E: ::dafny_runtime::DafnyType>(condition: bool, error: &_E) -> ::std::rc::Rc> { - if condition { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) - } else { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { - error: error.clone() - }) - } - } - } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - write!(_formatter, "Wrappers_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) - } - } - #[derive(PartialEq, Clone)] - pub enum Option { - None {}, - Some { value: T }, - _PhantomVariant(::std::marker::PhantomData) - } - impl Option { - pub fn ToResult(self: &::std::rc::Rc) -> ::std::rc::Rc>> { - let mut _source0: ::std::rc::Rc> = self.clone(); - if matches!((&_source0).as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Failure { - error: ::dafny_runtime::string_utf16_of("Option is None") - }) - } else { - let mut r#___mcc_h0: T = _source0.value().clone(); - let mut v: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Success { - value: v.clone() - }) - } - } - pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { - let mut _source1: ::std::rc::Rc> = self.clone(); - if matches!((&_source1).as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) { - default.clone() - } else { - let mut r#___mcc_h0: T = _source1.value().clone(); - let mut v: T = r#___mcc_h0.clone(); - v.clone() - } - } - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!(self.as_ref(), super::r#_Wrappers_Compile::Option::None{ .. }) - } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) - } - pub fn Extract(self: &::std::rc::Rc) -> T { - self.value().clone() - } - pub fn value(&self) -> &T { - match self { - Option::None { } => panic!("field does not exist on this variant"), - Option::Some { value, } => value, - Option::_PhantomVariant(..) => panic!() - } - } - } - impl ::std::fmt::Debug for Option { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - impl ::dafny_runtime::DafnyPrint for Option { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - match self { - Option::None { } => { - write!(_formatter, "Wrappers_Compile.Option.None")?; - Ok(()) - }, - Option::Some { value, } => { - write!(_formatter, "Wrappers_Compile.Option.Some(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - }, - Option::_PhantomVariant(..) => {panic!()} - } - } - } - impl Eq for Option {} - impl ::std::hash::Hash for Option { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Option::None { } => { - - }, - Option::Some { value, } => { - value.hash(_state) - }, - Option::_PhantomVariant(..) => {panic!()} - } - } - } - impl ::std::default::Default for Option { - fn default() -> Option { - Option::None {} - } - } - impl ::std::convert::AsRef> for &Option { - fn as_ref(&self) -> Self { - self + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn Need<_E: ::dafny_runtime::DafnyType>( + condition: bool, + error: &_E, + ) -> ::std::rc::Rc> { + if condition { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) + } else { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { + error: error.clone(), + }) + } + } } - } - #[derive(PartialEq, Clone)] - pub enum Result { - Success { value: T }, - Failure { error: R }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData) - } - impl Result { - pub fn ToOption(self: &::std::rc::Rc) -> ::std::rc::Rc> { - let mut _source2: ::std::rc::Rc> = self.clone(); - if matches!((&_source2).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { - let mut r#___mcc_h0: T = _source2.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: s.clone() - }) - } else { - let mut r#___mcc_h1: R = _source2.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } + + #[derive(PartialEq, Clone)] + pub enum Option { + None {}, + Some { value: T }, + _PhantomVariant(::std::marker::PhantomData), } - pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { - let mut _source3: ::std::rc::Rc> = self.clone(); - if matches!((&_source3).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { - let mut r#___mcc_h0: T = _source3.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - s.clone() - } else { - let mut r#___mcc_h1: R = _source3.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - default.clone() - } + + impl Option { + pub fn ToResult( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + let mut _source0: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source0).as_ref(), + super::r#_Wrappers_Compile::Option::None { .. } + ) { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: ::dafny_runtime::string_utf16_of("Option is None"), + }) + } else { + let mut r#___mcc_h0: T = _source0.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + T, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: v.clone(), + }) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source1: ::std::rc::Rc> = self.clone(); + if matches!( + (&_source1).as_ref(), + super::r#_Wrappers_Compile::Option::None { .. } + ) { + default.clone() + } else { + let mut r#___mcc_h0: T = _source1.value().clone(); + let mut v: T = r#___mcc_h0.clone(); + v.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + super::r#_Wrappers_Compile::Option::None { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Option::None {} => panic!("field does not exist on this variant"), + Option::Some { value } => value, + Option::_PhantomVariant(..) => panic!(), + } + } } - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!(self.as_ref(), super::r#_Wrappers_Compile::Result::Failure{ .. }) + + impl ::std::fmt::Debug for Option { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { - error: self.error().clone() - }) + + impl ::dafny_runtime::DafnyPrint for Option { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Option::None {} => { + write!(_formatter, "r#_Wrappers_Compile.Option.None")?; + Ok(()) + } + Option::Some { value } => { + write!(_formatter, "r#_Wrappers_Compile.Option.Some(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Option::_PhantomVariant(..) => { + panic!() + } + } + } } - pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc, reWrap: &::std::rc::Rc _NewR>) -> ::std::rc::Rc> { - let mut _source4: ::std::rc::Rc> = self.clone(); - if matches!((&_source4).as_ref(), super::r#_Wrappers_Compile::Result::Success{ .. }) { - let mut r#___mcc_h0: T = _source4.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { - value: s.clone() - }) - } else { - let mut r#___mcc_h1: R = _source4.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { - error: reWrap(&e) - }) - } + + impl Eq for Option {} + + impl ::std::hash::Hash for Option { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Option::None {} => {} + Option::Some { value } => value.hash(_state), + Option::_PhantomVariant(..) => { + panic!() + } + } + } } - pub fn Extract(self: &::std::rc::Rc) -> T { - self.value().clone() + + impl ::std::default::Default + for Option + { + fn default() -> Option { + Option::None {} + } } - pub fn value(&self) -> &T { - match self { - Result::Success { value, } => value, - Result::Failure { error, } => panic!("field does not exist on this variant"), - Result::_PhantomVariant(..) => panic!() - } + + impl ::std::convert::AsRef> for &Option { + fn as_ref(&self) -> Self { + self + } } - pub fn error(&self) -> &R { - match self { - Result::Success { value, } => panic!("field does not exist on this variant"), - Result::Failure { error, } => error, - Result::_PhantomVariant(..) => panic!() - } + + #[derive(PartialEq, Clone)] + pub enum Result { + Success { value: T }, + Failure { error: R }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), } - } - impl ::std::fmt::Debug for Result { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + + impl Result { + pub fn ToOption( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + let mut _source2: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source2).as_ref(), + super::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source2.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source2.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) + } + } + pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { + let mut _source3: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source3).as_ref(), + super::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source3.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + s.clone() + } else { + let mut r#___mcc_h1: R = _source3.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + default.clone() + } + } + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + super::r#_Wrappers_Compile::Result::Failure { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { + error: self.error().clone(), + }) + } + pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + reWrap: &::std::rc::Rc _NewR>, + ) -> ::std::rc::Rc> { + let mut _source4: ::std::rc::Rc> = + self.clone(); + if matches!( + (&_source4).as_ref(), + super::r#_Wrappers_Compile::Result::Success { .. } + ) { + let mut r#___mcc_h0: T = _source4.value().clone(); + let mut s: T = r#___mcc_h0.clone(); + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { + value: s.clone(), + }) + } else { + let mut r#___mcc_h1: R = _source4.error().clone(); + let mut e: R = r#___mcc_h1.clone(); + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { + error: reWrap(&e), + }) + } + } + pub fn Extract(self: &::std::rc::Rc) -> T { + self.value().clone() + } + pub fn value(&self) -> &T { + match self { + Result::Success { value } => value, + Result::Failure { error } => panic!("field does not exist on this variant"), + Result::_PhantomVariant(..) => panic!(), + } + } + pub fn error(&self) -> &R { + match self { + Result::Success { value } => panic!("field does not exist on this variant"), + Result::Failure { error } => error, + Result::_PhantomVariant(..) => panic!(), + } + } } - } - impl ::dafny_runtime::DafnyPrint for Result { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - match self { - Result::Success { value, } => { - write!(_formatter, "Wrappers_Compile.Result.Success(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - }, - Result::Failure { error, } => { - write!(_formatter, "Wrappers_Compile.Result.Failure(")?; - ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - }, - Result::_PhantomVariant(..) => {panic!()} - } + + impl ::std::fmt::Debug + for Result + { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } } - } - impl Eq for Result {} - impl ::std::hash::Hash for Result { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Result::Success { value, } => { - value.hash(_state) - }, - Result::Failure { error, } => { - error.hash(_state) - }, - Result::_PhantomVariant(..) => {panic!()} - } + + impl ::dafny_runtime::DafnyPrint + for Result + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Result::Success { value } => { + write!(_formatter, "r#_Wrappers_Compile.Result.Success(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::Failure { error } => { + write!(_formatter, "r#_Wrappers_Compile.Result.Failure(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Result::_PhantomVariant(..) => { + panic!() + } + } + } } - } - impl ::std::default::Default for Result { - fn default() -> Result { - Result::Success { - value: ::std::default::Default::default() - } + + impl Eq for Result {} + + impl< + T: ::dafny_runtime::DafnyType + ::std::hash::Hash, + R: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for Result + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Result::Success { value } => value.hash(_state), + Result::Failure { error } => error.hash(_state), + Result::_PhantomVariant(..) => { + panic!() + } + } + } } - } - impl ::std::convert::AsRef> for &Result { - fn as_ref(&self) -> Self { - self + + impl< + T: ::dafny_runtime::DafnyType + ::std::default::Default, + R: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for Result + { + fn default() -> Result { + Result::Success { + value: ::std::default::Default::default(), + } + } } - } - #[derive(PartialEq, Clone)] - pub enum Outcome { - Pass {}, - Fail { error: E }, - _PhantomVariant(::std::marker::PhantomData) - } - impl Outcome { - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!(self.as_ref(), super::r#_Wrappers_Compile::Outcome::Fail{ .. }) + + impl + ::std::convert::AsRef> for &Result + { + fn as_ref(&self) -> Self { + self + } } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>(self: &::std::rc::Rc) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { - error: self.error().clone() - }) + + #[derive(PartialEq, Clone)] + pub enum Outcome { + Pass {}, + Fail { error: E }, + _PhantomVariant(::std::marker::PhantomData), } - pub fn error(&self) -> &E { - match self { - Outcome::Pass { } => panic!("field does not exist on this variant"), - Outcome::Fail { error, } => error, - Outcome::_PhantomVariant(..) => panic!() - } + + impl Outcome { + pub fn IsFailure(self: &::std::rc::Rc) -> bool { + matches!( + self.as_ref(), + super::r#_Wrappers_Compile::Outcome::Fail { .. } + ) + } + pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( + self: &::std::rc::Rc, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { + error: self.error().clone(), + }) + } + pub fn error(&self) -> &E { + match self { + Outcome::Pass {} => panic!("field does not exist on this variant"), + Outcome::Fail { error } => error, + Outcome::_PhantomVariant(..) => panic!(), + } + } } - } - impl ::std::fmt::Debug for Outcome { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + + impl ::std::fmt::Debug for Outcome { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } } - } - impl ::dafny_runtime::DafnyPrint for Outcome { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - match self { - Outcome::Pass { } => { - write!(_formatter, "Wrappers_Compile.Outcome.Pass")?; - Ok(()) - }, - Outcome::Fail { error, } => { - write!(_formatter, "Wrappers_Compile.Outcome.Fail(")?; - ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - }, - Outcome::_PhantomVariant(..) => {panic!()} - } + + impl ::dafny_runtime::DafnyPrint for Outcome { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Outcome::Pass {} => { + write!(_formatter, "r#_Wrappers_Compile.Outcome.Pass")?; + Ok(()) + } + Outcome::Fail { error } => { + write!(_formatter, "r#_Wrappers_Compile.Outcome.Fail(")?; + ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Outcome::_PhantomVariant(..) => { + panic!() + } + } + } } - } - impl Eq for Outcome {} - impl ::std::hash::Hash for Outcome { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Outcome::Pass { } => { - - }, - Outcome::Fail { error, } => { - error.hash(_state) - }, - Outcome::_PhantomVariant(..) => {panic!()} - } + + impl Eq for Outcome {} + + impl ::std::hash::Hash for Outcome { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Outcome::Pass {} => {} + Outcome::Fail { error } => error.hash(_state), + Outcome::_PhantomVariant(..) => { + panic!() + } + } + } } - } - impl ::std::default::Default for Outcome { - fn default() -> Outcome { - Outcome::Pass {} + + impl ::std::default::Default + for Outcome + { + fn default() -> Outcome { + Outcome::Pass {} + } } - } - impl ::std::convert::AsRef> for &Outcome { - fn as_ref(&self) -> Self { - self + + impl ::std::convert::AsRef> for &Outcome { + fn as_ref(&self) -> Self { + self + } } - } } pub mod r#_StandardLibrary_Compile_dUInt_Compile { - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn UInt8Less(a: u8, b: u8) -> bool { - a < b - } - pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { - s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() - } - pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { - s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() - } - pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> bool { - s.cardinality() < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() - } - pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 256) as u8; - let mut b1: u8 = (x % 256) as u8; - ::dafny_runtime::seq![b0, b1] - } - pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { - let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; - x0 + s.get(&::dafny_runtime::int!(1)) as u16 - } - pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 16777216) as u8; - let mut x0: u32 = x - b0 as u32 * 16777216; - let mut b1: u8 = (x0 / 65536) as u8; - let mut x1: u32 = x0 - b1 as u32 * 65536; - let mut b2: u8 = (x1 / 256) as u8; - let mut b3: u8 = (x1 % 256) as u8; - ::dafny_runtime::seq![b0, b1, b2, b3] - } - pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { - let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; - let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; - let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; - x2 + s.get(&::dafny_runtime::int!(3)) as u32 - } - pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 72057594037927936) as u8; - let mut x0: u64 = x - b0 as u64 * 72057594037927936; - let mut b1: u8 = (x0 / 281474976710656) as u8; - let mut x1: u64 = x0 - b1 as u64 * 281474976710656; - let mut b2: u8 = (x1 / 1099511627776) as u8; - let mut x2: u64 = x1 - b2 as u64 * 1099511627776; - let mut b3: u8 = (x2 / 4294967296) as u8; - let mut x3: u64 = x2 - b3 as u64 * 4294967296; - let mut b4: u8 = (x3 / 16777216) as u8; - let mut x4: u64 = x3 - b4 as u64 * 16777216; - let mut b5: u8 = (x4 / 65536) as u8; - let mut x5: u64 = x4 - b5 as u64 * 65536; - let mut b6: u8 = (x5 / 256) as u8; - let mut b7: u8 = (x5 % 256) as u8; - ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] - } - pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { - let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; - let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; - let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; - let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; - let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; - let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; - let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; - let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; - x - } - pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"65536") - } - pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"4294967296") - } - pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"18446744073709551616") - } - pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"2147483648") - } - pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"9223372036854775808") - } - } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - write!(_formatter, "StandardLibrary_Compile.UInt_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn UInt8Less(a: u8, b: u8) -> bool { + a < b + } + pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() + } + pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() + } + pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> bool { + s.cardinality() + < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() + } + pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 256) as u8; + let mut b1: u8 = (x % 256) as u8; + ::dafny_runtime::seq![b0, b1] + } + pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { + let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; + x0 + s.get(&::dafny_runtime::int!(1)) as u16 + } + pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 16777216) as u8; + let mut x0: u32 = x - b0 as u32 * 16777216; + let mut b1: u8 = (x0 / 65536) as u8; + let mut x1: u32 = x0 - b1 as u32 * 65536; + let mut b2: u8 = (x1 / 256) as u8; + let mut b3: u8 = (x1 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3] + } + pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { + let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; + let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; + let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; + x2 + s.get(&::dafny_runtime::int!(3)) as u32 + } + pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { + let mut b0: u8 = (x / 72057594037927936) as u8; + let mut x0: u64 = x - b0 as u64 * 72057594037927936; + let mut b1: u8 = (x0 / 281474976710656) as u8; + let mut x1: u64 = x0 - b1 as u64 * 281474976710656; + let mut b2: u8 = (x1 / 1099511627776) as u8; + let mut x2: u64 = x1 - b2 as u64 * 1099511627776; + let mut b3: u8 = (x2 / 4294967296) as u8; + let mut x3: u64 = x2 - b3 as u64 * 4294967296; + let mut b4: u8 = (x3 / 16777216) as u8; + let mut x4: u64 = x3 - b4 as u64 * 16777216; + let mut b5: u8 = (x4 / 65536) as u8; + let mut x5: u64 = x4 - b5 as u64 * 65536; + let mut b6: u8 = (x5 / 256) as u8; + let mut b7: u8 = (x5 % 256) as u8; + ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] + } + pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { + let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; + let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; + let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; + let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; + let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; + let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; + let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; + let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; + x + } + pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"65536") + } + pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"4294967296") + } + pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"18446744073709551616") + } + pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"2147483648") + } + pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { + ::dafny_runtime::int!(b"9223372036854775808") + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint8(pub u8); - impl ::std::default::Default for uint8 { - fn default() -> Self { - uint8(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint8(pub u8); + + impl ::std::default::Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for uint8 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for uint8 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for uint8 { - type Target = u8; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for uint8 { + type Target = u8; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint16(pub u16); - impl ::std::default::Default for uint16 { - fn default() -> Self { - uint16(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint16(pub u16); + + impl ::std::default::Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for uint16 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for uint16 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for uint16 { - type Target = u16; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for uint16 { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint32(pub u32); - impl ::std::default::Default for uint32 { - fn default() -> Self { - uint32(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint32(pub u32); + + impl ::std::default::Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for uint32 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for uint32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for uint32 { - type Target = u32; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for uint32 { + type Target = u32; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint64(pub u64); - impl ::std::default::Default for uint64 { - fn default() -> Self { - uint64(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct uint64(pub u64); + + impl ::std::default::Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for uint64 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for uint64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for uint64 { - type Target = u64; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for uint64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct int32(pub i32); - impl ::std::default::Default for int32 { - fn default() -> Self { - int32(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int32(pub i32); + + impl ::std::default::Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for int32 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for int32 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for int32 { - type Target = i32; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for int32 { + type Target = i32; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct int64(pub i64); - impl ::std::default::Default for int64 { - fn default() -> Self { - int64(::std::default::Default::default()) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct int64(pub i64); + + impl ::std::default::Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) + } } - } - impl ::dafny_runtime::DafnyPrint for int64 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for int64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for int64 { - type Target = i64; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for int64 { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct posInt64(pub u64); - impl ::std::default::Default for posInt64 { - fn default() -> Self { - posInt64(1) + + #[derive(Clone, PartialEq)] + #[repr(transparent)] + pub struct posInt64(pub u64); + + impl ::std::default::Default for posInt64 { + fn default() -> Self { + posInt64(1) + } } - } - impl ::dafny_runtime::DafnyPrint for posInt64 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, in_seq: bool) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + + impl ::dafny_runtime::DafnyPrint for posInt64 { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + in_seq: bool, + ) -> ::std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) + } } - } - impl ::std::ops::Deref for posInt64 { - type Target = u64; - fn deref(&self) -> &Self::Target { - &self.0 + + impl ::std::ops::Deref for posInt64 { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } } - } - pub type seq16 = ::dafny_runtime::Sequence; - pub type seq32 = ::dafny_runtime::Sequence; - pub type seq64 = ::dafny_runtime::Sequence; + + pub type seq16 = ::dafny_runtime::Sequence; + + pub type seq32 = ::dafny_runtime::Sequence; + + pub type seq64 = ::dafny_runtime::Sequence; } pub mod r#_StandardLibrary_Compile { - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn Join<_T: ::dafny_runtime::DafnyType>(ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, joiner: &::dafny_runtime::Sequence<_T>) -> ::dafny_runtime::Sequence<_T> { - let mut _accumulator: ::dafny_runtime::Sequence<_T> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; - let mut ss = ss.clone(); - let mut joiner = joiner.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if ss.cardinality() == ::dafny_runtime::int!(1) { - return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); - } else { - _accumulator = _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); - let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ss.drop(&::dafny_runtime::int!(1)); - let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); - ss = _in0.clone(); - joiner = _in1.clone(); - continue 'TAIL_CALL_START; - } - } - } - pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { - let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; - let mut s = s.clone(); - let mut delim = delim.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - let mut i: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(&s, &delim, &::dafny_runtime::int!(0)); - if matches!((&i).as_ref(), super::r#_Wrappers_Compile::Option::Some{ .. }) { - _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); - let mut _in2: ::dafny_runtime::Sequence<_T> = s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); - let mut _in3: _T = delim.clone(); - s = _in2.clone(); - delim = _in3.clone(); - continue 'TAIL_CALL_START; - } else { - return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); - } - } - } - pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { - let mut i: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(s, delim, &::dafny_runtime::int!(0)); - (s.take(i.value()), s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))),) - } - pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, delim: &_T) -> ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> { - let mut valueOrError0: ::std::rc::Rc> = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>(s, delim, &::dafny_runtime::int!(0)); - if valueOrError0.IsFailure() { - (valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>()/* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */) - } else { - let mut i: super::_System::nat = (valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>::Some { - value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1))),) - }) - } - } - pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Sequence<_T>, c: &_T, i: &super::_System::nat) -> ::std::rc::Rc> { - super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>(s, { - let c: _T = c.clone(); - &({ - let mut c = c.clone(); - ::std::rc::Rc::new(move |x: &_T| -> bool { - x.clone() == c.clone() - }) + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn Join<_T: ::dafny_runtime::DafnyType>( + ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, + joiner: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut ss = ss.clone(); + let mut joiner = joiner.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if ss.cardinality() == ::dafny_runtime::int!(1) { + return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); + } else { + _accumulator = + _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); + let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ss.drop(&::dafny_runtime::int!(1)); + let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); + ss = _in0.clone(); + joiner = _in1.clone(); + continue 'TAIL_CALL_START; + } + } + } + pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut delim = delim.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + let mut i: ::std::rc::Rc< + super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + &s, + &delim, + &::dafny_runtime::int!(0), + ); + if matches!( + (&i).as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); + let mut _in2: ::dafny_runtime::Sequence<_T> = + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); + let mut _in3: _T = delim.clone(); + s = _in2.clone(); + delim = _in3.clone(); + continue 'TAIL_CALL_START; + } else { + return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); + } + } + } + pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { + let mut i: ::std::rc::Rc< + super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + ( + s.take(i.value()), + s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), + ) + } + pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + delim: &_T, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Option<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>, + > { + let mut valueOrError0: ::std::rc::Rc< + super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, + > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( + s, + delim, + &::dafny_runtime::int!(0), + ); + if valueOrError0.IsFailure() { + valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() + /* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */ + } else { + let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */; + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<( + ::dafny_runtime::Sequence<_T>, + ::dafny_runtime::Sequence<_T>, + )>::Some { + value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), }) - }, i) - } - pub fn FindIndex<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>, f: &::std::rc::Rc bool>, i: &super::_System::nat) -> ::std::rc::Rc> { - let mut s = s.clone(); - let mut f = f.clone(); - let mut i = i.clone(); - 'TAIL_CALL_START: loop { - if i.clone() == s.cardinality() { - return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}); - } else { - if (&f)(&s.get(&i)) { - return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: i.clone() - }); - } else { - let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); - let mut _in5: ::std::rc::Rc bool> = f.clone(); - let mut _in6: ::dafny_runtime::DafnyInt = i.clone() + ::dafny_runtime::int!(1); - s = _in4.clone(); - f = _in5.clone(); - i = _in6.clone(); - continue 'TAIL_CALL_START; - } - } - } - } - pub fn Filter<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>, f: &::std::rc::Rc bool>) -> ::dafny_runtime::Sequence<_T> { - let mut _accumulator: ::dafny_runtime::Sequence<_T> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; - let mut s = s.clone(); - let mut f = f.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if s.cardinality() == ::dafny_runtime::int!(0) { - return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); - } else { - if (&f)(&s.get(&::dafny_runtime::int!(0))) { - _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); - let mut _in7: ::dafny_runtime::Sequence<_T> = s.drop(&::dafny_runtime::int!(1)); - let mut _in8: ::std::rc::Rc bool> = f.clone(); - s = _in7.clone(); - f = _in8.clone(); - continue 'TAIL_CALL_START; - } else { - let mut _in9: ::dafny_runtime::Sequence<_T> = s.drop(&::dafny_runtime::int!(1)); - let mut _in10: ::std::rc::Rc bool> = f.clone(); - s = _in9.clone(); - f = _in10.clone(); - continue 'TAIL_CALL_START; - } - } - } - } - pub fn Min(a: &::dafny_runtime::DafnyInt, b: &::dafny_runtime::DafnyInt) -> ::dafny_runtime::DafnyInt { - if a.clone() < b.clone() { - a.clone() - } else { - b.clone() - } - } - pub fn Fill<_T: ::dafny_runtime::DafnyType>(value: &_T, n: &super::_System::nat) -> ::dafny_runtime::Sequence<_T> { - { - let _initializer = { - let value: _T = value.clone(); - { - let mut value = value.clone(); - ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { - value.clone() - }) + } + } + pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Sequence<_T>, + c: &_T, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( + s, + { + let c: _T = c.clone(); + &({ + let mut c = c.clone(); + ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) + }) + }, + i, + ) + } + pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + i: &::dafny_runtime::_System::nat, + ) -> ::std::rc::Rc> + { + let mut s = s.clone(); + let mut f = f.clone(); + let mut i = i.clone(); + 'TAIL_CALL_START: loop { + if i.clone() == s.cardinality() { + return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::None {}); + } else { + if (&f)(&s.get(&i)) { + return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< + ::dafny_runtime::_System::nat, + >::Some { + value: i.clone(), + }); + } else { + let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); + let mut _in5: ::std::rc::Rc bool> = f.clone(); + let mut _in6: ::dafny_runtime::DafnyInt = + i.clone() + ::dafny_runtime::int!(1); + s = _in4.clone(); + f = _in5.clone(); + i = _in6.clone(); + continue 'TAIL_CALL_START; + } + } + } + } + pub fn Filter<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + f: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<_T> { + let mut _accumulator: ::dafny_runtime::Sequence<_T> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; + let mut s = s.clone(); + let mut f = f.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); + } else { + if (&f)(&s.get(&::dafny_runtime::int!(0))) { + _accumulator = _accumulator + .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); + let mut _in7: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in8: ::std::rc::Rc bool> = f.clone(); + s = _in7.clone(); + f = _in8.clone(); + continue 'TAIL_CALL_START; + } else { + let mut _in9: ::dafny_runtime::Sequence<_T> = + s.drop(&::dafny_runtime::int!(1)); + let mut _in10: ::std::rc::Rc bool> = f.clone(); + s = _in9.clone(); + f = _in10.clone(); + continue 'TAIL_CALL_START; } - }; - ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()).map(|i| _initializer(&i)).collect::<::dafny_runtime::Sequence<_>>() + } + } } - } - pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>(s: &::dafny_runtime::Sequence<_T>) -> *mut [_T] { - let mut _init0: ::std::rc::Rc _T> = { - let s: ::dafny_runtime::Sequence<_T> = s.clone(); - ({ - let s = s.clone(); - ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { - s.get(i) - })}) - }; - ::dafny_runtime::array::initialize(&s.cardinality(), _init0) - } - pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, b: &::dafny_runtime::Sequence<_T>, less: &::std::rc::Rc bool>) -> bool { - Self::LexicographicLessOrEqualAux(a, b, less, &::dafny_runtime::int!(0)) - } - pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, b: &::dafny_runtime::Sequence<_T>, less: &::std::rc::Rc bool>, lengthOfCommonPrefix: &super::_System::nat) -> bool { - lengthOfCommonPrefix.clone() <= b.cardinality() && ::dafny_runtime::Forall::forall(&::dafny_runtime::Range(::dafny_runtime::int!(0), lengthOfCommonPrefix.clone()), { - let a = a.clone(); - let b = b.clone(); - ::std::rc::Rc::new(move |i| a.get(i) == b.get(i))}) && (lengthOfCommonPrefix.clone() == a.cardinality() || lengthOfCommonPrefix.clone() < b.cardinality() && ((less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))))) - } - pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>(s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, less: &::std::rc::Rc bool>) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { - let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; - let mut s = s.clone(); - let mut less = less.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if s.clone() == ::dafny_runtime::set!{} { - return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>)); - } else { - return (&({ - let mut s = s.clone(); - let mut less = less.clone(); - ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + pub fn Min( + a: &::dafny_runtime::DafnyInt, + b: &::dafny_runtime::DafnyInt, + ) -> ::dafny_runtime::DafnyInt { + if a.clone() < b.clone() { + a.clone() + } else { + b.clone() + } + } + pub fn Fill<_T: ::dafny_runtime::DafnyType>( + value: &_T, + n: &::dafny_runtime::_System::nat, + ) -> ::dafny_runtime::Sequence<_T> { + { + let _initializer = { + let value: _T = value.clone(); + { + let mut value = value.clone(); + ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { + value.clone() + }) + } + }; + ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) + .map(|i| _initializer(&i)) + .collect::<::dafny_runtime::Sequence<_>>() + } + } + pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( + s: &::dafny_runtime::Sequence<_T>, + ) -> ::dafny_runtime::Object<[_T]> { + let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); + let mut _init0: ::std::rc::Rc _T> = { + let s: ::dafny_runtime::Sequence<_T> = s.clone(); + { + let mut s = s.clone(); + ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) + } + }; + let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = + ::dafny_runtime::array::placebos_usize_rcmut::<_T>(s.cardinality().as_usize()); + for r#__i0_0 in + ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) + { + { + let __idx0 = + ::from(r#__i0_0.clone()).unwrap(); + ::dafny_runtime::md!(_nw0.clone())[__idx0] = ::std::mem::MaybeUninit::new( + (&_init0)(&::dafny_runtime::int!(r#__i0_0.clone())), + ); + } + } + a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_rcmut( + _nw0.clone(), + )); + return a.read(); + } + pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + ) -> bool { + ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) + }).as_ref()) + } + pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + b: &::dafny_runtime::Sequence<_T>, + less: &::std::rc::Rc bool>, + lengthOfCommonPrefix: &::dafny_runtime::_System::nat, + ) -> bool { + lengthOfCommonPrefix.clone() <= b.cardinality() + && ::dafny_runtime::integer_range( + ::dafny_runtime::int!(0), + lengthOfCommonPrefix.clone(), + ) + .all( + ({ + let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) + || a.get(&i) == b.get(&i) + }, + ) + }) + .as_ref(), + ) + && (lengthOfCommonPrefix.clone() == a.cardinality() + || lengthOfCommonPrefix.clone() < b.cardinality() + && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) + } + pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { + let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; + let mut s = s.clone(); + let mut less = less.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.clone() == ::dafny_runtime::set! {} { + return _accumulator.concat( + &(::dafny_runtime::seq![] + as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), + ); + } else { + return (&({ + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); 'label_goto__ASSIGN_SUCH_THAT_0: loop { - for r#__assign_such_that_0 in (&s).iter() { + for r#__assign_such_that_0 in (&s).iter().cloned() { a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); if s.contains(&a.read()) && super::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { break 'label_goto__ASSIGN_SUCH_THAT_0; } - }; + } panic!("Halt"); break; }; ::dafny_runtime::seq![a.read()].concat(&super::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) }) - }))(&::dafny_runtime::int!(0)); + }))(&::dafny_runtime::int!(0)); + } + } + } + pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( + a: &::dafny_runtime::Sequence<_T>, + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { + s.contains(a) && s.iter().cloned().all(({ + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); + ::std::rc::Rc::new(move |r#__forall_var_1: ::dafny_runtime::Sequence<_T>| -> bool { + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) + }).as_ref()) } - } - } - pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>(a: &::dafny_runtime::Sequence<_T>, s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, less: &::std::rc::Rc bool>) -> bool { - s.contains(a) && - ::dafny_runtime::Forall::forall(s, { - let a = a.clone(); - let less = less.clone(); - ::std::rc::Rc::new(move |z| Self::LexicographicLessOrEqual(&a, z, &less)) - }) - } - } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - write!(_formatter, "StandardLibrary_Compile.__default") - } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) } - } } +pub mod UTF8 { + pub struct _default {} -pub mod r#_UTF8_Compile { - use dafny_runtime::dafny_runtime_conversions; - use dafny_runtime::ToPrimitive; - use dafny_runtime::BigInt; - use crate::UTF8; - pub struct _default {} - impl _default { - pub fn new() -> Self { - _default {} - } - pub fn Encode(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { - UTF8::UTF8::Encode(s) - } - pub fn Decode(b: &::dafny_runtime::Sequence) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { - UTF8::UTF8::Decode(b) - } - - pub fn CreateEncodeSuccess(bytes: &super::r#_UTF8_Compile::ValidUTF8Bytes) -> ::std::rc::Rc>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Success {value: (bytes.clone()) }) - } - pub fn CreateEncodeFailure(error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::>::Failure {error: (error.clone()) }) - } - pub fn CreateDecodeSuccess(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Success {value: (s.clone()) }) - } - pub fn CreateDecodeFailure(error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Failure {error: (error.clone()) }) - } - pub fn IsASCIIString(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> bool { - true - } - pub fn EncodeAscii(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> super::r#_UTF8_Compile::ValidUTF8Bytes { - let mut _accumulator: super::r#_UTF8_Compile::ValidUTF8Bytes = ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; - let mut s = s.clone(); - 'TAIL_CALL_START: loop { - if s.cardinality() == ::dafny_runtime::DafnyInt::from(0) { - return _accumulator.concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); - } else { - let mut x: ::dafny_runtime::Sequence = ::dafny_runtime::seq![0 as u8]; - _accumulator = _accumulator.concat(&x); - let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = s.drop(&::dafny_runtime::DafnyInt::from(1)); - s = _in0.clone(); - continue 'TAIL_CALL_START; - } - } - } - pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { - (/*optimized*/0) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/127) - } - pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { - (/*optimized*/194) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/223) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) - } - pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { - s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/224) && ((/*optimized*/160) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || (/*optimized*/225) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/236) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/237) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/159)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) || (/*optimized*/238) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/239) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) - } - pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { - s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/240) && ((/*optimized*/144) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) || (/*optimized*/241) <= s.get(&::dafny_runtime::DafnyInt::from(0)) && s.get(&::dafny_runtime::DafnyInt::from(0)) <= (/*optimized*/243) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) || s.get(&::dafny_runtime::DafnyInt::from(0)) == (/*optimized*/244) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(1)) && s.get(&::dafny_runtime::DafnyInt::from(1)) <= (/*optimized*/143)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(2)) && s.get(&::dafny_runtime::DafnyInt::from(2)) <= (/*optimized*/191)) && ((/*optimized*/128) <= s.get(&::dafny_runtime::DafnyInt::from(3)) && s.get(&::dafny_runtime::DafnyInt::from(3)) <= (/*optimized*/191)) - } - pub fn ValidUTF8Range(a: &::dafny_runtime::Sequence, lo: &super::_System::nat, hi: &super::_System::nat) -> bool { - let mut a = a.clone(); - let mut lo = lo.clone(); - let mut hi = hi.clone(); - 'TAIL_CALL_START: loop { - if lo.clone() == hi.clone() { - return true; - } else { - let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); - if <(super::r#_UTF8_Compile::_default)>::Uses1Byte(&r) { - let mut _in1: ::dafny_runtime::Sequence = a.clone(); - let mut _in2: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(1); - let mut _in3: super::_System::nat = hi.clone(); - a = _in1.clone(); - lo = _in2.clone(); - hi = _in3.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::DafnyInt::from(2) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses2Bytes(&r) { - let mut _in4: ::dafny_runtime::Sequence = a.clone(); - let mut _in5: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(2); - let mut _in6: super::_System::nat = hi.clone(); - a = _in4.clone(); - lo = _in5.clone(); - hi = _in6.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::DafnyInt::from(3) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses3Bytes(&r) { - let mut _in7: ::dafny_runtime::Sequence = a.clone(); - let mut _in8: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(3); - let mut _in9: super::_System::nat = hi.clone(); - a = _in7.clone(); - lo = _in8.clone(); - hi = _in9.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::DafnyInt::from(4) <= r.cardinality() && <(super::r#_UTF8_Compile::_default)>::Uses4Bytes(&r) { - let mut _in10: ::dafny_runtime::Sequence = a.clone(); - let mut _in11: ::dafny_runtime::DafnyInt = lo.clone() + ::dafny_runtime::DafnyInt::from(4); - let mut _in12: super::_System::nat = hi.clone(); - a = _in10.clone(); - lo = _in11.clone(); - hi = _in12.clone(); - continue 'TAIL_CALL_START; + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn CreateEncodeSuccess( + bytes: &super::UTF8::ValidUTF8Bytes, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: bytes.clone(), + }) + } + pub fn CreateEncodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn CreateDecodeSuccess( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Success { + value: s.clone(), + }) + } + pub fn CreateDecodeFailure( + error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Failure { + error: error.clone(), + }) + } + pub fn IsASCIIString( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> bool { + let mut _hresult: bool = ::default(); + let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); + for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { + if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { + _hresult = false; + return _hresult; + } + } + _hresult = true; + return _hresult; + return _hresult; + } + pub fn EncodeAscii( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> super::UTF8::ValidUTF8Bytes { + let mut _accumulator: super::UTF8::ValidUTF8Bytes = + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; + let mut s = s.clone(); + let mut _accumulator = _accumulator.clone(); + 'TAIL_CALL_START: loop { + if s.cardinality() == ::dafny_runtime::int!(0) { + return _accumulator + .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); } else { - return false; + let mut x: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; + _accumulator = _accumulator.concat(&x); + let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + s.drop(&::dafny_runtime::int!(1)); + s = _in11.clone(); + continue 'TAIL_CALL_START; } - } } - } } - } - } - pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { - <(super::r#_UTF8_Compile::_default)>::ValidUTF8Range(s, &::dafny_runtime::DafnyInt::from(0), &s.cardinality()) - } - } - impl ::std::default::Default for _default { - fn default() -> Self { - _default::new() - } - } - impl ::dafny_runtime::DafnyPrint for _default { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - write!(_formatter, "UTF8_Compile.__default") + pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { + 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 + } + pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { + 194 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 223 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + } + pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 224 + && (160 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 225 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 236 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 237 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 159) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + || 238 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 239 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + } + pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { + s.get(&::dafny_runtime::int!(0)) == 240 + && (144 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || 241 <= s.get(&::dafny_runtime::int!(0)) + && s.get(&::dafny_runtime::int!(0)) <= 243 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + || s.get(&::dafny_runtime::int!(0)) == 244 + && (128 <= s.get(&::dafny_runtime::int!(1)) + && s.get(&::dafny_runtime::int!(1)) <= 143) + && (128 <= s.get(&::dafny_runtime::int!(2)) + && s.get(&::dafny_runtime::int!(2)) <= 191) + && (128 <= s.get(&::dafny_runtime::int!(3)) + && s.get(&::dafny_runtime::int!(3)) <= 191) + } + pub fn ValidUTF8Range( + a: &::dafny_runtime::Sequence, + lo: &::dafny_runtime::_System::nat, + hi: &::dafny_runtime::_System::nat, + ) -> bool { + let mut a = a.clone(); + let mut lo = lo.clone(); + let mut hi = hi.clone(); + 'TAIL_CALL_START: loop { + if lo.clone() == hi.clone() { + return true; + } else { + let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); + if super::UTF8::_default::Uses1Byte(&r) { + let mut _in12: ::dafny_runtime::Sequence = a.clone(); + let mut _in13: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(1); + let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); + a = _in12.clone(); + lo = _in13.clone(); + hi = _in14.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(2) <= r.cardinality() + && super::UTF8::_default::Uses2Bytes(&r) + { + let mut _in15: ::dafny_runtime::Sequence = a.clone(); + let mut _in16: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(2); + let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); + a = _in15.clone(); + lo = _in16.clone(); + hi = _in17.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(3) <= r.cardinality() + && super::UTF8::_default::Uses3Bytes(&r) + { + let mut _in18: ::dafny_runtime::Sequence = a.clone(); + let mut _in19: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(3); + let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); + a = _in18.clone(); + lo = _in19.clone(); + hi = _in20.clone(); + continue 'TAIL_CALL_START; + } else { + if ::dafny_runtime::int!(4) <= r.cardinality() + && super::UTF8::_default::Uses4Bytes(&r) + { + let mut _in21: ::dafny_runtime::Sequence = a.clone(); + let mut _in22: ::dafny_runtime::DafnyInt = + lo.clone() + ::dafny_runtime::int!(4); + let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); + a = _in21.clone(); + lo = _in22.clone(); + hi = _in23.clone(); + continue 'TAIL_CALL_START; + } else { + return false; + } + } + } + } + } + } + } + pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { + super::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) + } } - } - impl ::std::cmp::PartialEq for _default { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + + pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; + + pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { + ::dafny_runtime::seq![] as ::dafny_runtime::Sequence } - } - pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; } pub mod r#_StandardLibraryInterop_Compile { - pub struct WrappersInterop {} - impl WrappersInterop { - pub fn new() -> Self { - WrappersInterop {} - } - pub fn _allocated() -> *mut Self { - ::dafny_runtime::allocate::() - } - pub fn CreateStringSome(s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>) -> ::std::rc::Rc>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: s.clone() - }) - } - pub fn CreateStringNone() -> ::std::rc::Rc>> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::None {}) - } - pub fn CreateBooleanSome(b: bool) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: b - }) - } - pub fn CreateBooleanNone() -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } - } - impl ::std::default::Default for WrappersInterop { - fn default() -> Self { - WrappersInterop::new() - } - } - impl ::dafny_runtime::DafnyPrint for WrappersInterop { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { - write!(_formatter, "StandardLibraryInterop_Compile.WrappersInterop") - } - } - impl ::std::cmp::PartialEq for WrappersInterop { - fn eq(&self, other: &Self) -> bool { - ::std::ptr::eq(self, other) + pub struct WrappersInterop {} + + impl WrappersInterop { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn CreateStringSome( + s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::Some { + value: s.clone(), + }) + } + pub fn CreateStringNone() -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Option< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >::None {}) + } + pub fn CreateBooleanSome( + b: bool, + ) -> ::std::rc::Rc> { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) + } + pub fn CreateBooleanNone() -> ::std::rc::Rc> { + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) + } } - } } -pub mod _module { - -} \ No newline at end of file +pub mod _module {} diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs index 8ba31f253..789b96b02 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs @@ -11,7 +11,7 @@ mod TestUTF8 { let unicodeString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); let expectedBytes = dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; - let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&unicodeString); + let _r = implementation_from_dafny::UTF8::_default::Encode(&unicodeString); if _r.IsFailure() { panic!("Encode failed"); } @@ -27,7 +27,7 @@ mod TestUTF8 { ::dafny_runtime::DafnyCharUTF16('c' as u16), ::dafny_runtime::DafnyCharUTF16(0xD800) ]; - let encoded = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&invalidUnicode); + let encoded = implementation_from_dafny::UTF8::_default::Encode(&invalidUnicode); assert!(encoded.IsFailure()); } @@ -36,7 +36,7 @@ mod TestUTF8 { let unicodeBytes = ::dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; assert!( - implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes( + implementation_from_dafny::UTF8::_default::Uses2Bytes( &::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8] ) ); @@ -45,21 +45,21 @@ mod TestUTF8 { unicodeBytes.slice(&::dafny_runtime::int!(5), &::dafny_runtime::int!(9)) ); assert!( - implementation_from_dafny::r#_UTF8_Compile::_default::ValidUTF8Range( + implementation_from_dafny::UTF8::_default::ValidUTF8Range( &unicodeBytes, &::dafny_runtime::int!(7), &::dafny_runtime::int!(9) ) ); assert!( - implementation_from_dafny::r#_UTF8_Compile::_default::ValidUTF8Range( + implementation_from_dafny::UTF8::_default::ValidUTF8Range( &unicodeBytes, &::dafny_runtime::int!(0), &::dafny_runtime::int!(9) ) ); let expectedString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); - let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&unicodeBytes); + let _r = implementation_from_dafny::UTF8::_default::Decode(&unicodeBytes); if _r.IsFailure() { panic!("Decode failed"); } @@ -72,7 +72,7 @@ mod TestUTF8 { let invalidUnicode = ::dafny_runtime::seq![ 0x61 as u8, 0x62 as u8, 0x63 as u8, 0xED as u8, 0xA0 as u8, 0x80 as u8 ]; - let _r = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&invalidUnicode); + let _r = implementation_from_dafny::UTF8::_default::Decode(&invalidUnicode); assert!(_r.IsFailure()); } @@ -80,66 +80,66 @@ mod TestUTF8 { fn Test1Byte() { // Null let mut decoded = ::dafny_runtime::string_utf16_of("\u{0000}"); - let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); let mut encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x00 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); let mut redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); // Space decoded = ::dafny_runtime::string_utf16_of(" "); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x20 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("$"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x24 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("0"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x30 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("A"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x41 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("a"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0x61 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); @@ -148,42 +148,42 @@ mod TestUTF8 { #[test] fn Test2Bytes() { let mut decoded = ::dafny_runtime::string_utf16_of("\u{00A3}"); - let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); let mut encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA3 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); + let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); let mut redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{00A9}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA9 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{00AE}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xAE as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{03C0}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!(::dafny_runtime::seq![0xCF as u8, 0x80 as u8], encoded); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); @@ -192,67 +192,67 @@ mod TestUTF8 { #[test] fn Test3Bytes() { let mut decoded = ::dafny_runtime::string_utf16_of("\u{2386}"); - let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); let mut encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x86 as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); + let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); let mut redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{2387}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x87 as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{231B}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xE2 as u8, 0x8C as u8, 0x9B as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{1D78}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xE1 as u8, 0xB5 as u8, 0xB8 as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{732B}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xE7 as u8, 0x8C as u8, 0xAB as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); @@ -264,7 +264,7 @@ mod TestUTF8 { ::dafny_runtime::DafnyCharUTF16(0xD808), ::dafny_runtime::DafnyCharUTF16(0xDC00) ]; - let mut _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); println!( "{}", ::dafny_runtime::DafnyPrintWrapper(&_r.as_ref().clone()) @@ -275,21 +275,21 @@ mod TestUTF8 { ::dafny_runtime::seq![0xF0 as u8, 0x92 as u8, 0x80 as u8, 0x80 as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses4Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); + let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); let mut redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); decoded = ::dafny_runtime::string_utf16_of("\u{1D7C1}"); - _r = implementation_from_dafny::r#_UTF8_Compile::_default::Encode(&decoded); + _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); assert!(!_r.IsFailure()); encoded = _r.Extract(); assert_eq!( ::dafny_runtime::seq![0xF0 as u8, 0x9D as u8, 0x9F as u8, 0x81 as u8], encoded ); - assert!(implementation_from_dafny::r#_UTF8_Compile::_default::Uses4Bytes(&encoded)); - _r2 = implementation_from_dafny::r#_UTF8_Compile::_default::Decode(&encoded); + assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); + _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); assert!(!_r2.IsFailure()); redecoded = _r2.Extract(); assert_eq!(decoded, redecoded); diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml b/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml index 08fbd06ff..872ba7130 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml @@ -9,3 +9,4 @@ paste = "1.0" num = "0.4" itertools = "0.11.0" as-any = "0.3.1" +nightly-crimes = "=1.0.0" \ No newline at end of file diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs b/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs index 68171ac08..4ad5e3db1 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs @@ -1,28 +1,43 @@ #[cfg(test)] mod tests; -use std::{any::Any, borrow::Borrow, cell::{RefCell, UnsafeCell}, cmp::Ordering, collections::{HashMap, HashSet}, fmt::{Debug, Display, Formatter}, hash::{Hash, Hasher}, mem, ops::{Add, Deref, Div, Mul, Neg, Rem, Sub}, rc::Rc}; + +mod system; +pub use mem::MaybeUninit; use num::{bigint::ParseBigIntError, Integer, Num, One, Signed}; pub use once_cell::unsync::Lazy; -pub use mem::MaybeUninit; +use std::{ + any::Any, + borrow::Borrow, + cell::{RefCell, UnsafeCell}, + cmp::Ordering, + collections::{HashMap, HashSet}, + fmt::{Debug, Display, Formatter}, + hash::{Hash, Hasher}, + mem, + ops::{Add, Deref, Div, Mul, Neg, Rem, Sub}, + rc::{Rc, Weak}, +}; + +pub use system::*; +pub use itertools; pub use num::bigint::BigInt; pub use num::rational::BigRational; pub use num::FromPrimitive; -pub use num::ToPrimitive; pub use num::NumCast; +pub use num::ToPrimitive; pub use num::Zero; -pub use itertools; pub use std::convert::Into; // An atomic box is just a RefCell in Rust pub type SizeT = usize; -pub trait DafnyType: Clone + DafnyPrint + Debug + 'static {} +pub trait DafnyType: Clone + DafnyPrint + 'static {} -impl DafnyType for T where T: Clone + DafnyPrint + Debug + 'static {} +impl DafnyType for T where T: Clone + DafnyPrint + 'static {} pub trait DafnyTypeEq: DafnyType + Hash + Eq {} -impl DafnyTypeEq for T where T: DafnyType + Hash + Eq {} +impl DafnyTypeEq for T where T: DafnyType + Hash + Eq {} // Dafny's type (0) compiles to NontrivialDefault to prevent subset types from being considered as Default if their witness is nonzero pub trait NontrivialDefault { @@ -42,20 +57,20 @@ pub mod dafny_runtime_conversions { pub type DafnyCharUTF16 = crate::DafnyCharUTF16; pub type DafnyClass = *mut T; pub type DafnyArray = *mut [T]; - pub type DafnyArray2 = *mut [DafnyArray]; - pub type DafnyArray3 = *mut [DafnyArray2]; + pub type DafnyArray2 = *mut crate::Array2; + pub type DafnyArray3 = *mut crate::Array3; use num::BigInt; use num::ToPrimitive; use std::collections::HashMap; use std::collections::HashSet; - use std::rc::Rc; use std::hash::Hash; + use std::rc::Rc; - // Conversion to and from Dafny classes + // Conversion to and from Dafny classes. All these methods take ownership of the class. pub unsafe fn dafny_class_to_struct(ptr: DafnyClass) -> T { - ptr.as_ref().unwrap().clone() + *dafny_class_to_boxed_struct(ptr) } pub unsafe fn dafny_class_to_boxed_struct(ptr: DafnyClass) -> Box { Box::from_raw(ptr) @@ -67,17 +82,29 @@ pub mod dafny_runtime_conversions { Box::into_raw(t) } + // Conversions to and from Dafny arrays. They all take ownership + pub unsafe fn dafny_array_to_vec(ptr: DafnyArray) -> Vec { + ptr.as_ref().unwrap().to_vec() + } + pub fn vec_to_dafny_array(array: Vec) -> DafnyArray { + Box::into_raw(array.into_boxed_slice()) + } + pub unsafe fn dafny_array2_to_vec(ptr: DafnyArray2) -> Vec> { + Box::from_raw(ptr).to_vec() + } + pub fn dafny_int_to_bigint(i: &DafnyInt) -> BigInt { i.data.as_ref().clone() } pub fn bigint_to_dafny_int(i: &BigInt) -> DafnyInt { - DafnyInt{data: Rc::new(i.clone())} + DafnyInt { + data: Rc::new(i.clone()), + } } - pub fn dafny_sequence_to_vec( - s: &DafnySequence, - elem_converter: fn(&T) -> X) -> Vec - where T: DafnyType + pub fn dafny_sequence_to_vec(s: &DafnySequence, elem_converter: fn(&T) -> X) -> Vec + where + T: DafnyType, { let mut array: Vec = Vec::with_capacity(s.cardinality_usize()); DafnySequence::::append_recursive(&mut array, s); @@ -85,9 +112,12 @@ pub mod dafny_runtime_conversions { } // Used for external conversions - pub fn vec_to_dafny_sequence(array: &Vec, elem_converter: fn(&X) -> T) - -> DafnySequence - where T: DafnyType + pub fn vec_to_dafny_sequence( + array: &Vec, + elem_converter: fn(&X) -> T, + ) -> DafnySequence + where + T: DafnyType, { let mut result: Vec = Vec::with_capacity(array.len()); for elem in array.iter() { @@ -95,20 +125,31 @@ pub mod dafny_runtime_conversions { } DafnySequence::::from_array_owned(result) } - - pub fn dafny_map_to_hashmap(m: &DafnyMap, converter_k: fn(&K)->K2, converter_v: fn(&V)->V2) -> HashMap - where - K: DafnyTypeEq, V: DafnyTypeEq, - K2: Eq + Hash, V2: Clone + + pub fn dafny_map_to_hashmap( + m: &DafnyMap, + converter_k: fn(&K) -> K2, + converter_v: fn(&V) -> V2, + ) -> HashMap + where + K: DafnyTypeEq, + V: DafnyTypeEq, + K2: Eq + Hash, + V2: Clone, { m.to_hashmap_owned(converter_k, converter_v) } - pub fn hashmap_to_dafny_map(map: &HashMap, converter_k: fn(&K2)->K, converter_v: fn(&V2)->V) - -> DafnyMap - where - K: DafnyTypeEq, V: DafnyTypeEq, - K2: Eq + Hash, V2: Clone + pub fn hashmap_to_dafny_map( + map: &HashMap, + converter_k: fn(&K2) -> K, + converter_v: fn(&V2) -> V, + ) -> DafnyMap + where + K: DafnyTypeEq, + V: DafnyTypeEq, + K2: Eq + Hash, + V2: Clone, { DafnyMap::::from_hashmap(map, converter_k, converter_v) } @@ -128,7 +169,7 @@ pub mod dafny_runtime_conversions { characters.iter().map(|v| v.0).collect::() } } - + // --unicode-chars:false pub mod unicode_chars_false { use crate::Sequence; @@ -140,18 +181,26 @@ pub mod dafny_runtime_conversions { Sequence::from_array_owned(s.encode_utf16().map(|v| crate::DafnyCharUTF16(v)).collect()) } pub fn dafny_string_to_string(s: &DafnyString) -> String { - let characters = s.to_array().as_ref().iter().map(|v| v.0).collect::>(); + let characters = s + .to_array() + .as_ref() + .iter() + .map(|v| v.0) + .collect::>(); String::from_utf16_lossy(&characters) } } - - pub fn set_to_dafny_set(set: &HashSet, converter: fn(&U) -> T) - -> DafnySet - { + + pub fn set_to_dafny_set( + set: &HashSet, + converter: fn(&U) -> T, + ) -> DafnySet { DafnySet::from_iterator(set.iter().map(converter)) } pub fn dafny_set_to_set(set: &DafnySet, converter: fn(&T) -> U) -> HashSet - where T: DafnyTypeEq, U: Clone + Eq + Hash + where + T: DafnyTypeEq, + U: Clone + Eq + Hash, { let mut result: HashSet = HashSet::new(); for s in set.data.iter() { @@ -160,8 +209,13 @@ pub mod dafny_runtime_conversions { result } - pub fn dafny_multiset_to_owned_vec(ms: &DafnyMultiset, converter: fn(&T) -> U) -> Vec - where T: DafnyTypeEq, U: Clone + Eq + pub fn dafny_multiset_to_owned_vec( + ms: &DafnyMultiset, + converter: fn(&T) -> U, + ) -> Vec + where + T: DafnyTypeEq, + U: Clone + Eq, { let mut result: Vec = Vec::new(); for s in ms.data.iter() { @@ -174,16 +228,14 @@ pub mod dafny_runtime_conversions { } pub fn vec_to_dafny_multiset(vec: &Vec, converter: fn(&U) -> T) -> DafnyMultiset - where T: DafnyTypeEq, U: Clone + Eq + Hash + where + T: DafnyTypeEq, + U: Clone + Eq + Hash, { - DafnyMultiset::from_iterator( - vec.into_iter().map(|u: &U| converter(u)) - ) + DafnyMultiset::from_iterator(vec.into_iter().map(|u: &U| converter(u))) } - } - // ************** // Dafny integers // ************** @@ -191,12 +243,15 @@ pub mod dafny_runtime_conversions { // Zero-cost abstraction over a Rc #[derive(Clone)] pub struct DafnyInt { - data: Rc + data: Rc, } impl DafnyInt { - fn new(data: Rc) -> DafnyInt { - DafnyInt{data} + pub fn new(data: Rc) -> DafnyInt { + DafnyInt { data } + } + pub fn as_usize(&self) -> usize { + self.to_usize().unwrap() } } @@ -212,7 +267,7 @@ impl AsRef for DafnyInt { macro_rules! truncate { ($x:expr, $t:ty) => { <$crate::DafnyInt as $crate::Into<$t>>::into($x) - } + }; } impl Into for DafnyInt { @@ -325,7 +380,9 @@ impl Add for DafnyInt { type Output = DafnyInt; fn add(self, rhs: DafnyInt) -> Self::Output { - DafnyInt{data: Rc::new(self.data.as_ref() + rhs.data.as_ref())} + DafnyInt { + data: Rc::new(self.data.as_ref() + rhs.data.as_ref()), + } } } @@ -333,7 +390,9 @@ impl Mul for DafnyInt { type Output = DafnyInt; fn mul(self, rhs: DafnyInt) -> Self::Output { - DafnyInt{data: Rc::new(self.data.as_ref() * rhs.data.as_ref())} + DafnyInt { + data: Rc::new(self.data.as_ref() * rhs.data.as_ref()), + } } } @@ -341,7 +400,9 @@ impl Div for DafnyInt { type Output = DafnyInt; fn div(self, rhs: DafnyInt) -> Self::Output { - DafnyInt{data: Rc::new(self.data.as_ref() / rhs.data.as_ref())} + DafnyInt { + data: Rc::new(self.data.as_ref() / rhs.data.as_ref()), + } } } @@ -349,14 +410,18 @@ impl Sub for DafnyInt { type Output = DafnyInt; fn sub(self, rhs: DafnyInt) -> Self::Output { - DafnyInt{data: Rc::new(self.data.as_ref() - rhs.data.as_ref())} + DafnyInt { + data: Rc::new(self.data.as_ref() - rhs.data.as_ref()), + } } } impl Rem for DafnyInt { type Output = DafnyInt; fn rem(self, rhs: DafnyInt) -> Self::Output { - DafnyInt{data: Rc::new(self.data.as_ref() % rhs.data.as_ref())} + DafnyInt { + data: Rc::new(self.data.as_ref() % rhs.data.as_ref()), + } } } impl Neg for DafnyInt { @@ -364,13 +429,17 @@ impl Neg for DafnyInt { #[inline] fn neg(self) -> Self::Output { - DafnyInt{data: Rc::new(-self.data.as_ref())} + DafnyInt { + data: Rc::new(-self.data.as_ref()), + } } } impl Zero for DafnyInt { #[inline] fn zero() -> Self { - DafnyInt{data: Rc::new(BigInt::zero())} + DafnyInt { + data: Rc::new(BigInt::zero()), + } } #[inline] fn is_zero(&self) -> bool { @@ -380,7 +449,9 @@ impl Zero for DafnyInt { impl One for DafnyInt { #[inline] fn one() -> Self { - DafnyInt{data: Rc::new(BigInt::one())} + DafnyInt { + data: Rc::new(BigInt::one()), + } } } impl Num for DafnyInt { @@ -388,7 +459,9 @@ impl Num for DafnyInt { #[inline] fn from_str_radix(s: &str, radix: u32) -> Result { - Ok(DafnyInt{data: Rc::new(BigInt::from_str_radix(s, radix)?)}) + Ok(DafnyInt { + data: Rc::new(BigInt::from_str_radix(s, radix)?), + }) } } impl Ord for DafnyInt { @@ -400,17 +473,23 @@ impl Ord for DafnyInt { impl Signed for DafnyInt { #[inline] fn abs(&self) -> Self { - DafnyInt{data: Rc::new(self.data.as_ref().abs())} + DafnyInt { + data: Rc::new(self.data.as_ref().abs()), + } } #[inline] fn abs_sub(&self, other: &Self) -> Self { - DafnyInt{data: Rc::new(self.data.as_ref().abs_sub(other.data.as_ref()))} + DafnyInt { + data: Rc::new(self.data.as_ref().abs_sub(other.data.as_ref())), + } } #[inline] fn signum(&self) -> Self { - DafnyInt{data: Rc::new(self.data.as_ref().signum())} + DafnyInt { + data: Rc::new(self.data.as_ref().signum()), + } } #[inline] @@ -435,23 +514,30 @@ impl PartialOrd for DafnyInt { impl DafnyInt { #[inline] pub fn parse_bytes(number: &[u8], radix: u32) -> DafnyInt { - DafnyInt{data: ::std::rc::Rc::new(BigInt::parse_bytes(number, radix).unwrap())} + DafnyInt { + data: ::std::rc::Rc::new(BigInt::parse_bytes(number, radix).unwrap()), + } } pub fn from_usize(usize: usize) -> DafnyInt { - DafnyInt{data: Rc::new(BigInt::from(usize))} + DafnyInt { + data: Rc::new(BigInt::from(usize)), + } } pub fn from_i32(i: i32) -> DafnyInt { - DafnyInt{data: Rc::new(BigInt::from(i))} + DafnyInt { + data: Rc::new(BigInt::from(i)), + } } } -macro_rules! impl_dafnyint_from{ +macro_rules! impl_dafnyint_from { () => {}; ($type:ident) => { - impl From<$type> for DafnyInt - { + impl From<$type> for DafnyInt { fn from(n: $type) -> Self { - DafnyInt{data: Rc::new(n.into())} + DafnyInt { + data: Rc::new(n.into()), + } } } }; @@ -469,14 +555,14 @@ impl_dafnyint_from! { i64 } impl_dafnyint_from! { i128 } impl_dafnyint_from! { usize } -impl <'a> From<&'a [u8]> for DafnyInt { +impl<'a> From<&'a [u8]> for DafnyInt { fn from(number: &[u8]) -> Self { DafnyInt::parse_bytes(number, 10) } } // Now the same but for &[u8, N] for any kind of such references -impl <'a, const N: usize> From<&'a [u8; N]> for DafnyInt { +impl<'a, const N: usize> From<&'a [u8; N]> for DafnyInt { fn from(number: &[u8; N]) -> Self { DafnyInt::parse_bytes(number, 10) } @@ -486,10 +572,9 @@ impl <'a, const N: usize> From<&'a [u8; N]> for DafnyInt { // Immutable sequences // ************** -impl Eq for Sequence {} +impl Eq for Sequence {} -impl Add<&Sequence> for &Sequence -{ +impl Add<&Sequence> for &Sequence { type Output = Sequence; fn add(self, rhs: &Sequence) -> Self::Output { @@ -497,7 +582,7 @@ impl Add<&Sequence> for &Sequence } } -impl Hash for Sequence { +impl Hash for Sequence { fn hash(&self, state: &mut H) { self.cardinality_usize().hash(state); let array = self.to_array(); @@ -511,10 +596,11 @@ impl Hash for Sequence { // Clone can be derived automatically #[derive(Clone)] pub enum Sequence - where T: DafnyType, +where + T: DafnyType, { ArraySequence { - // Values could be a native array because we will know statically that all + // Values could be a native array because we will know statically that all // accesses are in bounds when using this data structure values: Rc>, }, @@ -522,30 +608,32 @@ pub enum Sequence left: Rc>>, right: Rc>>, length: SizeT, - boxed: Rc>>>> - } + boxed: Rc>>>>, + }, } -impl Sequence -where T: DafnyType { +impl Sequence +where + T: DafnyType, +{ pub fn from_array(values: &Vec) -> Sequence { Sequence::ArraySequence { - values: Rc::new(values.clone()) + values: Rc::new(values.clone()), } } pub fn from_array_slice(values: &Vec, start: &DafnyInt, end: &DafnyInt) -> Sequence { Sequence::ArraySequence { - values: Rc::new(values[start.to_usize().unwrap()..end.to_usize().unwrap()].to_vec()) + values: Rc::new(values[start.to_usize().unwrap()..end.to_usize().unwrap()].to_vec()), } } pub fn from_array_take(values: &Vec, n: &DafnyInt) -> Sequence { Sequence::ArraySequence { - values: Rc::new(values[..n.to_usize().unwrap()].to_vec()) + values: Rc::new(values[..n.to_usize().unwrap()].to_vec()), } } pub fn from_array_drop(values: &Vec, n: &DafnyInt) -> Sequence { Sequence::ArraySequence { - values: Rc::new(values[n.to_usize().unwrap()..].to_vec()) + values: Rc::new(values[n.to_usize().unwrap()..].to_vec()), } } pub fn from_array_owned(values: Vec) -> Sequence { @@ -565,12 +653,19 @@ where T: DafnyType { // Let's convert the if then else below to a proper match statement match self { Sequence::ArraySequence { values, .. } => - // The length of the elements - Rc::clone(values), - Sequence::ConcatSequence { length, boxed, left, right } => { - let clone_boxed = boxed.as_ref().clone(); - let clone_boxed_borrowed = clone_boxed.borrow(); - let borrowed: Option<&Rc>> = clone_boxed_borrowed.as_ref(); + // The length of the elements + { + Rc::clone(values) + } + Sequence::ConcatSequence { + length, + boxed, + left, + right, + } => { + let into_boxed = boxed.as_ref().clone(); + let into_boxed_borrowed = into_boxed.borrow(); + let borrowed: Option<&Rc>> = into_boxed_borrowed.as_ref(); if let Some(cache) = borrowed.as_ref() { return Rc::clone(cache); } @@ -594,16 +689,20 @@ where T: DafnyType { pub fn append_recursive(array: &mut Vec, this: &Sequence) { match this { Sequence::ArraySequence { values, .. } => - // The length of the elements - for value in values.iter() { - array.push(value.clone()); - }, - Sequence::ConcatSequence { boxed, left, right, .. } => - // Let's create an array of size length and fill it up recursively - { - let clone_boxed = boxed.as_ref().clone(); - let clone_boxed_borrowed = clone_boxed.borrow(); - let borrowed: Option<&Rc>> = clone_boxed_borrowed.as_ref(); + // The length of the elements + { + for value in values.iter() { + array.push(value.clone()); + } + } + Sequence::ConcatSequence { + boxed, left, right, .. + } => + // Let's create an array of size length and fill it up recursively + { + let into_boxed = boxed.as_ref().clone(); + let into_boxed_borrowed = into_boxed.borrow(); + let borrowed: Option<&Rc>> = into_boxed_borrowed.as_ref(); if let Some(values) = borrowed.as_ref() { for value in values.iter() { array.push(value.clone()); @@ -613,7 +712,7 @@ where T: DafnyType { // safety: When a concat is initialized, the left and right are well defined Sequence::::append_recursive(array, unsafe { &mut *left.get() }); Sequence::::append_recursive(array, unsafe { &mut *right.get() }); - } + } } } /// Returns the cardinality of this [`Sequence`]. @@ -621,10 +720,11 @@ where T: DafnyType { pub fn cardinality_usize(&self) -> SizeT { match self { Sequence::ArraySequence { values, .. } => - // The length of the elements - values.len(), - Sequence::ConcatSequence { length, .. } => - *length, + // The length of the elements + { + values.len() + } + Sequence::ConcatSequence { length, .. } => *length, } } pub fn cardinality(&self) -> DafnyInt { @@ -650,7 +750,7 @@ where T: DafnyType { let start_index = start.data.as_ref().to_usize().unwrap(); let new_data = Sequence::from_array_owned(self.to_array()[start_index..].to_vec()); new_data - } + } pub fn update_index(&self, index: &DafnyInt, value: &T) -> Self { let mut result = self.to_array().as_ref().clone(); @@ -665,39 +765,63 @@ where T: DafnyType { pub fn get(&self, index: &DafnyInt) -> T { self.get_usize(index.data.to_usize().unwrap()) } + pub fn iter(&self) -> SequenceIter { + SequenceIter { + array: self.to_array(), + index: 0, + } + } } -impl Default for Sequence { +pub struct SequenceIter { + array: Rc>, + index: SizeT, +} +impl Iterator for SequenceIter { + type Item = T; + fn next(&mut self) -> Option { + if self.index < self.array.len() { + let result = self.array[self.index].clone(); + self.index += 1; + Some(result) + } else { + None + } + } +} + +impl Default for Sequence { fn default() -> Self { Sequence::from_array_owned(vec![]) } } -impl NontrivialDefault for Sequence { +impl NontrivialDefault for Sequence { fn nontrivial_default() -> Self { Self::default() } } -impl Sequence { +impl Sequence { pub fn as_dafny_multiset(&self) -> Multiset { Multiset::from_array(&self.to_array()) } } // Makes it possible to write iterator.collect::> and obtain a sequence -impl FromIterator for Sequence { +impl FromIterator for Sequence { fn from_iter>(iter: I) -> Self { Sequence::from_array_owned(iter.into_iter().collect()) } } -impl Sequence { +impl Sequence { pub fn contains(&self, value: &T) -> bool { self.to_array().contains(value) } } -impl PartialEq> for Sequence - where T: DafnyTypeEq +impl PartialEq> for Sequence +where + T: DafnyTypeEq, { fn eq(&self, other: &Sequence) -> bool { // Iterate through both elements and verify that they are equal @@ -716,13 +840,17 @@ impl PartialEq> for Sequence } } -impl PartialOrd for Sequence { +impl PartialOrd for Sequence { fn partial_cmp(&self, other: &Sequence) -> Option { // Comparison is only prefix-based match self.cardinality_usize().cmp(&other.cardinality_usize()) { Ordering::Equal => { - if self == other { Some(Ordering::Equal) } else { None } - }, + if self == other { + Some(Ordering::Equal) + } else { + None + } + } Ordering::Less => { for i in 0..self.cardinality_usize() { if self.get_usize(i) != other.get_usize(i) { @@ -730,7 +858,7 @@ impl PartialOrd for Sequence { } } Some(Ordering::Less) - }, + } Ordering::Greater => { for i in 0..other.cardinality_usize() { if self.get_usize(i) != other.get_usize(i) { @@ -743,29 +871,28 @@ impl PartialOrd for Sequence { } } -impl DafnyPrint for Sequence -{ +impl DafnyPrint for Sequence { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { if !V::is_char() { write!(f, "[")?; } - let mut first = true; - for value in self.to_array().iter() { - if !first && !V::is_char() { - write!(f, ", ")?; - } - first = false; - value.fmt_print(f, true)?; - } - if !V::is_char() { - write!(f, "]") - } else { - write!(f, "") - } + let mut first = true; + for value in self.to_array().iter() { + if !first && !V::is_char() { + write!(f, ", ")?; + } + first = false; + value.fmt_print(f, true)?; + } + if !V::is_char() { + write!(f, "]") + } else { + write!(f, "") + } } } -impl Debug for Sequence { +impl Debug for Sequence { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) } @@ -777,36 +904,37 @@ impl Debug for Sequence { #[derive(Clone)] pub struct Map - where K: DafnyTypeEq, V: DafnyTypeEq +where + K: DafnyTypeEq, + V: DafnyTypeEq, { - data: Rc> + data: Rc>, } -impl Default for Map -{ +impl Default for Map { fn default() -> Self { Map { - data: Rc::new(HashMap::new()) + data: Rc::new(HashMap::new()), } } } -impl NontrivialDefault for Map -{ +impl NontrivialDefault for Map { fn nontrivial_default() -> Self { Self::default() } } -impl Hash for Map -{ +impl Hash for Map { fn hash(&self, state: &mut H) { self.data.len().hash(state); // Worst performance for things that are not hashable like maps } } -impl PartialEq> for Map - where K: DafnyTypeEq, V: DafnyTypeEq +impl PartialEq> for Map +where + K: DafnyTypeEq, + V: DafnyTypeEq, { fn eq(&self, other: &Map) -> bool { if self.data.len() != other.data.len() { @@ -821,34 +949,40 @@ impl PartialEq> for Map } } -impl Eq for Map { -} +impl Eq for Map {} -impl Map -{ +impl Map { pub fn new_empty() -> Map { Map { - data: Rc::new(HashMap::new()) + data: Rc::new(HashMap::new()), } } pub fn from_array(values: &Vec<(K, V)>) -> Map { - Self::from_iterator(values.iter().map(|(k, v)| - (k.clone(), v.clone()))) + Self::from_iterator(values.iter().map(|(k, v)| (k.clone(), v.clone()))) } pub fn from_iterator(data: I) -> Map - where I: Iterator + where + I: Iterator, { let mut result: HashMap = HashMap::new(); for (k, v) in data { result.insert(k, v); - } - Self::from_hashmap_owned(result) + } + Self::from_hashmap_owned(result) } pub fn from_hashmap_owned(values: HashMap) -> Map { - Map { data: Rc::new(values) } + Map { + data: Rc::new(values), + } } - pub fn to_hashmap_owned(&self, converter_k: fn(&K)->K2, converter_v: fn(&V)->V2) -> HashMap - where K2: Eq + std::hash::Hash, V2: Clone + pub fn to_hashmap_owned( + &self, + converter_k: fn(&K) -> K2, + converter_v: fn(&V) -> V2, + ) -> HashMap + where + K2: Eq + std::hash::Hash, + V2: Clone, { let mut result: HashMap = HashMap::new(); for (k, v) in self.data.iter() { @@ -890,7 +1024,7 @@ impl Map } pub fn subtract(&self, keys: &Set) -> Self { if keys.cardinality_usize() == 0 { - return self.clone() + return self.clone(); } let mut result: HashMap = HashMap::new(); for (k, v) in self.data.iter() { @@ -901,18 +1035,23 @@ impl Map Self::from_hashmap_owned(result) } - pub fn from_hashmap(map: &HashMap, converter_k: fn(&K2)->K, converter_v: fn(&V2)->V) - -> Map - where - K: DafnyTypeEq, V: DafnyTypeEq, - K2: Eq + Hash, V2: Clone + pub fn from_hashmap( + map: &HashMap, + converter_k: fn(&K2) -> K, + converter_v: fn(&V2) -> V, + ) -> Map + where + K: DafnyTypeEq, + V: DafnyTypeEq, + K2: Eq + Hash, + V2: Clone, { let mut result: HashMap = HashMap::new(); for (k, v) in map.iter() { result.insert(converter_k(k), converter_v(v)); } Map { - data: Rc::new(result) + data: Rc::new(result), } } pub fn keys(&self) -> Set { @@ -941,26 +1080,38 @@ impl Map result.insert(index, value); Map::from_hashmap_owned(result) } + + pub fn iter_raw(&self) -> std::collections::hash_map::Iter<'_, K, V> { + self.data.iter() + } + + pub fn iter(&self) -> impl Iterator + '_ { + self.data.iter().map(|(k, _v)| k).cloned() + } } -impl Map { +impl Map { pub fn as_dafny_multiset(&self) -> Multiset { Multiset::from_hashmap(&self.data) } } pub struct MapBuilder - where K: Clone + Eq + std::hash::Hash, V: Clone +where + K: Clone + Eq + std::hash::Hash, + V: Clone, { - data: HashMap + data: HashMap, } -impl MapBuilder - where K: DafnyTypeEq, V: DafnyTypeEq +impl MapBuilder +where + K: DafnyTypeEq, + V: DafnyTypeEq, { pub fn new() -> MapBuilder { MapBuilder { - data: HashMap::new() + data: HashMap::new(), } } pub fn add(&mut self, key: &K, value: &V) { @@ -972,29 +1123,31 @@ impl MapBuilder } } -impl DafnyPrint for Map - where K: DafnyTypeEq, V: DafnyTypeEq +impl DafnyPrint for Map +where + K: DafnyTypeEq, + V: DafnyTypeEq, { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { f.write_str("map[")?; - let mut first = true; - for (k, v) in self.data.iter() { - if !first { - f.write_str(", ")?; - } - first = false; - k.fmt_print(f, in_seq)?; - f.write_str(" := ")?; - v.fmt_print(f, in_seq)?; - } - f.write_str("}") - + let mut first = true; + for (k, v) in self.data.iter() { + if !first { + f.write_str(", ")?; + } + first = false; + k.fmt_print(f, in_seq)?; + f.write_str(" := ")?; + v.fmt_print(f, in_seq)?; + } + f.write_str("}") } } - -impl Debug for Map - where K: DafnyTypeEq, V: DafnyTypeEq +impl Debug for Map +where + K: DafnyTypeEq, + V: DafnyTypeEq, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) @@ -1006,26 +1159,27 @@ impl Debug for Map // ************** #[derive(Clone)] -pub struct Set -{ - data: Rc> +pub struct Set { + data: Rc>, } -impl Default for Set - where T: DafnyTypeEq +impl Default for Set +where + T: DafnyTypeEq, { fn default() -> Self { Self::new_empty() } } -impl NontrivialDefault for Set { +impl NontrivialDefault for Set { fn nontrivial_default() -> Self { Self::default() } } -impl PartialEq> for Set - where V: DafnyTypeEq +impl PartialEq> for Set +where + V: DafnyTypeEq, { fn eq(&self, other: &Set) -> bool { // 1. Same cardinality @@ -1048,7 +1202,7 @@ impl PartialEq> for Set } } -impl PartialOrd for Set { +impl PartialOrd for Set { fn partial_cmp(&self, other: &Self) -> Option { // Partial ordering is inclusion if self.cardinality_usize() <= other.cardinality_usize() { @@ -1073,7 +1227,7 @@ impl PartialOrd for Set { } } -impl Set { +impl Set { pub fn new_empty() -> Set { Self::from_hashset_owned(HashSet::new()) } @@ -1081,7 +1235,8 @@ impl Set { Self::from_iterator(array.iter().map(|v| v.clone())) } pub fn from_iterator(data: I) -> Set - where I: Iterator + where + I: Iterator, { let mut set: HashSet = HashSet::new(); for value in data { @@ -1094,7 +1249,7 @@ impl Set { } pub fn from_hashset_owned(hashset: HashSet) -> Set { Set { - data: Rc::new(hashset) + data: Rc::new(hashset), } } pub fn cardinality_usize(&self) -> usize { @@ -1132,7 +1287,7 @@ impl Set { } // Start with an empty vec with capacity the smallest of both sets let mut result = HashSet::new(); - + // iterate over the other, take only elements in common for value in self.data.iter() { if other.data.contains(value) { @@ -1151,7 +1306,7 @@ impl Set { } // Start with a vec the size of the first one let mut result = HashSet::new(); - + // iterate over the other, take only elements not in second for value in self.data.iter() { if !other.contains(value) { @@ -1217,16 +1372,16 @@ impl Set { } pub struct SetBuilder - where T: Clone + Eq + std::hash::Hash +where + T: Clone + Eq + std::hash::Hash, { - data: HashMap + data: HashMap, } -impl SetBuilder -{ +impl SetBuilder { pub fn new() -> SetBuilder { SetBuilder { - data: HashMap::new() + data: HashMap::new(), } } pub fn add(&mut self, value: &T) { @@ -1239,13 +1394,12 @@ impl SetBuilder for (k, _v) in self.data.iter() { result.push(k.clone()); } - + Set::from_array(&result) } } -impl DafnyPrint for Set -{ +impl DafnyPrint for Set { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { f.write_str("{")?; let mut first = true; @@ -1260,8 +1414,9 @@ impl DafnyPrint for Set } } -impl Debug for Set - where V: DafnyTypeEq +impl Debug for Set +where + V: DafnyTypeEq, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) @@ -1273,16 +1428,14 @@ impl Debug for Set // ******************* #[derive(Clone)] -pub struct Multiset -{ +pub struct Multiset { pub data: HashMap, - pub size: DafnyInt + pub size: DafnyInt, } -impl Multiset -{ +impl Multiset { pub fn new_empty() -> Multiset { - Self::from_array(&vec!()) + Self::from_array(&vec![]) } pub fn get_total(map: &HashMap) -> DafnyInt { let mut total = DafnyInt::zero(); @@ -1291,20 +1444,21 @@ impl Multiset } total } - pub fn from_hashmap_owned(map: HashMap) -> Multiset{ + pub fn from_hashmap_owned(map: HashMap) -> Multiset { Multiset { size: Self::get_total(&map), - data: map + data: map, } } - pub fn from_hashmap(map: &HashMap) -> Multiset{ + pub fn from_hashmap(map: &HashMap) -> Multiset { Self::from_hashmap_owned(map.clone()) } pub fn from_array(data: &Vec) -> Multiset { Self::from_iterator(data.iter().map(|x| x.clone())) } pub fn from_iterator(data: I) -> Multiset - where I: Iterator + where + I: Iterator, { let mut hashmap: HashMap = HashMap::new(); let mut total: DafnyInt = DafnyInt::zero(); @@ -1315,7 +1469,7 @@ impl Multiset } Multiset { data: hashmap, - size: total + size: total, } } pub fn from_set(set: &Set) -> Multiset { @@ -1354,7 +1508,7 @@ impl Multiset return self.clone(); } if self.size.is_zero() { - return other.clone() + return other.clone(); } let mut result = self.data.clone(); for (k, v) in other.data.iter() { @@ -1362,14 +1516,17 @@ impl Multiset let new_count = old_count.clone() + v.clone(); result.insert(k.clone(), new_count); } - Multiset { data: result, size: self.size.clone() + other.size.clone() } + Multiset { + data: result, + size: self.size.clone() + other.size.clone(), + } } pub fn intersect(&self, other: &Multiset) -> Multiset { if other.size.is_zero() { - return other.clone() + return other.clone(); } if self.size.is_zero() { - return self.clone() + return self.clone(); } let mut result = HashMap::::new(); let mut total = DafnyInt::zero(); @@ -1385,7 +1542,10 @@ impl Multiset total = total + resulting_count; } } - Multiset { data: result, size: total } + Multiset { + data: result, + size: total, + } } pub fn subtract(&self, other: &Multiset) -> Multiset { if other.size.is_zero() { @@ -1407,7 +1567,10 @@ impl Multiset result.insert(k.clone(), new_count); } } - Multiset { data: result, size: total } + Multiset { + data: result, + size: total, + } } pub fn disjoint(&self, other: &Multiset) -> bool { for value in other.data.keys() { @@ -1425,24 +1588,31 @@ impl Multiset pub fn peek(&self) -> V { self.data.iter().next().unwrap().0.clone() } -} + pub fn iter_raw(&self) -> std::collections::hash_map::Iter<'_, V, DafnyInt> { + self.data.iter() + } + pub fn iter(&self) -> impl Iterator + '_ { + self.data.iter().map(|(k, _v)| k).cloned() + } +} -impl Default for Multiset - where T: DafnyTypeEq +impl Default for Multiset +where + T: DafnyTypeEq, { fn default() -> Self { Self::new_empty() } } -impl NontrivialDefault for Multiset { +impl NontrivialDefault for Multiset { fn nontrivial_default() -> Self { Self::default() } } -impl PartialOrd> for Multiset { +impl PartialOrd> for Multiset { fn partial_cmp(&self, other: &Multiset) -> Option { match self.cardinality().cmp(&other.cardinality()) { Ordering::Less => { @@ -1460,7 +1630,7 @@ impl PartialOrd> for Multiset { } } Some(Ordering::Equal) - }, + } Ordering::Greater => { for value in self.data.keys() { if !other.contains(value) || self.get(value) < other.get(value) { @@ -1473,7 +1643,7 @@ impl PartialOrd> for Multiset { } } -impl DafnyPrint for Multiset { +impl DafnyPrint for Multiset { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { f.write_str("multiset{")?; let mut first = true; @@ -1490,16 +1660,16 @@ impl DafnyPrint for Multiset { } } - -impl Debug for Multiset - where V: DafnyTypeEq +impl Debug for Multiset +where + V: DafnyTypeEq, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) } } -impl PartialEq> for Multiset { +impl PartialEq> for Multiset { fn eq(&self, other: &Multiset) -> bool { if self.cardinality() != other.cardinality() { return false; @@ -1513,8 +1683,8 @@ impl PartialEq> for Multiset { true } } -impl Eq for Multiset {} -impl Hash for Multiset { +impl Eq for Multiset {} +impl Hash for Multiset { fn hash(&self, state: &mut H) { self.cardinality().hash(state); } @@ -1522,58 +1692,23 @@ impl Hash for Multiset { // Define the AsAny trait pub trait AsAny { - fn as_any(&self) -> &dyn Any; - fn as_any_mut(&mut self) -> &mut dyn Any; + fn as_any(&self) -> &dyn Any; + fn as_any_mut(&mut self) -> &mut dyn Any; } impl AsAny for dyn Any { - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } -} -pub fn is_instance_of(theobject: *const C) -> bool { - // safety: Dafny won't call this function unless it can guarantee the object is still allocated - unsafe { &*theobject }.as_any().downcast_ref::().is_some() -} -trait DafnyUpdowncast { - fn updowncast(&self) -> U; - fn is_instance_of(&self) -> bool; -} -/*impl DafnyUpdowncast<*const U> for T -{ - fn updowncast(&self) -> *const U { - self.as_any().downcast_ref::().unwrap() - } - - fn is_instance_of(&self) -> bool { - is_instance_of::(self) - //self.as_any().downcast_ref::().is_some() - } -}*/ -impl DafnyUpdowncast<*const U> for *const T -{ - fn updowncast(&self) -> *const U { - // safety: Dafny won't call this function unless it can guarantee the object is still allocated - unsafe { &**self }.as_any().downcast_ref::().unwrap() + fn as_any(&self) -> &dyn Any { + self } - - fn is_instance_of(&self) -> bool { - is_instance_of::(*self) - //self.as_any().downcast_ref::().is_some() + fn as_any_mut(&mut self) -> &mut dyn Any { + self } } -impl DafnyUpdowncast<*const U> for Rc -{ - fn updowncast(&self) -> *const U { - self.as_any().downcast_ref::().unwrap() - } - - fn is_instance_of(&self) -> bool { - is_instance_of::(self.as_ref()) - //self.as_any().downcast_ref::().is_some() - } +pub fn is_instance_of(theobject: *const C) -> bool { + // safety: Dafny won't call this function unless it can guarantee the object is still allocated + unsafe { &*theobject } + .as_any() + .downcast_ref::() + .is_some() } pub fn dafny_rational_to_int(r: &BigRational) -> BigInt { @@ -1582,11 +1717,9 @@ pub fn dafny_rational_to_int(r: &BigRational) -> BigInt { pub fn nullable_referential_equality(left: Option>, right: Option>) -> bool { match (left, right) { - (Some(l), Some(r)) => { - Rc::ptr_eq(&l, &r) - } + (Some(l), Some(r)) => Rc::ptr_eq(&l, &r), (None, None) => true, - _ => false + _ => false, } } @@ -1629,10 +1762,10 @@ pub struct IntegerRange + One + Ord + Clone> { current: A, } -impl + One + Ord + Clone> Iterator for IntegerRange { +impl + One + Ord + Clone> Iterator for IntegerRange { type Item = A; - fn next(&mut self) -> Option { + fn next(&mut self) -> Option { if self.current < self.hi { let result = self.current.clone(); self.current = self.current.clone() + One::one(); @@ -1643,28 +1776,92 @@ impl + One + Ord + Clone> Iterator for IntegerRange { } } -pub fn integer_range + One + Ord + Clone>(low: A, hi: A) -> impl Iterator { - IntegerRange { - hi, - current: low +pub fn integer_range + One + Ord + Clone>( + low: A, + hi: A, +) -> impl Iterator { + IntegerRange { hi, current: low } +} + +pub struct IntegerRangeDown + One + Ord + Clone> { + current: A, + low: A, +} + +impl + One + Ord + Clone> Iterator for IntegerRangeDown { + type Item = A; + + fn next(&mut self) -> Option { + if self.current > self.low { + self.current = self.current.clone() - One::one(); + Some(self.current.clone()) + } else { + None + } + } +} + +pub fn integer_range_down + One + Ord + Clone>( + hi: A, + low: A, +) -> impl Iterator { + IntegerRangeDown { current: hi, low } +} + +// Unbounded versions + +pub struct IntegerRangeUnbounded + One + Clone> { + current: A, +} +impl + One + Clone> Iterator for IntegerRangeUnbounded { + type Item = A; + + fn next(&mut self) -> Option { + let result = self.current.clone(); + self.current = self.current.clone() + One::one(); + Some(result) + } +} +pub fn integer_range_unbounded + One + Clone>( + low: A, +) -> impl Iterator { + IntegerRangeUnbounded { current: low } +} + +pub struct IntegerRangeDownUnbounded + One + Clone> { + current: A, +} + +impl + One + Clone> Iterator for IntegerRangeDownUnbounded { + type Item = A; + + fn next(&mut self) -> Option { + self.current = self.current.clone() - One::one(); + Some(self.current.clone()) } } +pub fn integer_range_down_unbounded + One + Clone>( + hi: A, +) -> impl Iterator { + IntegerRangeDownUnbounded { current: hi } +} + pub struct LazyFieldWrapper(pub Lazy A>>); -impl PartialEq for LazyFieldWrapper { +impl PartialEq for LazyFieldWrapper { fn eq(&self, other: &Self) -> bool { self.0.deref() == other.0.deref() } } -impl Default for LazyFieldWrapper { +impl Default for LazyFieldWrapper { fn default() -> Self { Self(Lazy::new(Box::new(A::default))) } } -impl DafnyPrint for LazyFieldWrapper { +impl DafnyPrint for LazyFieldWrapper { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { self.0.deref().fmt_print(f, in_seq) } @@ -1691,29 +1888,29 @@ macro_rules! dafny_print_function_loop { } // Emit functions till 32 parameters dafny_print_function_loop! { A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 - A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27 A28 A29 A30 A31 A32 } +A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27 A28 A29 A30 A31 A32 } pub struct FunctionWrapper(pub A); -impl DafnyPrint for FunctionWrapper { +impl DafnyPrint for FunctionWrapper { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { write!(f, "") } } -impl Clone for FunctionWrapper { +impl Clone for FunctionWrapper { fn clone(&self) -> Self { Self(self.0.clone()) } } -impl PartialEq for FunctionWrapper> { +impl PartialEq for FunctionWrapper> { fn eq(&self, other: &Self) -> bool { Rc::ptr_eq(&self.0, &other.0) } } pub struct DafnyPrintWrapper(pub T); -impl Display for DafnyPrintWrapper<&T> { +impl Display for DafnyPrintWrapper<&T> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.0.fmt_print(f, false) } @@ -1739,7 +1936,7 @@ pub trait DafnyPrint { } } -impl DafnyPrint for *const T { +impl DafnyPrint for *const T { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { write!(f, "<{} object>", std::any::type_name::()) } @@ -1794,9 +1991,9 @@ pub type DafnyStringUTF16 = Sequence; impl DafnyPrint for DafnyCharUTF16 { #[inline] fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { - let real_char = char::decode_utf16(vec!(self.clone()).iter().map(|v| v.0)) - .map(|r| r.map_err(|e| e.unpaired_surrogate())) - .collect::>()[0]; + let real_char = char::decode_utf16(vec![self.clone()].iter().map(|v| v.0)) + .map(|r| r.map_err(|e| e.unpaired_surrogate())) + .collect::>()[0]; let rendered_char = match real_char { Ok(c) => c, Err(e) => { @@ -1817,8 +2014,7 @@ impl DafnyPrint for DafnyCharUTF16 { } } -impl Debug for DafnyCharUTF16 -{ +impl Debug for DafnyCharUTF16 { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) } @@ -1862,8 +2058,7 @@ impl DafnyPrint for DafnyChar { } } -impl Debug for DafnyChar -{ +impl Debug for DafnyChar { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f, false) } @@ -1887,11 +2082,11 @@ impl Hash for DafnyChar { } } -impl DafnyPrint for Option { +impl DafnyPrint for Option { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { match self { Some(x) => x.fmt_print(f, false), - None => write!(f, "null") + None => write!(f, "null"), } } } @@ -1975,13 +2170,13 @@ impl DafnyPrint for BigRational { } } -impl DafnyPrint for Rc { +impl DafnyPrint for Rc { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { self.as_ref().fmt_print(f, in_seq) } } -impl DafnyPrint for Vec { +impl DafnyPrint for Vec { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { if !T::is_char() { write!(f, "[")?; @@ -2007,13 +2202,13 @@ impl DafnyPrint for Vec { } } -impl DafnyPrint for RefCell { +impl DafnyPrint for RefCell { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { self.borrow().fmt_print(f, _in_seq) } } -impl DafnyPrint for HashSet { +impl DafnyPrint for HashSet { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { write!(f, "{{")?; @@ -2041,14 +2236,15 @@ pub fn char_lt(left: char, right: char) -> bool { } pub fn string_of(s: &str) -> DafnyString { - s.chars().map(|v| DafnyChar(v)).collect::>() + s.chars() + .map(|v| DafnyChar(v)) + .collect::>() } pub fn string_utf16_of(s: &str) -> DafnyStringUTF16 { Sequence::from_array_owned(s.encode_utf16().map(|v| DafnyCharUTF16(v)).collect()) } - macro_rules! impl_tuple_print { ($($items:ident)*) => { impl <$($items,)*> DafnyPrint for ($($items,)*) @@ -2063,7 +2259,7 @@ macro_rules! impl_tuple_print { write!(f, "(")?; let mut i = 0; - + $( if (i > 0) { write!(f, ", ")?; @@ -2161,30 +2357,410 @@ macro_rules! map { macro_rules! int { ($x:expr) => { $crate::DafnyInt::from($x) - } + }; } ////////// // Arrays ////////// -// An Dafny array is a zero-cost abstraction over a pointer on a native array +macro_rules! ARRAY_GETTER_LENGTH0 { + () => { + #[inline] + pub fn length0(&self) -> DafnyInt { + DafnyInt::from(self.length0_usize()) + } + #[inline] + pub fn length0_usize(&self) -> usize { + self.data.len() + } + } +} +macro_rules! ARRAY_GETTER_LENGTH { + ($field: ident, $field_usize: ident) => { + #[inline] + pub fn $field(&self) -> DafnyInt { + $crate::DafnyInt::from(self.$field_usize()) + } + #[inline] + pub fn $field_usize(&self) -> usize { + self.$field + } + } +} -// array![1, 2, 3] create a Dafny array +// An 1-dimensional Dafny array is a zero-cost abstraction over a pointer on a native array #[macro_export] macro_rules! array { ($($x:expr), *) => { array::from_native(Box::new([$($x), *])) } } -pub mod array { - use std::{ - boxed::Box, - rc::Rc, - vec::Vec, + +macro_rules! ARRAY_INIT { + {$length: ident, $inner: expr} => { + $crate::array::initialize_box_usize($length, { + Rc::new(move |_| { $inner }) + }) + } +} + +macro_rules! ARRAY_INIT_INNER { + ($length: ident) => { + $crate::array::placebos_box_usize::($length) + } +} + +// ARRAY_DATA_TYPE(length0, length1, length2) will return +// Box<[Box<[Box<[T]>]>]> +macro_rules! ARRAY_DATA_TYPE { + ($length:ident) => { + Box<[T]> }; - use num::ToPrimitive; + ($length:ident, $($rest_length:ident),+) => { + Box<[ARRAY_DATA_TYPE!($($rest_length),+)]> + }; +} + +// Macro to generate generalizations of the function placebos_usize to higher-dimensions arrays + +#[macro_export] +macro_rules! INIT_ARRAY_DATA { + // Handle the innermost array initialization + ($ArrayType:ident, $last_length:ident) => { + ARRAY_INIT_INNER!($last_length) + }; + // Handle recursive array initialization for multiple dimensions + ($ArrayType:ident, $first_length:ident, $($rest_length:ident),+) => { + ARRAY_INIT!($first_length, INIT_ARRAY_DATA!($ArrayType, $($rest_length),+)) + }; +} + +macro_rules! ARRAY_METHODS { + // Accepts any number of length identifiers + ($ArrayType:ident, $length0: ident, $($length:ident),+) => { + pub fn placebos_usize( + $length0: usize, + $($length: usize),+ + ) -> *mut $ArrayType<$crate::MaybeUninit> { + Box::into_raw(Box::new($ArrayType { + $($length: $length),+, + data: INIT_ARRAY_DATA!($ArrayType, $length0, $($length),+), + })) + } + + pub fn placebos( + $length0: &$crate::DafnyInt, + $($length: &$crate::DafnyInt),+ + ) -> *mut $ArrayType<$crate::MaybeUninit> { + Self::placebos_usize( + $length0.as_usize(), + $($length.as_usize()),+ + ) + } + + // Once all the elements have been initialized, transform the signature of the pointer + pub fn construct(p: *mut $ArrayType<$crate::MaybeUninit>) -> *mut $ArrayType { + unsafe { std::mem::transmute(p) } + } + // Once all the elements have been initialized, transform the signature of the pointer + pub fn construct_rcmut(p: $crate::Object<$ArrayType>>) -> Object<$ArrayType> { + unsafe { std::mem::transmute(p) } + } + }; +} + + +macro_rules! ARRAY_STRUCT { + ($ArrayType:ident, $length0: ident, $($length:ident),+) => { + pub struct $ArrayType { + $($length: usize),+, + data: ARRAY_DATA_TYPE!($length0, $($length),+), + } + } +} + +macro_rules! ARRAY_TO_VEC_LOOP { + (@inner $self: ident, $tmp: ident, $data: expr) => { + $tmp.push($data.clone()); + }; + (@for $self: ident, $tmp: ident, $data: expr, $length_usize: ident $(, $rest_length_usize: ident)*) => { + for i in 0..$self.$length_usize() { + ARRAY_TO_VEC_LOOP!(@inner $self, $tmp, $data[i] $(, $rest_length_usize)*); + } + }; + (@inner $self: ident, $outerTmp: ident, $data: expr $(, $rest_length_usize: ident)*) => { + { + let mut tmp = Vec::new(); + ARRAY_TO_VEC_LOOP!(@for $self, tmp, $data $(, $rest_length_usize)*); + $outerTmp.push(tmp); + } + }; + + ($self: ident, $data: expr $(, $rest_length_usize: ident)*) => { + { + let mut tmp = Vec::new(); + ARRAY_TO_VEC_LOOP!(@for $self, tmp, $data $(, $rest_length_usize)*); + tmp + } + }; +} + +macro_rules! ARRAY_TO_VEC_TYPE { + ($length0: ident) => { + Vec + }; + ($length0: ident $(, $res_length: ident)*) => { + Vec + } +} + +macro_rules! ARRAY_TO_VEC { + ($length0_usize: ident $(, $res_length_usize: ident)*) => { + pub fn to_vec(&self) -> ARRAY_TO_VEC_TYPE!($length0_usize, $($res_length_usize),*) { + ARRAY_TO_VEC_LOOP!(self, self.data, $length0_usize, $($res_length_usize),*) + } + } +} + +macro_rules! ARRAY_LENGTHS { + () => { + + }; + (($length0: ident, $length0_usize: ident) $(, $rest: tt)*) => { + ARRAY_GETTER_LENGTH0!(); + ARRAY_LENGTHS!($(, $rest)*); + }; + (, ($length: ident, $length_usize: ident) $(, $rest: tt)*) => { + ARRAY_GETTER_LENGTH!($length, $length_usize); + ARRAY_LENGTHS!($(, $rest)*); + } +} + +macro_rules! ARRAY_METHODS_WRAPPER { + ($ArrayType:ident, $(($length:ident, $length_usize: ident)), +) => { + ARRAY_METHODS!($ArrayType, $($length), +); + } +} + +macro_rules! ARRAY_TO_VEC_WRAPPER { + ($(($length:ident, $length_usize: ident)), +) => { + ARRAY_TO_VEC!($($length_usize), +); + } +} + +macro_rules! ARRAY_STRUCT_WRAPPER { + ($ArrayType:ident, $(($length:ident, $length_usize: ident)), +) => { + ARRAY_STRUCT!($ArrayType, $($length), +); + } +} + +macro_rules! ARRAY_DEF { + ($ArrayType:ident, $(($length:ident, $length_usize: ident)), +) => { + ARRAY_STRUCT_WRAPPER!($ArrayType, $(($length, $length_usize)), +); + impl $ArrayType { + ARRAY_LENGTHS!{ + $(($length, $length_usize)), + + } + ARRAY_METHODS_WRAPPER!{$ArrayType, + $(($length, $length_usize)), + + } + } + impl $ArrayType { + ARRAY_TO_VEC_WRAPPER!{ + $(($length, $length_usize)), + + } + } + } +} + +// Array2 to Array16 + +ARRAY_DEF!{Array2, + (length0, length0_usize), + (length1, length1_usize) +} + +ARRAY_DEF!{Array3, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize) +} + +ARRAY_DEF!{Array4, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize) +} + +ARRAY_DEF!{Array5, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize) +} + +ARRAY_DEF!{Array6, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize) +} + +ARRAY_DEF!{Array7, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize) +} + +ARRAY_DEF!{Array8, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize) +} + +ARRAY_DEF!{Array9, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize) +} + +ARRAY_DEF!{Array10, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize) +} + +ARRAY_DEF!{Array11, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize) +} + +ARRAY_DEF!{Array12, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize), + (length11, length11_usize) +} + +ARRAY_DEF!{Array13, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize), + (length11, length11_usize), + (length12, length12_usize) +} + +ARRAY_DEF!{Array14, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize), + (length11, length11_usize), + (length12, length12_usize), + (length13, length13_usize) +} + +ARRAY_DEF!{Array15, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize), + (length11, length11_usize), + (length12, length12_usize), + (length13, length13_usize), + (length14, length14_usize) +} + +ARRAY_DEF!{Array16, + (length0, length0_usize), + (length1, length1_usize), + (length2, length2_usize), + (length3, length3_usize), + (length4, length4_usize), + (length5, length5_usize), + (length6, length6_usize), + (length7, length7_usize), + (length8, length8_usize), + (length9, length9_usize), + (length10, length10_usize), + (length11, length11_usize), + (length12, length12_usize), + (length13, length13_usize), + (length14, length14_usize), + (length15, length15_usize) +} + +pub mod array { use super::DafnyInt; + use num::ToPrimitive; + use std::mem::MaybeUninit; + use std::{boxed::Box, rc::Rc, vec::Vec}; #[inline] pub fn from_native(v: Box<[T]>) -> *mut [T] { Box::into_raw(v) @@ -2193,6 +2769,9 @@ pub mod array { pub fn from_vec(v: Vec) -> *mut [T] { from_native(v.into_boxed_slice()) } + pub fn to_vec(v: *mut [T]) -> Vec { + unsafe { Box::from_raw(v) }.into_vec() + } pub fn initialize_usize(n: usize, initializer: Rc T>) -> *mut [T] { let mut v = Vec::with_capacity(n); for i in 0..n { @@ -2200,19 +2779,57 @@ pub mod array { } from_vec(v) } + + pub fn placebos(n: &DafnyInt) -> *mut [MaybeUninit] { + placebos_usize(n.as_usize()) + } + pub fn placebos_usize(n: usize) -> *mut [MaybeUninit] { + Box::into_raw(placebos_box_usize(n)) + } + pub fn placebos_usize_rcmut(n: usize) -> super::Object<[MaybeUninit]> { + super::rcmut::array_object_from_box(placebos_box_usize(n)) + } + // Once all the elements have been initialized, transform the signature of the pointer + pub fn construct(p: *mut [MaybeUninit]) -> *mut [T] { + unsafe { std::mem::transmute(p) } + } + pub fn construct_rcmut(p: super::Object<[MaybeUninit]>) -> super::Object<[T]> { + unsafe { std::mem::transmute(p) } + } + + pub fn placebos_box(n: &DafnyInt) -> Box<[MaybeUninit]> { + placebos_box_usize(n.to_usize().unwrap()) + } + pub fn placebos_box_usize(n_usize: usize) -> Box<[MaybeUninit]> { + // This code is optimized to take a constant time. See: + // https://users.rust-lang.org/t/allocate-a-boxed-array-of-maybeuninit/110169/7 + std::iter::repeat_with(MaybeUninit::uninit) + .take(n_usize) + .collect() + } + pub fn initialize(n: &DafnyInt, initializer: Rc T>) -> *mut [T] { - let n_usize = n.to_usize().unwrap(); + Box::into_raw(initialize_box(n, initializer)) + } + + pub fn initialize_box(n: &DafnyInt, initializer: Rc T>) -> Box<[T]> { + initialize_box_usize(n.to_usize().unwrap(), initializer) + } + pub fn initialize_box_usize( + n_usize: usize, + initializer: Rc T>, + ) -> Box<[T]> { let mut v = Vec::with_capacity(n_usize); for i in 0..n_usize { v.push(initializer(&int!(i))); } - from_vec(v) + v.into_boxed_slice() } - + #[inline] pub fn length_usize(this: *mut [T]) -> usize { - // safety: Dafny won't call this function unless it can guarantee the array is still allocated - unsafe{&*this}.len() + // safety: Dafny won't call this function unless it can guarantee the array is still allocated + super::read!(this).len() } #[inline] pub fn length(this: *mut [T]) -> DafnyInt { @@ -2221,7 +2838,7 @@ pub mod array { #[inline] pub fn get_usize(this: *mut [T], i: usize) -> T { // safety: Dafny won't call this function unless it can guarantee the array is still allocated - (unsafe{&*this} as &[T])[i].clone() + (unsafe { &*this } as &[T])[i].clone() } #[inline] pub fn get(this: *mut [T], i: &DafnyInt) -> T { @@ -2230,7 +2847,7 @@ pub mod array { #[inline] pub fn update_usize(this: *mut [T], i: usize, val: T) { // safety: Dafny won't call this function unless it can guarantee the array is still allocated - (unsafe{&mut *this} as &mut [T])[i] = val; + (unsafe { &mut *this } as &mut [T])[i] = val; } #[inline] pub fn update(this: *mut [T], i: &DafnyInt, val: T) { @@ -2238,7 +2855,6 @@ pub mod array { } } - /////////////////// // Class helpers // /////////////////// @@ -2250,7 +2866,7 @@ pub fn allocate() -> *mut T { } // Generic function to safely deallocate a raw pointer #[inline] -pub fn deallocate(pointer: *const T) { +pub fn deallocate(pointer: *const T) { // safety: Dafny won't call this function unless it can guarantee the array is still allocated unsafe { // Takes ownership of the reference, @@ -2259,74 +2875,41 @@ pub fn deallocate(pointer: *const T) { } } -impl DafnyPrint for *mut T { +impl DafnyPrint for *mut T { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { write!(f, "object") } } -impl NontrivialDefault for *mut T { +impl NontrivialDefault for *mut T { fn nontrivial_default() -> Self { 0 as *mut T } } - -// BoundedPools with methods such as forall, exists, iter. - -pub trait Forall { - // Takes ownership of the function because otherwise it's hard to - // generate code to create a function and borrow it immediately - // without assigning it to a variable first - fn forall(&self, f: Rc bool>) -> bool; -} - -pub struct Range(pub DafnyInt, pub DafnyInt); - -impl Range { - pub fn new(start: &DafnyInt, end: &DafnyInt) -> Range { - Range(start.clone(), end.clone()) - } +pub struct ExactPool { + current: T, + yielded: bool, } -impl Forall for Range { - fn forall(&self, f: Rc bool>) -> bool { - let mut i: DafnyInt = self.0.clone(); - while i < self.1.clone() { - if !f(&i) { - return false; - } - i = i + int!(1); - } - true - } -} - -impl Forall for Sequence { - fn forall(&self, f: Rc bool>) -> bool { - let a = self.to_array(); - let col = a.iter(); - for v in col { - if !f(v) { - return false; - } +// Implement iterator for an exact pool, yielding +impl Iterator for ExactPool { + type Item = T; + fn next(&mut self) -> Option { + if self.yielded { + None + } else { + self.yielded = true; + Some(self.current.clone()) } - true } } - -impl Forall for Set { - fn forall(&self, f: Rc bool>) -> bool { - let col = self.data.iter(); - for v in col { - if !f(v) { - return false; - } - } - true +pub fn exact_range(value: T) -> ExactPool { + ExactPool { + current: value, + yielded: false, } } - // Any Dafny trait must require classes extending it to have a method "as_any_mut" // that can convert the reference from that trait to a reference of Any @@ -2334,16 +2917,22 @@ impl Forall for Set { #[macro_export] macro_rules! cast { ($raw:expr, $id:ty) => { - $crate::modify!($raw).as_any_mut().downcast_mut::<$id>().unwrap() as *mut $id - } + $crate::modify!($raw) + .as_any_mut() + .downcast_mut::<$id>() + .unwrap() as *mut $id + }; } // 'is' is meant to be used on references only, to check if a trait reference is a class reference #[macro_export] macro_rules! is { ($raw:expr, $id:ty) => { - $crate::modify!($raw).as_any_mut().downcast_mut::<$id>().is_some() - } + $crate::modify!($raw) + .as_any_mut() + .downcast_mut::<$id>() + .is_some() + }; } // cast_any is meant to be used on references only, to convert any references (classes or traits)* @@ -2352,10 +2941,9 @@ macro_rules! is { macro_rules! cast_any { ($raw:expr) => { $crate::modify!($raw).as_any_mut() - } + }; } - // When initializing an uninitialized field for the first time, // we ensure we don't drop the previous content // This is problematic if the same field is overwritten multiple times @@ -2364,7 +2952,7 @@ macro_rules! cast_any { macro_rules! update_field_nodrop { ($ptr:expr, $field:ident, $value:expr) => { $crate::update_nodrop!((*$ptr).$field, $value) - } + }; } // When initializing an uninitialized field for the first time, @@ -2401,51 +2989,313 @@ macro_rules! read { // If the field is guaranteed to be assigned only once, update_field_nodrop is sufficient #[macro_export] macro_rules! update_field_uninit { - ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => { - { - let computed_value = $value; - if $field_assigned { - $crate::modify!($t).$field = computed_value; + ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ + let computed_value = $value; + if $field_assigned { + $crate::modify!($t).$field = computed_value; + } else { + $crate::update_field_nodrop!($t, $field, computed_value); + $field_assigned = true; + } + }}; +} + +// Macro to call at the end of the first new; constructor when not every field is guaranteed to be assigned. +#[macro_export] +macro_rules! update_field_if_uninit { + ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ + let computed_value = $value; + if !$field_assigned { + $crate::update_field_nodrop!($t, $field, computed_value); + $field_assigned = true; + } + }}; +} + +///////////////// +// Reference-counted classes mode +///////////////// + +pub struct Object(pub Option>); + +impl Clone for Object { + fn clone(&self) -> Self { + Object(self.0.clone()) + } +} + +impl Debug for Object { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + self.fmt_print(f, false) + } +} +impl DafnyPrint for Object { + fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { + write!(f, "") + } +} + +impl PartialEq for Object { + fn eq(&self, other: &Self) -> bool { + if let Some(p) = &self.0 { + if let Some(q) = &other.0 { + // To compare addresses, we need to ensure we only compare thin pointers + // https://users.rust-lang.org/t/comparing-addresses-between-fat-and-thin-pointers/89008 + ::std::ptr::eq(p.as_ref().get() as *const (), q.as_ref().get() as *const ()) } else { - $crate::update_field_nodrop!($t, $field, computed_value); - $field_assigned = true; + false } + } else { + false + } + } +} + +impl std::hash::Hash for Object { + fn hash(&self, state: &mut H) { + if let Some(p) = &self.0 { + p.as_ref().get().hash(state); + } else { + 0.hash(state); } } } -// Macro to call at the end of the first new; constructor when not every field is guaranteed to be assigned. #[macro_export] -macro_rules! update_field_if_uninit { - ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => { - { - let computed_value = $value; - if !$field_assigned { - $crate::update_field_nodrop!($t, $field, computed_value); - $field_assigned = true; +macro_rules! cast_object { + ($raw:expr, $id:ty) => { + unsafe { + let res: $crate::Object<$id> = + $crate::Object(Some(::std::rc::Rc::from_raw( + ::std::rc::Rc::into_raw($raw.0.unwrap()) as _))); + res + } + }; +} + +// Returns an object whose fields are yet initialized. Only use update_field_uninit_rcmut and update_field_if_uninit_rcmut to initialize fields. +pub fn allocate_rcmut() -> Object { + unsafe { mem::transmute(object::new::>(MaybeUninit::uninit())) } +} + +pub struct AllocationTracker { + allocations: Vec> +} + +pub fn allocate_rcmut_track(allocation_tracker: &mut AllocationTracker) -> Object { + let res = allocate_rcmut::(); + allocation_tracker.allocations.push(Rc::>::downgrade(&res.0.clone().unwrap())); + res +} + +pub fn is_instance_of_rcmut(theobject: Object) -> bool { + // safety: Dafny won't call this function unless it can guarantee the object is still allocated + unsafe { + rcmut::borrow(&theobject.0.unwrap()).as_any().downcast_ref::().is_some() + } +} + +// Equivalent of update_field_nodrop but for rcmut +#[macro_export] +macro_rules! update_field_nodrop_rcmut { + ($ptr:expr, $field: ident, $value:expr) => { + $crate::update_nodrop_rcmut!(($crate::rcmut::borrow_mut(&mut $ptr.0.clone().unwrap())).$field, $value) + }; +} + +// Equivalent of update_nodrop but for rcmut +#[macro_export] +macro_rules! update_nodrop_rcmut { + ($ptr:expr, $value:expr) => { + unsafe { unsafe { ::std::ptr::addr_of_mut!($ptr).write($value) } } + }; +} + +// Equivalent of update_field_if_uninit but for rcmut +#[macro_export] +macro_rules! update_field_if_uninit_rcmut { + ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ + let computed_value = $value; + if !$field_assigned { + $crate::update_field_nodrop_rcmut!($t, $field, computed_value); + $field_assigned = true; + } + }}; +} + +// Equivalent of update_field_uninit but for rcmut +#[macro_export] +macro_rules! update_field_uninit_rcmut { + ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ + let computed_value = $value; + if $field_assigned { + $crate::md!($t).$field = computed_value; + } else { + $crate::update_field_nodrop_rcmut!($t, $field, computed_value); + $field_assigned = true; + } + }}; +} + +// Equivalent of modify but for rcmut +#[macro_export] +macro_rules! md { + ($x:expr) => { + unsafe { $crate::rcmut::borrow_mut(&mut $x.0.unwrap()) } + }; +} + +// Equivalent of read but for rcmut +#[macro_export] +macro_rules! rd { + ($x:expr) => { + unsafe { $crate::rcmut::borrow(& $x.0.unwrap()) } + }; +} + +// Count the number of references to the given object +#[macro_export] +macro_rules! refcount { + ($x:expr) => { + Rc::strong_count(unsafe { rcmut::as_rc(& $x.0.unwrap()) }) + }; +} + +pub mod object { + pub fn new(val: T) -> crate::Object { + crate::Object(Some(crate::rcmut::new(val))) + } +} + +// Inspired from https://crates.io/crates/rcmut +pub mod rcmut { + use std::cell::UnsafeCell; + use std::mem::{self, MaybeUninit}; + use std::rc::Rc; + use std::sync::Arc; + + pub fn array_object_from_rc(data: Rc<[T]>) -> crate::Object<[T]> { + crate::Object(Some(unsafe { crate::rcmut::from_rc(data) })) + } + pub fn array_object_from_box(data: Box<[T]>) -> crate::Object<[T]> { + let data: Rc<[T]> = data.into(); + crate::Object(Some(unsafe { crate::rcmut::from_rc(data) })) + } + pub struct Array { + pub data: Box<[T]>, + } + impl Array { + pub fn new(data: Box<[T]>) -> crate::Object> { + crate::Object(Some(crate::rcmut::new(Array { data }))) + } + + pub fn placebos_usize(length: usize) -> crate::Object>> { + let x = crate::array::placebos_box_usize::(length); + crate::rcmut::Array::>::new(x) + } + } + /// A reference counted smart pointer with unrestricted mutability. + pub type RcMut = Rc>; + + /// Create a new RcMut for a value. + pub fn new(val: T) -> RcMut { + Rc::new(UnsafeCell::new(val)) + } + /// Retrieve the inner Rc as a reference. + pub unsafe fn from(value: Box) -> RcMut { + mem::transmute(Rc::new(*value)) + } + + pub unsafe fn from_rc(value: Rc) -> RcMut { + mem::transmute(value) + } + + pub unsafe fn as_rc(this: &RcMut) -> &Rc { + mem::transmute(this) + } + pub unsafe fn to_rc(this: RcMut) -> Rc { + mem::transmute(this) + } + + /// Retrieve the inner Rc as a mutable reference. + pub unsafe fn as_rc_mut(this: &mut RcMut) -> &mut Rc { + mem::transmute(this) + } + + /// Get a reference to the value. + #[inline] + pub unsafe fn borrow(this: &RcMut) -> &T { + mem::transmute(this.get()) + } + + /// Get a mutable reference to the value. + #[inline] + pub unsafe fn borrow_mut(this: &mut RcMut) -> &mut T { + mem::transmute(this.get()) + } + + /// A reference counted smart pointer with unrestricted mutability. + pub struct ArcMut { + inner: Arc>, + } + + impl Clone for ArcMut { + fn clone(&self) -> ArcMut { + ArcMut { + inner: self.inner.clone(), } } } + + impl ArcMut { + /// Create a new ArcMut for a value. + pub fn new(val: T) -> ArcMut { + ArcMut { + inner: Arc::new(UnsafeCell::new(val)), + } + } + } + + impl ArcMut { + /// Retrieve the inner Rc as a reference. + pub unsafe fn as_arc(&self) -> &Arc { + mem::transmute(&self.inner) + } + + /// Retrieve the inner Rc as a mutable reference. + pub unsafe fn as_arc_mut(&mut self) -> &mut Arc { + mem::transmute(&mut self.inner) + } + + /// Get a reference to the value. + pub unsafe fn borrow(&self) -> &T { + mem::transmute(self.inner.get()) + } + + /// Get a mutable reference to the value. + pub unsafe fn borrow_mut(&mut self) -> &mut T { + mem::transmute(self.inner.get()) + } + } } ///////////////// // Method helpers ///////////////// - // A MaybePlacebo is a value that is either a placebo or a real value. // It is a wrapper around a MaybeUninit value, but knowing whether the value is a placebo or not. // That way, when it is dropped, the underlying value is only dropped if it is not a placebo. pub struct MaybePlacebo(Option); -impl MaybePlacebo { +impl MaybePlacebo { #[inline] pub fn read(&self) -> T { // safety: Dafny will guarantee we will never read a placebo value - unsafe {self.0.clone().unwrap_unchecked()} + unsafe { self.0.clone().unwrap_unchecked() } } } -impl MaybePlacebo { +impl MaybePlacebo { #[inline] pub fn new() -> Self { MaybePlacebo(None) @@ -2460,7 +3310,7 @@ impl MaybePlacebo { macro_rules! tuple_extract_index { ($x:expr, $i:expr) => { $x.$i - } + }; } // A macro that maps tuple (a, b, c...) to produce (MaybePlacebo::from(a), MaybePlacebo::from(b), MaybePlacebo::from(c)) @@ -2483,15 +3333,40 @@ macro_rules! maybe_placebos_from { // Coercion //////////////// -pub trait UpcastTo { - fn upcast_to(&self) -> U; +// To use this trait, one needs to clone the element before. +pub trait UpcastTo: Clone { + fn upcast_to(self) -> U; } #[macro_export] macro_rules! UpcastTo { ($from:ty, $to:ty) => { - impl $crate::UpcastTo<*mut $to> for &mut $from { - fn upcast_to(&self) -> *mut $to { + impl $crate::UpcastTo<*mut $to> for & $from { + fn upcast_to(self) -> *mut $to { + self as *const $to as *mut $to + } + } + }; +} +use nightly_crimes::nightly_crimes; +nightly_crimes! { + #![feature(unsize)] + impl UpcastTo<::std::rc::Rc> for ::std::rc::Rc + where + From: ?Sized + core::marker::Unsize, + To: ?Sized, + { + fn upcast_to(self) -> ::std::rc::Rc { + self as ::std::rc::Rc + } + } +} + +#[macro_export] +macro_rules! UpcastToRc { + ($from:ty, $to:ty) => { + impl $crate::UpcastTo<::std::rc::Rc<$to>> for ::std::rc::Rc<$from> { + fn upcast_to(&self) -> ::std::rc::Rc<$to> { (*self) as *const $to as *mut $to } } @@ -2499,54 +3374,64 @@ macro_rules! UpcastTo { } // UpcastTo for pointers -impl UpcastTo<*mut dyn Any> for *mut T { - fn upcast_to(&self) -> *mut dyn Any { - (*self) as *const dyn Any as *mut dyn Any +impl UpcastTo<*mut dyn Any> for *mut T { + fn upcast_to(self) -> *mut dyn Any { + self as *const dyn Any as *mut dyn Any + } +} + +impl UpcastTo> for Object +where + To: ?Sized, + Rc: UpcastTo>, +{ + fn upcast_to(self) -> Object { + Object(Some(unsafe { rcmut::from_rc(rcmut::to_rc(self.0.clone().unwrap()).upcast_to()) })) } } // UpcastTo for sets -impl - UpcastTo> for Set - where V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo +impl UpcastTo> for Set +where + V: DafnyTypeEq, + U: DafnyTypeEq + UpcastTo, { - fn upcast_to(&self) -> Set { + fn upcast_to(self) -> Set { // We need to upcast individual elements let mut new_set: HashSet = HashSet::::default(); for value in self.data.iter() { - new_set.insert(value.upcast_to()); + new_set.insert(value.clone().upcast_to()); } Set::from_hashset_owned(new_set) } } // UpcastTo for sequences -impl - UpcastTo> for Sequence - where V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo +impl UpcastTo> for Sequence +where + V: DafnyTypeEq, + U: DafnyTypeEq + UpcastTo, { - fn upcast_to(&self) -> Sequence { + fn upcast_to(self) -> Sequence { // We need to upcast individual elements let mut new_seq: Vec = Vec::::default(); for value in self.to_array().iter() { - new_seq.push(value.upcast_to()); + new_seq.push(value.clone().upcast_to()); } Sequence::from_array_owned(new_seq) } } // Upcast for multisets -impl - UpcastTo> for Multiset - where V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo +impl UpcastTo> for Multiset +where + V: DafnyTypeEq, + U: DafnyTypeEq + UpcastTo, { - fn upcast_to(&self) -> Multiset { + fn upcast_to(self) -> Multiset { // We need to upcast individual elements let mut new_multiset: HashMap = HashMap::::default(); - for (value, count) in self.data.iter() { + for (value, count) in self.data.into_iter() { new_multiset.insert(value.upcast_to(), count.clone()); } Multiset::from_hashmap_owned(new_multiset) @@ -2554,20 +3439,18 @@ impl } // Upcast for Maps -impl UpcastTo> for Map - where K: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo, - V: DafnyTypeEq +impl UpcastTo> for Map +where + K: DafnyTypeEq, + U: DafnyTypeEq + UpcastTo, + V: DafnyTypeEq, { - fn upcast_to(&self) -> Map { + fn upcast_to(self) -> Map { // We need to upcast individual elements let mut new_map: HashMap = HashMap::::default(); for (key, value) in self.data.iter() { - new_map.insert(key.clone(), value.upcast_to()); + new_map.insert(key.clone(), value.clone().upcast_to()); } Map::from_hashmap_owned(new_map) } } - - - diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/src/system/mod.rs b/TestModels/dafny-dependencies/dafny_runtime_rust/src/system/mod.rs new file mode 100644 index 000000000..64d4e6203 --- /dev/null +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/src/system/mod.rs @@ -0,0 +1,3739 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] +pub mod _System { + pub type nat = crate::DafnyInt; + + #[derive(PartialEq, Clone)] + pub enum Tuple2 { + _T2 { + _0: T0, + _1: T1 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple2 { + pub fn _0(&self) -> &T0 { + match self { + Tuple2::_T2 { _0, _1, } => _0, + Tuple2::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple2::_T2 { _0, _1, } => _1, + Tuple2::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple2 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple2::_T2 { _0, _1, } => { + write!(_formatter, "_System.Tuple2._T2(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple2::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple2 {} + + impl ::std::hash::Hash + for Tuple2 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple2::_T2 { _0, _1, } => { + _0.hash(_state); + _1.hash(_state) + }, + Tuple2::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple2 { + fn default() -> Tuple2 { + Tuple2::_T2 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple2 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple0 { + _T0 {} + } + + impl Tuple0 {} + + impl ::std::fmt::Debug + for Tuple0 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple0 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple0::_T0 { } => { + write!(_formatter, "_System.Tuple0._T0")?; + Ok(()) + }, + } + } + } + + impl Eq + for Tuple0 {} + + impl ::std::hash::Hash + for Tuple0 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple0::_T0 { } => { + + }, + } + } + } + + impl ::std::default::Default + for Tuple0 { + fn default() -> Tuple0 { + Tuple0::_T0 {} + } + } + + impl ::std::convert::AsRef + for &Tuple0 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple1 { + _T1 { + _0: T0 + }, + _PhantomVariant(::std::marker::PhantomData) + } + + impl Tuple1 { + pub fn _0(&self) -> &T0 { + match self { + Tuple1::_T1 { _0, } => _0, + Tuple1::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple1 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple1::_T1 { _0, } => { + write!(_formatter, "_System.Tuple1._T1(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple1::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple1 {} + + impl ::std::hash::Hash + for Tuple1 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple1::_T1 { _0, } => { + _0.hash(_state) + }, + Tuple1::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple1 { + fn default() -> Tuple1 { + Tuple1::_T1 { + _0: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple1 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple3 { + _T3 { + _0: T0, + _1: T1, + _2: T2 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple3 { + pub fn _0(&self) -> &T0 { + match self { + Tuple3::_T3 { _0, _1, _2, } => _0, + Tuple3::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple3::_T3 { _0, _1, _2, } => _1, + Tuple3::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple3::_T3 { _0, _1, _2, } => _2, + Tuple3::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple3 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple3 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple3::_T3 { _0, _1, _2, } => { + write!(_formatter, "_System.Tuple3._T3(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple3::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple3 {} + + impl ::std::hash::Hash + for Tuple3 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple3::_T3 { _0, _1, _2, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state) + }, + Tuple3::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple3 { + fn default() -> Tuple3 { + Tuple3::_T3 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple3 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple4 { + _T4 { + _0: T0, + _1: T1, + _2: T2, + _3: T3 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple4 { + pub fn _0(&self) -> &T0 { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => _0, + Tuple4::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => _1, + Tuple4::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => _2, + Tuple4::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => _3, + Tuple4::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple4 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple4 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => { + write!(_formatter, "_System.Tuple4._T4(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple4::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple4 {} + + impl ::std::hash::Hash + for Tuple4 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple4::_T4 { _0, _1, _2, _3, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state) + }, + Tuple4::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple4 { + fn default() -> Tuple4 { + Tuple4::_T4 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple4 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple5 { + _T5 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple5 { + pub fn _0(&self) -> &T0 { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => _0, + Tuple5::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => _1, + Tuple5::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => _2, + Tuple5::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => _3, + Tuple5::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => _4, + Tuple5::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple5 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple5 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => { + write!(_formatter, "_System.Tuple5._T5(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple5::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple5 {} + + impl ::std::hash::Hash + for Tuple5 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple5::_T5 { _0, _1, _2, _3, _4, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state) + }, + Tuple5::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple5 { + fn default() -> Tuple5 { + Tuple5::_T5 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple5 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple6 { + _T6 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple6 { + pub fn _0(&self) -> &T0 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _0, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _1, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _2, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _3, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _4, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => _5, + Tuple6::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple6 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple6 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => { + write!(_formatter, "_System.Tuple6._T6(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple6::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple6 {} + + impl ::std::hash::Hash + for Tuple6 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple6::_T6 { _0, _1, _2, _3, _4, _5, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state) + }, + Tuple6::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple6 { + fn default() -> Tuple6 { + Tuple6::_T6 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple6 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple7 { + _T7 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple7 { + pub fn _0(&self) -> &T0 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _0, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _1, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _2, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _3, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _4, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _5, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => _6, + Tuple7::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple7 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple7 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => { + write!(_formatter, "_System.Tuple7._T7(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple7::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple7 {} + + impl ::std::hash::Hash + for Tuple7 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple7::_T7 { _0, _1, _2, _3, _4, _5, _6, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state) + }, + Tuple7::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple7 { + fn default() -> Tuple7 { + Tuple7::_T7 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple7 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple8 { + _T8 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple8 { + pub fn _0(&self) -> &T0 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _0, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _1, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _2, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _3, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _4, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _5, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _6, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => _7, + Tuple8::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple8 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple8 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => { + write!(_formatter, "_System.Tuple8._T8(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple8::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple8 {} + + impl ::std::hash::Hash + for Tuple8 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple8::_T8 { _0, _1, _2, _3, _4, _5, _6, _7, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state) + }, + Tuple8::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple8 { + fn default() -> Tuple8 { + Tuple8::_T8 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple8 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple9 { + _T9 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple9 { + pub fn _0(&self) -> &T0 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _0, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _1, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _2, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _3, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _4, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _5, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _6, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _7, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => _8, + Tuple9::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple9 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple9 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => { + write!(_formatter, "_System.Tuple9._T9(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple9::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple9 {} + + impl ::std::hash::Hash + for Tuple9 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple9::_T9 { _0, _1, _2, _3, _4, _5, _6, _7, _8, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state) + }, + Tuple9::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple9 { + fn default() -> Tuple9 { + Tuple9::_T9 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple9 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple10 { + _T10 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple10 { + pub fn _0(&self) -> &T0 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _0, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _1, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _2, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _3, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _4, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _5, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _6, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _7, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _8, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _9, + Tuple10::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple10 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple10 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => { + write!(_formatter, "_System.Tuple10._T10(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple10::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple10 {} + + impl ::std::hash::Hash + for Tuple10 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple10::_T10 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state) + }, + Tuple10::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple10 { + fn default() -> Tuple10 { + Tuple10::_T10 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple10 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple11 { + _T11 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple11 { + pub fn _0(&self) -> &T0 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _0, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _1, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _2, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _3, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _4, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _5, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _6, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _7, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _8, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _9, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _10, + Tuple11::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple11 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple11 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => { + write!(_formatter, "_System.Tuple11._T11(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple11::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple11 {} + + impl ::std::hash::Hash + for Tuple11 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple11::_T11 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state) + }, + Tuple11::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple11 { + fn default() -> Tuple11 { + Tuple11::_T11 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple11 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple12 { + _T12 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple12 { + pub fn _0(&self) -> &T0 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _0, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _1, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _2, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _3, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _4, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _5, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _6, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _7, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _8, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _9, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _10, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _11, + Tuple12::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple12 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple12 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => { + write!(_formatter, "_System.Tuple12._T12(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple12::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple12 {} + + impl ::std::hash::Hash + for Tuple12 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple12::_T12 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state) + }, + Tuple12::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple12 { + fn default() -> Tuple12 { + Tuple12::_T12 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple12 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple13 { + _T13 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple13 { + pub fn _0(&self) -> &T0 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _0, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _1, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _2, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _3, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _4, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _5, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _6, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _7, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _8, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _9, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _10, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _11, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _12, + Tuple13::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple13 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple13 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => { + write!(_formatter, "_System.Tuple13._T13(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple13::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple13 {} + + impl ::std::hash::Hash + for Tuple13 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple13::_T13 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state) + }, + Tuple13::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple13 { + fn default() -> Tuple13 { + Tuple13::_T13 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple13 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple14 { + _T14 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple14 { + pub fn _0(&self) -> &T0 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _0, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _1, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _2, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _3, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _4, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _5, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _6, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _7, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _8, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _9, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _10, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _11, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _12, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _13, + Tuple14::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple14 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple14 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => { + write!(_formatter, "_System.Tuple14._T14(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple14::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple14 {} + + impl ::std::hash::Hash + for Tuple14 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple14::_T14 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state) + }, + Tuple14::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple14 { + fn default() -> Tuple14 { + Tuple14::_T14 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple14 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple15 { + _T15 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple15 { + pub fn _0(&self) -> &T0 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _0, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _1, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _2, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _3, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _4, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _5, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _6, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _7, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _8, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _9, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _10, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _11, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _12, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _13, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _14, + Tuple15::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple15 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple15 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => { + write!(_formatter, "_System.Tuple15._T15(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple15::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple15 {} + + impl ::std::hash::Hash + for Tuple15 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple15::_T15 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state) + }, + Tuple15::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple15 { + fn default() -> Tuple15 { + Tuple15::_T15 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple15 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple16 { + _T16 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14, + _15: T15 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple16 { + pub fn _0(&self) -> &T0 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _0, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _1, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _2, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _3, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _4, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _5, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _6, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _7, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _8, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _9, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _10, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _11, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _12, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _13, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _14, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + pub fn _15(&self) -> &T15 { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _15, + Tuple16::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple16 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple16 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => { + write!(_formatter, "_System.Tuple16._T16(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple16::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple16 {} + + impl ::std::hash::Hash + for Tuple16 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple16::_T16 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state); + _15.hash(_state) + }, + Tuple16::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple16 { + fn default() -> Tuple16 { + Tuple16::_T16 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default(), + _15: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple16 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple17 { + _T17 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14, + _15: T15, + _16: T16 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple17 { + pub fn _0(&self) -> &T0 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _0, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _1, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _2, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _3, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _4, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _5, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _6, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _7, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _8, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _9, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _10, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _11, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _12, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _13, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _14, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _15(&self) -> &T15 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _15, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + pub fn _16(&self) -> &T16 { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _16, + Tuple17::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple17 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple17 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => { + write!(_formatter, "_System.Tuple17._T17(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple17::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple17 {} + + impl ::std::hash::Hash + for Tuple17 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple17::_T17 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state); + _15.hash(_state); + _16.hash(_state) + }, + Tuple17::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple17 { + fn default() -> Tuple17 { + Tuple17::_T17 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default(), + _15: ::std::default::Default::default(), + _16: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple17 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple18 { + _T18 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14, + _15: T15, + _16: T16, + _17: T17 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple18 { + pub fn _0(&self) -> &T0 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _0, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _1, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _2, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _3, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _4, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _5, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _6, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _7, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _8, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _9, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _10, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _11, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _12, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _13, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _14, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _15(&self) -> &T15 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _15, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _16(&self) -> &T16 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _16, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + pub fn _17(&self) -> &T17 { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _17, + Tuple18::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple18 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple18 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => { + write!(_formatter, "_System.Tuple18._T18(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple18::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple18 {} + + impl ::std::hash::Hash + for Tuple18 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple18::_T18 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state); + _15.hash(_state); + _16.hash(_state); + _17.hash(_state) + }, + Tuple18::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple18 { + fn default() -> Tuple18 { + Tuple18::_T18 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default(), + _15: ::std::default::Default::default(), + _16: ::std::default::Default::default(), + _17: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple18 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple19 { + _T19 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14, + _15: T15, + _16: T16, + _17: T17, + _18: T18 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple19 { + pub fn _0(&self) -> &T0 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _0, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _1, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _2, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _3, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _4, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _5, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _6, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _7, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _8, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _9, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _10, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _11, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _12, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _13, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _14, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _15(&self) -> &T15 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _15, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _16(&self) -> &T16 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _16, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _17(&self) -> &T17 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _17, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + pub fn _18(&self) -> &T18 { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _18, + Tuple19::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple19 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple19 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => { + write!(_formatter, "_System.Tuple19._T19(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_18, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple19::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple19 {} + + impl ::std::hash::Hash + for Tuple19 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple19::_T19 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state); + _15.hash(_state); + _16.hash(_state); + _17.hash(_state); + _18.hash(_state) + }, + Tuple19::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple19 { + fn default() -> Tuple19 { + Tuple19::_T19 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default(), + _15: ::std::default::Default::default(), + _16: ::std::default::Default::default(), + _17: ::std::default::Default::default(), + _18: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple19 { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum Tuple20 { + _T20 { + _0: T0, + _1: T1, + _2: T2, + _3: T3, + _4: T4, + _5: T5, + _6: T6, + _7: T7, + _8: T8, + _9: T9, + _10: T10, + _11: T11, + _12: T12, + _13: T13, + _14: T14, + _15: T15, + _16: T16, + _17: T17, + _18: T18, + _19: T19 + }, + _PhantomVariant(::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData, + ::std::marker::PhantomData) + } + + impl Tuple20 { + pub fn _0(&self) -> &T0 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _0, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _1(&self) -> &T1 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _1, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _2(&self) -> &T2 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _2, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _3(&self) -> &T3 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _3, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _4(&self) -> &T4 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _4, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _5(&self) -> &T5 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _5, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _6(&self) -> &T6 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _6, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _7(&self) -> &T7 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _7, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _8(&self) -> &T8 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _8, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _9(&self) -> &T9 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _9, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _10(&self) -> &T10 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _10, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _11(&self) -> &T11 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _11, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _12(&self) -> &T12 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _12, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _13(&self) -> &T13 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _13, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _14(&self) -> &T14 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _14, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _15(&self) -> &T15 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _15, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _16(&self) -> &T16 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _16, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _17(&self) -> &T17 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _17, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _18(&self) -> &T18 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _18, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + pub fn _19(&self) -> &T19 { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _19, + Tuple20::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for Tuple20 { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + crate::DafnyPrint::fmt_print(self, f, true) + } + } + + impl crate::DafnyPrint + for Tuple20 { + fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => { + write!(_formatter, "_System.Tuple20._T20(")?; + crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_18, _formatter, false)?; + write!(_formatter, ", ")?; + crate::DafnyPrint::fmt_print(_19, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + }, + Tuple20::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl Eq + for Tuple20 {} + + impl ::std::hash::Hash + for Tuple20 { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Tuple20::_T20 { _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => { + _0.hash(_state); + _1.hash(_state); + _2.hash(_state); + _3.hash(_state); + _4.hash(_state); + _5.hash(_state); + _6.hash(_state); + _7.hash(_state); + _8.hash(_state); + _9.hash(_state); + _10.hash(_state); + _11.hash(_state); + _12.hash(_state); + _13.hash(_state); + _14.hash(_state); + _15.hash(_state); + _16.hash(_state); + _17.hash(_state); + _18.hash(_state); + _19.hash(_state) + }, + Tuple20::_PhantomVariant(..) => {panic!()}, + } + } + } + + impl ::std::default::Default + for Tuple20 { + fn default() -> Tuple20 { + Tuple20::_T20 { + _0: ::std::default::Default::default(), + _1: ::std::default::Default::default(), + _2: ::std::default::Default::default(), + _3: ::std::default::Default::default(), + _4: ::std::default::Default::default(), + _5: ::std::default::Default::default(), + _6: ::std::default::Default::default(), + _7: ::std::default::Default::default(), + _8: ::std::default::Default::default(), + _9: ::std::default::Default::default(), + _10: ::std::default::Default::default(), + _11: ::std::default::Default::default(), + _12: ::std::default::Default::default(), + _13: ::std::default::Default::default(), + _14: ::std::default::Default::default(), + _15: ::std::default::Default::default(), + _16: ::std::default::Default::default(), + _17: ::std::default::Default::default(), + _18: ::std::default::Default::default(), + _19: ::std::default::Default::default() + } + } + } + + impl ::std::convert::AsRef> + for &Tuple20 { + fn as_ref(&self) -> Self { + self + } + } +} \ No newline at end of file diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs b/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs index 6f4e10326..9488eb471 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs @@ -1,8 +1,9 @@ - pub mod experimental; // Test module #[cfg(test)] mod tests { + use crate::rcmut::RcMut; + use crate::*; #[test] @@ -26,7 +27,7 @@ mod tests { let seq = Sequence::::from_array_owned(values.clone()); assert_eq!(seq.cardinality_usize(), 3); assert_eq!(seq.to_array(), values.into()); - + // Create a concat array, wrap it into a lazy one, get the i-th element, // and verify that this operation flattened the array let left = Sequence::::from_array_owned(vec![1, 2, 3]); @@ -35,25 +36,32 @@ mod tests { assert_eq!(concat.cardinality_usize(), 6); match &concat { - Sequence::ConcatSequence { boxed, length, left, ..} => { + Sequence::ConcatSequence { + boxed, + length, + left, + .. + } => { assert_eq!(*length, 6); - assert_eq!(unsafe {&*left.get()}.cardinality_usize(), 3); + assert_eq!(unsafe { &*left.get() }.cardinality_usize(), 3); // Test that boxed is None assert!(boxed.as_ref().clone().borrow().as_ref().is_none()); - }, - _ => panic!("This should never happen") + } + _ => panic!("This should never happen"), } - let value = concat.select(0); + let value = concat.get_usize(0); assert_eq!(value, 1); match &concat { - crate::Sequence::ConcatSequence { boxed, ..} => { - assert_eq!(*boxed.as_ref().clone().borrow().as_ref().unwrap().as_ref(), vec![1, 2, 3, 4, 5, 6]); - }, - _ => panic!("This should never happen") + crate::Sequence::ConcatSequence { boxed, .. } => { + assert_eq!( + *boxed.as_ref().clone().borrow().as_ref().unwrap().as_ref(), + vec![1, 2, 3, 4, 5, 6] + ); + } + _ => panic!("This should never happen"), } } - #[test] fn test_dafny_int() { assert_eq!(int!(0).to_usize(), Some(0)); @@ -63,10 +71,19 @@ mod tests { #[test] fn test_dafny_sequence_print() { let hello: DafnyString = seq![ - DafnyChar('H'), DafnyChar('e'), DafnyChar('l'), DafnyChar('l'), DafnyChar('o')]; + DafnyChar('H'), + DafnyChar('e'), + DafnyChar('l'), + DafnyChar('l'), + DafnyChar('o') + ]; assert_eq!(DafnyPrintWrapper(&hello).to_string(), "Hello"); let hello: DafnyStringUTF16 = seq![ - DafnyCharUTF16(0x0048), DafnyCharUTF16(0x0065), DafnyCharUTF16(0x006c), DafnyCharUTF16(0x006c), DafnyCharUTF16(0x006f) + DafnyCharUTF16(0x0048), + DafnyCharUTF16(0x0065), + DafnyCharUTF16(0x006c), + DafnyCharUTF16(0x006c), + DafnyCharUTF16(0x006f) ]; assert_eq!(DafnyPrintWrapper(&hello).to_string(), "Hello"); assert_eq!(DafnyPrintWrapper(&string_of("Hello")).to_string(), "Hello"); @@ -89,35 +106,38 @@ mod tests { #[test] fn test_dafny_set() { - let s = set!{55, 56, 57, 56, 58}; - let t = set!{59, 58, 57}; + let s = set! {55, 56, 57, 56, 58}; + let t = set! {59, 58, 57}; assert_eq!(s.cardinality_usize(), 4); assert_eq!(s.cardinality(), int!(4)); assert_eq!(s.contains(&55), true); assert_eq!(s.contains(&54), false); - assert_eq!(s.merge(&set!{}), s); - assert_eq!(set!{}.merge(&s), s); - assert_eq!(s.merge(&t), set!{59, 58, 57, 56, 55}); - assert_eq!(s.intersect(&t), set!{57, 58}); - assert_eq!(s.subtract(&set!{}), s); - assert_eq!(set!{}.subtract(&s), set!{}); + assert_eq!(s.merge(&set! {}), s); + assert_eq!(set! {}.merge(&s), s); + assert_eq!(s.merge(&t), set! {59, 58, 57, 56, 55}); + assert_eq!(s.intersect(&t), set! {57, 58}); + assert_eq!(s.subtract(&set! {}), s); + assert_eq!(set! {}.subtract(&s), set! {}); let smt = s.subtract(&t); - assert_eq!(smt, set!{55, 56}); - assert_eq!(t.subtract(&s), set!{59}); - assert_eq!(s.disjoint(&set!{}), true); - assert_eq!(set!{}.disjoint(&s), true); + assert_eq!(smt, set! {55, 56}); + assert_eq!(t.subtract(&s), set! {59}); + assert_eq!(s.disjoint(&set! {}), true); + assert_eq!(set! {}.disjoint(&s), true); assert_eq!(s.disjoint(&t), false); assert_eq!(t.disjoint(&s), false); assert_eq!(smt.disjoint(&t), true); assert_eq!(t.disjoint(&smt), true); assert_eq!(s.elements(), s); - assert_eq!(s.as_dafny_multiset(), Multiset::from_array(&vec!(55, 56, 57, 58))); + assert_eq!( + s.as_dafny_multiset(), + Multiset::from_array(&vec!(55, 56, 57, 58)) + ); } #[test] fn test_dafny_multiset() { - let s = multiset!{55, 56, 57, 56, 58}; - let t = multiset!{59, 58, 57, 56}; + let s = multiset! {55, 56, 57, 56, 58}; + let t = multiset! {59, 58, 57, 56}; assert_eq!(s.cardinality_usize(), 5); assert_eq!(s.cardinality(), int!(5)); assert_eq!(s.contains(&55), true); @@ -126,20 +146,20 @@ mod tests { assert_eq!(s.get(&55), int!(1)); assert_eq!(s.get(&56), int!(2)); assert_eq!(s.get(&57), int!(1)); - assert_eq!(s.merge(&multiset!{}), s); - assert_eq!(multiset!{}.merge(&s), s); - let merged = multiset!{59, 58, 58, 57, 57, 56, 56, 56, 55}; + assert_eq!(s.merge(&multiset! {}), s); + assert_eq!(multiset! {}.merge(&s), s); + let merged = multiset! {59, 58, 58, 57, 57, 56, 56, 56, 55}; assert_eq!(s.merge(&t), merged); assert_eq!(merged.cardinality_usize(), 9); - assert_eq!(s.intersect(&t), multiset!{57, 58, 56}); - assert_eq!(s.subtract(&multiset!{}), s); - assert_eq!(multiset!{}.subtract(&s), multiset!{}); + assert_eq!(s.intersect(&t), multiset! {57, 58, 56}); + assert_eq!(s.subtract(&multiset! {}), s); + assert_eq!(multiset! {}.subtract(&s), multiset! {}); let smt = s.subtract(&t); - assert_eq!(smt, multiset!{55, 56}); + assert_eq!(smt, multiset! {55, 56}); let tms = t.subtract(&s); - assert_eq!(tms, multiset!{59}); - assert_eq!(s.disjoint(&multiset!{}), true); - assert_eq!(multiset!{}.disjoint(&s), true); + assert_eq!(tms, multiset! {59}); + assert_eq!(s.disjoint(&multiset! {}), true); + assert_eq!(multiset! {}.disjoint(&s), true); assert_eq!(s.disjoint(&t), false); assert_eq!(t.disjoint(&s), false); assert_eq!(smt.disjoint(&t), false); @@ -153,8 +173,8 @@ mod tests { fn test_dafny_map() { let m_empty: Map = map![]; let m_3 = map![1 => 2, 3 => 6, 5 => 10]; - let k_3 = set!{1, 3, 5}; - let v_3 = set!{2, 6, 10}; + let k_3 = set! {1, 3, 5}; + let v_3 = set! {2, 6, 10}; assert_eq!(m_empty.cardinality_usize(), 0); assert_eq!(m_empty.cardinality(), int!(0)); assert_eq!(m_3.cardinality_usize(), 3); @@ -171,7 +191,7 @@ mod tests { assert_eq!(m_4.contains(&0), true); m_4 = m_4.update_index_owned(0, 7); assert_eq!(m_4.contains(&0), true); - + assert_eq!(m_4.get(&0), 7); assert_eq!(m_4.cardinality_usize(), 4); assert_eq!(m_4.merge(&map![]), m_4); @@ -181,8 +201,8 @@ mod tests { println!("m_4 is {:?}", m_4); assert_eq!(m_4.get(&3), 6); assert_eq!(m_5.get(&3), 9); - assert_eq!(m_5.subtract(&set!{}), m_5); - let m_4b = m_5.subtract(&set!{3}); + assert_eq!(m_5.subtract(&set! {}), m_5); + let m_4b = m_5.subtract(&set! {3}); assert_eq!(m_4b.cardinality_usize(), 4); assert_eq!(m_4b.contains(&3), false) } @@ -231,13 +251,85 @@ mod tests { assert_eq!(array::get_usize(v3, 1), int!(10)); } + #[test] + fn test_array2() { + let p = Array2::::placebos(&int!(3), &int!(4)); + for i in 0..3 { + for j in 0..4 { + modify!(p).data[i][j] = MaybeUninit::new(int!(i + j)); + } + } + let p = Array2::construct(p); + assert_eq!(read!(p).length0_usize(), 3); + assert_eq!(read!(p).length1_usize(), 4); + let v = read!(p).to_vec(); + assert_eq!(v.len(), 3); + assert_eq!(v, vec![ + vec![int!(0), int!(1), int!(2), int!(3)], + vec![int!(1), int!(2), int!(3), int!(4)], + vec![int!(2), int!(3), int!(4), int!(5)]]); + + deallocate(p); + // Allocate an array whose first dimension is zero + let p = Array2::::placebos(&int!(0), &int!(4)); + let p = Array2::construct(p); + assert_eq!(read!(p).length0_usize(), 0); + assert_eq!(read!(p).length1_usize(), 4); + deallocate(p); + } + + #[test] + fn test_array3() { + let a = Array3::::placebos(&int!(3), &int!(2), &int!(4)); + for i in 0..3 { + for j in 0..2 { + for k in 0..4 { + modify!(a).data[i][j][k] = MaybeUninit::new(DafnyInt::from(i * j + k)); + } + } + } + let a = Array3::construct(a); + assert_eq!(read!(a).length0(), int!(3)); + assert_eq!(read!(a).length1(), int!(2)); + assert_eq!(read!(a).length2(), int!(4)); + let v = read!(a).to_vec(); + assert_eq!(v.len(), 3); + for i in 0..3 { + for j in 0..2 { + for k in 0..4 { + assert_eq!(read!(a).data[i][j][k], DafnyInt::from(i * j + k)); + assert_eq!(v[i][j][k], DafnyInt::from(i * j + k)); + } + } + } + deallocate(a); + // Even if the first two dimensions are zero, the third dimension should not be zero + let a = Array3::::placebos(&int!(0), &int!(0), &int!(4)); + let a = Array3::construct(a); + assert_eq!(read!(a).length0(), int!(0)); + assert_eq!(read!(a).length1(), int!(0)); + assert_eq!(read!(a).length2(), int!(4)); + deallocate(a); + } + struct ClassWrapper { - /*var*/t: T, - /*var*/x: crate::DafnyInt, - /*const*/next: *mut ClassWrapper, - /*const*/constant: crate::DafnyInt + /*var*/ t: T, + /*var*/ x: crate::DafnyInt, + /*const*/ next: *mut ClassWrapper, + /*const*/ constant: crate::DafnyInt, } - impl ClassWrapper { + impl AsAny for ClassWrapper + where + T: 'static, + { + fn as_any(&self) -> &dyn Any { + self + } + fn as_any_mut(&mut self) -> &mut dyn Any { + self + } + } + impl ClassWrapper { fn constant_plus_x(&self) -> crate::DafnyInt { self.constant.clone() + self.x.clone() } @@ -246,7 +338,7 @@ mod tests { } } - impl ClassWrapper { + impl ClassWrapper { fn constructor(t: T) -> *mut ClassWrapper { let this = crate::allocate::>(); update_field_nodrop!(this, t, t); @@ -284,7 +376,6 @@ mod tests { assert_eq!(Rc::strong_count(&x_copy.data), 1); } - #[test] #[allow(unused_unsafe)] fn test_extern_class_wrapper_with_box() { @@ -293,7 +384,7 @@ mod tests { t: 53, x: int!(0), next: std::ptr::null_mut(), - constant: int!(42) + constant: int!(42), }); assert_eq!(read!(c).constant, int!(42)); modify!(c).increment_x(); @@ -301,7 +392,6 @@ mod tests { // Automatically dropped } - #[test] #[allow(unused_unsafe)] fn test_extern_class_wrapper_with_mutable_borrow() { @@ -310,27 +400,29 @@ mod tests { t: 53, x: int!(0), next: std::ptr::null_mut(), - constant: int!(42) + constant: int!(42), }; assert_eq!(read!(c).constant, int!(42)); modify!(c).increment_x(); assert_eq!(read!(c).constant_plus_x(), int!(43)); // Automatically dropped } - + // Requires test1 || test2 + // We will not do that as it enables the compiler to assume that t contains a valid Rc when it does not. + // Prefer MaybePlacebo fn assign_lazy_in_method(test1: bool, test2: bool) -> Rc { - let mut t = var_uninit!(Rc); - let mut t_assigned: bool = false; + let mut t = MaybePlacebo::>::new(); if test1 { - update_uninit!(t, t_assigned, Rc::new(5 as i32)); + t = MaybePlacebo::from(Rc::new(5 as i32)); } if test2 { - update_uninit!(t, t_assigned, Rc::new(7 as i32 + if test1 {*t} else {0})); + t = MaybePlacebo::from(Rc::new( + 7 as i32 + if test1 { *MaybePlacebo::read(&t) } else { 0 }, + )); } - println!("{}", *t); - assert!(t_assigned); - t + println!("{}", MaybePlacebo::read(&t)); + MaybePlacebo::read(&t) } #[test] @@ -343,32 +435,6 @@ mod tests { assert_eq!(*t, 12); } - // Uninitialized variables must be forgotten, otherwise Rust will try to clean them - // up and it will result in segfaults. - fn assign_possibly_uninit(return_noassign: bool, update_if_continue: bool) -> Rc { - let mut t = var_uninit!(Rc); - if return_noassign { - forget!(t); - return Rc::new(2); - } - let mut t_assigned: bool = false; - if update_if_continue { - update_uninit!(t, t_assigned, Rc::new(5 as i32)); - } - forget_uninit!(t, t_assigned); - Rc::new(1) - } - - #[test] - fn assign_possibly_uninit_test() { - let mut t = assign_possibly_uninit(true, true); - assert_eq!(*t, 2); - t = assign_possibly_uninit(false, true); - assert_eq!(*t, 1); - t = assign_possibly_uninit(false, false); - assert_eq!(*t, 1); - } - fn override_placebo(o: T, do_override: bool) { let mut x: MaybePlacebo = MaybePlacebo::::new(); if do_override { @@ -382,7 +448,8 @@ mod tests { override_placebo::>(Rc::new(BigInt::from(1)), true); override_placebo::(int!(1), false); override_placebo::(int!(1), true); - let _x: MaybePlacebo<*mut ClassWrapper> = MaybePlacebo::<*mut ClassWrapper>::new(); + let _x: MaybePlacebo<*mut ClassWrapper> = + MaybePlacebo::<*mut ClassWrapper>::new(); //let mut f: Rc Class> = Class> as Placebo>::new(); } @@ -395,78 +462,303 @@ mod tests { assert_eq!(c.read(), 3); assert_eq!(d.read(), 4); } -} -// Struct containing two reference-counted fields + #[test] + fn test_coercion_immutable() { + let o = ClassWrapper::::constructor(1); + let a = UpcastTo::<*mut dyn Any>::upcast_to(o); + assert_eq!(cast!(a, ClassWrapper), o); + let seq_o = seq![o]; + let seq_a = UpcastTo::>::upcast_to(seq_o); + assert_eq!(cast!(seq_a.get_usize(0), ClassWrapper), o); + let set_o = set! {o}; + let set_a = UpcastTo::>::upcast_to(set_o); + assert_eq!(cast!(set_a.peek(), ClassWrapper), o); + let multiset_o = multiset! {o, o}; + let multiset_a = UpcastTo::>::upcast_to(multiset_o); + assert_eq!(cast!(multiset_a.peek(), ClassWrapper), o); + let map_o = map![1 => o, 2 => o]; + let map_a = UpcastTo::>::upcast_to(map_o); + assert_eq!(cast!(map_a.get(&1), ClassWrapper), o); + } -mod node_graph { - use std::rc::Rc; - use std::cell::RefCell; - type NodeRef = Rc>>; + #[test] + fn test_defaults() { + let set_i32 = as Default>::default(); + let seq_i32 = as Default>::default(); + let map_i32 = as Default>::default(); + let multiset_i32 = as Default>::default(); + assert_eq!(set_i32.cardinality_usize(), 0); + assert_eq!(seq_i32.cardinality_usize(), 0); + assert_eq!(map_i32.cardinality_usize(), 0); + assert_eq!(multiset_i32.cardinality_usize(), 0); + } - #[derive(Clone)] - // The private representation of a node. - struct _Node { - inner_value: I, - adjacent: Vec>, + #[test] + fn test_nontrivial_defaults() { + let set_i32 = as NontrivialDefault>::nontrivial_default(); + let seq_i32 = as NontrivialDefault>::nontrivial_default(); + let map_i32 = as NontrivialDefault>::nontrivial_default(); + let multiset_i32 = as NontrivialDefault>::nontrivial_default(); + assert_eq!(set_i32.cardinality_usize(), 0); + assert_eq!(seq_i32.cardinality_usize(), 0); + assert_eq!(map_i32.cardinality_usize(), 0); + assert_eq!(multiset_i32.cardinality_usize(), 0); + let ptr_i32 = <*mut i32 as NontrivialDefault>::nontrivial_default(); + assert_eq!(ptr_i32, std::ptr::null_mut()); } - #[derive(Clone)] - // The public representation of a node, with some syntactic sugar. - struct Node(NodeRef); - impl Node { - // Creates a new node with no edges. - fn new(inner: I) -> Node { - let node = _Node { inner_value: inner, adjacent: vec![] }; - Node(Rc::new(RefCell::new(node))) - } + #[test] + fn test_function_wrappers() { + let f: Rc i32> = Rc::new(|i: i32| i + 1); + let g = f.clone(); + let _h = seq![g]; + } - // Adds a directed edge from this node to other node. - fn add_adjacent(&self, other: &Node) { - (self.0.borrow_mut()).adjacent.push(other.0.clone()); + #[test] + fn test_forall_exists() { + assert!(integer_range(int!(0), int!(10)) + .all(Rc::new(|i: DafnyInt| i.clone() < int!(10)).as_ref())); + assert!(!integer_range(int!(0), int!(11)) + .all(Rc::new(|i: DafnyInt| i.clone() < int!(10)).as_ref())); + assert!(!integer_range(int!(0), int!(10)) + .any(Rc::new(|i: DafnyInt| i.clone() >= int!(10)).as_ref())); + assert!(integer_range(int!(0), int!(11)) + .any(Rc::new(|i: DafnyInt| i.clone() >= int!(10)).as_ref())); + + assert!(integer_range(int!(0), int!(10)).all( + Rc::new(|i: DafnyInt| !(i.clone() % int!(4) == int!(0)) + || i.clone() < int!(10) && i.clone() % int!(2) == int!(0)) + .as_ref() + )); + assert!(integer_range(int!(0), int!(11)).all( + Rc::new(|i: DafnyInt| !(i.clone() % int!(4) == int!(0)) + || i.clone() < int!(10) && i.clone() % int!(2) == int!(0)) + .as_ref() + )); + assert!(!integer_range(int!(0), int!(10)).any( + Rc::new(|i: DafnyInt| i.clone() % int!(4) == int!(0) + && i.clone() >= int!(10) + && i.clone() % int!(2) == int!(0)) + .as_ref() + )); + assert!(!integer_range(int!(0), int!(11)).any( + Rc::new(|i: DafnyInt| i.clone() % int!(4) == int!(0) + && i.clone() >= int!(10) + && i.clone() % int!(2) == int!(0)) + .as_ref() + )); + + assert!(exact_range(10).all(Rc::new(|i: i32| i == 10).as_ref())); + assert!(exact_range(10).any(Rc::new(|i: i32| i == 10).as_ref())); + assert!(!exact_range(10).all(Rc::new(|i: i32| i != 10).as_ref())); + assert!(!exact_range(10).any(Rc::new(|i: i32| i != 10).as_ref())); + + assert!(seq![1, 3, 5, 7] + .iter() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(!seq![1, 3, 5, 7] + .iter() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + assert!(!seq![1, 3, 5, 7, 8] + .iter() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(seq![1, 3, 5, 7, 8] + .iter() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + + assert!(set! {1, 3, 5, 7} + .iter() + .cloned() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(!set! {1, 3, 5, 7} + .iter() + .cloned() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + assert!(!set! {1, 3, 5, 7, 8} + .iter() + .cloned() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(set! {1, 3, 5, 7, 8} + .iter() + .cloned() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + + for i in set! {1, 3, 5, 7}.iter() { + println!("{}", i); } + + assert!(multiset! {1, 1, 5, 7} + .iter() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(!multiset! {1, 1, 5, 7} + .iter() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + assert!(!multiset! {1, 1, 5, 7, 8} + .iter() + .all(Rc::new(|i: u32| i % 2 == 1).as_ref())); + assert!(multiset! {1, 1, 5, 7, 8} + .iter() + .any(Rc::new(|i: u32| i % 2 == 0).as_ref())); + + let m = map![1 => 4, 3 => 6, 5 => 8]; + let m2 = m.clone(); + let m3 = m.clone(); + assert!(m + .clone() + .iter() + .all(Rc::new(move |i: u32| i + 3 == m2.get(&i)).as_ref())); + assert!(!m + .iter() + .any(Rc::new(move |i: u32| i + 2 == m3.get(&i)).as_ref())); + let m = map![1 => 4, 3 => 7, 5 => 7]; + let m2 = m.clone(); + let m3 = m.clone(); + assert!(!m + .clone() + .iter() + .all(Rc::new(move |i: u32| i + 3 == m2.get(&i)).as_ref())); + assert!(m + .iter() + .any(Rc::new(move |i: u32| i + 2 == m3.get(&i)).as_ref())); } - #[derive(Clone)] - struct Graph { - nodes: Vec>, + + #[test] + fn test_for_loops() { + let mut sum: i32 = 0; + for i in integer_range(1, 11) { + sum += i; + } + assert_eq!(sum, 55); + + let mut sum: i32 = 0; + for i in integer_range_down(11, 1) { + sum += i; + } + assert_eq!(sum, 55); + + let mut sum: i32 = 0; + for i in integer_range_unbounded(1) { + sum += i; + if i == 10 { + break; + } + } + assert_eq!(sum, 55); + + let mut sum: i32 = 0; + for i in integer_range_down_unbounded(11) { + sum += i; + if i == 1 { + break; + } + } + assert_eq!(sum, 55); } - impl Graph { - fn with_nodes(nodes: Vec>) -> Self { - Graph { nodes: nodes } + trait NodeRcMutTrait: AsAny {} + + pub struct NodeRcMut { + val: DafnyInt, + next: Object, + } + impl AsAny for NodeRcMut { + fn as_any(&self) -> &dyn Any { + self + } + fn as_any_mut(&mut self) -> &mut dyn Any { + self + } + } + impl NodeRcMut { + fn _ctor(this: Object, val: DafnyInt) { + let mut val_assign = false; + let mut next_assign = false; + update_field_uninit_rcmut!(this.clone(), val, val_assign, val); + update_field_if_uninit_rcmut!(this.clone(), next, next_assign, Object(None)); } } + impl NodeRcMutTrait for NodeRcMut {} - impl Drop for Graph { - fn drop(&mut self) { - // Drop all the nodes in the graph by removing all their edges - for node in self.nodes.iter() { - let mut node = node.0.borrow_mut(); - node.adjacent.clear(); - } + #[test] + fn test_rcmut() { + let x: Object = allocate_rcmut::(); + NodeRcMut::_ctor(x.clone(), int!(42)); + assert_eq!(refcount!(x.clone()), 2); + assert_eq!(rd!(x.clone()).val, int!(42)); + md!(x.clone()).next = x.clone(); + assert_eq!(refcount!(x.clone()), 3); + assert_eq!(rd!(rd!(x.clone()).next.clone()).val, int!(42)); + md!(rd!(x.clone()).next.clone()).next = Object(None); + assert_eq!(refcount!(x.clone()), 2); + let y: Object = x.clone().upcast_to(); + assert_eq!(refcount!(x.clone()), 3); + let z: Object = x.clone().upcast_to(); + assert_eq!(refcount!(x.clone()), 4); + let a2: Object = cast_object!(y.clone(), NodeRcMut); + assert_eq!(refcount!(x.clone()), 5); + assert_eq!(rd!(a2.clone()).val, int!(42)); + let a3: Object = cast_object!(z.clone(), NodeRcMut); + assert_eq!(refcount!(x.clone()), 6); + assert_eq!(rd!(a3.clone()).val, int!(42)); + + let a: Object<[i32]> = rcmut::array_object_from_rc(Rc::new([42, 43, 44])); + assert_eq!(rd!(a.clone()).len(), 3); + assert_eq!(rd!(a.clone())[0], 42); + assert_eq!(rd!(a.clone())[1], 43); + assert_eq!(rd!(a.clone())[2], 44); + let b = a.clone(); + md!(b.clone())[0] = 45; + assert_eq!(rd!(a.clone())[0], 45); + } + + pub struct NodeRawMut { + val: DafnyInt, + next: *mut NodeRawMut, + } + impl NodeRawMut { + fn _ctor(this: *mut NodeRawMut, val: DafnyInt) { + let mut val_assign = false; + update_field_uninit!(this, val, val_assign, val); } } - impl Drop for Node { - fn drop(&mut self) { - // Drop all the edges from this node - let mut node: std::cell::RefMut<'_, _Node> = self.0.borrow_mut(); - //node.adjacent.clear(); + impl AsAny for NodeRawMut { + fn as_any(&self) -> &dyn Any { + self + } + fn as_any_mut(&mut self) -> &mut dyn Any { + self } } + impl NodeRcMutTrait for NodeRawMut {} + + UpcastTo!(NodeRawMut, dyn NodeRcMutTrait); #[test] - fn test() { - let a = Node::new(1); - let b = Node::new(2); - assert_eq!(Rc::strong_count(&a.0), 1); - assert_eq!(Rc::strong_count(&b.0), 1); - a.add_adjacent(&b); - assert_eq!(Rc::strong_count(&a.0), 1); - assert_eq!(Rc::strong_count(&b.0), 2); - b.add_adjacent(&a); - assert_eq!(Rc::strong_count(&a.0), 2); - assert_eq!(Rc::strong_count(&b.0), 2); - drop(b); - assert_eq!(Rc::strong_count(&a.0), 1); - } -} \ No newline at end of file + fn test_rawmut() { + let x: *mut NodeRawMut = allocate::(); + NodeRawMut::_ctor(x.clone(), int!(42)); + //assert_eq!(refcount!(x.clone()), 2); + assert_eq!(read!(x.clone()).val, int!(42)); + modify!(x.clone()).next = x.clone(); + //assert_eq!(refcount!(x.clone()), 3); + assert_eq!(read!(read!(x.clone()).next.clone()).val, int!(42)); + modify!(read!(x.clone()).next.clone()).next = std::ptr::null_mut(); + //assert_eq!(refcount!(x.clone()), 2); + let y = x.upcast_to(); + let z: *mut dyn NodeRcMutTrait = modify!(x).upcast_to(); + let a2: *mut NodeRawMut = cast!(y, NodeRawMut); + let a3: *mut NodeRawMut = cast!(z, NodeRawMut); + //assert_eq!(refcount!(x.clone()), 3); + deallocate(x); + + let a = array::from_native(Box::new([42, 43, 44])); + assert_eq!(read!(a.clone()).len(), 3); + assert_eq!(read!(a.clone())[0], 42); + assert_eq!(read!(a.clone())[1], 43); + assert_eq!(read!(a.clone())[2], 44); + let b = a.clone(); + modify!(b.clone())[0] = 45; + assert_eq!(read!(a.clone())[0], 45); + } +}