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


C++ PrototypeAST类代码示例

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


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

示例1: visitPrototype

FunctionAST *Parser::visitFuncttionDefinition() {
    int bkup = Tokens->getCurIndex();

    PrototypeAST *proto = visitPrototype();
    if (!proto) {
        return NULL;
    } else if ((PrototypeTable.find(proto->getName()) != PrototypeTable.end() &&
                    PrototypeTable[proto->getName()] != proto->getParamNum()) ||
                FunctionTable.find(proto->getName()) != FunctionTable.end()) {
        fprintf(stderr, "Function: %s is redefined", proto->getName().c_str());
        SAFE_DELETE(proto);
        return NULL;
    }

    VariableTable.clear();
    FunctionStmtAST *func_stmt = visitFunctionStatement(proto);
    if (func_stmt) {
        FunctionTable[proto->getName()] = proto->getParamNum();
        return new FunctionAST(proto, func_stmt);
    } else {
        SAFE_DELETE(proto);
        Tokens->applyTokenIndex(bkup);
        return NULL;
    }
}
开发者ID:delaemon,项目名称:LLVM-TutorialLanguage,代码行数:25,代码来源:parser.cpp

示例2:

//! Compares two function prototypes to see if they have the same signature
bool PrototypeAST::operator==( const PrototypeAST& rhs ) const {
	if( GetName() != rhs.GetName() ) return false;
	if( m_pReturnType != rhs.m_pReturnType ) return false;
	if( m_pArgs.size() != rhs.m_pArgs.size() ) return false;
	for( uint iArg=0; iArg<m_pArgs.size(); ++iArg ) {
		if( m_pArgs[iArg]->GetType() != rhs.m_pArgs[iArg]->GetType() ) return false;
	} // end for arg

	return true;
} // end PrototypeAST::operator==()
开发者ID:schnarf,项目名称:Ruffian,代码行数:11,代码来源:FunctionAST.cpp

示例3: verifyFunction

Function *FunctionAST::Codegen() {
  NamedValues.clear();
  
  Function *TheFunction = Proto->Codegen();
  if (TheFunction == 0)
    return 0;
  
  // Create a new basic block to start insertion into.
  BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
  Builder.SetInsertPoint(BB);
  
  if (Value *RetVal = Body->Codegen()) {
    // Finish off the function.
    Builder.CreateRet(RetVal);

    // Validate the generated code, checking for consistency.
    verifyFunction(*TheFunction);

    // Optimize the function.
    TheFPM->run(*TheFunction);
    
    return TheFunction;
  }
  
  // Error reading body, remove function.
  TheFunction->eraseFromParent();
  return 0;
}
开发者ID:RCSL-HKUST,项目名称:heterosim,代码行数:28,代码来源:toy.cpp

示例4: verifyFunction

Function *FunctionAST::Codegen() {
  NamedValues.clear();

  Function *TheFunction = Proto->Codegen();
  if (TheFunction == 0)
    return 0;

  // If this is an operator, install it.
  if (Proto->isBinaryOp())
    BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence();

  // Create a new basic block to start insertion into.
  BasicBlock *BB = BasicBlock::Create(TheContext, "entry", TheFunction);
  Builder.SetInsertPoint(BB);

  // Add all arguments to the symbol table and create their allocas.
  Proto->CreateArgumentAllocas(TheFunction);

  if (Value *RetVal = Body->Codegen()) {
    // Finish off the function.
    Builder.CreateRet(RetVal);

    // Validate the generated code, checking for consistency.
    verifyFunction(*TheFunction);

    return TheFunction;
  }

  // Error reading body, remove function.
  TheFunction->eraseFromParent();

  if (Proto->isBinaryOp())
    BinopPrecedence.erase(Proto->getOperatorName());
  return 0;
}
开发者ID:1995hnagamin,项目名称:llvm,代码行数:35,代码来源:toy.cpp


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