@@ -615,75 +615,7 @@ export abstract class LuaTranspiler {
615615 }
616616
617617 public transpileSwitch ( node : ts . SwitchStatement ) : string {
618- const expression = this . transpileExpression ( node . expression , true ) ;
619- const clauses = node . caseBlock . clauses ;
620-
621- let result = this . indent + "-------Switch statement start-------\n" ;
622-
623- const switchVarName = "____switch" + this . genVarCounter ;
624- this . genVarCounter ++ ;
625-
626- result += this . indent + `local ${ switchVarName } = ${ expression } \n` ;
627-
628- let hasDefaultClause = false ;
629-
630- // If statement to go to right entry label
631- clauses . forEach ( ( clause , index ) => {
632- if ( ts . isCaseClause ( clause ) ) {
633- result += this . indent +
634- `if ${ this . transpileExpression ( clause . expression , true ) } == ${ switchVarName } then\n` ;
635-
636- this . pushIndent ( ) ;
637- result += this . indent + `goto ${ switchVarName } _case_${ index } \n` ;
638- this . popIndent ( ) ;
639-
640- result += this . indent + "end\n" ;
641- } else if ( ts . isDefaultClause ( clause ) ) {
642- hasDefaultClause = true ;
643- }
644- } ) ;
645-
646- result += "\n" ;
647-
648- // If no case condition is matched jump to end or default immediately
649- if ( hasDefaultClause ) {
650- result += this . indent + `goto ${ switchVarName } _default\n` ;
651- } else {
652- result += this . indent + `goto ${ switchVarName } _end\n` ;
653- }
654-
655- result += "\n" ;
656-
657- const transpileClauseBody = ( clause : ts . CaseOrDefaultClause ) => {
658- this . transpilingSwitch ++ ;
659- result += this . indent + "do\n" ;
660- this . pushIndent ( ) ;
661- result += this . transpileBlock ( ts . createBlock ( clause . statements ) ) ;
662- this . popIndent ( ) ;
663- result += this . indent + "end\n" ;
664- this . transpilingSwitch -- ;
665- } ;
666-
667- clauses . forEach ( ( clause , index ) => {
668- if ( ts . isCaseClause ( clause ) ) {
669- result += this . indent + `::${ switchVarName } _case_${ index } ::\n` ;
670-
671- transpileClauseBody ( clause ) ;
672-
673- if ( tsHelper . containsStatement ( clause . statements , ts . SyntaxKind . BreakStatement ) ) {
674- result += this . indent + `goto ${ switchVarName } _end\n` ;
675- }
676- } else if ( ts . isDefaultClause ( clause ) ) {
677- result += this . indent + `::${ switchVarName } _default::\n` ;
678-
679- transpileClauseBody ( clause ) ;
680- }
681- } ) ;
682-
683- result += this . indent + `::${ switchVarName } _end::\n` ;
684- result += this . indent + "-------Switch statement end-------\n" ;
685-
686- return result ;
618+ throw TSTLErrors . UnsupportedForTarget ( "Switch statements" , this . options . luaTarget , node ) ;
687619 }
688620
689621 public transpileTry ( node : ts . TryStatement ) : string {
0 commit comments