github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library@v0.2.0/JSON_Utils_Views_Writers/JSON_Utils_Views_Writers.go (about)

     1  // Package JSON_Utils_Views_Writers
     2  // Dafny module JSON_Utils_Views_Writers compiled into Go
     3  
     4  package JSON_Utils_Views_Writers
     5  
     6  import (
     7  	os "os"
     8  
     9  	m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions"
    10  	m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64"
    11  	m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas"
    12  	m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts"
    13  	m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals"
    14  	m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear"
    15  	m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod"
    16  	m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO"
    17  	m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare"
    18  	m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions"
    19  	m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals"
    20  	m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt"
    21  	m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings"
    22  	m_JSON_Utils_Views_Core "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/JSON_Utils_Views_Core"
    23  	m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm"
    24  	m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_"
    25  	m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals"
    26  	m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear"
    27  	m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul"
    28  	m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals"
    29  	m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear"
    30  	m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power"
    31  	m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations"
    32  	m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq"
    33  	m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort"
    34  	m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting"
    35  	m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary"
    36  	m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop"
    37  	m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence"
    38  	m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String"
    39  	m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt"
    40  	m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams"
    41  	m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings"
    42  	m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_"
    43  	m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm"
    44  	m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm"
    45  	m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
    46  	m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_"
    47  	_dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny"
    48  )
    49  
    50  var _ = os.Args
    51  var _ _dafny.Dummy__
    52  var _ m__System.Dummy__
    53  var _ m_Wrappers.Dummy__
    54  var _ m_Relations.Dummy__
    55  var _ m_Seq_MergeSort.Dummy__
    56  var _ m__Math.Dummy__
    57  var _ m_Seq.Dummy__
    58  var _ m_BoundedInts.Dummy__
    59  var _ m__Unicode.Dummy__
    60  var _ m_Functions.Dummy__
    61  var _ m_Utf8EncodingForm.Dummy__
    62  var _ m_Utf16EncodingForm.Dummy__
    63  var _ m_UnicodeStrings.Dummy__
    64  var _ m_FileIO.Dummy__
    65  var _ m_GeneralInternals.Dummy__
    66  var _ m_MulInternalsNonlinear.Dummy__
    67  var _ m_MulInternals.Dummy__
    68  var _ m_Mul.Dummy__
    69  var _ m_ModInternalsNonlinear.Dummy__
    70  var _ m_DivInternalsNonlinear.Dummy__
    71  var _ m_ModInternals.Dummy__
    72  var _ m_DivInternals.Dummy__
    73  var _ m_DivMod.Dummy__
    74  var _ m_Power.Dummy__
    75  var _ m_Logarithm.Dummy__
    76  var _ m_StandardLibraryInterop.Dummy__
    77  var _ m_StandardLibrary_UInt.Dummy__
    78  var _ m_StandardLibrary_Sequence.Dummy__
    79  var _ m_StandardLibrary_String.Dummy__
    80  var _ m_StandardLibrary.Dummy__
    81  var _ m_Streams.Dummy__
    82  var _ m_Sorting.Dummy__
    83  var _ m_HexStrings.Dummy__
    84  var _ m_GetOpt.Dummy__
    85  var _ m_FloatCompare.Dummy__
    86  var _ m_Base64.Dummy__
    87  var _ m_Base64Lemmas.Dummy__
    88  var _ m_Actions.Dummy__
    89  var _ m_JSON_Utils_Views_Core.Dummy__
    90  
    91  type Dummy__ struct{}
    92  
    93  // Definition of datatype Chain
    94  type Chain struct {
    95  	Data_Chain_
    96  }
    97  
    98  func (_this Chain) Get_() Data_Chain_ {
    99  	return _this.Data_Chain_
   100  }
   101  
   102  type Data_Chain_ interface {
   103  	isChain()
   104  }
   105  
   106  type CompanionStruct_Chain_ struct {
   107  }
   108  
   109  var Companion_Chain_ = CompanionStruct_Chain_{}
   110  
   111  type Chain_Empty struct {
   112  }
   113  
   114  func (Chain_Empty) isChain() {}
   115  
   116  func (CompanionStruct_Chain_) Create_Empty_() Chain {
   117  	return Chain{Chain_Empty{}}
   118  }
   119  
   120  func (_this Chain) Is_Empty() bool {
   121  	_, ok := _this.Get_().(Chain_Empty)
   122  	return ok
   123  }
   124  
   125  type Chain_Chain struct {
   126  	Previous Chain
   127  	V        m_JSON_Utils_Views_Core.View__
   128  }
   129  
   130  func (Chain_Chain) isChain() {}
   131  
   132  func (CompanionStruct_Chain_) Create_Chain_(Previous Chain, V m_JSON_Utils_Views_Core.View__) Chain {
   133  	return Chain{Chain_Chain{Previous, V}}
   134  }
   135  
   136  func (_this Chain) Is_Chain() bool {
   137  	_, ok := _this.Get_().(Chain_Chain)
   138  	return ok
   139  }
   140  
   141  func (CompanionStruct_Chain_) Default() Chain {
   142  	return Companion_Chain_.Create_Empty_()
   143  }
   144  
   145  func (_this Chain) Dtor_previous() Chain {
   146  	return _this.Get_().(Chain_Chain).Previous
   147  }
   148  
   149  func (_this Chain) Dtor_v() m_JSON_Utils_Views_Core.View__ {
   150  	return _this.Get_().(Chain_Chain).V
   151  }
   152  
   153  func (_this Chain) String() string {
   154  	switch data := _this.Get_().(type) {
   155  	case nil:
   156  		return "null"
   157  	case Chain_Empty:
   158  		{
   159  			return "Writers.Chain.Empty"
   160  		}
   161  	case Chain_Chain:
   162  		{
   163  			return "Writers.Chain.Chain" + "(" + _dafny.String(data.Previous) + ", " + _dafny.String(data.V) + ")"
   164  		}
   165  	default:
   166  		{
   167  			return "<unexpected>"
   168  		}
   169  	}
   170  }
   171  
   172  func (_this Chain) Equals(other Chain) bool {
   173  	switch data1 := _this.Get_().(type) {
   174  	case Chain_Empty:
   175  		{
   176  			_, ok := other.Get_().(Chain_Empty)
   177  			return ok
   178  		}
   179  	case Chain_Chain:
   180  		{
   181  			data2, ok := other.Get_().(Chain_Chain)
   182  			return ok && data1.Previous.Equals(data2.Previous) && data1.V.Equals(data2.V)
   183  		}
   184  	default:
   185  		{
   186  			return false // unexpected
   187  		}
   188  	}
   189  }
   190  
   191  func (_this Chain) EqualsGeneric(other interface{}) bool {
   192  	typed, ok := other.(Chain)
   193  	return ok && _this.Equals(typed)
   194  }
   195  
   196  func Type_Chain_() _dafny.TypeDescriptor {
   197  	return type_Chain_{}
   198  }
   199  
   200  type type_Chain_ struct {
   201  }
   202  
   203  func (_this type_Chain_) Default() interface{} {
   204  	return Companion_Chain_.Default()
   205  }
   206  
   207  func (_this type_Chain_) String() string {
   208  	return "JSON_Utils_Views_Writers.Chain"
   209  }
   210  func (_this Chain) ParentTraits_() []*_dafny.TraitID {
   211  	return [](*_dafny.TraitID){}
   212  }
   213  
   214  var _ _dafny.TraitOffspring = Chain{}
   215  
   216  func (_this Chain) Length() _dafny.Int {
   217  	{
   218  		var _0___accumulator _dafny.Int = _dafny.Zero
   219  		_ = _0___accumulator
   220  		goto TAIL_CALL_START
   221  	TAIL_CALL_START:
   222  		if (_this).Is_Empty() {
   223  			return (_dafny.Zero).Plus(_0___accumulator)
   224  		} else {
   225  			_0___accumulator = (_dafny.IntOfUint32(((_this).Dtor_v()).Length())).Plus(_0___accumulator)
   226  			var _in0 Chain = (_this).Dtor_previous()
   227  			_ = _in0
   228  			_this = _in0
   229  
   230  			goto TAIL_CALL_START
   231  		}
   232  	}
   233  }
   234  func (_this Chain) Count() _dafny.Int {
   235  	{
   236  		var _0___accumulator _dafny.Int = _dafny.Zero
   237  		_ = _0___accumulator
   238  		goto TAIL_CALL_START
   239  	TAIL_CALL_START:
   240  		if (_this).Is_Empty() {
   241  			return (_dafny.Zero).Plus(_0___accumulator)
   242  		} else {
   243  			_0___accumulator = (_dafny.One).Plus(_0___accumulator)
   244  			var _in0 Chain = (_this).Dtor_previous()
   245  			_ = _in0
   246  			_this = _in0
   247  
   248  			goto TAIL_CALL_START
   249  		}
   250  	}
   251  }
   252  func (_this Chain) Bytes() _dafny.Sequence {
   253  	{
   254  		var _0___accumulator _dafny.Sequence = _dafny.SeqOf()
   255  		_ = _0___accumulator
   256  		goto TAIL_CALL_START
   257  	TAIL_CALL_START:
   258  		if (_this).Is_Empty() {
   259  			return _dafny.Companion_Sequence_.Concatenate(_dafny.SeqOf(), _0___accumulator)
   260  		} else {
   261  			_0___accumulator = _dafny.Companion_Sequence_.Concatenate(((_this).Dtor_v()).Bytes(), _0___accumulator)
   262  			var _in0 Chain = (_this).Dtor_previous()
   263  			_ = _in0
   264  			_this = _in0
   265  
   266  			goto TAIL_CALL_START
   267  		}
   268  	}
   269  }
   270  func (_this Chain) Append(v_k m_JSON_Utils_Views_Core.View__) Chain {
   271  	{
   272  		if ((_this).Is_Chain()) && (m_JSON_Utils_Views_Core.Companion_Default___.Adjacent((_this).Dtor_v(), v_k)) {
   273  			return Companion_Chain_.Create_Chain_((_this).Dtor_previous(), m_JSON_Utils_Views_Core.Companion_Default___.Merge((_this).Dtor_v(), v_k))
   274  		} else {
   275  			return Companion_Chain_.Create_Chain_(_this, v_k)
   276  		}
   277  	}
   278  }
   279  func (_this Chain) CopyTo(dest _dafny.Array, end uint32) {
   280  	{
   281  		goto TAIL_CALL_START
   282  	TAIL_CALL_START:
   283  		if (_this).Is_Chain() {
   284  			var _0_end uint32
   285  			_ = _0_end
   286  			_0_end = (end) - (func() uint32 { return (((_this).Dtor_v()).Length()) })()
   287  			((_this).Dtor_v()).CopyTo(dest, _0_end)
   288  			var _in0 Chain = (_this).Dtor_previous()
   289  			_ = _in0
   290  			var _in1 _dafny.Array = dest
   291  			_ = _in1
   292  			var _in2 uint32 = _0_end
   293  			_ = _in2
   294  			_this = _in0
   295  
   296  			dest = _in1
   297  			end = _in2
   298  			goto TAIL_CALL_START
   299  		}
   300  	}
   301  }
   302  
   303  // End of datatype Chain
   304  
   305  // Definition of class Writer
   306  type Writer struct {
   307  }
   308  
   309  func New_Writer_() *Writer {
   310  	_this := Writer{}
   311  
   312  	return &_this
   313  }
   314  
   315  type CompanionStruct_Writer_ struct {
   316  }
   317  
   318  var Companion_Writer_ = CompanionStruct_Writer_{}
   319  
   320  func (*Writer) String() string {
   321  	return "JSON_Utils_Views_Writers.Writer"
   322  }
   323  func (_this *CompanionStruct_Writer_) Witness() Writer__ {
   324  	return Companion_Writer___.Create_Writer_(uint32(0), Companion_Chain_.Create_Empty_())
   325  }
   326  
   327  // End of class Writer
   328  
   329  func Type_Writer_() _dafny.TypeDescriptor {
   330  	return type_Writer_{}
   331  }
   332  
   333  type type_Writer_ struct {
   334  }
   335  
   336  func (_this type_Writer_) Default() interface{} {
   337  	return Companion_Writer_.Witness()
   338  }
   339  
   340  func (_this type_Writer_) String() string {
   341  	return "JSON_Utils_Views_Writers.Writer"
   342  }
   343  
   344  // Definition of datatype Writer__
   345  type Writer__ struct {
   346  	Data_Writer___
   347  }
   348  
   349  func (_this Writer__) Get_() Data_Writer___ {
   350  	return _this.Data_Writer___
   351  }
   352  
   353  type Data_Writer___ interface {
   354  	isWriter__()
   355  }
   356  
   357  type CompanionStruct_Writer___ struct {
   358  }
   359  
   360  var Companion_Writer___ = CompanionStruct_Writer___{}
   361  
   362  type Writer___Writer struct {
   363  	Length uint32
   364  	Chain  Chain
   365  }
   366  
   367  func (Writer___Writer) isWriter__() {}
   368  
   369  func (CompanionStruct_Writer___) Create_Writer_(Length uint32, Chain Chain) Writer__ {
   370  	return Writer__{Writer___Writer{Length, Chain}}
   371  }
   372  
   373  func (_this Writer__) Is_Writer() bool {
   374  	_, ok := _this.Get_().(Writer___Writer)
   375  	return ok
   376  }
   377  
   378  func (CompanionStruct_Writer___) Default() Writer__ {
   379  	return Companion_Writer___.Create_Writer_(uint32(0), Companion_Chain_.Default())
   380  }
   381  
   382  func (_this Writer__) Dtor_length() uint32 {
   383  	return _this.Get_().(Writer___Writer).Length
   384  }
   385  
   386  func (_this Writer__) Dtor_chain() Chain {
   387  	return _this.Get_().(Writer___Writer).Chain
   388  }
   389  
   390  func (_this Writer__) String() string {
   391  	switch data := _this.Get_().(type) {
   392  	case nil:
   393  		return "null"
   394  	case Writer___Writer:
   395  		{
   396  			return "Writers.Writer_.Writer" + "(" + _dafny.String(data.Length) + ", " + _dafny.String(data.Chain) + ")"
   397  		}
   398  	default:
   399  		{
   400  			return "<unexpected>"
   401  		}
   402  	}
   403  }
   404  
   405  func (_this Writer__) Equals(other Writer__) bool {
   406  	switch data1 := _this.Get_().(type) {
   407  	case Writer___Writer:
   408  		{
   409  			data2, ok := other.Get_().(Writer___Writer)
   410  			return ok && data1.Length == data2.Length && data1.Chain.Equals(data2.Chain)
   411  		}
   412  	default:
   413  		{
   414  			return false // unexpected
   415  		}
   416  	}
   417  }
   418  
   419  func (_this Writer__) EqualsGeneric(other interface{}) bool {
   420  	typed, ok := other.(Writer__)
   421  	return ok && _this.Equals(typed)
   422  }
   423  
   424  func Type_Writer___() _dafny.TypeDescriptor {
   425  	return type_Writer___{}
   426  }
   427  
   428  type type_Writer___ struct {
   429  }
   430  
   431  func (_this type_Writer___) Default() interface{} {
   432  	return Companion_Writer___.Default()
   433  }
   434  
   435  func (_this type_Writer___) String() string {
   436  	return "JSON_Utils_Views_Writers.Writer__"
   437  }
   438  func (_this Writer__) ParentTraits_() []*_dafny.TraitID {
   439  	return [](*_dafny.TraitID){}
   440  }
   441  
   442  var _ _dafny.TraitOffspring = Writer__{}
   443  
   444  func (_this Writer__) Bytes() _dafny.Sequence {
   445  	{
   446  		return ((_this).Dtor_chain()).Bytes()
   447  	}
   448  }
   449  func (_static CompanionStruct_Writer___) SaturatedAddU32(a uint32, b uint32) uint32 {
   450  	if (a) <= ((m_BoundedInts.Companion_Default___.UINT32__MAX()) - (func() uint32 { return (b) })()) {
   451  		return (a) + (b)
   452  	} else {
   453  		return m_BoundedInts.Companion_Default___.UINT32__MAX()
   454  	}
   455  }
   456  func (_this Writer__) Append(v_k m_JSON_Utils_Views_Core.View__) Writer__ {
   457  	{
   458  		return Companion_Writer___.Create_Writer_(Companion_Writer___.SaturatedAddU32((_this).Dtor_length(), (v_k).Length()), ((_this).Dtor_chain()).Append(v_k))
   459  	}
   460  }
   461  func (_this Writer__) Then(fn func(Writer__) Writer__) Writer__ {
   462  	{
   463  		return (fn)(_this)
   464  	}
   465  }
   466  func (_this Writer__) CopyTo(dest _dafny.Array) {
   467  	{
   468  		((_this).Dtor_chain()).CopyTo(dest, (_this).Dtor_length())
   469  	}
   470  }
   471  func (_this Writer__) ToArray() _dafny.Array {
   472  	{
   473  		var bs _dafny.Array = _dafny.NewArrayWithValue(nil, _dafny.IntOf(0))
   474  		_ = bs
   475  		var _nw0 _dafny.Array = _dafny.NewArrayWithValue(uint8(0), _dafny.IntOfAny((_this).Dtor_length()))
   476  		_ = _nw0
   477  		bs = _nw0
   478  		(_this).CopyTo(bs)
   479  		return bs
   480  	}
   481  }
   482  func (_static CompanionStruct_Writer___) Empty() Writer__ {
   483  	return Companion_Writer___.Create_Writer_(uint32(0), Companion_Chain_.Create_Empty_())
   484  }
   485  func (_this Writer__) Unsaturated_q() bool {
   486  	{
   487  		return ((_this).Dtor_length()) != (m_BoundedInts.Companion_Default___.UINT32__MAX()) /* dircomp */
   488  	}
   489  }
   490  func (_this Writer__) Empty_q() bool {
   491  	{
   492  		return ((_this).Dtor_chain()).Is_Empty()
   493  	}
   494  }
   495  
   496  // End of datatype Writer__