(file)
| 1531 | |
| 1532 | class SourceData { |
| 1533 | constructor(file) { |
| 1534 | this.scripts = new Map(); |
| 1535 | for (let i = 0; i < file.scripts.length; i++) { |
| 1536 | const scriptBlock = file.scripts[i]; |
| 1537 | if (scriptBlock === null) continue; // Array may be sparse. |
| 1538 | if (scriptBlock.source === undefined) continue; |
| 1539 | let source = scriptBlock.source.split("\n"); |
| 1540 | this.scripts.set(i, source); |
| 1541 | } |
| 1542 | |
| 1543 | this.functions = new Map(); |
| 1544 | for (let codeId = 0; codeId < file.code.length; ++codeId) { |
| 1545 | let codeBlock = file.code[codeId]; |
| 1546 | if (codeBlock.source && codeBlock.func !== undefined) { |
| 1547 | let data = this.functions.get(codeBlock.func); |
| 1548 | if (!data) { |
| 1549 | data = new FunctionSourceData(codeBlock.source.script, |
| 1550 | codeBlock.source.start, |
| 1551 | codeBlock.source.end); |
| 1552 | this.functions.set(codeBlock.func, data); |
| 1553 | } |
| 1554 | data.addSourceBlock(codeId, codeBlock.source); |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | for (let tick of file.ticks) { |
| 1559 | let stack = tick.s; |
| 1560 | for (let i = 0; i < stack.length; i += 2) { |
| 1561 | let codeId = stack[i]; |
| 1562 | if (codeId < 0) continue; |
| 1563 | let functionId = file.code[codeId].func; |
| 1564 | if (this.functions.has(functionId)) { |
| 1565 | let codeOffset = stack[i + 1]; |
| 1566 | this.functions.get(functionId).addOffsetSample(codeId, codeOffset); |
| 1567 | } |
| 1568 | } |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | getScript(scriptId) { |
| 1573 | return this.scripts.get(scriptId); |
nothing calls this directly
no test coverage detected