<commit_before>'use strict'
var util = require('./util')

function Enum (enumDef) {
  this.enumDef = enumDef
  this.typeName = 'enum'
  this.storageSlots = 1
  var length = enumDef.children.length
  this.storageBytes = 0
  while (length > 1) {
    length = length / 256
    this.storageBytes++
  }
}

Enum.prototype.decodeFromStorage = function (location, storageContent) {
  var value = util.extractHexValue(location, storageContent, this.storageBytes)
  value = parseInt(value, 16)
  if (this.enumDef.children.length > value) {
    return this.enumDef.children[value].attributes.name
  } else {
    return 'INVALID_ENUM<' + value + '>'
  }
}

module.exports = Enum<commit_msg>decode enum<commit_after>'use strict'
var util = require('./util')

function Enum (enumDef) {
  this.enumDef = enumDef
  this.typeName = 'enum'
  this.storageSlots = 1
  var length = enumDef.children.length
  this.storageBytes = 0
  while (length > 1) {
    length = length / 256
    this.storageBytes++
  }
}

Enum.prototype.decodeFromStorage = function (location, storageContent) {
  var value = util.extractHexValue(location, storageContent, this.storageBytes)
  value = parseInt(value, 16)
  return output(value, this.enumDef)
}

Enum.prototype.decodeLocals = function (stackHeight, stack, memory) {
  var defaultValue = 0
  if (stack.length - 1 < stackHeight) {
    defaultValue = 0
  } else {
    defaultValue = util.extractHexByteSlice(stack[stack.length - 1 - stackHeight], this.storageBytes, 0)
    defaultValue = parseInt(defaultValue, 16)
  }
  return output(defaultValue, this.enumDef)
}

function output (value, enumDef) {
  if (enumDef.children.length > value) {
    return enumDef.children[value].attributes.name
  } else {
    return 'INVALID_ENUM<' + value + '>'
  }
}

module.exports = Enum
{'fraction_non_alphanumeric': 0.12038073908174692, 'fraction_numerical': 0.012877939529675251, 'mean_word_length': 3.8559782608695654, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '4197401', 'n_tokens_mistral': 584, 'n_tokens_neox': 567, 'n_words': 132}