]> git.tdb.fi Git - libs/gl.git/commitdiff
Tweak the builtin type generation
authorMikko Rasa <tdb@tdb.fi>
Fri, 5 Mar 2021 21:06:45 +0000 (23:06 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 5 Mar 2021 23:00:31 +0000 (01:00 +0200)
Give bool a size and insert the types in the order they're defined in.

source/glsl/builtin.cpp

index 670cfc2d9f4878b1d55abca1cf453adf8c628816..c9483151823f973088229cbbab9f2307c0a21816 100644 (file)
@@ -26,32 +26,34 @@ Module *get_builtins_module()
                Module *module = new Module(parser.parse(*io, "<builtin>", BUILTIN_SOURCE));
 
                NodeList<Statement> &shared_body = module->shared.content.body;
+               NodeList<Statement>::iterator insert_point = shared_body.begin();
 
                RefPtr<BasicTypeDeclaration> 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 = "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);
                for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)