X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fresolve.h;h=92a7c336de71fbbb8a217dd7ece8dd29040c4ea2;hp=633ff11d27b4382e66ce6240847ac84907b54f5a;hb=0585e361d8714ac4efc3ae3e1d5c8c9aa8841c34;hpb=91e65bc9e24a6889995081035f6f6f0a78a6c20e diff --git a/source/glsl/resolve.h b/source/glsl/resolve.h index 633ff11d..92a7c336 100644 --- a/source/glsl/resolve.h +++ b/source/glsl/resolve.h @@ -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 alias_map; - std::map array_types; + std::map, TypeDeclaration *> array_types; NodeList::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 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 redeclared_builtins; + std::vector redeclared_builtins; std::set nodes_to_remove; public: - VariableResolver(); - bool apply(Stage &); private: @@ -84,6 +78,7 @@ private: 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 &); }; @@ -102,20 +97,17 @@ private: struct ArgumentInfo { - BasicTypeDeclaration *type; - unsigned component_count; - - ArgumentInfo(): type(0), component_count(0) { } + BasicTypeDeclaration *type = 0; + unsigned component_count = 0; }; - Stage *stage; + Stage *stage = 0; + const FunctionDeclaration *current_function = 0; std::vector basic_types; NodeList::iterator insert_point; - bool r_any_resolved; + bool r_any_resolved = false; public: - ExpressionResolver(); - bool apply(Stage &); private: @@ -142,15 +134,17 @@ 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 > declarations; - bool r_any_resolved; + bool r_any_resolved = false; public: bool apply(Stage &);