<commit_before>#include "rdb_protocol/func.hpp"

#include "rdb_protocol/counted_term.hpp"
#include "rdb_protocol/env.hpp"
#include "rdb_protocol/pb_utils.hpp"
#include "rdb_protocol/pseudo_literal.hpp"
#include "rdb_protocol/ql2.pb.h"
#include "rdb_protocol/term_walker.hpp"
#include "stl_utils.hpp"

#pragma GCC diagnostic ignored "-Wshadow"

namespace ql {

func_t::func_t(const protob_t<const Term> &term) : pb_rcheckable_t(term) { }
func_t::func_t(const protob_t<const Backtrace> &bt_source) : pb_rcheckable_t(bt_source) { }
func_t::~func_t() { }

counted_t<val_t> func_t::call(env_t *env) const {
    std::vector<counted_t<const datum_t> > args;
    return call(env, args);
}

counted_t<val_t> func_t::call(env_t *env, counted_t<const datum_t> arg) const {
    return call(env, make_vector(arg));
}

counted_t<val_t> func_t::call(env_t *env,
                              counted_t<const datum_t> arg1,
                              counted_t<const datum_t> arg2) const {
    return call(env, make_vector(arg1, arg2));
}

void func_t::assert_deterministic(const char *extra_msg) const {
    rcheck(is_deterministic(),
           base_exc_t::GENERIC,
           strprintf("Could not prove function deterministic.  %s", extra_msg));
}

reql_func_t::reql_func_t(const protob_t<const Backtrace> backtrace,
                         const var_scope_t &_captured_scope,
                         std::vector<sym_t> _arg_names,
                         counted_t<term_t> _body)
    : func_t(backtrace), captured_scope(_captured_scope),
      arg_names(std::move(_arg_names)), body(std::move(_body)) { }

reql_func_t::~reql_func_t() { }

counted_t<val_t> reql_func_t::call(env_t *env, const std::vector<counted_t<const datum_t> > &args) const {
    try {
        // RSI: This allow arg_names.size() to be 0.  Why do we allow this?  (Is the behavior subtly different in the new implementation?  Because in the old implementation, maybe some stuff saw random old argptrs values...)
        rcheck(arg_names.size() == args.size() || arg_names.size() == 0,
               base_exc_t::GENERIC,
               strprintf("Expected %zd argument(s) but found %zu.",
                         arg_names.size(), args.size()));

        std::vector<std::pair<sym_t, counted_t<const datum_t> > > new_vars;
        for (size_t i = 0; i < arg_names.size(); ++i) {<commit_msg>Trimmed wrong part of a comment.<commit_after>#include "rdb_protocol/func.hpp"

#include "rdb_protocol/counted_term.hpp"
#include "rdb_protocol/env.hpp"
#include "rdb_protocol/pb_utils.hpp"
#include "rdb_protocol/pseudo_literal.hpp"
#include "rdb_protocol/ql2.pb.h"
#include "rdb_protocol/term_walker.hpp"
#include "stl_utils.hpp"

#pragma GCC diagnostic ignored "-Wshadow"

namespace ql {

func_t::func_t(const protob_t<const Term> &term) : pb_rcheckable_t(term) { }
func_t::func_t(const protob_t<const Backtrace> &bt_source) : pb_rcheckable_t(bt_source) { }
func_t::~func_t() { }

counted_t<val_t> func_t::call(env_t *env) const {
    std::vector<counted_t<const datum_t> > args;
    return call(env, args);
}

counted_t<val_t> func_t::call(env_t *env, counted_t<const datum_t> arg) const {
    return call(env, make_vector(arg));
}

counted_t<val_t> func_t::call(env_t *env,
                              counted_t<const datum_t> arg1,
                              counted_t<const datum_t> arg2) const {
    return call(env, make_vector(arg1, arg2));
}

void func_t::assert_deterministic(const char *extra_msg) const {
    rcheck(is_deterministic(),
           base_exc_t::GENERIC,
           strprintf("Could not prove function deterministic.  %s", extra_msg));
}

reql_func_t::reql_func_t(const protob_t<const Backtrace> backtrace,
                         const var_scope_t &_captured_scope,
                         std::vector<sym_t> _arg_names,
                         counted_t<term_t> _body)
    : func_t(backtrace), captured_scope(_captured_scope),
      arg_names(std::move(_arg_names)), body(std::move(_body)) { }

reql_func_t::~reql_func_t() { }

counted_t<val_t> reql_func_t::call(env_t *env, const std::vector<counted_t<const datum_t> > &args) const {
    try {
        // RSI: This allow arg_names.size() to be 0.  Why do we allow this?
        rcheck(arg_names.size() == args.size() || arg_names.size() == 0,
               base_exc_t::GENERIC,
               strprintf("Expected %zd argument(s) but found %zu.",
                         arg_names.size(), args.size()));

        std::vector<std::pair<sym_t, counted_t<const datum_t> > > new_vars;
        for (size_t i = 0; i < arg_names.size(); ++i) {
{'fraction_non_alphanumeric': 0.13062472695500219, 'fraction_numerical': 0.0034949759720401923, 'mean_word_length': 3.4456310679611653, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7187538', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1655, 'n_words': 313}