Method
emitTypeSwitch
(
types: OrderedSet<T>,
condition: (t: T) => Sourcelike,
withBlock: boolean,
withReturn: boolean,
f: (t: T) => void
)
Source from the content-addressed store, hash-verified
| 486 | }; |
| 487 | |
| 488 | emitTypeSwitch<T extends Sourcelike>( |
| 489 | types: OrderedSet<T>, |
| 490 | condition: (t: T) => Sourcelike, |
| 491 | withBlock: boolean, |
| 492 | withReturn: boolean, |
| 493 | f: (t: T) => void |
| 494 | ): void { |
| 495 | assert(!withReturn || withBlock, "Can only have return with block"); |
| 496 | types.forEach(t => { |
| 497 | this.emitLine("if (", condition(t), ")"); |
| 498 | if (withBlock) { |
| 499 | this.emitBlock(() => { |
| 500 | f(t); |
| 501 | if (withReturn) { |
| 502 | this.emitLine("return;"); |
| 503 | } |
| 504 | }); |
| 505 | } else { |
| 506 | this.indent(() => f(t)); |
| 507 | } |
| 508 | }); |
| 509 | } |
| 510 | |
| 511 | emitConverterMembers = (): void => { |
| 512 | const enumNames = this.enums.map(this.nameForNamedType); |
Tested by
no test coverage detected