Bitwise operators on integers.
This commit is contained in:
parent
f077d41e09
commit
1ec15b9409
4 changed files with 12 additions and 1 deletions
|
@ -92,10 +92,13 @@ let apply_op partial loc op se_list =
|
|||
| ">=", [Sint n1; Sint n2] -> Sbool (n1 >= n2)
|
||||
| "<", [Sint n1; Sint n2] -> Sbool (n1 < n2)
|
||||
| ">", [Sint n1; Sint n2] -> Sbool (n1 > n2)
|
||||
| ">>>", [Sint n1; Sint n2] -> Sint (n1 lsr n2)
|
||||
| "<<<", [Sint n1; Sint n2] -> Sint (n1 lsl n2)
|
||||
| "&", [Sbool b1; Sbool b2] -> Sbool (b1 && b2)
|
||||
| "or", [Sbool b1; Sbool b2] -> Sbool (b1 || b2)
|
||||
| "not", [Sbool b] -> Sbool (not b)
|
||||
| "~-", [Sint n] -> Sint (-n)
|
||||
| "~~", [Sint n] -> Sint (lnot n)
|
||||
| "~-.", [Sfloat f] -> Sfloat (-. f)
|
||||
| f,_ -> Misc.internal_error ("Static evaluation failed of the pervasive operator "^f)
|
||||
)
|
||||
|
|
|
@ -109,6 +109,7 @@ let copname = function
|
|||
| "+." -> "+" | "-." -> "-" | "<" -> "<" | ">" -> ">" | "<=" -> "<="
|
||||
| ">=" -> ">=" | "<=." -> "<=" | "<." -> "<" | ">=." -> ">=" | ">." -> ">"
|
||||
| "~-" -> "-" | "not" -> "!" | "%" -> "%"
|
||||
| ">>>" -> ">>" | "<<<" -> "<<"
|
||||
| op -> op
|
||||
|
||||
(** Translates an Obc var_dec to a tuple (name, cty). *)
|
||||
|
@ -267,12 +268,13 @@ and cop_of_op_aux op_name cexps = match op_name with
|
|||
| { qual = Pervasives; name = op } ->
|
||||
begin match op,cexps with
|
||||
| ("~-" | "~-."), [e] -> Cuop ("-", e)
|
||||
| ("~~"), [e] -> Cuop ("~", e)
|
||||
| "not", [e] -> Cuop ("!", e)
|
||||
| (
|
||||
"=" | "<>"
|
||||
| "&" | "or"
|
||||
| "+" | "-" | "*" | "/"
|
||||
| "*." | "/." | "+." | "-." | "%"
|
||||
| "*." | "/." | "+." | "-." | "%" | "<<<" | ">>>"
|
||||
| "<" | ">" | "<=" | ">=" | "<=." | "<." | ">=." | ">."), [el;er] ->
|
||||
Cbop (copname op, el, er)
|
||||
| _ -> Cfun_call(op, cexps)
|
||||
|
|
|
@ -113,6 +113,9 @@ and op ff (f, e_l) =
|
|||
| "/." -> "/"
|
||||
| "+." -> "+"
|
||||
| "-." -> "-"
|
||||
| "~~" -> "~"
|
||||
| "<<<" -> "<<"
|
||||
| ">>>" -> ">>"
|
||||
| op -> op
|
||||
in
|
||||
match Names.modul f with
|
||||
|
|
|
@ -27,6 +27,9 @@ val fun (not)(bool) returns (bool)
|
|||
val fun (or)(bool;bool) returns (bool)
|
||||
val fun (xor)(bool;bool) returns (bool)
|
||||
val fun (~-)(int) returns (int)
|
||||
val fun (~~)(int) returns (int)
|
||||
val fun (>>>)(int;int) returns (int)
|
||||
val fun (<<<)(int;int) returns (int)
|
||||
val fun (~-.)(float) returns (float)
|
||||
val fun do_stuff(int) returns (int)
|
||||
val fun between(int;int) returns (int)
|
||||
|
|
Loading…
Reference in a new issue