From d53269e09e7c9a55f15a5db63be43da5ac01535e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 8 Oct 2017 09:45:47 +0200 Subject: [PATCH] Shaders - add input loader errors for main file --- shaders.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/shaders.cc b/shaders.cc index 6def6be..dfc2812 100644 --- a/shaders.cc +++ b/shaders.cc @@ -157,6 +157,7 @@ void T_InputReader_::handleDirective( void T_InputReader_::error( __rd__ std::string const& err ) { + printf( "input error (%d - %s)\n" , line , err.c_str( ) ); input.errors.push_back( T_ShaderInputError{ line , err } ); } @@ -323,6 +324,10 @@ struct T_CodeBuilder_ void include( __rd__ std::string const& name , __rd__ const uint32_t lines ); void next( ); + + void addInputLoaderErrors( + __rd__ T_ShaderInput const* input , + __rd__ std::string const& name ); }; /*----------------------------------------------------------------------------*/ @@ -341,6 +346,7 @@ bool T_CodeBuilder_::buildCode( ) } else { code.type = E_ShaderType( int( main->type ) - 2 ); } + addInputLoaderErrors( main , name ); cname = name; current = main; @@ -409,10 +415,7 @@ void T_CodeBuilder_::include( // Add input loader errors if ( libraries.find( nname ) == libraries.end( ) ) { - for ( auto const& errs : isi->errors ) { - code.errors.push_back( T_ShaderError{ - nname , errs.line , errs.error } ); - } + addInputLoaderErrors( isi , nname ); } libraries.insert( nname ); @@ -437,6 +440,16 @@ void T_CodeBuilder_::next( ) } } +void T_CodeBuilder_::addInputLoaderErrors( + __rd__ T_ShaderInput const* input , + __rd__ std::string const& name ) +{ + for ( auto const& errs : input->errors ) { + code.errors.push_back( T_ShaderError{ + name , errs.line , errs.error } ); + } +} + } // namespace