コード例 #1
0
ファイル: Disassembler.cpp プロジェクト: FriedBreakfast/Psi
 void DisassemblerContext::print_exists(const ValuePtr<Exists>& term, bool bracket) {
   if (bracket)
     *m_output << '(';
   *m_output << "exists (";
   
   unsigned n_parameters = term->parameter_types().size();
   unsigned parameter_name_base = m_parameter_name_index;
   m_parameter_name_index += n_parameters;
   
   boost::format name_formatter("%%%s");
   
   m_parameter_names.push_back(ParameterNameList::value_type());
   ParameterNameList::value_type& name_list = m_parameter_names.back();
   for (unsigned ii = 0; ii != n_parameters; ++ii) {
     if (ii)
       *m_output << ", ";
     
     std::string name = str(name_formatter % (parameter_name_base + ii));
     *m_output << name << " : ";
     print_term(term->parameter_types()[ii], false);
     
     name_list.push_back(name);
   }
   
   *m_output << ") > ";
   
   print_term(term->result(), true);
   
   m_parameter_names.pop_back();
   m_parameter_name_index = parameter_name_base;
   
   if (bracket)
     *m_output << ')';
 }
コード例 #2
0
ファイル: Disassembler.cpp プロジェクト: FriedBreakfast/Psi
    void DisassemblerContext::print_function_type_term(const ValuePtr<FunctionType>& term, bool bracket, const ValuePtr<Function>& use_names) {
      PSI_ASSERT(!use_names || (term->parameter_types().size() == use_names->parameters().size()));
      
      if (bracket)
        *m_output << '(';

      *m_output << "function";
      switch (term->calling_convention()) {
      case cconv_c: break;
      case cconv_x86_stdcall: *m_output << " cc_x86_stdcall";
      case cconv_x86_thiscall: *m_output << " cc_x86_thiscall";
      case cconv_x86_fastcall: *m_output << " cc_x86_fastcall";
      default: PSI_FAIL("Unknown calling convention in disassembler");
      }
      if (term->sret())
        *m_output << " sret";
      *m_output << " (";
      
      unsigned n_parameters = term->parameter_types().size();
      unsigned parameter_name_base = m_parameter_name_index;
      m_parameter_name_index += n_parameters;
      
      boost::format name_formatter("%%%s");
      
      m_parameter_names.push_back(ParameterNameList::value_type());
      ParameterNameList::value_type& name_list = m_parameter_names.back();
      for (unsigned ii = 0; ii != n_parameters; ++ii) {
        if (ii)
          *m_output << ", ";
        
        std::string name;
        if (use_names) {
          *m_output << TermNamePrinter(&m_names.find(use_names->parameters().at(ii))->second->name);
        } else {
          *m_output << name_formatter % (parameter_name_base + ii);
        }
        
        const ParameterType& ty = term->parameter_types()[ii];
        *m_output << " :";
        print_parameter_attributes(ty.attributes);
        *m_output << ' ';
        print_term(ty.value, false);
        
        name_list.push_back(name);
      }
      
      *m_output << ") >";
      print_parameter_attributes(term->result_type().attributes);
      *m_output << ' ';
      print_term(term->result_type().value, true);
      
      m_parameter_names.pop_back();
      m_parameter_name_index = parameter_name_base;
      
      if (bracket)
        *m_output << ')';
    }