================ idProgram::CompileText ================ */
| 1826 | ================ |
| 1827 | */ |
| 1828 | bool idProgram::CompileText( const char *source, const char *text, bool console ) { |
| 1829 | idCompiler compiler; |
| 1830 | int i; |
| 1831 | idVarDef *def; |
| 1832 | idStr ospath; |
| 1833 | |
| 1834 | // use a full os path for GetFilenum since it calls OSPathToRelativePath to convert filenames from the parser |
| 1835 | ospath = fileSystem->RelativePathToOSPath( source ); |
| 1836 | filenum = GetFilenum( ospath ); |
| 1837 | |
| 1838 | try { |
| 1839 | compiler.CompileFile( text, filename, console ); |
| 1840 | |
| 1841 | // check to make sure all functions prototyped have code |
| 1842 | for( i = 0; i < varDefs.Num(); i++ ) { |
| 1843 | def = varDefs[ i ]; |
| 1844 | if ( ( def->Type() == ev_function ) && ( ( def->scope->Type() == ev_namespace ) || def->scope->TypeDef()->Inherits( &type_object ) ) ) { |
| 1845 | if ( !def->value.functionPtr->eventdef && !def->value.functionPtr->firstStatement ) { |
| 1846 | throw idCompileError( va( "function %s was not defined\n", def->GlobalName() ) ); |
| 1847 | } |
| 1848 | } |
| 1849 | } |
| 1850 | } |
| 1851 | |
| 1852 | catch( idCompileError &err ) { |
| 1853 | if ( console ) { |
| 1854 | gameLocal.Printf( "%s\n", err.error ); |
| 1855 | return false; |
| 1856 | } else { |
| 1857 | gameLocal.Error( "%s\n", err.error ); |
| 1858 | } |
| 1859 | }; |
| 1860 | |
| 1861 | if ( !console ) { |
| 1862 | CompileStats(); |
| 1863 | } |
| 1864 | |
| 1865 | return true; |
| 1866 | } |
| 1867 | |
| 1868 | /* |
| 1869 | ================ |
no test coverage detected