package encoder

// The opcode after the value of a member of omitempty ( OpUnwriteEmpty ) unwrites the member if the value is empty,
// for the semantics of encoding/json/v2, which omit a member by what its value writes. The output is compact, a
// value followed by a comma.

// newUnwriteEmptyCode returns the opcode after the value of a member of omitempty, whose key is key, which
// unwrites the member if the value is empty ( see UnwriteEmptyMember ).
func newUnwriteEmptyCode( *compileContext,  string) *Opcode {
	 := &Opcode{
		Op:         OpUnwriteEmpty,
		Idx:        opcodeOffset(.ptrIndex),
		Key:        ,
		DisplayIdx: .opcodeIndex,
		Indent:     .indent,
	}
	.incOpcodeIndex()
	return 
}

// UnwriteEmptyMember unwrites the member which ends the output b, whose key has keyLen bytes, if its value is
// empty, as the v2 semantics define it: null, "", {} or []. The opcode runs only right after the opcodes of its
// field wrote the member, the key followed by the value and a comma: a field which is omitted goes to NextField,
// past the opcode, so the member starts keyLen bytes before its value.
//
// The value is empty if it is one of them right after the colon of the key: a longer value can end with the bytes
// of one, as "\"" ends with "", but doesn't start there.
func ( *RuntimeContext,  []byte,  int) []byte {
	 := len() - 1 // the comma
	 := 2
	if  <  {
		return 
	}
	switch [-1] {
	case '"':
		if [-2] != '"' {
			return 
		}
	case '}':
		if [-2] != '{' {
			return 
		}
	case ']':
		if [-2] != '[' {
			return 
		}
	case 'l':
		 = 4
		if  <  || string([-:]) != "null" {
			return 
		}
	default:
		return 
	}
	if --1 < 0 || [--1] != ':' {
		return 
	}
	 :=  -  - 
	if  < 0 {
		return 
	}
	.Rewrote()
	return [:]
}