on master help sign in
Fix #1506, inlining bit shifts with arguments in the wrong order
e56cb2eEvan Czaplicki
src/Generate/JavaScript/Expression.hs+11−11
@@ -287,9 +287,9 @@ generateCall func args =
287 Nothing ->
287 Nothing ->
288 generateCallHelp func args
288 generateCallHelp func args
289
289
290− (Opt.Var var, [left, right]) ->
290+ (Opt.Var var, [ arg1, arg2 ]) ->
291− case getBinaryOp var of
291+ case getBinaryOp var arg1 arg2 of
292− Just op ->
292+ Just (op, left, right) ->
293 do jsLeft <- generateJsExpr left
293 do jsLeft <- generateJsExpr left
294 jsRight <- generateJsExpr right
294 jsRight <- generateJsExpr right
295 jsExpr $ InfixExpr () op jsLeft jsRight
295 jsExpr $ InfixExpr () op jsLeft jsRight
@@ -328,19 +328,19 @@ getUnaryOp var =
328 Nothing
328 Nothing
329
329
330
330
331−getBinaryOp :: Var.Canonical -> Maybe InfixOp
331+getBinaryOp :: Var.Canonical -> Opt.Expr -> Opt.Expr -> Maybe (InfixOp, Opt.Expr, Opt.Expr)
332−getBinaryOp (Var.Canonical home name) =
332+getBinaryOp (Var.Canonical home name) left right =
333 if home /= bitwise then
333 if home /= bitwise then
334 Nothing
334 Nothing
335
335
336 else
336 else
337 case name of
337 case name of
338− "and" -> Just OpBAnd
338+ "and" -> Just ( OpBAnd, left, right )
339− "or" -> Just OpBOr
339+ "or" -> Just ( OpBOr, left, right )
340− "xor" -> Just OpBXor
340+ "xor" -> Just ( OpBXor, left, right )
341− "shiftLeftBy" -> Just OpLShift
341+ "shiftLeftBy" -> Just ( OpLShift, right, left )
342− "shiftRightBy" -> Just OpSpRShift
342+ "shiftRightBy" -> Just ( OpSpRShift, right, left )
343− "shiftRightZfBy" -> Just OpZfRShift
343+ "shiftRightZfBy" -> Just ( OpZfRShift, right, left )
344 _ -> Nothing
344 _ -> Nothing
345
345
346
346