package binary

import (
	
	

	
	
	
)

// decodeMemory returns the api.Memory decoded with the WebAssembly 1.0 (20191205) Binary Format.
//
// See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#binary-memory
func decodeMemory(
	 *bytes.Reader,
	 api.CoreFeatures,
	 func( uint32,  *uint32) (, ,  uint32),
	 uint32,
) (*wasm.Memory, error) {
	, , ,  := decodeLimitsType()
	if  != nil {
		return nil, 
	}

	if  {
		if !.IsEnabled(experimental.CoreFeaturesThreads) {
			return nil, fmt.Errorf("shared memory requested but threads feature not enabled")
		}

		// This restriction may be lifted in the future.
		// https://webassembly.github.io/threads/core/binary/types.html#memory-types
		if  == nil {
			return nil, fmt.Errorf("shared memory requires a maximum size to be specified")
		}
	}

	, ,  := (, )
	 := &wasm.Memory{Min: , Cap: , Max: , IsMaxEncoded:  != nil, IsShared: }

	return , .Validate()
}