Fate compiler #553

Merged
zxq9 merged 87 commits from fate-compiler into master 2019-05-07 22:48:47 +09:00
Showing only changes of commit 1d39464190 - Show all commits

View File

@ -888,8 +888,20 @@ r_constant_propagation({i, Ann, I}, Code) ->
end;
r_constant_propagation(_, _) -> false.
eval_op('EQ', [X, Y]) -> X =:= Y; %% TODO: more
eval_op(_, _) -> no_eval.
eval_op('ADD', [X, Y]) -> X + Y;
eval_op('SUB', [X, Y]) -> X - Y;
eval_op('MUL', [X, Y]) -> X * Y;
eval_op('DIV', [X, Y]) when Y /= 0 -> X div Y;
eval_op('MOD', [X, Y]) when Y /= 0 -> X rem Y;
eval_op('POW', [_, _]) -> no_eval;
eval_op('LT', [X, Y]) -> X < Y;
eval_op('GT', [X, Y]) -> X > Y;
eval_op('EQ', [X, Y]) -> X =:= Y;
eval_op('ELT', [X, Y]) -> X =< Y;
eval_op('EGT', [X, Y]) -> X >= Y;
eval_op('NEQ', [X, Y]) -> X =/= Y;
eval_op('NOT', [X]) -> not X;
eval_op(_, _) -> no_eval. %% TODO: bits?
%% Prune impossible branches from switches
r_prune_impossible_branches({switch, ?i(V), Type, Alts, missing}, Code) ->