Fix to the method/array dispatch issue
This commit is contained in:
parent
efae821996
commit
8a6a46d0d3
@ -804,13 +804,13 @@ namespace chaiscript
|
|||||||
|
|
||||||
std::string fun_name;
|
std::string fun_name;
|
||||||
std::vector<std::pair<std::string, Proxy_Function > > funs;
|
std::vector<std::pair<std::string, Proxy_Function > > funs;
|
||||||
if (this->children[i]->identifier == AST_Node_Type::Fun_Call) {
|
if ((this->children[i]->identifier == AST_Node_Type::Fun_Call) || (this->children[i]->identifier == AST_Node_Type::Array_Call)) {
|
||||||
fun_name = this->children[i]->children[0]->text;
|
fun_name = this->children[i]->children[0]->text;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fun_name = this->children[i]->text;
|
fun_name = this->children[i]->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ss.set_stack(new_stack);
|
ss.set_stack(new_stack);
|
||||||
retval = ss.call_function(fun_name, plb);
|
retval = ss.call_function(fun_name, plb);
|
||||||
@ -828,6 +828,23 @@ namespace chaiscript
|
|||||||
ss.set_stack(prev_stack);
|
ss.set_stack(prev_stack);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
if (this->children[i]->identifier == AST_Node_Type::Array_Call) {
|
||||||
|
for (unsigned int j = 1; j < this->children[i]->children.size(); ++j) {
|
||||||
|
try {
|
||||||
|
retval = ss.call_function("[]", retval, this->children[i]->children[j]->eval(ss));
|
||||||
|
}
|
||||||
|
catch(std::out_of_range &) {
|
||||||
|
throw Eval_Error("Out of bounds exception");
|
||||||
|
}
|
||||||
|
catch(const dispatch_error &){
|
||||||
|
throw Eval_Error("Can not find appropriate array lookup '[]' ");
|
||||||
|
}
|
||||||
|
catch(Eval_Error &ee) {
|
||||||
|
ee.call_stack.push_back(this->children[i]->children[j]);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user