| 685 | } |
| 686 | |
| 687 | addNestedFunktion(child) { |
| 688 | if (this.script != child.script) throw "Incompatible script"; |
| 689 | if (child == null) throw "Nesting non child"; |
| 690 | this.nested.push(child); |
| 691 | if (this.nested.length > 1) { |
| 692 | // Make sure the nested children don't overlap and have been inserted in |
| 693 | // byte start position order. |
| 694 | let last = this.nested[this.nested.length - 2]; |
| 695 | if (last.end > child.start || last.start > child.start || |
| 696 | last.end > child.end || last.start > child.end) { |
| 697 | throw "Wrongly nested child added"; |
| 698 | } |
| 699 | } |
| 700 | child.nestingLevel = this.nestingLevel + 1; |
| 701 | return child.nestingLevel; |
| 702 | } |
| 703 | |
| 704 | getBytes() { |
| 705 | return this.end - this.start; |