X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fparser.cpp;h=1f0d712467f3b43c2d9990dfa277bb1c46d0ff42;hp=d9fdbc4ea998e56d98d2209e6a5d79558511bf34;hb=9ec831710f64a62ad5f2e896a55ae82a3519f29e;hpb=3f899b1fc2e04f4fe74c99ad3e8ebb900c257214 diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index d9fdbc4e..1f0d7124 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -29,14 +29,14 @@ Parser::~Parser() delete module; } -Module &Parser::parse(const string &s, const string &n, unsigned i) +Module &Parser::parse(const string &s, const string &n, int i) { source = s; parse_source(n, i); return *module; } -Module &Parser::parse(IO::Base &io, const string &n, unsigned i) +Module &Parser::parse(IO::Base &io, const string &n, int i) { source = string(); while(!io.eof()) @@ -49,14 +49,15 @@ Module &Parser::parse(IO::Base &io, const string &n, unsigned i) return *module; } -void Parser::parse_source(const string &name, unsigned index) +void Parser::parse_source(const string &name, int index) { delete module; module = new Module; cur_stage = &module->shared; base_index = index; source_index = index; - source_reference(1, name); + if(index>=0) + source_reference(1, name); tokenizer.begin(name, source); allow_stage_change = true; while(!tokenizer.peek_token().empty()) @@ -74,7 +75,7 @@ void Parser::set_required_version(const Version &ver) void Parser::source_reference(unsigned index, const string &name) { - if(index<1) + if(index<1 || base_index<0) throw invalid_shader_source(tokenizer.get_location(), "Invalid source reference"); module->source_map.set_name(base_index+index-1, name);