<commit_before>/**
 ** \file runner/interpreter.cc
 ** \brief Implementation of runner::Interpreter.
 */

// #define ENABLE_DEBUG_TRACES

#include <libport/compiler.hh>
#include <libport/finally.hh>

#include <algorithm>
#include <deque>

#include <boost/range/iterator_range.hpp>

#include <libport/foreach.hh>
#include <libport/symbol.hh>

#include <kernel/uconnection.hh>

#include <object/cxx-conversions.hh>
#include <object/global.hh>
#include <object/lobby.hh>
#include <object/tag.hh>
#include <object/task.hh>

#include <runner/call.hh>
#include <runner/interpreter.hh>
#include <runner/raise.hh>

#include <parser/uparser.hh>

#include <scheduler/exception.hh>

namespace runner
{
  using libport::Finally;

  // This function takes an expression and attempts to decompose it
  // into a list of identifiers.
  typedef std::deque<libport::Symbol> tag_chain_type;
  static
  tag_chain_type
  decompose_tag_chain (ast::rConstExp e)
  {
    tag_chain_type res;
    while (!e->implicit())
    {
      ast::rConstCall c = e.unsafe_cast<const ast::Call>();
      if (!c || c->arguments_get())
	runner::raise_urbi(SYMBOL(ImplicitTagComponentError));
      res.push_front (c->name_get());
      e = c->target_get();
    }
    return res;
  }


  /*--------------.
  | Interpreter.  |
  `--------------*/

  Interpreter::Interpreter (rLobby lobby,
			    scheduler::Scheduler& sched,
			    ast::rConstAst ast,
			    const libport::Symbol& name)
    : Runner(lobby, sched, name)
    , ast_(ast)
    , code_(0)
    , result_(0)
    , stacks_(lobby)
  {
    init();
  }

  Interpreter::Interpreter(const Interpreter& model, rObject code,
			   const libport::Symbol& name, const objects_type& args)
    : Runner(model, name)
    , ast_(0)
    , code_(code)
    , args_(args)
    , result_(0)
    , call_stack_(model.call_stack_)<commit_msg>Restore the connection tag in the tag stack.<commit_after>/**
 ** \file runner/interpreter.cc
 ** \brief Implementation of runner::Interpreter.
 */

// #define ENABLE_DEBUG_TRACES

#include <libport/compiler.hh>
#include <libport/finally.hh>

#include <algorithm>
#include <deque>

#include <boost/range/iterator_range.hpp>

#include <libport/foreach.hh>
#include <libport/symbol.hh>

#include <kernel/uconnection.hh>

#include <object/cxx-conversions.hh>
#include <object/global.hh>
#include <object/lobby.hh>
#include <object/tag.hh>
#include <object/task.hh>

#include <runner/call.hh>
#include <runner/interpreter.hh>
#include <runner/raise.hh>

#include <parser/uparser.hh>

#include <scheduler/exception.hh>

namespace runner
{
  using libport::Finally;

  // This function takes an expression and attempts to decompose it
  // into a list of identifiers.
  typedef std::deque<libport::Symbol> tag_chain_type;
  static
  tag_chain_type
  decompose_tag_chain (ast::rConstExp e)
  {
    tag_chain_type res;
    while (!e->implicit())
    {
      ast::rConstCall c = e.unsafe_cast<const ast::Call>();
      if (!c || c->arguments_get())
	runner::raise_urbi(SYMBOL(ImplicitTagComponentError));
      res.push_front (c->name_get());
      e = c->target_get();
    }
    return res;
  }


  /*--------------.
  | Interpreter.  |
  `--------------*/

  Interpreter::Interpreter (rLobby lobby,
			    scheduler::Scheduler& sched,
			    ast::rConstAst ast,
			    const libport::Symbol& name)
    : Runner(lobby, sched, name)
    , ast_(ast)
    , code_(0)
    , result_(0)
    , stacks_(lobby)
  {
    init();
    tag_stack_.push_back
      (lobby->slot_get(SYMBOL(connectionTag))->as<object::Tag>());
  }

  Interpreter::Interpreter(const Interpreter& model, rObject code,
			   const libport::Symbol& name, const objects_type& args)
    : Runner(model, name)
    , ast_(0)
    , code_(code)
    , args_(args)
    , result_(0)
    , call_stack_(model.call_stack_)
{'fraction_non_alphanumeric': 0.1575072311333158, 'fraction_numerical': 0.002103602419142782, 'mean_word_length': 3.44392523364486, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 54, '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': '6115882', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1326, 'n_words': 262}