<commit_before>//===-- Support.cpp - Support routines for interpreter --------------------===//
// 
//  This file contains support routines for the interpreter core.
//
//===----------------------------------------------------------------------===//

#include "Interpreter.h"
#include "llvm/SymbolTable.h"
#include "llvm/Assembly/Writer.h"
#include <iostream>
using std::cout;

//===----------------------------------------------------------------------===//
//
// LookupMatchingNames helper - Search a symbol table for values matching Name.
//
static inline void LookupMatchingNames(const std::string &Name,SymTabValue &STV,
				       std::vector<Value*> &Results) {
  SymbolTable *SymTab = STV.getSymbolTable();
  if (SymTab == 0) return;                         // No symbolic values :(

  // Loop over all of the type planes in the symbol table...
  for (SymbolTable::iterator I = SymTab->begin(), E = SymTab->end();
       I != E; ++I) {
    SymbolTable::VarMap &Plane = I->second;
    
    // Search the symbol table plane for this name...
    SymbolTable::VarMap::iterator Val = Plane.find(Name);
    if (Val != Plane.end())
      Results.push_back(Val->second);                    // Found a name match!
  }
}

// LookupMatchingNames - Search the current function namespace, then the global
// namespace looking for values that match the specified name.  Return ALL
// matches to that name.  This is obviously slow, and should only be used for
// user interaction.
//
std::vector<Value*> Interpreter::LookupMatchingNames(const std::string &Name) {
  std::vector<Value*> Results;
  Function *CurMeth = getCurrentMethod();
  
  if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results);
  if (CurMod ) ::LookupMatchingNames(Name, *CurMod , Results);
  return Results;
}

// ChooseOneOption - Prompt the user to choose among the specified options to
// pick one value.  If no options are provided, emit an error.  If a single 
// option is provided, just return that option.
//
Value *Interpreter::ChooseOneOption(const std::string &Name,
				    const std::vector<Value*> &Opts) {
  switch (Opts.size()) {
  case 1: return Opts[0];
  case 0: <commit_msg>Eliminate use of SymTabValue class<commit_after>//===-- Support.cpp - Support routines for interpreter --------------------===//
// 
//  This file contains support routines for the interpreter core.
//
//===----------------------------------------------------------------------===//

#include "Interpreter.h"
#include "llvm/SymbolTable.h"
#include "llvm/Assembly/Writer.h"
#include <iostream>
using std::cout;

//===----------------------------------------------------------------------===//
//
// LookupMatchingNames helper - Search a symbol table for values matching Name.
//
static inline void LookupMatchingNames(const std::string &Name,
                                       SymbolTable *SymTab,
				       std::vector<Value*> &Results) {
  if (SymTab == 0) return;                         // No symbolic values :(

  // Loop over all of the type planes in the symbol table...
  for (SymbolTable::iterator I = SymTab->begin(), E = SymTab->end();
       I != E; ++I) {
    SymbolTable::VarMap &Plane = I->second;
    
    // Search the symbol table plane for this name...
    SymbolTable::VarMap::iterator Val = Plane.find(Name);
    if (Val != Plane.end())
      Results.push_back(Val->second);                    // Found a name match!
  }
}

// LookupMatchingNames - Search the current function namespace, then the global
// namespace looking for values that match the specified name.  Return ALL
// matches to that name.  This is obviously slow, and should only be used for
// user interaction.
//
std::vector<Value*> Interpreter::LookupMatchingNames(const std::string &Name) {
  std::vector<Value*> Results;
  Function *CurMeth = getCurrentMethod();
  
  if (CurMeth) ::LookupMatchingNames(Name, CurMeth->getSymbolTable(), Results);
  if (CurMod ) ::LookupMatchingNames(Name, CurMod ->getSymbolTable(), Results);
  return Results;
}

// ChooseOneOption - Prompt the user to choose among the specified options to
// pick one value.  If no options are provided, emit an error.  If a single 
// option is provided, just return that option.
//
Value *Interpreter::ChooseOneOption(const std::string &Name,
				    const std::vector<Value*> &Opts) {
  switch (Opts.size()) {
  case 1: return Opts[0];
  case 0: 
{'fraction_non_alphanumeric': 0.19735038830516216, 'fraction_numerical': 0.001827318410232983, 'mean_word_length': 2.373651771956857, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2639758', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1178, 'n_words': 403}