@@ -2740,22 +2740,30 @@ export class EmitterLua {
27402740 switch ( node . operator ) {
27412741 case ts . SyntaxKind . PlusPlusToken :
27422742 case ts . SyntaxKind . MinusMinusToken :
2743- this . functionContext . textCode . push ( "(function () " ) ;
2744- let opIndex = parseInt ( node . pos . toFixed ( ) ) ;
2745- if ( opIndex < 0 ) {
2746- opIndex = 0 ;
2747- }
2743+ if ( this . isValueNotRequired ( node . parent ) )
2744+ {
2745+ this . processExpression ( node . operand ) ;
2746+ this . functionContext . textCode . push ( " = " ) ;
2747+ this . processExpression ( node . operand ) ;
2748+ this . functionContext . textCode . push ( " + 1" ) ;
2749+ } else {
2750+ this . functionContext . textCode . push ( "(function () " ) ;
2751+ let opIndex = parseInt ( node . pos . toFixed ( ) ) ;
2752+ if ( opIndex < 0 ) {
2753+ opIndex = 0 ;
2754+ }
27482755
2749- const op = node . operator == ts . SyntaxKind . PlusPlusToken ? '+' : '-' ;
2756+ const op = node . operator == ts . SyntaxKind . PlusPlusToken ? '+' : '-' ;
27502757
2751- this . functionContext . textCode . push ( "local op" + opIndex + " = (" ) ;
2752- this . processExpression ( node . operand ) ;
2753- this . functionContext . textCode . push ( ") " ) ;
2754- this . processExpression ( node . operand ) ;
2755- this . functionContext . textCode . push ( " = " ) ;
2756- this . functionContext . textCode . push ( "op" + opIndex + " + 1 " ) ;
2757- this . functionContext . textCode . push ( "return op" + opIndex + " " ) ;
2758- this . functionContext . textCode . push ( "end)()" ) ;
2758+ this . functionContext . textCode . push ( "local op" + opIndex + " = (" ) ;
2759+ this . processExpression ( node . operand ) ;
2760+ this . functionContext . textCode . push ( ") " ) ;
2761+ this . processExpression ( node . operand ) ;
2762+ this . functionContext . textCode . push ( " = " ) ;
2763+ this . functionContext . textCode . push ( "op" + opIndex + " " + op + " 1 " ) ;
2764+ this . functionContext . textCode . push ( "return op" + opIndex + " " ) ;
2765+ this . functionContext . textCode . push ( "end)()" ) ;
2766+ }
27592767
27602768 break ;
27612769 }
0 commit comments