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


C++ compile函数代码示例

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


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

示例1: getString

/*
    Parse all the #cxy statements from the file.
    Binary nestings must run before the previous nest.
*/
void File::parse()
{
    std::string content = getString(m_id[Sti_t(Runstate::Execute)][Sti_t(Symbol::cntnt)]);
    content.push_back('\n');
    try
    {
        while (content.find("#cxy star") != std::string::npos)
        {

            sout("==================================================\n");
            sout("GENCONTENT:\n")
            sout(content)
            sout("==================================================\n");

            std::string instructions = get_first_most_nested_cxy_data(content);
            sout("==================================================\n");
            sout("Instructions queried:")
            sout(instructions)
            sout("==================================================\n");
            std::string operating_data;
            try
            {
                 operating_data = erase_all_cxy_statements(get_second_most_nested_data(content));
            }
            catch (std::exception &e)
            {
                std::cout << "Error during erasion stage: " << e.what() << std::endl;
            }

            reinstruct(instructions);
            m_data[m_id[Sti_t(Runstate::Execute)][Sti_t(Symbol::cntnt)]].push_back(operating_data); // Turn "cntnt" into the name... goto sleep

            compile();
            execute();

            std::string generated_content = m_data[m_id[Sti_t(Runstate::Execute)][Sti_t(Symbol::cntnt)]].back();

           // Remove the trailing ÿ or \n

            try
            {
                if (generated_content.size())
                generated_content.pop_back();
            }
            catch (std::out_of_range &exc_obj)
            {
                std::cout << "Out of range: " << exc_obj.what() << "\n";
                throw;
            }
                generated_content.push_back('\n');



                replace_second_most_nested_scope(content, generated_content);
                erase_first_most_nested_cxy_data(content);

        }

        m_data[m_id[Sti_t(Runstate::Execute)][Sti_t(Symbol::cntnt)]].back() = content;


    }
    catch (std::exception &e)
    {
        std::cout << "Error occurred during parsing: " << e.what() << std::endl;
        throw;
    }
}
开发者ID:BourgondAries,项目名称:Cxy-v0.1.0-draft.1,代码行数:72,代码来源:parse.cpp

示例2: compile

/*
 * break a collection of markdown input into
 * blocks of lists, code, html, and text to
 * be marked up.
 */
static Paragraph *
compile(Line *ptr, int toplevel, MMIOT *f)
{
    ParagraphRoot d = { 0, 0 };
    Paragraph *p = 0;
    Line *r;
    int para = toplevel;
    int blocks = 0;
    int hdr_type, list_type, list_class, indent;

    ptr = consume(ptr, &para);

    while ( ptr ) {
	if ( iscode(ptr) ) {
	    p = Pp(&d, ptr, CODE);
	    
	    if ( f->flags & MKD_1_COMPAT) {
		/* HORRIBLE STANDARDS KLUDGE: the first line of every block
		 * has trailing whitespace trimmed off.
		 */
		___mkd_tidy(&p->text->text);
	    }
	    
	    ptr = codeblock(p);
	}
#if WITH_FENCED_CODE
	else if ( iscodefence(ptr,3,0) && (p=fencedcodeblock(&d, &ptr)) )
	    /* yay, it's already done */ ;
#endif
	else if ( ishr(ptr) ) {
	    p = Pp(&d, 0, HR);
	    r = ptr;
	    ptr = ptr->next;
	    ___mkd_freeLine(r);
	}
	else if ( list_class = islist(ptr, &indent, f->flags, &list_type) ) {
	    if ( list_class == DL ) {
		p = Pp(&d, ptr, DL);
		ptr = definition_block(p, indent, f, list_type);
	    }
	    else {
		p = Pp(&d, ptr, list_type);
		ptr = enumerated_block(p, indent, f, list_class);
	    }
	}
	else if ( isquote(ptr) ) {
	    p = Pp(&d, ptr, QUOTE);
	    ptr = quoteblock(p, f->flags);
	    p->down = compile(p->text, 1, f);
	    p->text = 0;
	}
	else if ( ishdr(ptr, &hdr_type) ) {
	    p = Pp(&d, ptr, HDR);
	    ptr = headerblock(p, hdr_type);
	}
	else {
	    p = Pp(&d, ptr, MARKUP);
	    ptr = textblock(p, toplevel, f->flags);
	    /* tables are a special kind of paragraph */
	    if ( actually_a_table(f, p->text) )
		p->typ = TABLE;
	}

	if ( (para||toplevel) && !p->align )
	    p->align = PARA;

	blocks++;
	para = toplevel || (blocks > 1);
	ptr = consume(ptr, &para);

	if ( para && !p->align )
	    p->align = PARA;

    }
    return T(d);
}
开发者ID:Irfy,项目名称:discount,代码行数:81,代码来源:markdown.c

