1 #ifndef MSP_GL_SL_REFLECT_H_
2 #define MSP_GL_SL_REFLECT_H_
10 /** Compares two types for equality. Struct types are compared recursively. */
11 class TypeComparer: private NodeVisitor
19 static unsigned next_tag;
24 bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; }
27 void compare(Node &, Node &);
30 virtual void visit(Literal &);
31 virtual void visit(VariableReference &);
32 virtual void visit(BasicTypeDeclaration &);
33 virtual void visit(ImageTypeDeclaration &);
34 virtual void visit(StructDeclaration &);
35 virtual void visit(VariableDeclaration &);
38 /** Determines the number of interface locations required by a variable. */
39 class LocationCounter: private NodeVisitor
47 unsigned apply(VariableDeclaration &v) { v.visit(*this); return r_count; }
50 virtual void visit(BasicTypeDeclaration &);
51 virtual void visit(ImageTypeDeclaration &);
52 virtual void visit(StructDeclaration &);
53 virtual void visit(VariableDeclaration &);
56 /** Determines the size and alignment of a variable, in bytes. */
57 class MemoryRequirementsCalculator: private NodeVisitor
65 Result(unsigned s, unsigned a): size(s), alignment(a) { }
73 Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); }
76 virtual void visit(BasicTypeDeclaration &);
77 virtual void visit(StructDeclaration &);
78 virtual void visit(VariableDeclaration &);
81 /** Collects dependencies of a function. This includes global variables,
82 interface blocks, other functions and types. */
83 class DependencyCollector: private TraversingVisitor
86 std::set<Node *> dependencies;
87 std::set<Node *> locals;
88 std::set<FunctionDeclaration *> visited_functions;
91 std::set<Node *> apply(FunctionDeclaration &);
94 virtual void visit(VariableReference &);
95 virtual void visit(InterfaceBlockReference &);
96 virtual void visit(FunctionCall &);
97 virtual void visit(VariableDeclaration &);
98 virtual void visit(FunctionDeclaration &);