]> git.tdb.fi Git - libs/gl.git/commitdiff
Mostly cosmetic tweaks
authorMikko Rasa <tdb@tdb.fi>
Fri, 26 Feb 2021 18:26:27 +0000 (20:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 26 Feb 2021 18:26:27 +0000 (20:26 +0200)
source/glsl/optimize.cpp
source/glsl/syntax.cpp
source/glsl/syntax.h

index 1ebb87c5c2ea23360c33917104745273de6d8da0..3f63dd8a7debaac0c492c0f3f5a2e9491d989ebf 100644 (file)
@@ -14,7 +14,7 @@ InlineableFunctionLocator::InlineableFunctionLocator():
 void InlineableFunctionLocator::visit(FunctionCall &call)
 {
        FunctionDeclaration *def = call.declaration;
-       if(def && def->definition!=def)
+       if(def)
                def = def->definition;
 
        if(def)
@@ -95,7 +95,7 @@ void FunctionInliner::visit(FunctionCall &call)
                visit_and_inline(*i);
 
        FunctionDeclaration *def = call.declaration;
-       if(def && def->definition!=def)
+       if(def)
                def = def->definition;
 
        if(def && inlineable.count(def))
@@ -259,7 +259,7 @@ void UnusedVariableRemover::visit(VariableReference &var)
        if(var.declaration && !assignment_target)
        {
                VariableInfo &var_info = variables.back()[var.declaration];
-               var_info.assignments.clear();
+               clear_assignments(var_info, false);
                var_info.referenced = true;
        }
 }
@@ -441,7 +441,7 @@ void UnusedVariableRemover::visit(Iteration &iter)
        BlockVariableMap &block_variables = variables.back();
        for(BlockVariableMap::iterator i=block_variables.begin(); i!=block_variables.end(); ++i)
                if(!i->second.local && i->second.referenced)
-                       i->second.assignments.clear();
+                       clear_assignments(i->second, false);
 
        merge_down_variables();
 }
index bda0dd1d7b2a0d673bcea91fc1fdbab23307ce37..7f2efdce93ebb30557be4b713d49125bca646da0 100644 (file)
@@ -181,15 +181,15 @@ void Assignment::visit(NodeVisitor &visitor)
 
 
 FunctionCall::FunctionCall():
-       declaration(0),
-       constructor(false)
+       constructor(false),
+       declaration(0)
 { }
 
 FunctionCall::FunctionCall(const FunctionCall &other):
        name(other.name),
-       declaration(0),
        constructor(other.constructor),
-       arguments(other.arguments)
+       arguments(other.arguments),
+       declaration(0)
 { }
 
 void FunctionCall::visit(NodeVisitor &visitor)
@@ -241,25 +241,25 @@ void StructDeclaration::visit(NodeVisitor &visitor)
 
 VariableDeclaration::VariableDeclaration():
        constant(false),
-       type_declaration(0),
        array(false),
+       type_declaration(0),
        linked_declaration(0)
 { }
 
 VariableDeclaration::VariableDeclaration(const VariableDeclaration &other):
+       layout(other.layout),
        constant(other.constant),
        sampling(other.sampling),
        interpolation(other.interpolation),
        interface(other.interface),
        precision(other.precision),
        type(other.type),
-       type_declaration(0),
        name(other.name),
        array(other.array),
        array_size(other.array_size),
        init_expression(other.init_expression),
-       linked_declaration(0),
-       layout(other.layout)
+       type_declaration(0),
+       linked_declaration(0)
 { }
 
 VariableDeclaration::~VariableDeclaration()
@@ -310,8 +310,8 @@ FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
        return_type(other.return_type),
        name(other.name),
        parameters(other.parameters),
-       definition(other.definition==&other ? this : 0),
-       body(other.body)
+       body(other.body),
+       definition(other.definition==&other ? this : 0)
 { }
 
 void FunctionDeclaration::visit(NodeVisitor &visitor)
index 49699f2ed3811880e5ecbfb0495549379ff41784..55f47402f514538b959a459a07b3532e2a0d5efd 100644 (file)
@@ -108,6 +108,7 @@ struct Block: Node
 {
        NodeList<Statement> body;
        bool use_braces;
+
        std::map<std::string, VariableDeclaration *> variables;
        Block *parent;
 
@@ -142,6 +143,7 @@ struct ParenthesizedExpression: Expression
 struct VariableReference: Expression
 {
        std::string name;
+
        VariableDeclaration *declaration;
 
        VariableReference();
@@ -154,6 +156,7 @@ struct VariableReference: Expression
 struct InterfaceBlockReference: Expression
 {
        std::string name;
+
        InterfaceBlock *declaration;
 
        InterfaceBlockReference();
@@ -167,6 +170,7 @@ struct MemberAccess: Expression
 {
        NodePtr<Expression> left;
        std::string member;
+
        VariableDeclaration *declaration;
 
        MemberAccess();
@@ -202,6 +206,7 @@ struct BinaryExpression: Expression
 struct Assignment: BinaryExpression
 {
        bool self_referencing;
+
        VariableDeclaration *target_declaration;
 
        Assignment();
@@ -214,10 +219,11 @@ struct Assignment: BinaryExpression
 struct FunctionCall: Expression
 {
        std::string name;
-       FunctionDeclaration *declaration;
        bool constructor;
        NodeArray<Expression> arguments;
 
+       FunctionDeclaration *declaration;
+
        FunctionCall();
        FunctionCall(const FunctionCall &);
 
@@ -287,19 +293,20 @@ struct StructDeclaration: Statement
 
 struct VariableDeclaration: Statement
 {
+       NodePtr<Layout> layout;
        bool constant;
        std::string sampling;
        std::string interpolation;
        std::string interface;
        std::string precision;
        std::string type;
-       StructDeclaration *type_declaration;
        std::string name;
        bool array;
        NodePtr<Expression> array_size;
        NodePtr<Expression> init_expression;
+
+       StructDeclaration *type_declaration;
        VariableDeclaration *linked_declaration;
-       NodePtr<Layout> layout;
 
        VariableDeclaration();
        VariableDeclaration(const VariableDeclaration &);
@@ -316,6 +323,7 @@ struct InterfaceBlock: Statement
        Block members;
        std::string instance_name;
        bool array;
+
        InterfaceBlock *linked_block;
 
        InterfaceBlock();
@@ -331,9 +339,10 @@ struct FunctionDeclaration: Statement
        std::string return_type;
        std::string name;
        NodeArray<VariableDeclaration> parameters;
-       FunctionDeclaration *definition;
        Block body;
 
+       FunctionDeclaration *definition;
+
        FunctionDeclaration();
        FunctionDeclaration(const FunctionDeclaration &);