Fixed bracket/array parsing, empty calls and empty arrays are now permitted
[fridhskrift.git] / variable / comparison.cpp
blob34900ca30b5eedb9390e85ef15a762a4b0cc9d2a
1 #include <fridh/symbol.hpp>
3 namespace fridh
5 #define NUMERIC_COMPARISON(name, description, operator) \
6 void variable::name(variable const & argument, variable & output) const \
7 { \
8 if(is_numeric_type() && argument.is_numeric_type()) \
9 { \
10 if(is_floating_point_operation(argument)) \
11 output.new_boolean(get_floating_point_value() operator argument.get_floating_point_value()); \
12 else if(type == variable_type_identifier::unsigned_integer && argument.type == variable_type_identifier::signed_integer) \
13 output.new_boolean(unsigned_integer operator argument.unsigned_integer); \
14 else \
15 output.new_boolean(signed_integer operator argument.signed_integer); \
16 } \
17 else \
18 binary_argument_type_error(description, type, argument.type); \
21 NUMERIC_COMPARISON(less_than, "Less than", <)
22 NUMERIC_COMPARISON(less_than_or_equal, "Less than", <=)
23 NUMERIC_COMPARISON(greater_than, "Less than", >)
24 NUMERIC_COMPARISON(greater_than_or_equal, "Less than", >=)
26 void variable::not_equal(variable const & argument, variable & output) const
28 output.new_boolean(operator!=(argument));
31 void variable::equal(variable const & argument, variable & output) const
33 output.new_boolean(operator==(argument));
36 void variable::logical_not(variable & output) const
38 output.new_boolean(!get_boolean_value());