From 78f43047696fbb629e4bc9cfb1068e3fef77cb0a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 8 Mar 2021 13:47:30 +0200 Subject: [PATCH] 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. --- source/glsl/builtin.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; } -- 2.43.0