<commit_before>#include "interpreter.hpp"
#include "cpp_parser/cpp_parser.hpp"
#include "rewriting/rewriter.hpp"
#include "utils/mytuple.hpp"
#include "utils/rank.hpp"
#include "utils/utils.hpp"
#include <memory>
#include <iostream>
#include <fstream>

using namespace std;

single_node_cloner snc;

///////////////////////////////////////////////////////////////////////////////

interpreter::interpreter(rpl_environment& env, error_container& err_repo) :
    env(env),
    err_repo(err_repo),
    adispatch(env),
    sdispatch(env),
    gdispatch(env),
    odispatch(env),
    vdispatch(env),
    normform(env),
    ff(env),
    success(true)
{}

void interpreter::visit(assign_node& n) {
    // recurse for semantic check in skel tree
    id_node* idnode = dynamic_cast<id_node*>(n.rvalue);
    n.rvalue->accept(*this);

    if ( success && !idnode) {
        unranktorank2(*n.rvalue, snc);
        env.put(n.id, n.rvalue);
    } else if ( success ) {
        skel_node& skel = *env.get(idnode->id, idnode->index);
        env.put(n.id, skel.clone());
        delete n.rvalue;
    } else
        delete n.rvalue;

}

void interpreter::visit(show_node& n) {
    try {

        if ( n.id == "" && n.parameters.size() == 1) {
            cout << utils::to_string( gdispatch[n.parameters[0]]() ) << endl;
            return;
        }

        ann_printer p;
        vector<mytuple> tuples;
        auto range = env.range( n.id );
        auto index = n.index < 0 ? 0 : n.index;
        auto begin = range.first + ( n.index < 0 ? 0 : n.index );
        auto end   = n.index < 0 ? range.second : range.first + n.index + 1;

        for ( auto it = begin; it != end; it++ ) {

            tuples.push_back(mytuple());
            auto& last  = tuples.back();
            auto& skptr = *it;
            assignres(*skptr, env.get_inputsize());

            for (const string& par : n.parameters)
                if ( par != "show_default" ) {
                    printable& shower = *vdispatch[ par ];<commit_msg>fixed problem in assignment<commit_after>#include "interpreter.hpp"
#include "cpp_parser/cpp_parser.hpp"
#include "rewriting/rewriter.hpp"
#include "utils/mytuple.hpp"
#include "utils/rank.hpp"
#include "utils/utils.hpp"
#include <memory>
#include <iostream>
#include <fstream>

using namespace std;

single_node_cloner snc;

///////////////////////////////////////////////////////////////////////////////

interpreter::interpreter(rpl_environment& env, error_container& err_repo) :
    env(env),
    err_repo(err_repo),
    adispatch(env),
    sdispatch(env),
    gdispatch(env),
    odispatch(env),
    vdispatch(env),
    normform(env),
    ff(env),
    success(true)
{}

void interpreter::visit(assign_node& n) {

    id_node* idnode = dynamic_cast<id_node*>(n.rvalue);
    success = true;
    n.rvalue->accept(*this);

    if ( success && !idnode) {
        unranktorank2(*n.rvalue, snc);
        env.put(n.id, n.rvalue);
    } else if ( success ) {
        skel_node& skel = *env.get(idnode->id, idnode->index);
        env.put(n.id, skel.clone());
        delete n.rvalue;
    } else
        delete n.rvalue;
}

void interpreter::visit(show_node& n) {
    try {

        if ( n.id == "" && n.parameters.size() == 1) {
            cout << utils::to_string( gdispatch[n.parameters[0]]() ) << endl;
            return;
        }

        ann_printer p;
        vector<mytuple> tuples;
        auto range = env.range( n.id );
        auto index = n.index < 0 ? 0 : n.index;
        auto begin = range.first + ( n.index < 0 ? 0 : n.index );
        auto end   = n.index < 0 ? range.second : range.first + n.index + 1;

        for ( auto it = begin; it != end; it++ ) {

            tuples.push_back(mytuple());
            auto& last  = tuples.back();
            auto& skptr = *it;
            assignres(*skptr, env.get_inputsize());

            for (const string& par : n.parameters)
                if ( par != "show_default" ) {
                    printable& shower = *vdispatch[ par ];
{'fraction_non_alphanumeric': 0.18336247814139395, 'fraction_numerical': 0.0044966275293529855, 'mean_word_length': 2.077632590315142, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 19, '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': '2463617', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1322, 'n_words': 282}