Beispiel #1
0
bool TRI_StartScopeAql (TRI_aql_context_t* const context, const TRI_aql_scope_e type) {
  TRI_aql_scope_t* scope;
  TRI_aql_node_t* node;

  assert(context);

  scope = CreateScope(context, type);

  if (scope == NULL) {
    return false;
  }
  
  LOG_TRACE("starting scope of type %s", TRI_TypeNameScopeAql(scope->_type));
  TRI_PushBackVectorPointer(&context->_memory._scopes, (void*) scope);
  TRI_PushBackVectorPointer(&context->_currentScopes, (void*) scope);

  node = TRI_CreateNodeScopeStartAql(context, scope);
  if (node == NULL) {
    return false;
  }
  
  if (! TRI_AppendStatementListAql(context->_statements, node)) {
    return false;
  }

  return true;
}
Beispiel #2
0
bool TRI_EndScopeByReturnAql (TRI_aql_context_t* const context) {
  TRI_aql_scope_e type;
  TRI_aql_node_t* node;
  size_t n;

  assert(context);
  type = CurrentType(context);

  if (type == TRI_AQL_SCOPE_MAIN || type == TRI_AQL_SCOPE_SUBQUERY) {
    return true;
  }

  n = context->_currentScopes._length;
  assert(n > 0);

  while (n > 0) {
    TRI_aql_scope_t* scope;

    scope = (TRI_aql_scope_t*) TRI_RemoveVectorPointer(&context->_currentScopes, --n);
    assert(scope);

    LOG_TRACE("closing scope of type %s", TRI_TypeNameScopeAql(scope->_type));

    node = TRI_CreateNodeScopeEndAql(context, scope);
    if (node == NULL) {
      return false;
    }

    if (! TRI_AppendStatementListAql(context->_statements, node)) {
      return false;
    }

    if (scope->_type != TRI_AQL_SCOPE_FOR_NESTED) {
      // removed enough scopes
      break;
    }
  }

  return true;
}
Beispiel #3
0
bool TRI_EndScopeAql (TRI_aql_context_t* const context) {
  TRI_aql_scope_t* scope;
  TRI_aql_node_t* node;
  size_t n;

  assert(context);

  n = context->_currentScopes._length;
  assert(n > 0);

  scope = TRI_RemoveVectorPointer(&context->_currentScopes, --n);
  LOG_TRACE("closing scope of type %s", TRI_TypeNameScopeAql(scope->_type));

  node = TRI_CreateNodeScopeEndAql(context, scope);
  if (node == NULL) {
    return false;
  }

  if (! TRI_AppendStatementListAql(context->_statements, node)) {
    return false;
  }

  return true;
}