1
0
Fork 0

handle calls to user-defined functions

This commit is contained in:
Jan Steemann 2014-08-06 17:30:21 +02:00
parent e8f69490ff
commit 7c226df013
2 changed files with 42 additions and 2 deletions

View File

@ -529,7 +529,7 @@ void V8Executor::generateCodeCollection (AstNode const* node) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for a function call
/// @brief generate JavaScript code for a call to a built-in function
////////////////////////////////////////////////////////////////////////////////
void V8Executor::generateCodeFunctionCall (AstNode const* node) {
@ -557,6 +557,36 @@ void V8Executor::generateCodeFunctionCall (AstNode const* node) {
_buffer->appendText(")");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for a call to a user-defined function
////////////////////////////////////////////////////////////////////////////////
void V8Executor::generateCodeUserFunctionCall (AstNode const* node) {
TRI_ASSERT(node != nullptr);
TRI_ASSERT(node->numMembers() == 1);
char const* name = node->getStringValue();
TRI_ASSERT(name != nullptr);
auto args = node->getMember(0);
TRI_ASSERT(args != nullptr);
TRI_ASSERT(args->type == NODE_TYPE_LIST);
_buffer->appendText("aql.FCALL_USER(\"");
_buffer->appendJsonEncoded(name);
_buffer->appendText("\", [");
size_t const n = args->numMembers();
for (size_t i = 0; i < n; ++i) {
if (i > 0) {
_buffer->appendText(", ");
}
generateCodeNode(args->getMember(i));
}
_buffer->appendText("])");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for an expansion (i.e. [*] operator)
////////////////////////////////////////////////////////////////////////////////
@ -686,6 +716,10 @@ void V8Executor::generateCodeNode (AstNode const* node) {
generateCodeFunctionCall(node);
break;
case NODE_TYPE_FCALL_USER:
generateCodeUserFunctionCall(node);
break;
case NODE_TYPE_EXPAND:
generateCodeExpand(node);
break;

View File

@ -154,11 +154,17 @@ namespace triagens {
void generateCodeCollection (AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for a function call
/// @brief generate JavaScript code for a call to a built-in function
////////////////////////////////////////////////////////////////////////////////
void generateCodeFunctionCall (AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for a user-defined function
////////////////////////////////////////////////////////////////////////////////
void generateCodeUserFunctionCall (AstNode const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief generate JavaScript code for an expansion (i.e. [*] operator)
////////////////////////////////////////////////////////////////////////////////