package binary

import (
	
	

	
	
)

// decodeTable returns the wasm.Table decoded with the WebAssembly 1.0 (20191205) Binary Format.
//
// See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#binary-table
func decodeTable( *bytes.Reader,  api.CoreFeatures,  *wasm.Table) ( error) {
	.Type,  = .ReadByte()
	if  != nil {
		return fmt.Errorf("read leading byte: %v", )
	}

	if .Type != wasm.RefTypeFuncref {
		if  = .RequireEnabled(api.CoreFeatureReferenceTypes);  != nil {
			return fmt.Errorf("table type funcref is invalid: %w", )
		}
	}

	var  bool
	.Min, .Max, ,  = decodeLimitsType()
	if  != nil {
		return fmt.Errorf("read limits: %v", )
	}
	if .Min > wasm.MaximumFunctionIndex {
		return fmt.Errorf("table min must be at most %d", wasm.MaximumFunctionIndex)
	}
	if .Max != nil {
		if *.Max < .Min {
			return fmt.Errorf("table size minimum must not be greater than maximum")
		}
	}
	if  {
		return fmt.Errorf("tables cannot be marked as shared")
	}
	return
}