示例3: native_compile

static void native_compile(JNIEnv* env, jobject object, jstring sqlString)
{
    compile(env, object, GET_HANDLE(env, object), sqlString);
}
开发者ID:Spotme,项目名称:android-database-sqlcipher,代码行数:4,代码来源:net_sqlcipher_database_SQLiteCompiledSql.cpp

示例4: compile

	static bool compile(bx::CommandLine& _cmdLine, uint32_t _version, const std::string& _code, bx::WriterI* _writer, bool _firstPass)
	{
		const char* profile = _cmdLine.findOption('p', "profile");
		if (NULL == profile)
		{
			fprintf(stderr, "Error: Shader profile must be specified.\n");
			return false;
		}

		s_compiler = load();

		bool result = false;
		bool debug = _cmdLine.hasArg('\0', "debug");

		uint32_t flags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
		flags |= debug ? D3DCOMPILE_DEBUG : 0;
		flags |= _cmdLine.hasArg('\0', "avoid-flow-control") ? D3DCOMPILE_AVOID_FLOW_CONTROL : 0;
		flags |= _cmdLine.hasArg('\0', "no-preshader") ? D3DCOMPILE_NO_PRESHADER : 0;
		flags |= _cmdLine.hasArg('\0', "partial-precision") ? D3DCOMPILE_PARTIAL_PRECISION : 0;
		flags |= _cmdLine.hasArg('\0', "prefer-flow-control") ? D3DCOMPILE_PREFER_FLOW_CONTROL : 0;
		flags |= _cmdLine.hasArg('\0', "backwards-compatibility") ? D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY : 0;

		bool werror = _cmdLine.hasArg('\0', "Werror");

		if (werror)
		{
			flags |= D3DCOMPILE_WARNINGS_ARE_ERRORS;
		}

		uint32_t optimization = 3;
		if (_cmdLine.hasArg(optimization, 'O') )
		{
			optimization = bx::uint32_min(optimization, BX_COUNTOF(s_optimizationLevelD3D11) - 1);
			flags |= s_optimizationLevelD3D11[optimization];
		}
		else
		{
			flags |= D3DCOMPILE_SKIP_OPTIMIZATION;
		}

		BX_TRACE("Profile: %s", profile);
		BX_TRACE("Flags: 0x%08x", flags);

		ID3DBlob* code;
		ID3DBlob* errorMsg;

		// Output preprocessed shader so that HLSL can be debugged via GPA
		// or PIX. Compiling through memory won't embed preprocessed shader
		// file path.
		std::string hlslfp;

		if (debug)
		{
			hlslfp = _cmdLine.findOption('o');
			hlslfp += ".hlsl";
			writeFile(hlslfp.c_str(), _code.c_str(), (int32_t)_code.size() );
		}

		HRESULT hr = D3DCompile(_code.c_str()
			, _code.size()
			, hlslfp.c_str()
			, NULL
			, NULL
			, "main"
			, profile
			, flags
			, 0
			, &code
			, &errorMsg
			);
		if (FAILED(hr)
		|| (werror && NULL != errorMsg) )
		{
			const char* log = (char*)errorMsg->GetBufferPointer();

			int32_t line   = 0;
			int32_t column = 0;
			int32_t start  = 0;
			int32_t end    = INT32_MAX;

			bool found = false
				|| 2 == sscanf(log, "(%u,%u):",  &line, &column)
				|| 2 == sscanf(log, " :%u:%u: ", &line, &column)
				;

			if (found
			&&  0 != line)
			{
				start = bx::uint32_imax(1, line - 10);
				end   = start + 20;
			}

			printCode(_code.c_str(), line, start, end, column);
			fprintf(stderr, "Error: D3DCompile failed 0x%08x %s\n", (uint32_t)hr, log);
			errorMsg->Release();
			return false;
		}

		UniformArray uniforms;
		uint8_t numAttrs = 0;
//.........这里部分代码省略.........
开发者ID:CallmeNezha,项目名称:bgfx,代码行数:101,代码来源:shaderc_hlsl.cpp

示例5: address

int*
address(void)
{
	int sign, *a, opcnt, nextopand, *b, c;

	nextopand = -1;
	sign = 1;
	opcnt = 0;
	a = dot;
	do {
		do {
			c = getchr();
		} while(c == ' ' || c == '\t');
		if(c >= '0' && c <= '9') {
			peekc = c;
			if(!opcnt)
				a = zero;
			a += sign*getnum();
		} else
		switch(c) {
		case '$':
			a = dol;
		case '.':
			if(opcnt)
				error(Q);
			break;
		case '\'':
			c = getchr();
			if(opcnt || c < 'a' || c > 'z')
				error(Q);
			a = zero;
			do {
				a++;
			} while(a <= dol && names[c-'a'] != (*a & ~01));
			break;
		case '?':
			sign = -sign;
		case '/':
			compile(c);
			b = a;
			for(;;) {
				a += sign;
				if(a <= zero)
					a = dol;
				if(a > dol)
					a = zero;
				if(match(a))
					break;
				if(a == b)
					error(Q);
			}
			break;
		default:
			if(nextopand == opcnt) {
				a += sign;
				if(a < zero || dol < a)
					continue;       /* error(Q); */
			}
			if(c != '+' && c != '-' && c != '^') {
				peekc = c;
				if(opcnt == 0)
					a = 0;
				return a;
			}
			sign = 1;
			if(c != '+')
				sign = -sign;
			nextopand = ++opcnt;
			continue;
		}
		sign = 1;
		opcnt++;
	} while(zero <= a && a <= dol);
	error(Q);
	return 0;
}
开发者ID:9fans,项目名称:plan9port,代码行数:76,代码来源:ed.c

示例6: main

int main(int argc, char* argv[]){
	int buffer_size = 0;
	FILE* byte_code = 0;
	FILE* source = 0;
	char sign[2] = {'k', 'k'};
	char* output_file_name = "";
	double* buffer = (double*) calloc (MAX_BYTE_CODE_SIZE, sizeof(double));
	assert(buffer);
	
	if (argc == 1) {
		printf("Empty input file  name\n");
		free(buffer);
		return 0;
	}
	
	if (argc == 2) {
		printf("Empty output file name\n");
		free(buffer);
		return 0;
	}
	
	source = fopen(argv[1], "r+");
	output_file_name = strcat(argv[2],".kvm");
	byte_code = fopen(output_file_name, "wb");
	buffer_size = compile(source, buffer);
	
	if (buffer_size == 0) {
		printf("Translation error:Incorrect input file\n");
		free(buffer);
		fclose(source);
		fclose(byte_code);		
		return 0;
	}
	
	rewind(source);
	buffer_size = compile(source, buffer);

	if (buffer_size == 0) {
		printf("Translation error:Incorrect input file\n");
		free(buffer);
		fclose(source);
		fclose(byte_code);		
		return 0;
	}
	fwrite(sign, sizeof(char), 2, byte_code);

	if (fwrite(buffer, sizeof(double), buffer_size, byte_code) != buffer_size) {
		printf("Translation error\n");
		free(buffer);
		fclose(source);
		fclose(byte_code);
		return 0;
	}
	
	printf("Translation complete.\nByte-code size = %d\n", buffer_size);
	
	free(buffer);
	fclose(source);
	fclose(byte_code);
	return 0; 
}
开发者ID:proffK,项目名称:iLab,代码行数:61,代码来源:My_asm.c

示例7: compile

beregex::beregex(std::string pat_,int flags_):pat(pat_),flags(flags_),nreg_(0)
{
    compile();
}
开发者ID:jonstewart,项目名称:be13_api,代码行数:4,代码来源:beregex.cpp

示例8: hook_dxgi

bool hook_dxgi(void)
{
    pD3DCompile compile;
    ID3D10Blob *blob;
    HMODULE dxgi_module = get_system_module("dxgi.dll");
    HRESULT hr;
    void *present_addr;
    void *resize_addr;

    if (!dxgi_module) {
        return false;
    }

    compile = get_compiler();
    if (!compile) {
        hlog("hook_dxgi: failed to find d3d compiler library");
        return true;
    }

    /* ---------------------- */

    hr = compile(vertex_shader_string, sizeof(vertex_shader_string),
                 "vertex_shader_string", nullptr, nullptr, "main",
                 "vs_4_0", D3D10_SHADER_OPTIMIZATION_LEVEL1, 0, &blob,
                 nullptr);
    if (FAILED(hr)) {
        hlog_hr("hook_dxgi: failed to compile vertex shader", hr);
        return true;
    }

    vertex_shader_size = (size_t)blob->GetBufferSize();
    memcpy(vertex_shader_data, blob->GetBufferPointer(),
           blob->GetBufferSize());
    blob->Release();

    /* ---------------------- */

    hr = compile(pixel_shader_string, sizeof(pixel_shader_string),
                 "pixel_shader_string", nullptr, nullptr, "main",
                 "ps_4_0", D3D10_SHADER_OPTIMIZATION_LEVEL1, 0, &blob,
                 nullptr);
    if (FAILED(hr)) {
        hlog_hr("hook_dxgi: failed to compile pixel shader", hr);
        return true;
    }

    pixel_shader_size = (size_t)blob->GetBufferSize();
    memcpy(pixel_shader_data, blob->GetBufferPointer(),
           blob->GetBufferSize());
    blob->Release();

    /* ---------------------- */

    present_addr = get_offset_addr(dxgi_module,
                                   global_hook_info->offsets.dxgi.present);
    resize_addr = get_offset_addr(dxgi_module,
                                  global_hook_info->offsets.dxgi.resize);

    hook_init(&present, present_addr, (void*)hook_present,
              "IDXGISwapChain::Present");
    hook_init(&resize_buffers, resize_addr, (void*)hook_resize_buffers,
              "IDXGISwapChain::ResizeBuffers");

    rehook(&resize_buffers);
    rehook(&present);

    hlog("Hooked DXGI");
    return true;
}
开发者ID:reboot,项目名称:obs-studio,代码行数:69,代码来源:dxgi-capture.cpp

示例9: main

int main() {

  S.malloc = malloc;
  S.free = free;
  S.funcs = funcs;
  S.num_funcs = 0;
  while (funcs[S.num_funcs].name) S.num_funcs++;

  #ifdef BCM2708_PERI_BASE
  setup_io();
  #endif

  printf("Welcome to uscript.\n");
  FILE* fd = fopen(DATA_FILE, "r");
  if (fd) {
    if (fgetc(fd) == 'u') {
      while (1) {
        int key = fgetc(fd);
        if (key == 'u') break;
        printf("Loading %c...\n", key + 'a');
        int len = fgetc(fd);
        len = (len << 8) | fgetc(fd);
        uint8_t* stub = S.stubs[key] = malloc(len);
        int j;
        for (j = 0; j < len; j++) {
          stub[j] = fgetc(fd);
        }
      }

    }
    fclose(fd);
  }
  if (S.stubs[0]) {
    printf("Running auto script...\n");
    number out;
    signal(SIGINT, intHandler);
    stopLoop = 0;
    eval(&S, S.stubs[0], &out);
    signal(SIGINT, SIG_DFL);
  }

  uint8_t* line = NULL;
  size_t size = 0;
  while (1) {

    printf(KNRM "> " KGRN);
    if (getline((char**)&line, &size, stdin) < 0) {
      printf(KNRM "\n");
      return 0;
    }
    printf(KNRM);
    int len = compile(&S, line);
    if ((int) len < 0) {
      int offset = 1 - (int)len;
      while (offset--) printf(" ");
      printf(KRED "^\n");
      printf("Unexpected input\n" KNRM);
      continue;
    }
    uint8_t* program = line;
    while (program - line < len) {
      number result;
      signal(SIGINT, intHandler);
      stopLoop = 0;
      program = eval(&S, program, &result);
      signal(SIGINT, SIG_DFL);
      printf("%s%"PRId64"%s\n", KBLU, result, KNRM);
    }
  }

  return 0;
}
开发者ID:creationix,项目名称:uscript,代码行数:72,代码来源:main.c

示例10: compile

bool Shader::loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader)
{
    // Compile the shader program
    return compile(vertexShader.c_str(), fragmentShader.c_str());
}
开发者ID:AbdulTheProgrammer,项目名称:Bullet_Bomber,代码行数:5,代码来源:Shader.cpp

