<commit_before>#include <papyrus/PapyrusState.h>

#include <papyrus/PapyrusObject.h>

namespace caprica { namespace papyrus {

static const PapyrusFunction* searchRootStateForFunction(const identifier_ref& name, const PapyrusObject* obj) {
  for (auto f : obj->getRootState()->functions) {
    if (idEq(f.second->name, name))
      return f.second;
  }

  if (auto parentObj = obj->tryGetParentClass())
    return searchRootStateForFunction(name, parentObj);
  return nullptr;
}

void PapyrusState::semantic(PapyrusResolutionContext* ctx) {
  ctx->state = this;
  for (auto f : functions)
    f.second->semantic(ctx);
  ctx->state = nullptr;
}

void PapyrusState::semantic2(PapyrusResolutionContext* ctx) {
  ctx->state = this;
  if (name != "") {
    if (ctx->object->isConst())
      ctx->reportingContext.error(location, "Named states aren't allowed on const scripts.");
    if (ctx->object->isNative())<commit_msg>Minor fixup after the change to using an unordered map for function name lookup.<commit_after>#include <papyrus/PapyrusState.h>

#include <papyrus/PapyrusObject.h>

namespace caprica { namespace papyrus {

static const PapyrusFunction* searchRootStateForFunction(const identifier_ref& name, const PapyrusObject* obj) {
  auto f = obj->getRootState()->functions.find(name);
  if (f != obj->getRootState()->functions.end())
    return f->second;

  if (auto parentObj = obj->tryGetParentClass())
    return searchRootStateForFunction(name, parentObj);
  return nullptr;
}

void PapyrusState::semantic(PapyrusResolutionContext* ctx) {
  ctx->state = this;
  for (auto f : functions)
    f.second->semantic(ctx);
  ctx->state = nullptr;
}

void PapyrusState::semantic2(PapyrusResolutionContext* ctx) {
  ctx->state = this;
  if (name != "") {
    if (ctx->object->isConst())
      ctx->reportingContext.error(location, "Named states aren't allowed on const scripts.");
    if (ctx->object->isNative())
{'fraction_non_alphanumeric': 0.13315926892950392, 'fraction_numerical': 0.0010443864229765013, 'mean_word_length': 4.788519637462236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '4916029', 'n_tokens_mistral': 630, 'n_tokens_neox': 599, 'n_words': 143}