(level int, count int)
| 114 | } |
| 115 | |
| 116 | func (fp *FunctionProto) str(level int, count int) string { |
| 117 | indent := strings.Repeat(" ", level-1) |
| 118 | buf := []string{} |
| 119 | buf = append(buf, fmt.Sprintf("%v; function [%v] definition (level %v)\n", |
| 120 | indent, count, level)) |
| 121 | buf = append(buf, fmt.Sprintf("%v; %v upvalues, %v params, %v stacks\n", |
| 122 | indent, fp.NumUpvalues, fp.NumParameters, fp.NumUsedRegisters)) |
| 123 | for reg, linfo := range fp.DbgLocals { |
| 124 | buf = append(buf, fmt.Sprintf("%v.local %v ; %v\n", indent, linfo.Name, reg)) |
| 125 | } |
| 126 | for reg, upvalue := range fp.DbgUpvalues { |
| 127 | buf = append(buf, fmt.Sprintf("%v.upvalue %v ; %v\n", indent, upvalue, reg)) |
| 128 | } |
| 129 | for reg, conzt := range fp.Constants { |
| 130 | buf = append(buf, fmt.Sprintf("%v.const %v ; %v\n", indent, conzt.String(), reg)) |
| 131 | } |
| 132 | buf = append(buf, "\n") |
| 133 | |
| 134 | protono := 0 |
| 135 | for no, code := range fp.Code { |
| 136 | inst := opGetOpCode(code) |
| 137 | if inst == OP_CLOSURE { |
| 138 | buf = append(buf, "\n") |
| 139 | buf = append(buf, fp.FunctionPrototypes[protono].str(level+1, protono)) |
| 140 | buf = append(buf, "\n") |
| 141 | protono++ |
| 142 | } |
| 143 | buf = append(buf, fmt.Sprintf("%v[%03d] %v (line:%v)\n", |
| 144 | indent, no+1, opToString(code), fp.DbgSourcePositions[no])) |
| 145 | |
| 146 | } |
| 147 | buf = append(buf, fmt.Sprintf("%v; end of function\n", indent)) |
| 148 | return strings.Join(buf, "") |
| 149 | } |
| 150 | |
| 151 | /* }}} */ |
| 152 |
no test coverage detected