]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/builtin.cpp
Give declaration nodes to all GLSL types.
[libs/gl.git] / source / glsl / builtin.cpp
index 3800e14bbc0d412552e679f3e2697c514d1deba4..670cfc2d9f4878b1d55abca1cf453adf8c628816 100644 (file)
@@ -1,6 +1,7 @@
 #include <msp/gl/resources.h>
 #include <msp/io/seekable.h>
 #include "builtin.h"
+#include "generate.h"
 #include "parser.h"
 
 using namespace std;
@@ -24,6 +25,38 @@ Module *get_builtins_module()
                Parser parser;
                Module *module = new Module(parser.parse(*io, "<builtin>", BUILTIN_SOURCE));
 
+               NodeList<Statement> &shared_body = module->shared.content.body;
+
+               RefPtr<BasicTypeDeclaration> type = new BasicTypeDeclaration;
+               type->source = BUILTIN_SOURCE;
+               type->name = "void";
+               type->kind = BasicTypeDeclaration::VOID;
+               shared_body.insert(shared_body.begin(), type);
+
+               type = new BasicTypeDeclaration;
+               type->source = BUILTIN_SOURCE;
+               type->name = "bool";
+               type->kind = BasicTypeDeclaration::BOOL;
+               shared_body.insert(shared_body.begin(), 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);
+
+               type = new BasicTypeDeclaration;
+               type->source = BUILTIN_SOURCE;
+               type->name = "float";
+               type->size = 32;
+               type->kind = BasicTypeDeclaration::FLOAT;
+               shared_body.insert(shared_body.begin(), type);
+
+               TypeResolver().apply(module->shared);
+               for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
+                       TypeResolver().apply(*i);
+
                builtins_module = module;
        }
        return builtins_module.get();