(ip int, program *vm.Program)
| 115 | } |
| 116 | |
| 117 | func (ExprRuntimeDebug) extractCode(ip int, program *vm.Program) string { |
| 118 | locations := program.Locations() |
| 119 | src := program.Source().String() |
| 120 | |
| 121 | currentInstruction := locations[ip] |
| 122 | |
| 123 | var closest *file.Location |
| 124 | |
| 125 | for i := ip + 1; i < len(locations); i++ { |
| 126 | if locations[i].From > currentInstruction.From { |
| 127 | if closest == nil || locations[i].From < closest.From { |
| 128 | closest = &locations[i] |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | var end int |
| 134 | if closest == nil { |
| 135 | end = len(src) |
| 136 | } else { |
| 137 | end = closest.From |
| 138 | } |
| 139 | |
| 140 | return cleanTextForDebug(src[locations[ip].From:end]) |
| 141 | } |
| 142 | |
| 143 | func autoQuote(v any) string { |
| 144 | switch x := v.(type) { |
no test coverage detected