aboutsummaryrefslogtreecommitdiff
path: root/boot/evaluator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'boot/evaluator.cc')
-rw-r--r--boot/evaluator.cc42
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;
}