当前位置: 首页>>代码示例>>C++>>正文


C++ Label::GetType方法代码示例

本文整理汇总了C++中Label::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Label::GetType方法的具体用法?C++ Label::GetType怎么用?C++ Label::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Label的用法示例。


在下文中一共展示了Label::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FormatFunction

bool Architecture::FormatFunction(
    Document      const& rDoc,
    Address       const& rAddr,
    Function      const& rFunc,
    PrintData          & rPrintData) const
{
    auto FuncLabel = rDoc.GetLabelFromAddress(rAddr);

    if (rFunc.GetSize() != 0 && rFunc.GetInstructionCounter() != 0)
    {
        std::ostringstream oss;
        oss
                << std::hex << std::showbase << std::left
                << "; size=" << rFunc.GetSize()
                << ", insn_cnt=" << rFunc.GetInstructionCounter();

        rPrintData.AppendComment(oss.str());
    }
    else
        rPrintData.AppendComment("; imported");

    Id CurId;
    if (!rDoc.RetrieveDetailId(rAddr, 0, CurId))
        return true;

    FunctionDetail FuncDtl;
    if (!rDoc.GetFunctionDetail(CurId, FuncDtl))
        return true;

    rPrintData.AppendNewLine().AppendSpace(2).AppendComment(";").AppendSpace();

    auto const& RetType = FuncDtl.GetReturnType();

    std::string FuncName;
    Label CurLbl = rDoc.GetLabelFromAddress(rAddr);
    if (CurLbl.GetType() == Label::Unknown)
        FuncName = FuncDtl.GetName();
    else
        FuncName = CurLbl.GetName();

    FormatTypeDetail(RetType, rPrintData);
    rPrintData.AppendSpace().AppendLabel(FuncName).AppendOperator("(");

    bool FirstParam = true;
    auto const& Params = FuncDtl.GetParameters();
    for (auto const& Param : Params)
    {
        if (FirstParam)
            FirstParam = false;
        else
            rPrintData.AppendOperator(",").AppendSpace();

        FormatTypeDetail(Param.GetType(), rPrintData);
        rPrintData.AppendSpace().AppendLabel(Param.GetValue().GetName());
    }

    rPrintData.AppendOperator(");");

    return true;
}
开发者ID:johnjohnsp1,项目名称:medusa,代码行数:60,代码来源:architecture.cpp

示例2: FormatValue

bool Architecture::FormatValue(
  Document      const& rDoc,
  BinaryStream  const& rBinStrm,
  Address       const& rAddr,
  Value         const& rVal,
  std::string        & rStrCell,
  Cell::Mark::List   & rMarks) const
{
  std::ostringstream  oss;
  TOffset             Off;
  u8                  ValueType   = rVal.GetSubType();
  std::string         BasePrefix  = "";
  bool                IsUnk = false;

  auto const& rCurBinStrm = rDoc.GetBinaryStream();

  if (!rDoc.ConvertAddressToFileOffset(rAddr, Off))
    IsUnk = true;

  oss << std::setfill('0');

  switch (ValueType)
  {
  case Value::BinaryType:                                BasePrefix = "0b"; break; // TODO: Unimplemented
  case Value::DecimalType:              oss << std::dec; BasePrefix = "0n"; break;
  case Value::HexadecimalType: default: oss << std::hex; BasePrefix = "0x"; break;
  }

  Cell::Mark::Type MarkType = Cell::Mark::ImmediateType;
  switch (rVal.GetLength())
  {
  case 1: default:
    {
      if (IsUnk)
        oss << "db (?)";
      else
      {
        u8 Data;
        if (!rCurBinStrm.Read(Off, Data))
          return false;
        oss << "db " << BasePrefix << std::setw(2) << static_cast<u16>(Data); //  u8 type would be printed as char by ostream
      }
      break;
    }
  case 2:
    {
      if (IsUnk)
        oss << "dw (?)";
      else
      {
        u16 Data;
        if (!rCurBinStrm.Read(Off, Data))
          return false;

        Label Lbl = rDoc.GetLabelFromAddress(Data);
        if (Lbl.GetType() == Label::Unknown)
          oss << "dw " << BasePrefix << std::setw(4) << static_cast<u16>(Data);

        else
        {
          oss << "dw " << Lbl.GetLabel();
          MarkType = Cell::Mark::LabelType;
        }
      }
      break;
    }
  case 4:
    {
      if (IsUnk)
        oss << "dd (?)";
      else
      {
        u32 Data;
        if (!rCurBinStrm.Read(Off, Data))
          return false;

        Label Lbl = rDoc.GetLabelFromAddress(Data);
        if (Lbl.GetType() == Label::Unknown)
          oss << "dd " << BasePrefix << std::setw(8) << static_cast<u32>(Data);

        else
        {
          oss << "dd " << Lbl.GetLabel();
          MarkType = Cell::Mark::LabelType;
        }
      }
      break;
    }
  case 8:
    {
      if (IsUnk)
        oss << "dq (?)";
      else
      {
        u64 Data;
        if (!rCurBinStrm.Read(Off, Data))
          return false;

        Label Lbl = rDoc.GetLabelFromAddress(Data);
        if (Lbl.GetType() == Label::Unknown)
//.........这里部分代码省略.........
开发者ID:anat,项目名称:medusa,代码行数:101,代码来源:architecture.cpp


注:本文中的Label::GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。