OSDN Git Service

Composition2IRCompiler: Command と TrackListBlock の部分的な定義を追加
authorstarg <starg@users.osdn.me>
Tue, 2 Aug 2016 03:36:31 +0000 (12:36 +0900)
committerstarg <starg@users.osdn.me>
Tue, 2 Aug 2016 04:42:41 +0000 (13:42 +0900)
include/ir/track.hpp
src/ast2ir/composition2ir.cpp
src/ast2ir/composition2ir.hpp

index 8b15dc9..1c9f9af 100644 (file)
@@ -31,6 +31,7 @@ public:
 class TrackList final
 {
 public:
+    std::vector<AST::Attribute> Attributes;
     std::vector<Track> Tracks;
 };
 
index e8e9e95..512f5ea 100644 (file)
@@ -21,6 +21,12 @@ bool Composition2IRCompiler::Compile(const AST::Composition& ast, IR::TrackBlock
     {
         m_AttributeStack.push_back(ast.Attributes);
         AutoPop<decltype(m_AttributeStack)> autoPop(m_AttributeStack);
+        m_IR.TrackBlocks.at(index.ID).Attributes = m_AttributeStack.back();
+
+        for (auto&& i : ast.Statements)
+        {
+            m_IR.TrackBlocks[index.ID].Blocks.push_back(i.apply_visitor(*this));
+        }
 
         return true;
     }
@@ -40,6 +46,25 @@ bool Composition2IRCompiler::Compile(const AST::Composition& ast, IR::TrackBlock
     }
 }
 
+IR::TrackBlock::BlockType Composition2IRCompiler::operator()(const AST::Command& ast)
+{
+    return ast;
+}
+
+IR::TrackBlock::BlockType Composition2IRCompiler::operator()(const AST::TrackListBlock& ast)
+{
+    IR::TrackList trackList;
+    trackList.Attributes = ast.Attributes;
+    trackList.Tracks.reserve(ast.Tracks.size());
+
+    for (auto&& i : ast.Tracks)
+    {
+
+    }
+
+    return trackList;
+}
+
 } // namespace AST2IR
 
 } // namespace YAMML
index f4d259e..9f33b9a 100644 (file)
@@ -4,7 +4,7 @@
 #include <deque>
 #include <vector>
 
-#include <boost/optional.hpp>
+#include <boost/variant.hpp>
 
 #include <ast/attribute.hpp>
 #include <ast/composition.hpp>
@@ -18,7 +18,7 @@ namespace YAMML
 namespace AST2IR
 {
 
-class Composition2IRCompiler final : public Compiler::NestedCompilerBase
+class Composition2IRCompiler final : public Compiler::NestedCompilerBase, public boost::static_visitor<IR::TrackBlock::BlockType>
 {
 public:
     Composition2IRCompiler(Compiler::CompilerBase& parentCompiler, IR::Module& ir);
@@ -26,6 +26,9 @@ public:
     // Compiles ast into m_IR.Blocks[index.ID]
     bool Compile(const AST::Composition& ast, IR::TrackBlockReference index);
 
+    IR::TrackBlock::BlockType operator()(const AST::Command& ast);
+    IR::TrackBlock::BlockType operator()(const AST::TrackListBlock& ast);
+
 private:
     IR::Module& m_IR;
     std::deque<std::vector<AST::Attribute>> m_AttributeStack;