use a global void value for returning unknown values
This commit is contained in:
parent
cd1b3f8887
commit
5247de7d1b
@ -411,6 +411,11 @@ namespace chaiscript
|
|||||||
return detail::const_var_impl(t);
|
return detail::const_var_impl(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Boxed_Value void_var() {
|
||||||
|
static const auto v = Boxed_Value(Boxed_Value::Void_Type());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
inline Boxed_Value const_var(bool b) {
|
inline Boxed_Value const_var(bool b) {
|
||||||
static const auto t = detail::const_var_impl(true);
|
static const auto t = detail::const_var_impl(true);
|
||||||
static const auto f = detail::const_var_impl(false);
|
static const auto f = detail::const_var_impl(false);
|
||||||
|
@ -268,7 +268,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
static Boxed_Value handle()
|
static Boxed_Value handle()
|
||||||
{
|
{
|
||||||
return Boxed_Value(Boxed_Value::Void_Type());
|
return void_var();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,7 @@ namespace chaiscript
|
|||||||
} catch (const exception::name_conflict_error &e) {
|
} catch (const exception::name_conflict_error &e) {
|
||||||
throw exception::eval_error("Function redefined '" + e.name() + "'");
|
throw exception::eval_error("Function redefined '" + e.name() + "'");
|
||||||
}
|
}
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -778,7 +778,7 @@ namespace chaiscript
|
|||||||
// loop was broken intentionally
|
// loop was broken intentionally
|
||||||
}
|
}
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -795,7 +795,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
children[1]->eval(t_ss);
|
children[1]->eval(t_ss);
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -871,7 +871,7 @@ namespace chaiscript
|
|||||||
// loop broken
|
// loop broken
|
||||||
}
|
}
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -913,7 +913,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
++currentCase;
|
++currentCase;
|
||||||
}
|
}
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
mutable std::atomic_uint_fast32_t m_loc;
|
mutable std::atomic_uint_fast32_t m_loc;
|
||||||
@ -929,7 +929,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
children[1]->eval(t_ss);
|
children[1]->eval(t_ss);
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -943,7 +943,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
children[0]->eval(t_ss);
|
children[0]->eval(t_ss);
|
||||||
|
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1019,7 +1019,7 @@ namespace chaiscript
|
|||||||
throw detail::Return_Value(children[0]->eval(t_ss));
|
throw detail::Return_Value(children[0]->eval(t_ss));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw detail::Return_Value(Boxed_Value());
|
throw detail::Return_Value(void_var());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1038,7 +1038,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
return children.back()->eval(t_ss);
|
return children.back()->eval(t_ss);
|
||||||
} else {
|
} else {
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
} catch (const detail::Continue_Loop &) {
|
} catch (const detail::Continue_Loop &) {
|
||||||
throw exception::eval_error("Unexpected `continue` statement outside of a loop");
|
throw exception::eval_error("Unexpected `continue` statement outside of a loop");
|
||||||
@ -1362,7 +1362,7 @@ namespace chaiscript
|
|||||||
} catch (const exception::name_conflict_error &e) {
|
} catch (const exception::name_conflict_error &e) {
|
||||||
throw exception::eval_error("Method redefined '" + e.name() + "'");
|
throw exception::eval_error("Method redefined '" + e.name() + "'");
|
||||||
}
|
}
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -1397,7 +1397,7 @@ namespace chaiscript
|
|||||||
} catch (const exception::name_conflict_error &e) {
|
} catch (const exception::name_conflict_error &e) {
|
||||||
throw exception::eval_error("Attribute redefined '" + e.name() + "'");
|
throw exception::eval_error("Attribute redefined '" + e.name() + "'");
|
||||||
}
|
}
|
||||||
return Boxed_Value();
|
return void_var();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user