X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fbuiltin.cpp;h=b9fe487c7bb2f810360918167df628d05a5acbfb;hb=a159fe302af38ab3880c11317e382d1b04d80ace;hp=670cfc2d9f4878b1d55abca1cf453adf8c628816;hpb=4c805f55d89919d6971d600102ab4d6d65d56dc3;p=libs%2Fgl.git diff --git a/source/glsl/builtin.cpp b/source/glsl/builtin.cpp index 670cfc2d..b9fe487c 100644 --- a/source/glsl/builtin.cpp +++ b/source/glsl/builtin.cpp @@ -1,7 +1,6 @@ #include #include #include "builtin.h" -#include "generate.h" #include "parser.h" using namespace std; @@ -10,6 +9,13 @@ namespace Msp { namespace GL { namespace SL { +void populate_types(Stage &stage) +{ + for(NodeList::const_iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i) + if(TypeDeclaration *type = dynamic_cast(i->get())) + stage.types[type->name] = type; +} + Module *get_builtins_module() { static RefPtr builtins_module; @@ -22,42 +28,53 @@ Module *get_builtins_module() if(!io) return 0; - Parser parser; - Module *module = new Module(parser.parse(*io, "", BUILTIN_SOURCE)); + RefPtr module = new Module; + Parser parser(0); + parser.parse(*module, *io, "", BUILTIN_SOURCE); NodeList &shared_body = module->shared.content.body; + NodeList::iterator insert_point = shared_body.begin(); RefPtr type = new BasicTypeDeclaration; type->source = BUILTIN_SOURCE; type->name = "void"; type->kind = BasicTypeDeclaration::VOID; - shared_body.insert(shared_body.begin(), type); + shared_body.insert(insert_point, type); type = new BasicTypeDeclaration; type->source = BUILTIN_SOURCE; type->name = "bool"; + type->size = 1; type->kind = BasicTypeDeclaration::BOOL; - shared_body.insert(shared_body.begin(), type); + shared_body.insert(insert_point, type); type = new BasicTypeDeclaration; type->source = BUILTIN_SOURCE; type->name = "int"; type->size = 32; type->kind = BasicTypeDeclaration::INT; - shared_body.insert(shared_body.begin(), type); + shared_body.insert(insert_point, type); + + type = new BasicTypeDeclaration; + type->source = BUILTIN_SOURCE; + type->name = "uint"; + type->size = 32; + type->sign = false; + type->kind = BasicTypeDeclaration::INT; + shared_body.insert(insert_point, type); type = new BasicTypeDeclaration; type->source = BUILTIN_SOURCE; type->name = "float"; type->size = 32; type->kind = BasicTypeDeclaration::FLOAT; - shared_body.insert(shared_body.begin(), type); + shared_body.insert(insert_point, type); - TypeResolver().apply(module->shared); + populate_types(module->shared); for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) - TypeResolver().apply(*i); + populate_types(*i); - builtins_module = module; + builtins_module = module.release(); } return builtins_module.get(); }