diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-21 21:27:03 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-21 21:27:03 +0200 |
| commit | 5cc2947143f2a6ebd4ef1ae4d25ab956b87de808 (patch) | |
| tree | 0d4489b298da3be04ed4bce117f616468146a0f8 /boot/evaluator.cc | |
| parent | 44d6e8a27294e5ca7300ab11900011b73d9336d4 (diff) | |
| download | elna-cpp.tar.gz | |
Diffstat (limited to 'boot/evaluator.cc')
| -rw-r--r-- | boot/evaluator.cc | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/boot/evaluator.cc b/boot/evaluator.cc index 990f358..77a56ad 100644 --- a/boot/evaluator.cc +++ b/boot/evaluator.cc @@ -169,7 +169,7 @@ namespace elna::boot return std::nullopt; }, operand.value()); } - if (subject.operation() == unary_operator::negation) + if (subject.operation() == unary_operator::logical_negation) { return std::visit([](auto value) -> std::optional<constant_value> { using T = std::decay_t<decltype(value)>; @@ -178,7 +178,15 @@ namespace elna::boot { return constant_value{ !value }; } - else if constexpr (std::is_integral_v<T>) + return std::nullopt; + }, operand.value()); + } + if (subject.operation() == unary_operator::bitwise_negation) + { + return std::visit([](auto value) -> std::optional<constant_value> { + using T = std::decay_t<decltype(value)>; + + if constexpr (std::is_integral_v<T>) { return constant_value{ ~value }; } @@ -299,23 +307,44 @@ namespace elna::boot } return std::nullopt; case disjunction: - if constexpr (std::is_integral_v<T>) + case bitwise_disjunction: + if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>) { return constant_value{ lhs | rhs }; } return std::nullopt; case conjunction: - if constexpr (std::is_integral_v<T>) + case bitwise_conjunction: + if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>) { return constant_value{ lhs & rhs }; } return std::nullopt; case exclusive_disjunction: - if constexpr (std::is_integral_v<T>) + case bitwise_exclusive_disjunction: + if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>) { return constant_value{ lhs ^ rhs }; } return std::nullopt; + case logical_conjunction: + if constexpr (std::is_same_v<T, bool>) + { + return constant_value{ lhs && rhs }; + } + return std::nullopt; + case logical_disjunction: + if constexpr (std::is_same_v<T, bool>) + { + return constant_value{ lhs || rhs }; + } + return std::nullopt; + case logical_exclusive_disjunction: + if constexpr (std::is_same_v<T, bool>) + { + return constant_value{ lhs != rhs }; + } + return std::nullopt; case shift_left: if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>) { @@ -420,8 +449,7 @@ namespace elna::boot { return target.bool_size; } - else if (is_primitive_type(resolved, "String") - || resolved.get<slice_type>() != nullptr) + else if (resolved.get<slice_type>() != nullptr) { return target.pointer_size + target.word_size; } |
