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(BasicTypeDeclaration &);
31 virtual void visit(ImageTypeDeclaration &);
32 virtual void visit(StructDeclaration &);
33 virtual void visit(VariableDeclaration &);
36 /** Determines the number of interface locations required by a variable. */
37 class LocationCounter: private NodeVisitor
45 unsigned apply(VariableDeclaration &v) { v.visit(*this); return r_count; }
48 virtual void visit(BasicTypeDeclaration &);
49 virtual void visit(ImageTypeDeclaration &);
50 virtual void visit(StructDeclaration &);
51 virtual void visit(VariableDeclaration &);
54 /** Determines the size and alignment of a variable, in bytes. */
55 class MemoryRequirementsCalculator: private NodeVisitor
63 Result(unsigned s, unsigned a): size(s), alignment(a) { }
71 Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); }
74 virtual void visit(BasicTypeDeclaration &);
75 virtual void visit(StructDeclaration &);
76 virtual void visit(VariableDeclaration &);
79 /** Collects dependencies of a function. This includes global variables,
80 interface blocks, other functions and types. */
81 class DependencyCollector: private TraversingVisitor
84 std::set<Node *> dependencies;
85 std::set<Node *> locals;
88 std::set<Node *> apply(FunctionDeclaration &);
91 virtual void visit(VariableReference &);
92 virtual void visit(InterfaceBlockReference &);
93 virtual void visit(FunctionCall &);
94 virtual void visit(VariableDeclaration &);