<commit_before>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "FunctionContext.hpp"
#include "Variable.hpp"
#include "Utils.hpp"
#include "Value.hpp"

using std::map;
using std::string;
using std::endl;

using namespace eddic;

int FunctionContext::size(){
    int s = 0;
    for(auto it : m_stored){
        s += ::size(it.second->type());
    }

    return s;
}

std::shared_ptr<Variable> FunctionContext::newParameter(const std::string& variable, Type type){
    Position position(PARAMETER, currentParameter);
    
    currentParameter += ::size(type);

    return std::shared_ptr<Variable>(new Variable(variable, type, position));
}

std::shared_ptr<Variable> FunctionContext::newVariable(const std::string& variable, Type type){<commit_msg>The parameters are taken into account when calculating the size of the function local variables block<commit_after>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "FunctionContext.hpp"
#include "Variable.hpp"
#include "Utils.hpp"
#include "Value.hpp"

using std::map;
using std::string;
using std::endl;

using namespace eddic;

//TODO Do not take parameters into account for counting (result into useless stack allocations in the function)
int FunctionContext::size(){
    int s = 0;
    for(auto it : m_stored){
        s += ::size(it.second->type());
    }

    return s;
}

std::shared_ptr<Variable> FunctionContext::newParameter(const std::string& variable, Type type){
    Position position(PARAMETER, currentParameter);
    
    currentParameter += ::size(type);

    return std::shared_ptr<Variable>(new Variable(variable, type, position));
}

std::shared_ptr<Variable> FunctionContext::newVariable(const std::string& variable, Type type){
{'fraction_non_alphanumeric': 0.24210526315789474, 'fraction_numerical': 0.009649122807017544, 'mean_word_length': 5.425352112676056, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6165643', 'n_tokens_mistral': 636, 'n_tokens_neox': 600, 'n_words': 173}