(assignStmt: (v: string) => string, refState: string)
| 183 | } |
| 184 | |
| 185 | read(assignStmt: (v: string) => string, refState: string): string { |
| 186 | void refState; |
| 187 | const caseIndex = this.scope.uniqueName("caseIndex"); |
| 188 | const refFlag = this.scope.uniqueName("refFlag"); |
| 189 | const unionValue = this.scope.uniqueName("unionValue"); |
| 190 | const caseInfo = this.scope.uniqueName("caseInfo"); |
| 191 | const result = this.scope.uniqueName("result"); |
| 192 | return ` |
| 193 | const ${caseIndex} = ${this.builder.reader.readVarUInt32()}; |
| 194 | const ${refFlag} = ${this.builder.reader.readInt8()}; |
| 195 | let ${unionValue} = null; |
| 196 | if (${refFlag} === ${RefFlags.NullFlag}) { |
| 197 | ${unionValue} = null; |
| 198 | } else if (${refFlag} === ${RefFlags.RefFlag}) { |
| 199 | ${unionValue} = ${this.builder.referenceResolver.getReadRef(this.builder.reader.readVarUInt32())}; |
| 200 | } else { |
| 201 | ${this.readDeclaredCases(caseIndex, unionValue, refFlag, caseInfo)} |
| 202 | } |
| 203 | const ${result} = { case: ${caseIndex}, value: ${unionValue} }; |
| 204 | ${assignStmt(result)} |
| 205 | `; |
| 206 | } |
| 207 | |
| 208 | writeTypeInfo(): string { |
| 209 | const internalTypeId = this.typeInfo._typeId; |
nothing calls this directly
no test coverage detected