* 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)
| 452 | * setting the operation's result to a special expression. |
| 453 | */ |
| 454 | private executeOp(opIndex: number, skipOptional: boolean): TcbExpr | null { |
| 455 | const op = this.opQueue[opIndex]; |
| 456 | if (!(op instanceof TcbOp)) { |
| 457 | return op === null ? null : new TcbExpr(op.print(true /* ignoreComments */)); |
| 458 | } |
| 459 | |
| 460 | if (skipOptional && op.optional) { |
| 461 | return null; |
| 462 | } |
| 463 | |
| 464 | // Set the result of the operation in the queue to its circular fallback. If executing this |
| 465 | // operation results in a circular dependency, this will prevent an infinite loop and allow for |
| 466 | // the resolution of such cycles. |
| 467 | this.opQueue[opIndex] = op.circularFallback(); |
| 468 | let res = op.execute(); |
| 469 | if (res !== null) { |
| 470 | res = new TcbExpr(res.print(true /* ignoreComments */)); |
| 471 | } |
| 472 | // Once the operation has finished executing, it's safe to cache the real result. |
| 473 | this.opQueue[opIndex] = res; |
| 474 | return res; |
| 475 | } |
| 476 | |
| 477 | private appendNode(node: Node): void { |
| 478 | if (node instanceof Element) { |
no test coverage detected