]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/parser.cpp
Track source names in SL::Module
[libs/gl.git] / source / glsl / parser.cpp
index 60cc3516b0750db9f131e8a665b135c89d7dab7b..eee6212930f5dccabdac77b4a32467f91fb89727 100644 (file)
@@ -28,30 +28,30 @@ Parser::~Parser()
 Module &Parser::parse(const string &s, const string &n, unsigned i)
 {
        source = s;
-       source_index = i;
-       parse_source(n);
+       parse_source(n, i);
        return *module;
 }
 
 Module &Parser::parse(IO::Base &io, const string &n, unsigned i)
 {
        source = string();
-       source_index = i;
        while(!io.eof())
        {
                char buffer[4096];
                unsigned len = io.read(buffer, sizeof(buffer));
                source.append(buffer, len);
        }
-       parse_source(n);
+       parse_source(n, i);
        return *module;
 }
 
-void Parser::parse_source(const string &name)
+void Parser::parse_source(const string &name, unsigned index)
 {
        delete module;
        module = new Module;
        cur_stage = &module->shared;
+       source_index = index;
+       module->source_map.set_name(source_index, name);
        tokenizer.begin(name, source);
        while(RefPtr<Statement> statement = parse_global_declaration())
                cur_stage->content.body.push_back(statement);