mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Make sure to not deref null parse node
This commit is contained in:
parent
14eaefdceb
commit
f465d2ceca
@ -354,6 +354,7 @@ namespace chaiscript
|
|||||||
m_param_types(std::move(t_param_types)),
|
m_param_types(std::move(t_param_types)),
|
||||||
m_guard(std::move(t_guard)), m_parsenode(std::move(t_parsenode))
|
m_guard(std::move(t_guard)), m_parsenode(std::move(t_parsenode))
|
||||||
{
|
{
|
||||||
|
// assert(t_parsenode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -379,9 +380,17 @@ namespace chaiscript
|
|||||||
return m_guard;
|
return m_guard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_parse_tree() const {
|
||||||
|
return static_cast<bool>(m_parsenode);
|
||||||
|
}
|
||||||
|
|
||||||
const AST_Node &get_parse_tree() const
|
const AST_Node &get_parse_tree() const
|
||||||
{
|
{
|
||||||
return *m_parsenode;
|
if (m_parsenode) {
|
||||||
|
return *m_parsenode;
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error("Dynamic_Proxy_Function does not have parse_tree");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -262,6 +262,7 @@ namespace chaiscript
|
|||||||
bool t_dot_notation,
|
bool t_dot_notation,
|
||||||
const chaiscript::detail::Dispatch_Engine &t_ss)
|
const chaiscript::detail::Dispatch_Engine &t_ss)
|
||||||
{
|
{
|
||||||
|
assert(t_func);
|
||||||
int arity = t_func->get_arity();
|
int arity = t_func->get_arity();
|
||||||
std::vector<Type_Info> types = t_func->get_param_types();
|
std::vector<Type_Info> types = t_func->get_param_types();
|
||||||
|
|
||||||
@ -310,14 +311,14 @@ namespace chaiscript
|
|||||||
std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfun
|
std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfun
|
||||||
= std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_func);
|
= std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_func);
|
||||||
|
|
||||||
if (dynfun)
|
if (dynfun && dynfun->has_parse_tree())
|
||||||
{
|
{
|
||||||
Proxy_Function f = dynfun->get_guard();
|
Proxy_Function f = dynfun->get_guard();
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
auto dynfunguard = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
|
auto dynfunguard = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
|
||||||
if (dynfunguard)
|
if (dynfunguard && dynfunguard->has_parse_tree())
|
||||||
{
|
{
|
||||||
retval += " : " + format_guard(dynfunguard->get_parse_tree());
|
retval += " : " + format_guard(dynfunguard->get_parse_tree());
|
||||||
}
|
}
|
||||||
@ -350,6 +351,7 @@ namespace chaiscript
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (t_functions.size() == 1)
|
if (t_functions.size() == 1)
|
||||||
{
|
{
|
||||||
|
assert(t_functions[0]);
|
||||||
ss << " Expected: " << format_types(t_functions[0], t_dot_notation, t_ss) << '\n';
|
ss << " Expected: " << format_types(t_functions[0], t_dot_notation, t_ss) << '\n';
|
||||||
} else {
|
} else {
|
||||||
ss << " " << t_functions.size() << " overloads available:\n";
|
ss << " " << t_functions.size() << " overloads available:\n";
|
||||||
|
|||||||
@ -288,7 +288,9 @@ namespace chaiscript
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct Fun_Call_AST_Node : AST_Node_Impl<T> {
|
struct Fun_Call_AST_Node : AST_Node_Impl<T> {
|
||||||
Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
||||||
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) { }
|
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) {
|
||||||
|
assert(!this->children.empty());
|
||||||
|
}
|
||||||
|
|
||||||
template<bool Save_Params>
|
template<bool Save_Params>
|
||||||
Boxed_Value do_eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const
|
Boxed_Value do_eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user