66 BindingElement ,
77 Block ,
88 Bundle ,
9- CaseOrDefaultClause ,
109 chainBundle ,
1110 ClassDeclaration ,
1211 Debug ,
@@ -25,7 +24,6 @@ import {
2524 isArray ,
2625 isBindingPattern ,
2726 isBlock ,
28- isCaseClause ,
2927 isCustomPrologue ,
3028 isExpression ,
3129 isGeneratedIdentifier ,
@@ -49,7 +47,6 @@ import {
4947 skipOuterExpressions ,
5048 SourceFile ,
5149 Statement ,
52- SwitchStatement ,
5350 SyntaxKind ,
5451 TransformationContext ,
5552 TransformFlags ,
@@ -123,9 +120,6 @@ export function transformESNext(context: TransformationContext): (x: SourceFile
123120 case SyntaxKind . ForOfStatement :
124121 return visitForOfStatement ( node as ForOfStatement ) ;
125122
126- case SyntaxKind . SwitchStatement :
127- return visitSwitchStatement ( node as SwitchStatement ) ;
128-
129123 default :
130124 return visitEachChild ( node , visitor , context ) ;
131125 }
@@ -339,72 +333,6 @@ export function transformESNext(context: TransformationContext): (x: SourceFile
339333 return visitEachChild ( node , visitor , context ) ;
340334 }
341335
342- function visitCaseOrDefaultClause ( node : CaseOrDefaultClause , envBinding : Identifier ) {
343- if ( getUsingKindOfStatements ( node . statements ) !== UsingKind . None ) {
344- if ( isCaseClause ( node ) ) {
345- return factory . updateCaseClause (
346- node ,
347- visitNode ( node . expression , visitor , isExpression ) ,
348- transformUsingDeclarations ( node . statements , /*start*/ 0 , node . statements . length , envBinding , /*topLevelStatements*/ undefined ) ,
349- ) ;
350- }
351- else {
352- return factory . updateDefaultClause (
353- node ,
354- transformUsingDeclarations ( node . statements , /*start*/ 0 , node . statements . length , envBinding , /*topLevelStatements*/ undefined ) ,
355- ) ;
356- }
357- }
358- return visitEachChild ( node , visitor , context ) ;
359- }
360-
361- function visitSwitchStatement ( node : SwitchStatement ) {
362- // given:
363- //
364- // switch (expr) {
365- // case expr:
366- // using res = expr;
367- // }
368- //
369- // produces:
370- //
371- // const env_1 = { stack: [], error: void 0, hasError: false };
372- // try {
373- // switch(expr) {
374- // case expr:
375- // const res = __addDisposableResource(env_1, expr, false);
376- // }
377- // }
378- // catch (e_1) {
379- // env_1.error = e_1;
380- // env_1.hasError = true;
381- // }
382- // finally {
383- // __disposeResources(env_1);
384- // }
385- //
386- const usingKind = getUsingKindOfCaseOrDefaultClauses ( node . caseBlock . clauses ) ;
387- if ( usingKind ) {
388- const envBinding = createEnvBinding ( ) ;
389- return createDownlevelUsingStatements (
390- [
391- factory . updateSwitchStatement (
392- node ,
393- visitNode ( node . expression , visitor , isExpression ) ,
394- factory . updateCaseBlock (
395- node . caseBlock ,
396- node . caseBlock . clauses . map ( clause => visitCaseOrDefaultClause ( clause , envBinding ) ) ,
397- ) ,
398- ) ,
399- ] ,
400- envBinding ,
401- usingKind === UsingKind . Async ,
402- ) ;
403- }
404-
405- return visitEachChild ( node , visitor , context ) ;
406- }
407-
408336 /**
409337 * Transform `using` declarations in a statement list.
410338 */
@@ -870,13 +798,3 @@ function getUsingKindOfStatements(statements: readonly Statement[]): UsingKind {
870798 }
871799 return result ;
872800}
873-
874- function getUsingKindOfCaseOrDefaultClauses ( clauses : readonly CaseOrDefaultClause [ ] ) : UsingKind {
875- let result = UsingKind . None ;
876- for ( const clause of clauses ) {
877- const usingKind = getUsingKindOfStatements ( clause . statements ) ;
878- if ( usingKind === UsingKind . Async ) return UsingKind . Async ;
879- if ( usingKind > result ) result = usingKind ;
880- }
881- return result ;
882- }
0 commit comments