X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fparser.cpp;h=cbfa593ac590671b04f077f4bd2e44136f1312c7;hb=f901fcf41d8ca544085f448227f84bc6f966660d;hp=72f8ebfa6279982e675b98b9c5364044e90f3150;hpb=2016444ee144ce41f88c48e89c825137ad7e4ec2;p=libs%2Fgl.git diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index 72f8ebfa..cbfa593a 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -4,6 +4,7 @@ #include #include "builtin.h" #include "glsl_error.h" +#include "modulecache.h" #include "parser.h" #undef interface @@ -14,7 +15,8 @@ namespace Msp { namespace GL { namespace SL { -Parser::Parser(): +Parser::Parser(ModuleCache *s): + mod_cache(s), preprocessor(tokenizer), module(0) { @@ -25,20 +27,16 @@ Parser::Parser(): preprocessor.signal_line.connect(sigc::mem_fun(this, &Parser::line_change)); } -Parser::~Parser() -{ - delete module; -} - -Module &Parser::parse(const string &s, const string &n, int i) +void Parser::parse(Module &m, const string &s, const string &n, int i) { + SetForScope set_module(module, &m); source = s; parse_source(n, i); - return *module; } -Module &Parser::parse(IO::Base &io, const string &n, int i) +void Parser::parse(Module &m, IO::Base &io, const string &n, int i) { + SetForScope set_module(module, &m); source = string(); while(!io.eof()) { @@ -47,14 +45,10 @@ Module &Parser::parse(IO::Base &io, const string &n, int i) source.append(buffer, len); } parse_source(n, i); - return *module; } void Parser::parse_source(const string &name, int index) { - delete module; - module = new Module; - cur_stage = &module->shared; base_index = index; source_index = index; @@ -72,6 +66,7 @@ void Parser::parse_source(const string &name, int index) declared_types.insert("void"); declared_types.insert("bool"); declared_types.insert("int"); + declared_types.insert("uint"); declared_types.insert("float"); } @@ -536,7 +531,9 @@ RefPtr Parser::parse_literal() if(isdigit(literal->token[0])) { // TODO have the tokenizer return the type of the token - if(literal->token.back()=='f') + if(literal->token.back()=='u') + literal->value = lexical_cast(literal->token.substr(0, literal->token.size()-1)); + else if(literal->token.back()=='f') literal->value = lexical_cast(literal->token.substr(0, literal->token.size()-1)); else if(literal->token.find('.')!=string::npos) literal->value = lexical_cast(literal->token);