]> git.tdb.fi Git - libs/gl.git/commitdiff
Populate the builtin module's type maps directly
authorMikko Rasa <tdb@tdb.fi>
Mon, 8 Mar 2021 11:47:30 +0000 (13:47 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 8 Mar 2021 13:28:54 +0000 (15:28 +0200)
TypeResolver may do other, potentially disruptive things.  The contents
will be copied into the compiled module and properly resolved there.

source/glsl/builtin.cpp

index c9483151823f973088229cbbab9f2307c0a21816..9e0244df1cbd71efe3acb6c915fdda33d8e7ea64 100644 (file)
@@ -1,8 +1,8 @@
 #include <msp/gl/resources.h>
 #include <msp/io/seekable.h>
 #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<Statement>::const_iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i)
+               if(TypeDeclaration *type = dynamic_cast<TypeDeclaration *>(i->get()))
+                       stage.types[type->name] = type;
+}
+
 Module *get_builtins_module()
 {
        static RefPtr<Module> 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<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
-                       TypeResolver().apply(*i);
+                       populate_types(*i);
 
                builtins_module = module;
        }