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


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

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


在下文中一共展示了Label::GetName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Optimize

void Section::Optimize(AsmFile *fil)
{
    AsmExpr::SetSection(this);
    bool done = false;
    while (!done)
    {
        int pc = 0;
        done = true;
        for (int i=0; i < instructions.size(); i++)
        {
            if (instructions[i]->IsLabel())
            {
                Label *l = instructions[i]->GetLabel();
                if (l)
                {
                    l->SetOffset(pc);
                    labels[l->GetName()] = pc;
                }
            }
            else
            {
                int n = instructions[i]->GetSize() ;
                instructions[i]->SetOffset(pc);
                instructions[i]->Optimize(pc, false);
                int m = instructions[i]->GetSize() ;
                pc += m;
                if (n != m)
                    done = false;
            }
        }
    }
    int pc = 0;
    for (int i=0; i < instructions.size(); i++)
    {
        instructions[i]->Optimize(pc, true);
        pc += instructions[i]->GetSize();
    }
}
开发者ID:bencz,项目名称:OrangeC,代码行数:38,代码来源:Section.cpp

示例3: AddLabel

void Document::AddLabel(Address const& rAddr, Label const& rLabel, bool Force)
{
  if (rLabel.GetName().empty() && Force)
  {
    RemoveLabel(rAddr);
    return;
  }

  Label OldLbl, NewLbl = rLabel;
  Address Addr;
  if (m_spDatabase->GetLabelAddress(NewLbl, Addr))
  {
    do NewLbl.IncrementVersion();
    while (m_spDatabase->GetLabelAddress(NewLbl, Addr));
  }

  if (m_spDatabase->GetLabel(rAddr, OldLbl) == true)
  {
    if (OldLbl.IsAutoGenerated())
      Force = true;

    if (!Force)
      return;

    if (OldLbl == rLabel)
      return;

    if (!m_spDatabase->RemoveLabel(rAddr))
      return;

    m_LabelUpdatedSignal(rAddr, OldLbl, true);
  }

  m_spDatabase->AddLabel(rAddr, NewLbl);
  m_LabelUpdatedSignal(rAddr, NewLbl, false);
  m_DocumentUpdatedSignal();
}
开发者ID:GrimDerp,项目名称:medusa,代码行数:37,代码来源:document.cpp

示例4: DoLabel

void AsmFile::DoLabel(std::string &name, int lineno)
{
    NeedSection();
    Label *label;
    if (caseInsensitive)
    {
        for (int i=0; i < name.size(); i++)
            name[i] = toupper(name[i]);
    }
    std::string realName = name;
    bool nl = false;
    if (name.size() > 2)
    {
        if (name[0] == '.' && name[1] == '.' && name[2] == '@')
        {
            if (name.size() == 3)
                throw new std::runtime_error("Malformed non-local label");
            nl = true;
        }
    }
    if (!nl && name[0] == '.')
    {
        if (name == "..start")
        {
            if (startupSection)
            {
                throw new std::runtime_error("Multiple start addresses specified");
            }
            label = new Label(name, labels.size(), currentSection->GetSect());
            startupSection = currentSection;
        }
        else
        {
            if (currentLabel)
            {
                realName = currentLabel->GetName() + name;
            }
        }
    } 
    if (labels[realName] != NULL)
    {
        if (realName != "..start")
        {
            throw new std::runtime_error(std::string("Label '") + name + "' already exists.");
        }
    }
    else
    {
        if (inAbsolute)
        {
            label = new Label(realName, labels.size(), 0);
            label->SetOffset(absoluteValue);
            AsmExpr::SetEqu(realName, new AsmExprNode(absoluteValue));
            if (lineno >= 0)
                listing.Add(label, lineno, preProcessor.InMacro());
        }
        else
        {
            label = new Label(realName, labels.size(), currentSection->GetSect()-1);
        }
        if (name[0] != '.')
        {
            currentLabel = label;
            AsmExpr::SetCurrentLabel(label->GetName());
        }
        thisLabel = label;
        labels[realName] = label;
        numericLabels.push_back(label);
        if (!inAbsolute)
            currentSection->InsertLabel(label);
//		if (lineno >= 0)
//			listing.Add(thisLabel, lineno, preProcessor.InMacro());
        if (realName == "..start")
            startupLabel = label;
    }
    if (GetKeyword() == Lexer::colon)
    {
        NextToken();
        thisLabel = NULL;
    }
}
开发者ID:NoSuchProcess,项目名称:OrangeC,代码行数:81,代码来源:AsmFile.cpp

示例5: AddLabel

//--------------------------------------------------------------------------------------------------------------
// AddLabel(). Adds a new label pLabel to the mLabels dictionary. The key is pLabel.GetName() and the value
// is pLabel. Hint: look at DataSegment::AddVariable().
//--------------------------------------------------------------------------------------------------------------
void TextSegment::AddLabel(Label const& pLabel)
{
    mLabels.Add(pLabel.GetName(), pLabel);
}
开发者ID:matt-welch,项目名称:k1-microcontroller-assembler,代码行数:8,代码来源:TextSegment.cpp


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