static void gen_expr_call()

in sources/gen_sql.c [1027:1087]


static void gen_expr_call(ast_node *ast, CSTR op, int32_t pri, int32_t pri_new) {
  Contract(is_ast_call(ast));
  EXTRACT_ANY_NOTNULL(name_ast, ast->left);
  EXTRACT_STRING(name, name_ast);
  EXTRACT_NOTNULL(call_arg_list, ast->right);
  EXTRACT_NOTNULL(call_filter_clause, call_arg_list->left);
  EXTRACT(distinct, call_filter_clause->left);
  EXTRACT(opt_filter_clause, call_filter_clause->right);
  EXTRACT(arg_list, call_arg_list->right);

  // We never want this to appear. Calls to `cql_inferred_notnull` exist only as
  // the product of a rewrite rule and should not be visible to users.
  if (!Strcasecmp("cql_inferred_notnull", name)) {
    gen_arg_list(arg_list);
    return;
  }

  if (for_sqlite()) {
    // These functions are all no-ops in SQL and must not be emitted if we're
    // doing codegen: They're only present within queries in source programs for
    // the purpose of manipulating types.

    if (!Strcasecmp("nullable", name)) {
      gen_arg_list(arg_list);
      return;
    }

    if (!Strcasecmp("ptr", name)) {
      gen_arg_list(arg_list);
      return;
    }

    if (!Strcasecmp("sensitive", name)) {
      gen_arg_list(arg_list);
      return;
    }

    bool_t has_inline_func_callback = gen_callbacks && gen_callbacks->inline_func_callback;

    if (has_inline_func_callback) {
      if (ast->left && ast->left->sem && (ast->left->sem->sem_type & SEM_TYPE_INLINE_CALL)) {
        bool_t handled = gen_callbacks->inline_func_callback(ast, gen_callbacks->inline_func_context, output);

        if (handled) {
          return;
        }
      }
    }
  }

  gen_printf("%s(", name);
  if (distinct) {
    gen_printf("DISTINCT ");
  }
  gen_arg_list(arg_list);
  gen_printf(")");

  if (opt_filter_clause) {
    gen_opt_filter_clause(opt_filter_clause);
  }
}