* Execute a particular `TcbOp` in the `opQueue`. * * This method replaces the operation in the `opQueue` with the result of execution (once done) * and also protects against a circular dependency from the operation to itself by temporarily * setting the operation's result to a special ex
(opIndex: number, skipOptional: boolean)
| 444 | * setting the operation's result to a special expression. |
| 445 | */ |
| 446 | private executeOp(opIndex: number, skipOptional: boolean): TcbExpr | null { |
| 447 | const op = this.opQueue[opIndex]; |
| 448 | if (!(op instanceof TcbOp)) { |
| 449 | return op === null ? null : new TcbExpr(op.print(true /* ignoreComments */)); |
| 450 | } |
| 451 | |
| 452 | if (skipOptional && op.optional) { |
| 453 | return null; |
| 454 | } |
| 455 | |
| 456 | // Set the result of the operation in the queue to its circular fallback. If executing this |
| 457 | // operation results in a circular dependency, this will prevent an infinite loop and allow for |
| 458 | // the resolution of such cycles. |
| 459 | this.opQueue[opIndex] = op.circularFallback(); |
| 460 | let res = op.execute(); |
| 461 | if (res !== null) { |
| 462 | res = new TcbExpr(res.print(true /* ignoreComments */)); |
| 463 | } |
| 464 | // Once the operation has finished executing, it's safe to cache the real result. |
| 465 | this.opQueue[opIndex] = res; |
| 466 | return res; |
| 467 | } |
| 468 | |
| 469 | private appendNode(node: Node): void { |
| 470 | if (node instanceof Element) { |
no test coverage detected