MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / CompileFile

Method CompileFile

neo/game/script/Script_Compiler.cpp:2618–2700  ·  view source on GitHub ↗

============ idCompiler::CompileFile compiles the 0 terminated text, adding definitions to the program structure ============ */

Source from the content-addressed store, hash-verified

2616============
2617*/
2618void idCompiler::CompileFile( const char *text, const char *filename, bool toConsole ) {
2619 idTimer compile_time;
2620 bool error;
2621
2622 compile_time.Start();
2623
2624 idStr origFileName = filename; // DG: filename pointer might become invalid when calling NextToken() below
2625
2626 scope = &def_namespace;
2627 basetype = NULL;
2628 callthread = false;
2629 loopDepth = 0;
2630 eof = false;
2631 braceDepth = 0;
2632 immediateType = NULL;
2633 currentLineNumber = 0;
2634 console = toConsole;
2635
2636 memset( &immediate, 0, sizeof( immediate ) );
2637
2638 parser.SetFlags( LEXFL_ALLOWMULTICHARLITERALS );
2639 parser.LoadMemory( text, strlen( text ), filename );
2640 parserPtr = &parser;
2641
2642 // unread tokens to include script defines
2643 token = SCRIPT_DEFAULTDEFS;
2644 token.type = TT_STRING;
2645 token.subtype = token.Length();
2646 token.line = token.linesCrossed = 0;
2647 parser.UnreadToken( &token );
2648
2649 token = "include";
2650 token.type = TT_NAME;
2651 token.subtype = token.Length();
2652 token.line = token.linesCrossed = 0;
2653 parser.UnreadToken( &token );
2654
2655 token = "#";
2656 token.type = TT_PUNCTUATION;
2657 token.subtype = P_PRECOMP;
2658 token.line = token.linesCrossed = 0;
2659 parser.UnreadToken( &token );
2660
2661 // init the current token line to be the first line so that currentLineNumber is set correctly in NextToken
2662 token.line = 1;
2663
2664 error = false;
2665 try {
2666 // read first token
2667 NextToken();
2668 while( !eof && !error ) {
2669 // parse from global namespace
2670 ParseNamespace( &def_namespace );
2671 }
2672 }
2673
2674 catch( idCompileError &err ) {
2675 idStr error;

Callers

nothing calls this directly

Calls 13

sprintfFunction · 0.85
idCompileErrorClass · 0.70
StartMethod · 0.45
SetFlagsMethod · 0.45
LoadMemoryMethod · 0.45
LengthMethod · 0.45
UnreadTokenMethod · 0.45
GetFilenameMethod · 0.45
FreeSourceMethod · 0.45
StopMethod · 0.45
PrintfMethod · 0.45
OSPathToRelativePathMethod · 0.45

Tested by

no test coverage detected