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

Method CompileText

neo/game/script/Script_Program.cpp:1828–1866  ·  view source on GitHub ↗

================ idProgram::CompileText ================ */

Source from the content-addressed store, hash-verified

1826================
1827*/
1828bool 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================

Callers 1

Cmd_Script_fFunction · 0.45

Calls 11

vaFunction · 0.85
RelativePathToOSPathMethod · 0.80
idCompileErrorClass · 0.70
CompileFileMethod · 0.45
NumMethod · 0.45
TypeMethod · 0.45
InheritsMethod · 0.45
TypeDefMethod · 0.45
GlobalNameMethod · 0.45
PrintfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected