Fix dump format

This commit is contained in:
Masaaki Goshima 2020-08-22 18:13:44 +09:00
parent 97787fd7b6
commit a969fe7aff
1 changed files with 10 additions and 1 deletions

View File

@ -112,15 +112,24 @@ func (c *opcode) dump() string {
codes := []string{} codes := []string{}
for code := c; code.op != opEnd; { for code := c; code.op != opEnd; {
indent := strings.Repeat(" ", code.indent) indent := strings.Repeat(" ", code.indent)
codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code)))
switch code.op.codeType() { switch code.op.codeType() {
case codeArrayElem: case codeArrayElem:
codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code)))
code = code.toArrayElemCode().end code = code.toArrayElemCode().end
case codeSliceElem: case codeSliceElem:
codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code)))
code = code.toSliceElemCode().end code = code.toSliceElemCode().end
case codeMapKey: case codeMapKey:
codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code)))
code = code.toMapKeyCode().end 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: default:
codes = append(codes, fmt.Sprintf("%s%s ( %p )", indent, code.op, unsafe.Pointer(code)))
code = code.next code = code.next
} }
} }