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);