Work-around for negate and not. Boolean print isn't working
This commit is contained in:
@@ -526,11 +526,11 @@ void bootstrap(BoxedCPP_System &s)
|
|||||||
add_oper_add<std::string>(s);
|
add_oper_add<std::string>(s);
|
||||||
add_oper_add_equals <std::string>(s);
|
add_oper_add_equals <std::string>(s);
|
||||||
|
|
||||||
register_function(s, &print<int>, "print");
|
register_function(s, &print<const bool>, "print");
|
||||||
register_function(s, &print<std::string>, "print");
|
register_function(s, &print<std::string>, "print");
|
||||||
register_function(s, &print<double>, "print");
|
register_function(s, &print<double>, "print");
|
||||||
register_function(s, &print<float>, "print");
|
register_function(s, &print<size_t>, "print");
|
||||||
register_function(s, &print<bool>, "print");
|
register_function(s, &print<int>, "print");
|
||||||
|
|
||||||
s.register_function(boost::function<void ()>(boost::bind(&dump_system, boost::ref(s))), "dump_system");
|
s.register_function(boost::function<void ()>(boost::bind(&dump_system, boost::ref(s))), "dump_system");
|
||||||
s.register_function(boost::function<void (Boxed_Value)>(boost::bind(&dump_object, _1)), "dump_object");
|
s.register_function(boost::function<void (Boxed_Value)>(boost::bind(&dump_object, _1)), "dump_object");
|
||||||
|
@@ -140,8 +140,32 @@ Boxed_Value eval_token(Eval_System &ss, TokenPtr node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case (TokenType::Negate) :
|
case (TokenType::Negate) : {
|
||||||
case (TokenType::Not) :
|
retval = eval_token(ss, node->children[1]);
|
||||||
|
Param_List_Builder plb;
|
||||||
|
plb << retval;
|
||||||
|
plb << Boxed_Value(-1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
retval = dispatch(ss.get_function("*"), plb);
|
||||||
|
}
|
||||||
|
catch(std::exception &e){
|
||||||
|
throw EvalError("Can not find appropriate negation", node->children[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case (TokenType::Not) : {
|
||||||
|
bool cond;
|
||||||
|
try {
|
||||||
|
retval = eval_token(ss, node->children[1]);
|
||||||
|
cond = Cast_Helper<bool &>()(retval);
|
||||||
|
}
|
||||||
|
catch (std::exception) {
|
||||||
|
throw EvalError("Boolean not('!') condition not boolean", node->children[0]);
|
||||||
|
}
|
||||||
|
retval = Boxed_Value(!cond);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case (TokenType::Prefix) : {
|
case (TokenType::Prefix) : {
|
||||||
retval = eval_token(ss, node->children[1]);
|
retval = eval_token(ss, node->children[1]);
|
||||||
Param_List_Builder plb;
|
Param_List_Builder plb;
|
||||||
|
Reference in New Issue
Block a user