Fixed the variable code, replacing it with simpler arguments and using exceptions...
[fridhskrift.git] / variable / binary_operator.cpp
blob76c18d5bd0831525a125f0409217d6c474462e18
1 #include <fridh/symbol.hpp>
3 namespace fridh
5 #define BINARY_OPERATOR(name, description, operator) \
6 void variable::name(variable const & argument, variable & output) const \
7 { \
8 if(is_integer_type() && argument.is_integer_type()) \
9 output.new_unsigned_integer(unsigned_integer operator argument.unsigned_integer); \
10 else \
11 binary_argument_type_error(description, type, argument.type); \
14 BINARY_OPERATOR(shift_left, "Shift left", <<)
15 BINARY_OPERATOR(shift_right, "Shift right", >>)
16 BINARY_OPERATOR(binary_and, "Binary and", &)
17 BINARY_OPERATOR(binary_or, "Binary or", |)
18 BINARY_OPERATOR(binary_xor, "Binary exclusive or", ^)
20 void variable::binary_not(variable & output) const
22 if(is_integer_type())
23 output.new_unsigned_integer(~unsigned_integer);
24 else
25 unary_argument_type_error("Binary not", type);