From: starg Date: Wed, 3 Aug 2016 12:29:46 +0000 (+0900) Subject: IR2MIDICompiler::Compile() のエラー処理部分まで作成 X-Git-Tag: v0.1.827.0~86 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=85c2bce3b60565fe08194b634657342021af8756;p=yamml%2Fyamml-git.git IR2MIDICompiler::Compile() のエラー処理部分まで作成 --- diff --git a/include/ir2midi/ir2midi.hpp b/include/ir2midi/ir2midi.hpp new file mode 100644 index 0000000..ec34455 --- /dev/null +++ b/include/ir2midi/ir2midi.hpp @@ -0,0 +1,32 @@ + +#pragma once + +#include + +#include +#include +#include + +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 diff --git a/include/message/id.hpp b/include/message/id.hpp index bf77efb..574ea04 100644 --- a/include/message/id.hpp +++ b/include/message/id.hpp @@ -12,6 +12,7 @@ enum class MessageID Unknown, UnknownInPhrase2IR, UnknownInComposition2IR, + UnknownInIR2MIDI, DuplicatedCompositionName, DuplicatedPhraseName, NoSuchPhraseName, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 479ca95..24dabdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 index 0000000..f750b54 --- /dev/null +++ b/src/ir2midi/CMakeLists.txt @@ -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 index 0000000..fc35410 --- /dev/null +++ b/src/ir2midi/ir2midi.cpp @@ -0,0 +1,58 @@ + +#include + +#include +#include +#include + +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 index 0000000..e69de29 diff --git a/src/ir2midi/pch.hpp b/src/ir2midi/pch.hpp new file mode 100644 index 0000000..98c7d6a --- /dev/null +++ b/src/ir2midi/pch.hpp @@ -0,0 +1,8 @@ + +#pragma once + +#include +#include +#include + +#include