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

Method LoadAndParse

neo/framework/DeclManager.cpp:618–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616int c_savedMemory = 0;
617
618int idDeclFile::LoadAndParse() {
619 int i, numTypes;
620 idLexer src;
621 idToken token;
622 int startMarker;
623 char * buffer;
624 int length, size;
625 int sourceLine;
626 idStr name;
627 idDeclLocal *newDecl;
628 bool reparse;
629
630 // load the text
631 common->DPrintf( "...loading '%s'\n", fileName.c_str() );
632 length = fileSystem->ReadFile( fileName, (void **)&buffer, &timestamp );
633 if ( length == -1 ) {
634 common->FatalError( "couldn't load %s", fileName.c_str() );
635 return 0;
636 }
637
638 if ( !src.LoadMemory( buffer, length, fileName ) ) {
639 common->Error( "Couldn't parse %s", fileName.c_str() );
640 Mem_Free( buffer );
641 return 0;
642 }
643
644 // mark all the defs that were from the last reload of this file
645 for ( idDeclLocal *decl = decls; decl; decl = decl->nextInFile ) {
646 decl->redefinedInReload = false;
647 }
648
649 src.SetFlags( DECL_LEXER_FLAGS );
650
651 checksum = MD5_BlockChecksum( buffer, length );
652
653 fileSize = length;
654
655 // scan through, identifying each individual declaration
656 while( 1 ) {
657
658 startMarker = src.GetFileOffset();
659 sourceLine = src.GetLineNum();
660
661 // parse the decl type name
662 if ( !src.ReadToken( &token ) ) {
663 break;
664 }
665
666 declType_t identifiedType = DECL_MAX_TYPES;
667
668 // get the decl type from the type name
669 numTypes = declManagerLocal.GetNumDeclTypes();
670 for ( i = 0; i < numTypes; i++ ) {
671 idDeclType *typeInfo = declManagerLocal.GetDeclType( i );
672 if ( typeInfo && typeInfo->typeName.Icmp( token ) == 0 ) {
673 identifiedType = (declType_t) typeInfo->type;
674 break;
675 }

Callers 1

RegisterDeclFolderMethod · 0.80

Calls 15

Mem_FreeFunction · 0.85
MD5_BlockChecksumFunction · 0.85
ReadFileMethod · 0.80
GetNumDeclTypesMethod · 0.80
GetDeclTypeMethod · 0.80
GetDeclNameFromTypeMethod · 0.80
SetTextLocalMethod · 0.80
ParseLocalMethod · 0.80
IcmpMethod · 0.60
DPrintfMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected