package binary

import (
	
	

	
	
	
)

func decodeFunctionType( api.CoreFeatures,  *bytes.Reader,  *wasm.FunctionType) ( error) {
	,  := .ReadByte()
	if  != nil {
		return fmt.Errorf("read leading byte: %w", )
	}

	if  != 0x60 {
		return fmt.Errorf("%w: %#x != 0x60", ErrInvalidByte, )
	}

	, ,  := leb128.DecodeUint32()
	if  != nil {
		return fmt.Errorf("could not read parameter count: %w", )
	}

	,  := decodeValueTypes(, )
	if  != nil {
		return fmt.Errorf("could not read parameter types: %w", )
	}

	, ,  := leb128.DecodeUint32()
	if  != nil {
		return fmt.Errorf("could not read result count: %w", )
	}

	// Guard >1.0 feature multi-value
	if  > 1 {
		if  = .RequireEnabled(api.CoreFeatureMultiValue);  != nil {
			return fmt.Errorf("multiple result types invalid as %v", )
		}
	}

	,  := decodeValueTypes(, )
	if  != nil {
		return fmt.Errorf("could not read result types: %w", )
	}

	.Params = 
	.Results = 

	// cache the key for the function type
	_ = .String()

	return nil
}