<commit_before>'use strict'
var ui = require('../helpers/ui')
module.exports = {
  // vmTraceIndex has to point to a CALL, CODECALL, ...
  resolveCalledAddress: function (vmTraceIndex, trace) {
    var step = trace[vmTraceIndex]
    if (this.isCreateInstruction(step)) {
      return this.contractCreationToken(vmTraceIndex)
    } else if (this.isCallInstruction(step)) {
      var stack = step.stack // callcode, delegatecall, ...
      return ui.normalizeHex(stack[stack.length - 2])
    }
    return undefined
  },

  isCallInstruction: function (step) {
    return step.op === 'CALL' || step.op === 'CALLCODE' || step.op === 'CREATE' || step.op === 'DELEGATECALL'
  },

  isCreateInstruction: function (step) {
    return step.op === 'CREATE'
  },

  isReturnInstruction: function (step) {
    return step.op === 'RETURN'
  },

  isSSTOREInstruction: function (step) {
    return step.op === 'SSTORE'
  },

  newContextStorage: function (step) {
    return step.op === 'CREATE' || step.op === 'CALL'
  },

  isCallToPrecompiledContract: function (index, trace) {
    // if stack empty => this is not a precompiled contract
    var step = trace[index]
    if (this.isCallInstruction(step)) {
      return trace[index + 1].stack.length !== 0
    } else {
      return false
    }
  },

  contractCreationToken: function (index) {
    return '(Contract Creation - Step ' + index + ')'
  },
<commit_msg>Perform bounds check in case call fails.<commit_after>'use strict'
var ui = require('../helpers/ui')
module.exports = {
  // vmTraceIndex has to point to a CALL, CODECALL, ...
  resolveCalledAddress: function (vmTraceIndex, trace) {
    var step = trace[vmTraceIndex]
    if (this.isCreateInstruction(step)) {
      return this.contractCreationToken(vmTraceIndex)
    } else if (this.isCallInstruction(step)) {
      var stack = step.stack // callcode, delegatecall, ...
      return ui.normalizeHex(stack[stack.length - 2])
    }
    return undefined
  },

  isCallInstruction: function (step) {
    return step.op === 'CALL' || step.op === 'CALLCODE' || step.op === 'CREATE' || step.op === 'DELEGATECALL'
  },

  isCreateInstruction: function (step) {
    return step.op === 'CREATE'
  },

  isReturnInstruction: function (step) {
    return step.op === 'RETURN'
  },

  isSSTOREInstruction: function (step) {
    return step.op === 'SSTORE'
  },

  newContextStorage: function (step) {
    return step.op === 'CREATE' || step.op === 'CALL'
  },

  isCallToPrecompiledContract: function (index, trace) {
    // if stack empty => this is not a precompiled contract
    var step = trace[index]
    if (this.isCallInstruction(step)) {
      return index + 1 < trace.length && trace[index + 1].stack.length !== 0
    } else {
      return false
    }
  },

  contractCreationToken: function (index) {
    return '(Contract Creation - Step ' + index + ')'
  },

{'fraction_non_alphanumeric': 0.14540370499825236, 'fraction_numerical': 0.002446696959105208, 'mean_word_length': 3.141823444283647, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '1045681', 'n_tokens_mistral': 901, 'n_tokens_neox': 887, 'n_words': 227}