Added booleans. Add if/elseif/else and while blocks. Added more comparisons.

This commit is contained in:
Jonathan Turner
2009-06-05 11:45:57 +00:00
parent 5d1bae709a
commit 3f4aed0db9
2 changed files with 130 additions and 10 deletions

View File

@@ -28,12 +28,54 @@ Ret multiply(P1 p1, P2 p2)
return p1 * p2;
}
template<typename P1, typename P2>
bool bool_and(P1 p1, P2 p2)
{
return p1 && p2;
}
template<typename P1, typename P2>
bool bool_or(P1 p1, P2 p2)
{
return p1 || p2;
}
template<typename P1, typename P2>
bool equals(P1 p1, P2 p2)
{
return p1 == p2;
}
template<typename P1, typename P2>
bool not_equals(P1 p1, P2 p2)
{
return p1 != p2;
}
template<typename P1, typename P2>
bool less_than(P1 p1, P2 p2)
{
return p1 < p2;
}
template<typename P1, typename P2>
bool greater_than(P1 p1, P2 p2)
{
return p1 > p2;
}
template<typename P1, typename P2>
bool less_than_equals(P1 p1, P2 p2)
{
return p1 <= p2;
}
template<typename P1, typename P2>
bool greater_than_equals(P1 p1, P2 p2)
{
return p1 >= p2;
}
template<typename P1, typename P2>
P1 &timesequal(P1 &p1, P2 p2)
{
@@ -72,11 +114,39 @@ void bootstrap(BoxedCPP_System &s)
s.register_function(boost::function<double (double, int)>(&divide<double, double, int>), "/");
s.register_function(boost::function<double (double, double)>(&divide<double, double, double>), "/");
s.register_function(boost::function<bool (bool, bool)>(&bool_and<bool, bool>), "&&");
s.register_function(boost::function<bool (bool, bool)>(&bool_or<bool, bool>), "||");
s.register_function(boost::function<bool (int, int)>(&equals<int, int>), "==");
s.register_function(boost::function<bool (int, double)>(&equals<int, double>), "==");
s.register_function(boost::function<bool (double, int)>(&equals<double, int>), "==");
s.register_function(boost::function<bool (double, double)>(&equals<double, double>), "==");
s.register_function(boost::function<bool (int, int)>(&not_equals<int, int>), "!=");
s.register_function(boost::function<bool (int, double)>(&not_equals<int, double>), "!=");
s.register_function(boost::function<bool (double, int)>(&not_equals<double, int>), "!=");
s.register_function(boost::function<bool (double, double)>(&not_equals<double, double>), "!=");
s.register_function(boost::function<bool (int, int)>(&less_than<int, int>), "<");
s.register_function(boost::function<bool (int, double)>(&less_than<int, double>), "<");
s.register_function(boost::function<bool (double, int)>(&less_than<double, int>), "<");
s.register_function(boost::function<bool (double, double)>(&less_than<double, double>), "<");
s.register_function(boost::function<bool (int, int)>(&greater_than<int, int>), ">");
s.register_function(boost::function<bool (int, double)>(&greater_than<int, double>), ">");
s.register_function(boost::function<bool (double, int)>(&greater_than<double, int>), ">");
s.register_function(boost::function<bool (double, double)>(&greater_than<double, double>), ">");
s.register_function(boost::function<bool (int, int)>(&less_than_equals<int, int>), "<=");
s.register_function(boost::function<bool (int, double)>(&less_than_equals<int, double>), "<=");
s.register_function(boost::function<bool (double, int)>(&less_than_equals<double, int>), "<=");
s.register_function(boost::function<bool (double, double)>(&less_than_equals<double, double>), "<=");
s.register_function(boost::function<bool (int, int)>(&greater_than_equals<int, int>), ">=");
s.register_function(boost::function<bool (int, double)>(&greater_than_equals<int, double>), ">=");
s.register_function(boost::function<bool (double, int)>(&greater_than_equals<double, int>), ">=");
s.register_function(boost::function<bool (double, double)>(&greater_than_equals<double, double>), ">=");
s.register_function(boost::function<int (int, int)>(&multiply<int, int, int>), "*");
s.register_function(boost::function<double (int, double)>(&multiply<double, int, double>), "*");
s.register_function(boost::function<double (double, int)>(&multiply<double, double, int>), "*");