forked from Lephenixnoir/fxos
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#include "shell.h"
|
|
#include "parser.h"
|
|
|
|
//---
|
|
// .
|
|
//---
|
|
|
|
static std::vector<std::string> parse_dot(Session &, Parser &parser)
|
|
{
|
|
std::vector<std::string> files;
|
|
|
|
while(!parser.at_end())
|
|
files.push_back(parser.str());
|
|
|
|
return files;
|
|
}
|
|
|
|
void _dot(Session &s, std::vector<std::string> const &files, bool absolute)
|
|
{
|
|
std::vector<std::string> paths;
|
|
for(auto const &file: files) {
|
|
paths.push_back(absolute ? file : s.file(file).string());
|
|
}
|
|
lex_include(paths);
|
|
}
|
|
|
|
//---
|
|
// .dt
|
|
//---
|
|
|
|
static std::string parse_dot_dt(Session &session, Parser &parser)
|
|
{
|
|
std::string filename = parser.str();
|
|
parser.end();
|
|
return session.file(filename);
|
|
}
|
|
|
|
void _dot_dt(Session &, std::string filename)
|
|
{
|
|
Buffer buf(filename);
|
|
FxOS::load_instructions(buf);
|
|
}
|
|
|
|
//---
|
|
// Command registration
|
|
//---
|
|
|
|
static ShellCommand _dot_cmd(
|
|
".", [](Session &s, Parser &p) { _dot(s, parse_dot(s, p), false); },
|
|
[](Session &s, Parser &p) { parse_dot(s, p); }, "Include scripts", R"(
|
|
. "<script_1>" "<script_2>"...
|
|
|
|
Reads file paths from its string arguments, and executes each of them as a
|
|
sequence of commands in the order of the command line.
|
|
)");
|
|
|
|
static ShellCommand _dot_dt_cmd(
|
|
".dt", [](Session &s, Parser &p) { _dot_dt(s, parse_dot_dt(s, p)); },
|
|
[](Session &s, Parser &p) { parse_dot_dt(s, p); },
|
|
"Include Disassembly Table",
|
|
R"(
|
|
.dt "<file>"
|
|
|
|
Loads a disassembly table from the specified file. This command is mostly
|
|
designed to be used in startup scripts.
|
|
)");
|