on master help sign in
Fix #1506, inlining bit shifts with arguments in the wrong order
commite56cb2e81e5c49d078105a0ee182f176c9302d6f authorEvan Czaplicki <evancz@users.noreply.github.com> dateSat 15 Oct 2016, 20:44 (10 years ago) parent9635eff
1 file changed+11−11
src/Generate/JavaScript/Expression.hs+11−11
src/Generate/JavaScript/Expression.hs+11−11
@@ -287,9 +287,9 @@ generateCall func args =
287287 Nothing ->
288288 generateCallHelp func args
289289
290− (Opt.Var var, [left, right]) ->
291− case getBinaryOp var of
292− Just op ->
290+ (Opt.Var var, [ arg1, arg2 ]) ->
291+ case getBinaryOp var arg1 arg2 of
292+ Just (op, left, right) ->
293293 do jsLeft <- generateJsExpr left
294294 jsRight <- generateJsExpr right
295295 jsExpr $ InfixExpr () op jsLeft jsRight
@@ -328,19 +328,19 @@ getUnaryOp var =
328328 Nothing
329329
330330
331−getBinaryOp :: Var.Canonical -> Maybe InfixOp
332−getBinaryOp (Var.Canonical home name) =
331+getBinaryOp :: Var.Canonical -> Opt.Expr -> Opt.Expr -> Maybe (InfixOp, Opt.Expr, Opt.Expr)
332+getBinaryOp (Var.Canonical home name) left right =
333333 if home /= bitwise then
334334 Nothing
335335
336336 else
337337 case name of
338− "and" -> Just OpBAnd
339− "or" -> Just OpBOr
340− "xor" -> Just OpBXor
341− "shiftLeftBy" -> Just OpLShift
342− "shiftRightBy" -> Just OpSpRShift
343− "shiftRightZfBy" -> Just OpZfRShift
338+ "and" -> Just ( OpBAnd, left, right )
339+ "or" -> Just ( OpBOr, left, right )
340+ "xor" -> Just ( OpBXor, left, right )
341+ "shiftLeftBy" -> Just ( OpLShift, right, left )
342+ "shiftRightBy" -> Just ( OpSpRShift, right, left )
343+ "shiftRightZfBy" -> Just ( OpZfRShift, right, left )
344344 _ -> Nothing
345345
346346