]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programcompiler.h
Use vector when there's no reason to use some other container
[libs/gl.git] / source / programcompiler.h
index 6b1e1cdafe79f9be2ad0df6858cd89b95942e859..b14c03d8021fa5fa4726aa9a9ef6b9cbbb94be1c 100644 (file)
@@ -29,7 +29,7 @@ private:
        struct BlockModifier: Visitor
        {
                bool remove_node;
-               std::list<RefPtr<ProgramSyntax::Node> > insert_nodes;
+               std::vector<RefPtr<ProgramSyntax::Node> > insert_nodes;
 
                BlockModifier();
 
@@ -81,9 +81,9 @@ private:
        template<typename T>
        struct NodeGatherer: Visitor
        {
-               typedef std::list<T *> ResultType;
+               typedef std::vector<T *> ResultType;
 
-               std::list<T *> nodes;
+               std::vector<T *> nodes;
 
                const ResultType &get_result() const { return nodes; }
                using Visitor::visit;
@@ -158,13 +158,6 @@ private:
                virtual void visit(ProgramSyntax::Passthrough &);
        };
 
-       struct VariableRenamer: Visitor
-       {
-               using Visitor::visit;
-               virtual void visit(ProgramSyntax::VariableReference &);
-               virtual void visit(ProgramSyntax::VariableDeclaration &);
-       };
-
        struct DeclarationReorderer: Visitor
        {
                enum DeclarationKind
@@ -370,20 +363,24 @@ private:
        };
 
        Resources *resources;
-       ProgramParser parser;
        ProgramSyntax::Module *module;
+       std::set<std::string> imported_names;
 
 public:
        ProgramCompiler();
+       ~ProgramCompiler();
 
-       void compile(const std::string &);
-       void compile(IO::Base &, Resources * = 0);
+       void compile(const std::string &, const std::string & = "<string>");
+       void compile(IO::Base &, Resources * = 0, const std::string & = "<file>");
+       void compile(IO::Base &, const std::string &);
        void add_shaders(Program &);
 
 private:
        static ProgramSyntax::Module *create_builtins_module();
        static ProgramSyntax::Module &get_builtins_module();
        static ProgramSyntax::Stage *get_builtins(ProgramSyntax::StageType);
+       void append_module(ProgramSyntax::Module &);
+       void append_stage(ProgramSyntax::Stage &);
        void process();
        void import(const std::string &);
        void generate(ProgramSyntax::Stage &);