]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/resolve.h
Process loop initialization outside the body in UnusedVariableRemover
[libs/gl.git] / source / glsl / resolve.h
index ca9c4f3231f8416c69b493ba1a0a218ea200e135..fdbebfe8e3a8e8249407545d5abfef5ca291dda0 100644 (file)
@@ -15,11 +15,9 @@ namespace SL {
 class BlockHierarchyResolver: private TraversingVisitor
 {
 private:
-       bool r_any_resolved;
+       bool r_any_resolved = false;
 
 public:
-       BlockHierarchyResolver(): r_any_resolved(false) { }
-
        bool apply(Stage &s) { r_any_resolved = false; s.content.visit(*this); return r_any_resolved; }
 
 private:
@@ -30,16 +28,14 @@ private:
 class TypeResolver: private TraversingVisitor
 {
 private:
-       Stage *stage;
+       Stage *stage = 0;
        std::map<TypeDeclaration *, TypeDeclaration *> alias_map;
        std::map<TypeDeclaration *, TypeDeclaration *> array_types;
        NodeList<Statement>::iterator type_insert_point;
-       InterfaceBlock *iface_block;
-       bool r_any_resolved;
+       InterfaceBlock *iface_block = 0;
+       bool r_any_resolved = false;
 
 public:
-       TypeResolver();
-
        bool apply(Stage &);
 
 private:
@@ -59,18 +55,16 @@ of an interface block are turned into interface block references. */
 class VariableResolver: private TraversingVisitor
 {
 private:
-       Stage *stage;
+       Stage *stage = 0;
        RefPtr<Expression> r_replacement_expr;
-       bool r_any_resolved;
-       bool record_target;
-       bool r_self_referencing;
+       bool r_any_resolved = false;
+       bool record_target = false;
+       bool r_self_referencing = false;
        Assignment::Target r_assignment_target;
-       std::vector<VariableDeclaration *> redeclared_builtins;
+       std::vector<Statement *> redeclared_builtins;
        std::set<Node *> nodes_to_remove;
 
 public:
-       VariableResolver();
-
        bool apply(Stage &);
 
 private:
@@ -79,12 +73,12 @@ private:
        void check_assignment_target(Statement *);
        virtual void visit(VariableReference &);
        virtual void visit(InterfaceBlockReference &);
-       void add_to_chain(Assignment::Target::ChainType, unsigned);
        virtual void visit(MemberAccess &);
        virtual void visit(Swizzle &);
        virtual void visit(BinaryExpression &);
        virtual void visit(Assignment &);
        void merge_layouts(Layout &, const Layout &);
+       void redeclare_builtin(VariableDeclaration &, VariableDeclaration &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(InterfaceBlock &);
 };
@@ -103,27 +97,22 @@ private:
 
        struct ArgumentInfo
        {
-               BasicTypeDeclaration *type;
-               unsigned component_count;
+               BasicTypeDeclaration *type = 0;
+               unsigned component_count = 0;
        };
 
-       Stage *stage;
+       Stage *stage = 0;
+       const FunctionDeclaration *current_function = 0;
        std::vector<BasicTypeDeclaration *> basic_types;
        NodeList<Statement>::iterator insert_point;
-       bool r_any_resolved;
+       bool r_any_resolved = false;
 
 public:
-       ExpressionResolver();
-
        bool apply(Stage &);
 
 private:
-       static bool is_scalar(BasicTypeDeclaration &);
-       static bool is_vector_or_matrix(BasicTypeDeclaration &);
-       static BasicTypeDeclaration *get_element_type(BasicTypeDeclaration &);
-       static bool can_convert(BasicTypeDeclaration &, BasicTypeDeclaration &);
        static Compatibility get_compatibility(BasicTypeDeclaration &, BasicTypeDeclaration &);
-       BasicTypeDeclaration *find_type(BasicTypeDeclaration::Kind, unsigned);
+       BasicTypeDeclaration *find_type(BasicTypeDeclaration::Kind, unsigned, bool = true);
        BasicTypeDeclaration *find_type(BasicTypeDeclaration &, BasicTypeDeclaration::Kind, unsigned);
        void convert_to(RefPtr<Expression> &, BasicTypeDeclaration &);
        bool convert_to_element(RefPtr<Expression> &, BasicTypeDeclaration &);
@@ -145,20 +134,24 @@ private:
        virtual void visit(FunctionCall &);
        virtual void visit(BasicTypeDeclaration &);
        virtual void visit(VariableDeclaration &);
+       virtual void visit(FunctionDeclaration &);
+       virtual void visit(Return &);
 };
 
 /** Resolves function declarations and calls. */
 class FunctionResolver: private TraversingVisitor
 {
 private:
-       Stage *stage;
+       Stage *stage = 0;
        std::map<std::string, std::vector<FunctionDeclaration *> > declarations;
-       bool r_any_resolved;
+       bool r_any_resolved = false;
 
 public:
        bool apply(Stage &);
 
 private:
+       static bool can_convert_arguments(const FunctionCall &, const FunctionDeclaration &);
+
        virtual void visit(FunctionCall &);
        virtual void visit(FunctionDeclaration &);
 };