示例11: main

int main(int argc, char *argv[])
{
    char buffer[256];
    char *p;
    BOOLEAN multipleFiles = FALSE;
    BOOLEAN openOutput = TRUE;
    int rv;
    char realOutFile[260];
    char oldOutFile[260];
    srand(time(0));

        /*   signal(SIGSEGV,internalError) ;*/
        /*   signal(SIGFPE, internalError) ;*/

    /* initialize back end */
    if (!init_backend(&argc,argv))
        fatal("Could not initialize back end");

    if (chosenAssembler->Args)
    {
        CMDLIST *newArgs = calloc(sizeof(Args) + sizeof(Args[0]) * chosenAssembler->ArgCount, 1);
        if (newArgs)
        {
            memcpy(&newArgs[0], chosenAssembler->Args, 
                   chosenAssembler->ArgCount *sizeof(Args[0]));
            memcpy(&newArgs[chosenAssembler->ArgCount], &Args[0], sizeof(Args));
            ArgList = newArgs;
        }
    }		
    /* parse environment variables, command lines, and config files  */
    ccinit(argc, argv);
    
    /* loop through and preprocess all the files on the file list */
    if (clist && clist->next)
        multipleFiles = TRUE;
#ifdef PARSER_ONLY
    strcpy(buffer, clist->data);
    strcpy(realOutFile, outfile);
    outputfile(realOutFile, buffer, ".ods");
    if (!ccDBOpen(realOutFile))
        fatal("Cannot open database file %s", realOutFile);
#else
    BitInit();
    regInit();
#endif
    if (chosenAssembler->main_preprocess)
        openOutput = chosenAssembler->main_preprocess();
    while (clist)
    {
        cparams.prm_cplusplus = FALSE;
        strcpy(buffer, clist->data);
#ifndef PARSER_ONLY
        strcpy(realOutFile, outfile);
        if (cparams.prm_asmfile)
            outputfile(realOutFile, buffer, chosenAssembler->asmext);
        else
            outputfile(realOutFile, buffer, chosenAssembler->objext);
        strcpy(oldOutFile, realOutFile);
        StripExt(oldOutFile);
        AddExt(oldOutFile, ".tmp");
#else
        ccNewFile(buffer, TRUE);
#endif
        AddExt(buffer, ".C");
        p = strrchr(buffer, '.');
        if (*(p - 1) != '.')
        {
            if (p[1] == 'h' || p[1] == 'H') // compile H files as C++ for the IDE
                cparams.prm_cplusplus = TRUE;
            if (p[1] == 'c' || p[1] == 'C')
            if (p[2] == 'p' || p[2] == 'P')
            {
                if (p[3] == 'p' || p[3] == 'P')
                    cparams.prm_cplusplus = TRUE;
            }
            else
            {
                if (p[2] == 'x' || p[2] == 'X')
                {
                    if (p[3] == 'x' || p[3] == 'X')
                        cparams.prm_cplusplus = TRUE;
                }
            }
            else if ((p[2] == 'c' ||p[2] == 'C' ) && !p[3])
            {
                        cparams.prm_cplusplus = TRUE;
            }
            else
            {
                if (p[2] == '+')
                {
                    if (p[3] == '+')
                        cparams.prm_cplusplus = TRUE;
                }
            }
        }
        if (cparams.prm_cplusplus && chosenAssembler->msil)
            fatal("MSIL compiler does not compile C++ files at this time");
        inputFile = SrchPth2(buffer, "", "r");
        if (!inputFile)
//.........这里部分代码省略.........
开发者ID:bencz,项目名称:OrangeC,代码行数:101,代码来源:ccmain.c

示例12: va_arg

/*---------------------------------------------------------------------------
|   Facility      :  libnform
|   Function      :  static void *Make_RegularExpression_Type(va_list * ap)
|
|   Description   :  Allocate structure for regex type argument.
|
|   Return Values :  Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_RegularExpression_Type(va_list * ap)
{
#if HAVE_REGEX_H_FUNCS
  char *rx = va_arg(*ap,char *);
  RegExp_Arg *preg;

  preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
  if (preg)
    {
      if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
       && !regcomp(preg->pRegExp,rx,
		   (REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
	{
	  preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
	  *(preg->refCount) = 1;
	}
      else
	{
	  if (preg->pRegExp)
	    free(preg->pRegExp);
	  free(preg);
	  preg = (RegExp_Arg*)0;
	}
    }
  return((void *)preg);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
  char *rx = va_arg(*ap,char *);
  RegExp_Arg *pArg;

  pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));

  if (pArg)
    {
      int blen = RX_INCREMENT;
      pArg->compiled_expression = NULL;
      pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
      *(pArg->refCount) = 1;

      do {
	char *buf = (char *)malloc(blen);
	if (buf)
	  {
#if HAVE_REGEXP_H_FUNCS
	    char *last_pos = compile (rx, buf, &buf[blen], '\0');
#else /* HAVE_REGEXPR_H_FUNCS */
	    char *last_pos = compile (rx, buf, &buf[blen]);
#endif
	    if (reg_errno)
	      {
		free(buf);
		if (reg_errno==50)
		  blen += RX_INCREMENT;
		else
		  {
		    free(pArg);
		    pArg = NULL;
		    break;
		  }
	      }
	    else
	      {
		pArg->compiled_expression = buf;
		break;
	      }
	  }
      } while( blen <= MAX_RX_LEN );
    }
  if (pArg && !pArg->compiled_expression)
    {
      free(pArg);
      pArg = NULL;
    }
  return (void *)pArg;
#else
  return 0;
#endif
}
开发者ID:aosm,项目名称:old_ncurses,代码行数:85,代码来源:fty_regex.c

示例13: pattern

RegularExpression::Private::Private()
    : pattern("")
{
    compile(true);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:5,代码来源:BCRegularExpressionWK.cpp

示例14: type_

	shader::shader(GLenum type, const std::string& name, const std::string& code)
		: type_(type), shader_(0), name_(name)
	{
		ASSERT_LOG(compile(code), "Error compiling shader for " << name_);
	}
开发者ID:sweetkristas,项目名称:hexes,代码行数:5,代码来源:shaders.cpp

示例15: connect

void TestRunner::run()
{
    runOutput_.clear();
    connect(this, &TestRunner::compileFinished, this, &TestRunner::run_onCompileFinished_);
    compile();
}
开发者ID:dalboris,项目名称:QtProjectTemplate,代码行数:6,代码来源:TestRunner.cpp


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