@@ -383,25 +383,22 @@ function Unparser:unparseStatement(statement, tabbing)
383383 end
384384 end
385385 elseif self .luaVersion == LuaVersion .LuaU then
386- if statement .kind == AstKind .CompoundAddStatement then
387- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " +=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
388- elseif statement .kind == AstKind .CompoundSubStatement then
389- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " -=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
390- elseif statement .kind == AstKind .CompoundMulStatement then
391- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " *=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
392- elseif statement .kind == AstKind .CompoundDivStatement then
393- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " /=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
394- elseif statement .kind == AstKind .CompoundModStatement then
395- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " %=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
396- elseif statement .kind == AstKind .CompoundPowStatement then
397- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " ^=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
398- elseif statement .kind == AstKind .CompoundConcatStatement then
399- code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. " ..=" .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing );
386+ local compoundOperators = {
387+ [AstKind .CompoundAddStatement ] = " +=" ,
388+ [AstKind .CompoundSubStatement ] = " -=" ,
389+ [AstKind .CompoundMulStatement ] = " *=" ,
390+ [AstKind .CompoundDivStatement ] = " /=" ,
391+ [AstKind .CompoundModStatement ] = " %=" ,
392+ [AstKind .CompoundPowStatement ] = " ^=" ,
393+ [AstKind .CompoundConcatStatement ] = " ..=" ,
394+ }
395+
396+ local operator = compoundOperators [statement .kind ]
397+ if operator then
398+ code = code .. self :unparseExpression (statement .lhs , tabbing ) .. self :optionalWhitespace () .. operator .. self :optionalWhitespace () .. self :unparseExpression (statement .rhs , tabbing )
400399 else
401- logger :error (string.format (" \" %s\" is not a valid unparseable statement in %s!" , statement .kind , self .luaVersion ));
400+ logger :error (string.format (" \" %s\" is not a valid unparseable statement in %s!" , statement .kind , self .luaVersion ))
402401 end
403- else
404- logger :error (string.format (" \" %s\" is not a valid unparseable statement in %s!" , statement .kind , self .luaVersion ));
405402 end
406403
407404 return self :tabs (tabbing , false ) .. code ;
0 commit comments