Allow functions to return values.

Fixes #5922
This commit is contained in:
Gunnar Beutner 2014-04-02 09:04:49 +02:00
parent 0683fca535
commit 41d0dde52e
2 changed files with 7 additions and 2 deletions

View File

@ -475,7 +475,8 @@ Value AExpression::FunctionWrapper(const std::vector<Value>& arguments, const Ar
for (int i = 0; i < std::min(arguments.size(), funcargs->GetLength()); i++)
locals->Set(funcargs->Get(i), arguments[i]);
return expr->Evaluate(locals);
expr->Evaluate(locals);
return locals->Get("__result");
}
Value AExpression::OpFunction(const AExpression* expr, const Dictionary::Ptr& locals)

View File

@ -781,8 +781,12 @@ rterm: T_STRING
arr->Add(Empty);
arr->Add(*$4);
Array::Ptr arrex = make_shared<Array>();
arrex->Add(make_shared<AExpression>(&AExpression::OpSet, make_shared<AExpression>(&AExpression::OpLiteral, "__result", @4), *$4, @4));
delete $4;
AExpression::Ptr aexpr = make_shared<AExpression>(&AExpression::OpDict, arrex, true, @4);
arr->Add(aexpr);
$$ = new Value(make_shared<AExpression>(&AExpression::OpFunction, arr, Array::Ptr($2), DebugInfoRange(@1, @4)));
}