mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-20 00:29:54 +00:00
Coroutine generator becomes a part of the core EightBit library.
This commit is contained in:
parent
f837836072
commit
7af8a19e2f
@ -185,7 +185,6 @@
|
|||||||
<ClInclude Include="array_t.h" />
|
<ClInclude Include="array_t.h" />
|
||||||
<ClInclude Include="byte_t.h" />
|
<ClInclude Include="byte_t.h" />
|
||||||
<ClInclude Include="checker_t.h" />
|
<ClInclude Include="checker_t.h" />
|
||||||
<ClInclude Include="co_generator_t.h" />
|
|
||||||
<ClInclude Include="cycles_t.h" />
|
<ClInclude Include="cycles_t.h" />
|
||||||
<ClInclude Include="cycle_t.h" />
|
<ClInclude Include="cycle_t.h" />
|
||||||
<ClInclude Include="element_t.h" />
|
<ClInclude Include="element_t.h" />
|
||||||
|
@ -100,9 +100,6 @@
|
|||||||
<ClInclude Include="processor_test_suite_t.h">
|
<ClInclude Include="processor_test_suite_t.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="co_generator_t.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="checker_t.h">
|
<ClInclude Include="checker_t.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept
|
opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept
|
||||||
: parser_t(path) {}
|
: parser_t(path) {}
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
EightBit::co_generator_t<test_t> opcode_test_suite_t::generator() {
|
||||||
co_generator_t<test_t> opcode_test_suite_t::generator() {
|
|
||||||
for (const auto element : *this)
|
for (const auto element : *this)
|
||||||
co_yield test_t(element);
|
co_yield test_t(element);
|
||||||
}
|
}
|
||||||
#endif
|
|
@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <co_generator_t.h>
|
||||||
|
|
||||||
#include "parser_t.h"
|
#include "parser_t.h"
|
||||||
#include "test_t.h"
|
#include "test_t.h"
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#include "co_generator_t.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class opcode_test_suite_t final : public parser_t {
|
class opcode_test_suite_t final : public parser_t {
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] auto array() const noexcept { return raw().get_array(); }
|
[[nodiscard]] auto array() const noexcept { return raw().get_array(); }
|
||||||
@ -20,7 +18,5 @@ public:
|
|||||||
[[nodiscard]] auto begin() const noexcept { return array().begin(); }
|
[[nodiscard]] auto begin() const noexcept { return array().begin(); }
|
||||||
[[nodiscard]] auto end() const noexcept { return array().end(); }
|
[[nodiscard]] auto end() const noexcept { return array().end(); }
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
EightBit::co_generator_t<test_t> generator();
|
||||||
co_generator_t<test_t> generator();
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "processor_test_suite_t.h"
|
#include "processor_test_suite_t.h"
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#endif
|
|
||||||
|
|
||||||
processor_test_suite_t::processor_test_suite_t(std::string location) noexcept
|
processor_test_suite_t::processor_test_suite_t(std::string location) noexcept
|
||||||
: m_location(location) {
|
: m_location(location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
EightBit::co_generator_t<opcode_test_suite_t> processor_test_suite_t::generator() {
|
||||||
co_generator_t<opcode_test_suite_t> processor_test_suite_t::generator() {
|
|
||||||
std::filesystem::path directory = location();
|
std::filesystem::path directory = location();
|
||||||
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
||||||
co_yield opcode_test_suite_t(entry.path().string());
|
co_yield opcode_test_suite_t(entry.path().string());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
#include <co_generator_t.h>
|
||||||
#include "co_generator_t.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "opcode_test_suite_t.h"
|
#include "opcode_test_suite_t.h"
|
||||||
|
|
||||||
@ -18,7 +16,5 @@ public:
|
|||||||
|
|
||||||
std::string_view location() const noexcept { return m_location; }
|
std::string_view location() const noexcept { return m_location; }
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
EightBit::co_generator_t<opcode_test_suite_t> generator();
|
||||||
co_generator_t<opcode_test_suite_t> generator();
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <mos6502.h>
|
#include <mos6502.h>
|
||||||
#include <Disassembly.h>
|
#include <Disassembly.h>
|
||||||
#include <Symbols.h>
|
#include <Symbols.h>
|
||||||
|
#include <co_generator_t.h>
|
||||||
|
|
||||||
#include "simdjson/simdjson.h"
|
#include "simdjson/simdjson.h"
|
||||||
|
|
||||||
#define USE_COROUTINES
|
|
||||||
|
@ -26,8 +26,6 @@ int main() {
|
|||||||
checker_t checker(runner);
|
checker_t checker(runner);
|
||||||
checker.initialise();
|
checker.initialise();
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
|
|
||||||
processor_test_suite_t m6502_tests(directory);
|
processor_test_suite_t m6502_tests(directory);
|
||||||
auto opcode_generator = m6502_tests.generator();
|
auto opcode_generator = m6502_tests.generator();
|
||||||
while (opcode_generator) {
|
while (opcode_generator) {
|
||||||
@ -58,39 +56,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
std::filesystem::path location = directory;
|
|
||||||
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator{ location }) {
|
|
||||||
|
|
||||||
const auto& path = entry.path();
|
|
||||||
|
|
||||||
std::cout << "Processing: " << path.filename() << "\n";
|
|
||||||
opcode_test_suite_t opcode(path.string());
|
|
||||||
opcode.load();
|
|
||||||
|
|
||||||
for (const auto opcode_test_element : opcode) {
|
|
||||||
|
|
||||||
const auto test = test_t(opcode_test_element);
|
|
||||||
checker.check(test);
|
|
||||||
|
|
||||||
if (checker.invalid()) {
|
|
||||||
++invalid_opcode_count;
|
|
||||||
if (checker.unimplemented())
|
|
||||||
++unimplemented_opcode_count;
|
|
||||||
if (checker.undocumented())
|
|
||||||
++undocumented_opcode_count;
|
|
||||||
std::cout << "** Failed: " << test.name() << "\n";
|
|
||||||
for (const auto& message : checker.messages())
|
|
||||||
std::cout << "**** " << message << "\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const auto finish_time = std::chrono::steady_clock::now();
|
const auto finish_time = std::chrono::steady_clock::now();
|
||||||
const auto elapsed_time = finish_time - start_time;
|
const auto elapsed_time = finish_time - start_time;
|
||||||
const auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed_time).count();
|
const auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed_time).count();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
|
|
||||||
#include <coroutine>
|
#include <coroutine>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// from https://www.scs.stanford.edu/~dm/blog/c++-coroutines.html
|
// from https://www.scs.stanford.edu/~dm/blog/c++-coroutines.html
|
||||||
|
|
||||||
|
namespace EightBit {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct co_generator_t final {
|
struct co_generator_t final {
|
||||||
|
|
||||||
@ -57,5 +57,4 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // USE_COROUTINES
|
|
@ -148,6 +148,7 @@
|
|||||||
<ClInclude Include="..\inc\Bus.h" />
|
<ClInclude Include="..\inc\Bus.h" />
|
||||||
<ClInclude Include="..\inc\Chip.h" />
|
<ClInclude Include="..\inc\Chip.h" />
|
||||||
<ClInclude Include="..\inc\ClockedChip.h" />
|
<ClInclude Include="..\inc\ClockedChip.h" />
|
||||||
|
<ClInclude Include="..\inc\co_generator_t.h" />
|
||||||
<ClInclude Include="..\inc\Device.h" />
|
<ClInclude Include="..\inc\Device.h" />
|
||||||
<ClInclude Include="..\inc\EightBitCompilerDefinitions.h" />
|
<ClInclude Include="..\inc\EightBitCompilerDefinitions.h" />
|
||||||
<ClInclude Include="..\inc\EventArgs.h" />
|
<ClInclude Include="..\inc\EventArgs.h" />
|
||||||
|
@ -77,6 +77,9 @@
|
|||||||
<ClInclude Include="..\inc\IntelHexFile.h">
|
<ClInclude Include="..\inc\IntelHexFile.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\inc\co_generator_t.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <coroutine>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user