Use ?SHL and ?SHR for 'bsl' and 'bsr'

This commit is contained in:
Hans Svensson
2019-01-22 21:50:23 +01:00
parent 387fdf5c34
commit 23ccce4c22
5 changed files with 10 additions and 10 deletions
+3 -6
View File
@@ -526,12 +526,9 @@ ast_binop(Op, Ann, {typed, _, A, Type}, B, Icode)
ast_binop('++', _, A, B, Icode) ->
#funcall{ function = #var_ref{ name = {builtin, list_concat} },
args = [ast_body(A, Icode), ast_body(B, Icode)] };
ast_binop('bsl', _, A, B, Icode) ->
#binop{op = '*', left = ast_body(A, Icode),
right = #binop{op = '^', left = {integer, 2}, right = ast_body(B, Icode)}};
ast_binop('bsr', _, A, B, Icode) ->
#binop{op = 'div', left = ast_body(A, Icode),
right = #binop{op = '^', left = {integer, 2}, right = ast_body(B, Icode)}};
%% Bit shift operations takes their arguments backwards!?
ast_binop(Op, _, A, B, Icode) when Op =:= 'bsl'; Op =:= 'bsr' ->
#binop{op = Op, right = ast_body(A, Icode), left = ast_body(B, Icode)};
ast_binop(Op, _, A, B, Icode) ->
#binop{op = Op, left = ast_body(A, Icode), right = ast_body(B, Icode)}.