OSDN Git Service

IR2MIDICompiler::Compile() のエラー処理部分まで作成
authorstarg <starg@users.osdn.me>
Wed, 3 Aug 2016 12:29:46 +0000 (21:29 +0900)
committerstarg <starg@users.osdn.me>
Wed, 3 Aug 2016 12:29:46 +0000 (21:29 +0900)
include/ir2midi/ir2midi.hpp [new file with mode: 0644]
include/message/id.hpp
src/CMakeLists.txt
src/ir2midi/CMakeLists.txt [new file with mode: 0644]
src/ir2midi/ir2midi.cpp [new file with mode: 0644]
src/ir2midi/pch.cpp [new file with mode: 0644]
src/ir2midi/pch.hpp [new file with mode: 0644]

diff --git a/include/ir2midi/ir2midi.hpp b/include/ir2midi/ir2midi.hpp
new file mode 100644 (file)
index 0000000..ec34455
--- /dev/null
@@ -0,0 +1,32 @@
+
+#pragma once
+
+#include <string>
+
+#include <compiler/base.hpp>
+#include <ir/module.hpp>
+#include <midi/file.hpp>
+
+namespace YAMML
+{
+
+namespace IR2MIDI
+{
+
+class IR2MIDICompiler : public Compiler::CompilerBase
+{
+public:
+    bool Compile(const IR::Module& ir, const std::string& entryPoint);
+
+    MIDI::MIDIFile& GetMIDI();
+    const MIDI::MIDIFile& GetMIDI() const;
+
+private:
+    bool CompileTrackBlock(const IR::Module& ir, const std::string& trackBlock);
+
+    MIDI::MIDIFile m_MIDI;
+};
+
+} // namespace IR2MIDI
+
+} // namespace YAMML
index bf77efb..574ea04 100644 (file)
@@ -12,6 +12,7 @@ enum class MessageID
     Unknown,
     UnknownInPhrase2IR,
     UnknownInComposition2IR,
+    UnknownInIR2MIDI,
     DuplicatedCompositionName,
     DuplicatedPhraseName,
     NoSuchPhraseName,
index 479ca95..24dabdb 100644 (file)
@@ -1,4 +1,5 @@
 
 add_subdirectory(ast2ir)
+add_subdirectory(ir2midi)
 add_subdirectory(midiwriter)
 add_subdirectory(parser)
diff --git a/src/ir2midi/CMakeLists.txt b/src/ir2midi/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f750b54
--- /dev/null
@@ -0,0 +1,10 @@
+
+set(IR2MIDIHeaders
+    ../../include/ir2midi/ir2midi.hpp
+)
+
+set(IR2MIDISources
+    ir2midi.cpp
+)
+
+yamml_add_library(IR2MIDI STATIC IR2MIDISources IR2MIDIHeaders)
diff --git a/src/ir2midi/ir2midi.cpp b/src/ir2midi/ir2midi.cpp
new file mode 100644 (file)
index 0000000..fc35410
--- /dev/null
@@ -0,0 +1,58 @@
+
+#include <exception>
+
+#include <exceptions/messageexception.hpp>
+#include <ir2midi/ir2midi.hpp>
+#include <message/message.hpp>
+
+namespace YAMML
+{
+
+namespace IR2MIDI
+{
+
+bool IR2MIDICompiler::Compile(const IR::Module& ir, const std::string& entryPoint)
+{
+    try
+    {
+        return CompileTrackBlock(ir, entryPoint);
+    }
+    catch (const Exceptions::MessageException& e)
+    {
+        AddMessage(e.Item);
+        return false;
+    }
+    catch (const std::exception& e)
+    {
+        AddMessage(
+            Message::MessageItem{
+                Message::MessageKind::FetalError,
+                Message::MessageID::UnknownInIR2MIDI,
+                ir.Name,
+                {0, 0},
+                {e.what()}
+            }
+        );
+
+        return false;
+    }
+}
+
+MIDI::MIDIFile& IR2MIDICompiler::GetMIDI()
+{
+    return m_MIDI;
+}
+
+const MIDI::MIDIFile& IR2MIDICompiler::GetMIDI() const
+{
+    return m_MIDI;
+}
+
+bool IR2MIDICompiler::CompileTrackBlock(const IR::Module& ir, const std::string& trackBlock)
+{
+    return false;
+}
+
+} // namespace IR2MIDI
+
+} // namespace YAMML
diff --git a/src/ir2midi/pch.cpp b/src/ir2midi/pch.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/ir2midi/pch.hpp b/src/ir2midi/pch.hpp
new file mode 100644 (file)
index 0000000..98c7d6a
--- /dev/null
@@ -0,0 +1,8 @@
+
+#pragma once
+
+#include <exception>
+#include <string>
+#include <vector>
+
+#include <boost/variant.hpp>