[err]202605041103
This commit is contained in:
1 parent
b717e89992
commit
2732990e75
3 files changed
+15
-2
No files matched your search
@@ -109,6 +109,7 @@ std::vector<rot8_bytecode> r8asm_tape_out(std::span<const R8Instruction> ops) {
|
||||
case r8asm_builtin::ANCHOR:
|
||||
expand_anchor(tape, it.arg);
|
||||
case r8asm_builtin::ERASE:
|
||||
break;
|
||||
expand_erase(tape, it.arg);
|
||||
break;
|
||||
default:;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "r8asm/r8asm_macro.hh"
|
||||
#include "r8asm/r8asm_core.hh"
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
std::map<std::string, R8Macro> macros = {
|
||||
@@ -50,4 +51,13 @@ std::vector<R8Instruction> expand_single_macro(std::string macro_name,
|
||||
|
||||
std::vector<R8Instruction> expand_macros(std::vector<R8Instruction> &ins) {
|
||||
std::vector<R8Instruction> out_tape;
|
||||
for (auto i : ins) {
|
||||
if (r8asm_macro *macro = std::get_if<r8asm_macro>(&i.op)) {
|
||||
std::vector<R8Instruction> tmp_tape =
|
||||
(expand_single_macro(macro->name, macro->args));
|
||||
out_tape.insert(out_tape.end(), tmp_tape.begin(), tmp_tape.end());
|
||||
} else
|
||||
out_tape.push_back(i);
|
||||
}
|
||||
return (out_tape);
|
||||
}
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "r8asm/r8asm.hh"
|
||||
#include "r8asm/r8asm_asm.hh"
|
||||
#include "r8asm/r8asm_core.hh"
|
||||
#include "r8asm/r8asm_macro.hh"
|
||||
|
||||
@@ -12,8 +13,9 @@ int main() {
|
||||
{r8asm_macro("STEP"), {15}},
|
||||
{rot8_bytecode::OUT},
|
||||
};
|
||||
auto out_tape = r8asm_tape_out(expand_macros(ins));
|
||||
|
||||
// for (const auto i : tape)
|
||||
// std::cout << ROT8_BC_TO_CHAR(i);
|
||||
// for (auto i : out_tape)
|
||||
// std::cout << ROT8_BC_TO_CHAR(i);
|
||||
return (0);
|
||||
}
|
||||
Reference in new issue
Block a user