From 5cc2947143f2a6ebd4ef1ae4d25ab956b87de808 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 21 Jul 2026 21:27:03 +0200 Subject: Redefine strings as slice of constant characters --- boot/evaluator.cc | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'boot/evaluator.cc') 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 { using T = std::decay_t; @@ -178,7 +178,15 @@ namespace elna::boot { return constant_value{ !value }; } - else if constexpr (std::is_integral_v) + return std::nullopt; + }, operand.value()); + } + if (subject.operation() == unary_operator::bitwise_negation) + { + return std::visit([](auto value) -> std::optional { + using T = std::decay_t; + + if constexpr (std::is_integral_v) { return constant_value{ ~value }; } @@ -299,23 +307,44 @@ namespace elna::boot } return std::nullopt; case disjunction: - if constexpr (std::is_integral_v) + case bitwise_disjunction: + if constexpr (std::is_integral_v && !std::is_same_v) { return constant_value{ lhs | rhs }; } return std::nullopt; case conjunction: - if constexpr (std::is_integral_v) + case bitwise_conjunction: + if constexpr (std::is_integral_v && !std::is_same_v) { return constant_value{ lhs & rhs }; } return std::nullopt; case exclusive_disjunction: - if constexpr (std::is_integral_v) + case bitwise_exclusive_disjunction: + if constexpr (std::is_integral_v && !std::is_same_v) { return constant_value{ lhs ^ rhs }; } return std::nullopt; + case logical_conjunction: + if constexpr (std::is_same_v) + { + return constant_value{ lhs && rhs }; + } + return std::nullopt; + case logical_disjunction: + if constexpr (std::is_same_v) + { + return constant_value{ lhs || rhs }; + } + return std::nullopt; + case logical_exclusive_disjunction: + if constexpr (std::is_same_v) + { + return constant_value{ lhs != rhs }; + } + return std::nullopt; case shift_left: if constexpr (std::is_integral_v && !std::is_same_v) { @@ -420,8 +449,7 @@ namespace elna::boot { return target.bool_size; } - else if (is_primitive_type(resolved, "String") - || resolved.get() != nullptr) + else if (resolved.get() != nullptr) { return target.pointer_size + target.word_size; } -- cgit v1.2.3