1 #ifndef MSP_GL_SL_GENERATE_H_
2 #define MSP_GL_SL_GENERATE_H_
14 /** Manipulates specialization constants. If values are specified, turns
15 specialization constants into normal constants. Without values assigns
16 automatic constant_ids to specialization constants. */
17 class ConstantSpecializer: private TraversingVisitor
20 const std::map<std::string, int> *values;
23 ConstantSpecializer();
25 void apply(Stage &, const std::map<std::string, int> *);
28 virtual void visit(VariableDeclaration &);
31 /** Materializes implicitly declared interfaces.
33 Out variable declarations inside functions are moved to the global scope.
35 Passthrough statements are processed, generating out variables to match in
36 variables and copying values.
38 Unresolved variables are looked up in the previous stage's out variables. */
39 class InterfaceGenerator: private TraversingVisitor
43 std::string in_prefix;
44 std::string out_prefix;
47 std::vector<VariableDeclaration *> declared_inputs;
48 Block *iface_target_block;
49 NodeList<Statement>::iterator iface_insert_point;
50 NodeList<Statement>::iterator assignment_insert_point;
51 std::set<Node *> nodes_to_remove;
59 static std::string get_out_prefix(Stage::Type);
60 std::string change_prefix(const std::string &, const std::string &) const;
61 virtual void visit(Block &);
62 VariableDeclaration *generate_interface(VariableDeclaration &, const std::string &, const std::string &);
63 InterfaceBlock *generate_interface(InterfaceBlock &);
64 ExpressionStatement &insert_assignment(const std::string &, Expression *);
65 virtual void visit(VariableReference &);
66 virtual void visit(VariableDeclaration &);
67 virtual void visit(InterfaceBlock &);
68 virtual void visit(FunctionDeclaration &);
69 virtual void visit(Passthrough &);