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


C++ CodeGenContext::generateCode方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
	auto compileOnly = false;
	auto logLevel = 4;
	for(auto i = 0; i < argc; ++i) {
		if(std::string(argv[i]).compare("-c") == 0 || std::string(argv[i]).compare("--compile") == 0) {
			compileOnly = true;
		}
		if(std::string(argv[i]).find("--log") == 0) {
			if(argv[i][5] < '0' || argv[i][5] > '4') {
				std::cerr << "Bad level" << std::endl;
				exit(2);
			}
			logLevel = argv[i][5] - '0';
		}
	}
	yyparse();
	InitializeNativeTarget();
	InitializeNativeTargetAsmPrinter();
	InitializeNativeTargetAsmParser();
	CodeGenContext context;
	context.dclog.max_level = debug_stream::level(logLevel);
	createCoreFunctions(context);
	context.generateCode(*programBlock);
	if (!compileOnly) {
		auto val = context.runCode();
		(context.llclog << val.IntVal.getSExtValue() << "\n").flush();
	}
	return 0;
}
开发者ID:Librazy,项目名称:my_toy_compiler.sln,代码行数:30,代码来源:main.cpp

示例2: main

int main(int argc, char **argv)
{
    yyparse();
    std::cout << programBlock << std::endl;
    
    CodeGenContext context;
    context.generateCode(*programBlock);
    context.runCode();

    return 0;
}
开发者ID:gowithqi,项目名称:llvm-clike,代码行数:11,代码来源:main.cpp

示例3: main

int main(int argc, char **argv)
{
	yyparse();
	std::cout << programBlock << endl;
    // see http://comments.gmane.org/gmane.comp.compilers.llvm.devel/33877
	InitializeNativeTarget();
	CodeGenContext context;
	createCoreFunctions(context);
	context.generateCode(*programBlock);
	context.runCode();
	
	return 0;
}
开发者ID:0xcc,项目名称:my_toy_compiler,代码行数:13,代码来源:main.cpp

示例4: main

int main(int argc, char **argv)
{
	if (argc > 1) {
		extern FILE* yyin;
		if(!(yyin = fopen(argv[1], "r"))) {
			perror(argv[1]);
			return (1);
		}
	}
	
	yyparse();
	std::cout << programBlock << std::endl;
	
	CodeGenContext context;
	context.generateCode(*programBlock);
	context.runCode();
	
	
	return 0;
}
开发者ID:blackn1ght,项目名称:MSc-Project,代码行数:20,代码来源:main.cpp

示例5: prePass

void CInstance::prePass(CodeGenContext& context)
{
	// On the prepass, we need to generate the code for this module
	std::string includeName = filename.quoted.substr(1, filename.quoted.length() - 2);

	if (resetFileInput(includeName.c_str()) != 0)
	{
		context.gContext.ReportError(nullptr, EC_ErrorAtLocation, filename.quotedLoc, "Unable to instance module %s", includeName.c_str());
		return;
	}
	yyparse();
	if (g_ProgramBlock == 0)
	{
		context.gContext.ReportError(nullptr, EC_ErrorAtLocation, filename.quotedLoc, "Unable to parse module %s", includeName.c_str());
		return;
	}

	CodeGenContext* includefile;

	includefile = new CodeGenContext(context.gContext, &context);
	includefile->moduleName = ident.name + ".";

	if (context.gContext.opts.generateDebug)
	{
		context.gContext.scopingStack.push(context.gContext.CreateNewDbgFile(includeName.c_str()));
	}

	includefile->generateCode(*g_ProgramBlock);

	if (context.gContext.opts.generateDebug)
	{
		context.gContext.scopingStack.pop();
	}
	if (includefile->isErrorFlagged())
	{
		context.gContext.ReportError(nullptr , EC_ErrorAtLocation, filename.quotedLoc, "Unable to parse module %s", includeName.c_str());
		return;
	}
	context.m_includes[ident.name + "."] = includefile;
}
开发者ID:SavourySnaX,项目名称:EDL,代码行数:40,代码来源:instance.cpp

示例6: main

int main(int argc, char **argv)
{
    FILE *inpFile = fopen(argv[1], "r");
    if (!inpFile)
    {
        cout << "Error opening File" << endl;
        return -1;
    }

    yyin = inpFile;

    yyparse();
    std::cout << programBlock << endl;
    // see http://comments.gmane.org/gmane.comp.compilers.llvm.devel/33877
    llvm::InitializeNativeTarget();
    CodeGenContext context;
    context.generateCode(*programBlock);
    context.runCode();
    
    system("pause");
    return 0;
}
开发者ID:OpenFlex,项目名称:MiniC_llvm,代码行数:22,代码来源:main.cpp

示例7: main

int main(void)
{

  /* object to interface with llvm API (defined in codegen.cpp) */
  CodeGenContext context;

  /*
   *       Lexing and Parsing
   *       ------------------
   *   lexer feeds tokens to parser
   *   parser builds an AST stored in programBlock
   */

  yyparse();

  /* prints out root address of AST root */
  std::cout << "=================================" << std::endl
            << "Address of root AST node: "        << programBlock
            << std::endl << std::endl;

  /*
   *      Code Generation
   *      ---------------
   */

  /* establish host target & link target libraries JIT uses */
  llvm::InitializeNativeTarget();

  coreFuncs(context);

  context.generateCode(*programBlock);

  context.runCode();

  return EXIT_SUCCESS;
}
开发者ID:b7campbell,项目名称:mock-c-compiler,代码行数:36,代码来源:main.cpp


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