1 #include <ail/exception.hpp>
2 #include <fridh/symbol.hpp>
6 bool variable::array_equality(variable
const & other
) const
10 & other_vector
= *other
.array
;
12 std::size_t size
= vector
.size();
13 if(size
!= vector
.size())
16 for(std::size_t i
= 0; i
< size
; i
++)
18 if(vector
[i
] != other_vector
[i
])
25 bool variable::map_equality(variable
const & other
) const
29 & other_map
= *other
.map
;
31 if(this_map
.size() != other_map
.size())
34 for(types::map::const_iterator i
= this_map
.begin(), end
= this_map
.end(); i
!= end
; i
++)
36 types::map::const_iterator iterator
= other_map
.find(i
->first
);
37 if(iterator
== other_map
.end())
40 if(i
->second
!= iterator
->second
)
47 bool variable::operator==(variable
const & other
) const
49 if(is_numeric_type() && other
.is_numeric_type())
51 if(type
== variable_type_identifier::floating_point_value
|| other
.type
== variable_type_identifier::floating_point_value
)
52 return get_floating_point_value() == other
.get_floating_point_value();
54 return unsigned_integer
== other
.unsigned_integer
;
60 case variable_type_identifier::nil
:
61 case variable_type_identifier::none
:
62 return type
== other
.type
;
63 return type
== other
.type
;
65 case variable_type_identifier::boolean
:
66 return type
== other
.type
&& boolean
== other
.boolean
;
68 case variable_type_identifier::string
:
69 return type
== other
.type
&& *string
== *other
.string
;
71 case variable_type_identifier::array
:
72 return array_equality(other
);
74 case variable_type_identifier::map
:
75 return map_equality(other
);
77 case variable_type_identifier::function
:
78 throw ail::exception("Comparison of functions has not been implemented yet");
80 case variable_type_identifier::object
:
81 throw ail::exception("Comparison of objects has not been implemented yet");
83 case variable_type_identifier::signed_integer
:
84 case variable_type_identifier::unsigned_integer
:
85 case variable_type_identifier::floating_point_value
:
92 bool variable::operator!=(variable
const & other
) const
94 return !operator==(other
);