| 616 | int c_savedMemory = 0; |
| 617 | |
| 618 | int 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, ×tamp ); |
| 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 | } |
no test coverage detected