From a969fe7aff1420b4f82f8356dd963545949fc526 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 22 Aug 2020 18:13:44 +0900 Subject: [PATCH] Fix dump format --- encode_opcode.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/encode_opcode.go b/encode_opcode.go index b43dc41..3b78686 100644 --- a/encode_opcode.go +++ b/encode_opcode.go @@ -112,15 +112,24 @@ func (c *opcode) dump() string { codes := []string{} for code := c; code.op != opEnd; { indent := strings.Repeat(" ", code.indent) - codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code))) switch code.op.codeType() { case codeArrayElem: + codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code))) code = code.toArrayElemCode().end case codeSliceElem: + codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code))) code = code.toSliceElemCode().end case codeMapKey: + codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code))) code = code.toMapKeyCode().end + case codeStructField: + sf := code.toStructFieldCode() + key := sf.displayKey + offset := sf.offset + codes = append(codes, fmt.Sprintf("%s%s [%s:%d] ( %p )", indent, code.op, key, offset, unsafe.Pointer(code))) + code = code.next default: + codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code))) code = code.next } }