diff options
| author | gingerBill <bill@gingerbill.org> | 2018-08-26 18:05:59 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-08-26 18:05:59 +0100 |
| commit | 1830c1e57c5301151c26c0996ea5789b3b75a44f (patch) | |
| tree | d9544b0a3e35866313a0b8aae8fee41c8fd0cc82 /src/exact_value.cpp | |
| parent | e5735af6d6001a2a8b8df08d45ac1778dcc7b6f3 (diff) | |
Allow bitwise operation on enums
Diffstat (limited to 'src/exact_value.cpp')
| -rw-r--r-- | src/exact_value.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp index fb392c831..a4ceb5fa0 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -298,16 +298,6 @@ ExactValue exact_value_to_integer(ExactValue v) { return r; } -i64 exact_value_to_i64(ExactValue v) { - v = exact_value_to_integer(v); - i64 result = 0; - if (v.kind == ExactValue_Integer) { - return big_int_to_i64(&v.value_integer); - } - return result; -} - - ExactValue exact_value_to_float(ExactValue v) { switch (v.kind) { case ExactValue_Integer: @@ -370,6 +360,25 @@ ExactValue exact_value_make_imag(ExactValue v) { return r; } +i64 exact_value_to_i64(ExactValue v) { + v = exact_value_to_integer(v); + if (v.kind == ExactValue_Integer) { + return big_int_to_i64(&v.value_integer); + } + return 0; +} +f64 exact_value_to_f64(ExactValue v) { + v = exact_value_to_float(v); + if (v.kind == ExactValue_Float) { + return v.value_float; + } + return 0.0; +} + + + + + ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision, bool is_unsigned) { switch (op) { |