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{}
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
}
}