From: Mikko Rasa Date: Mon, 8 Mar 2021 11:47:30 +0000 (+0200) Subject: Populate the builtin module's type maps directly X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=78f43047696fbb629e4bc9cfb1068e3fef77cb0a;p=libs%2Fgl.git Populate the builtin module's type maps directly TypeResolver may do other, potentially disruptive things. The contents will be copied into the compiled module and properly resolved there. --- diff --git a/source/glsl/builtin.cpp b/source/glsl/builtin.cpp index c9483151..9e0244df 100644 --- a/source/glsl/builtin.cpp +++ b/source/glsl/builtin.cpp @@ -1,8 +1,8 @@ #include #include #include "builtin.h" -#include "generate.h" #include "parser.h" +#include "visitor.h" using namespace std; @@ -10,6 +10,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; @@ -55,9 +62,9 @@ Module *get_builtins_module() type->kind = BasicTypeDeclaration::FLOAT; 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; }