<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 <string>

#include "Types.hpp"
#include "CompilerException.hpp"

using namespace eddic;

int eddic::size(Type type){
    return type == Type::INT ? 4 : 8;
}

bool eddic::isType(std::string type){
    return type == "int" || type == "void" || type == "string";
}

Type eddic::stringToType(std::string type){
    if (type == "int") {
        return Type::INT;
    } else if (type == "string"){
        return Type::STRING;
    } else if(type == "void") {
        return Type::VOID;
    }

    throw CompilerException("Invalid type");
}<commit_msg>Use an array to store the size of the types<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 <string>

#include "Types.hpp"
#include "CompilerException.hpp"

using namespace eddic;

const int typeSizes[(int) Type::COUNT] = { 8, 4, 0 };

int eddic::size(Type type){
    return typeSizes[(int) type];
}

bool eddic::isType(std::string type){
    return type == "int" || type == "void" || type == "string";
}

Type eddic::stringToType(std::string type){
    if (type == "int") {
        return Type::INT;
    } else if (type == "string"){
        return Type::STRING;
    } else if(type == "void") {
        return Type::VOID;
    }

    throw CompilerException("Invalid type");
}
{'fraction_non_alphanumeric': 0.29102496016994156, 'fraction_numerical': 0.013276686139139671, 'mean_word_length': 4.119565217391305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1819768', 'n_tokens_mistral': 577, 'n_tokens_neox': 538, 'n_words': 152}