callTreeNode.tsx 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {Frame} from './frame';
  2. import {WeightedNode} from './weightedNode';
  3. export class CallTreeNode extends WeightedNode {
  4. readonly frame: Frame;
  5. private locked = false;
  6. parent: CallTreeNode | null;
  7. recursive: CallTreeNode | null;
  8. children: CallTreeNode[] = [];
  9. constructor(frame: Frame, parent: CallTreeNode | null) {
  10. super();
  11. this.recursive = null;
  12. this.parent = parent;
  13. this.frame = frame;
  14. }
  15. setParent(parent: CallTreeNode): void {
  16. this.parent = parent;
  17. }
  18. setRecursiveThroughNode(node: CallTreeNode): void {
  19. this.recursive = node;
  20. }
  21. isRecursive(): boolean {
  22. return !!this.recursive;
  23. }
  24. isDirectRecursive(): boolean {
  25. if (!this.parent) {
  26. return false;
  27. }
  28. return this.parent.frame === this.frame;
  29. }
  30. isLocked(): boolean {
  31. return this.locked;
  32. }
  33. lock(): void {
  34. this.locked = true;
  35. }
  36. isRoot(): boolean {
  37. return Frame.Root.name === this.frame.name;
  38. }
  39. static readonly Root = new CallTreeNode(Frame.Root, null);
  40. }