1 #ifndef MSP_GL_SL_GENERATE_H_
2 #define MSP_GL_SL_GENERATE_H_
14 /** Assigns IDs to specialization constants with an automatic ID. */
15 class ConstantIdAssigner: private TraversingVisitor
18 std::set<unsigned> used_ids;
19 std::map<std::string, unsigned> existing_constants;
20 std::vector<VariableDeclaration *> auto_constants;
23 void apply(Module &, const Features &);
26 virtual void visit(VariableDeclaration &);
29 /** Materializes implicitly declared interfaces.
31 Out variable declarations inside functions are moved to the global scope.
33 Passthrough statements are processed, generating out variables to match in
34 variables and copying values.
36 Unresolved variables are looked up in the previous stage's out variables. */
37 class InterfaceGenerator: private TraversingVisitor
41 std::string in_prefix;
42 std::string out_prefix;
43 bool function_scope = false;
44 bool copy_block = false;
45 std::vector<VariableDeclaration *> declared_inputs;
46 Block *iface_target_block = 0;
47 NodeList<Statement>::iterator iface_insert_point;
48 NodeList<Statement>::iterator assignment_insert_point;
49 std::set<Node *> nodes_to_remove;
55 static std::string get_out_prefix(Stage::Type);
56 std::string change_prefix(const std::string &, const std::string &) const;
57 virtual void visit(Block &);
58 VariableDeclaration *generate_interface(VariableDeclaration &, const std::string &, const std::string &);
59 InterfaceBlock *generate_interface(InterfaceBlock &);
60 ExpressionStatement &insert_assignment(const std::string &, Expression *);
61 virtual void visit(VariableReference &);
62 virtual void visit(VariableDeclaration &);
63 virtual void visit(InterfaceBlock &);
64 virtual void visit(FunctionDeclaration &);
65 virtual void visit(Passthrough &);