(origin: string)
| 237 | // Parses code generated by FormatEvalOrigin(), a function inside V8: |
| 238 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js |
| 239 | function mapEvalOrigin(origin: string): string { |
| 240 | // Most eval() calls are in this format |
| 241 | let match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin) |
| 242 | if (match) { |
| 243 | const position = mapSourcePosition({ |
| 244 | name: null, |
| 245 | source: match[2], |
| 246 | line: +match[3], |
| 247 | column: +match[4] - 1, |
| 248 | }) |
| 249 | return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})` |
| 250 | } |
| 251 | |
| 252 | // Parse nested eval() calls using recursion |
| 253 | match = /^eval at ([^(]+) \((.+)\)$/.exec(origin) |
| 254 | if (match) return `eval at ${match[1]} (${mapEvalOrigin(match[2])})` |
| 255 | |
| 256 | // Make sure we still return useful information if we didn't find anything |
| 257 | return origin |
| 258 | } |
| 259 | |
| 260 | // This is copied almost verbatim from the V8 source code at |
| 261 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The |
no test coverage detected