59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#include "legacy.h"
|
|
#include "session.h"
|
|
#include "parser.h"
|
|
|
|
#include <fxos/util/log.h>
|
|
|
|
bool legacy_command(Session &session, std::string const &cmd, Parser &parser)
|
|
{
|
|
if(cmd == "vc") {
|
|
std::string name
|
|
= parser.at_end()
|
|
? session.legacyGenerateSpaceName("space", true)
|
|
: session.legacyGenerateSpaceName(parser.symbol(), false);
|
|
parser.end();
|
|
|
|
/* Construct a new legacy space at name */
|
|
session.legacySpaces[name];
|
|
session.legacyCurrentSpace = name;
|
|
return true;
|
|
}
|
|
else if(cmd == "vm") {
|
|
LegacyBinding b;
|
|
b.path = parser.str();
|
|
while(!parser.at_end())
|
|
b.regions.push_back(parser.region(nullptr));
|
|
parser.end();
|
|
|
|
session.legacySpaces[session.legacyCurrentSpace].bindings.push_back(b);
|
|
return true;
|
|
}
|
|
else if(cmd == "vs") {
|
|
std::string name = parser.symbol("vspace_name");
|
|
parser.end();
|
|
|
|
if(session.legacySpaces.count(name))
|
|
session.legacyCurrentSpace = name;
|
|
return true;
|
|
}
|
|
else if(cmd == "ms") {
|
|
auto &lvs = session.legacySpaces[session.legacyCurrentSpace];
|
|
|
|
if(parser.lookahead().type == T::SYSCALL) {
|
|
int id = parser.expect(T::SYSCALL).value.NUM;
|
|
lvs.syscalls[id] = parser.symbol();
|
|
}
|
|
else {
|
|
int addr = parser.expr(nullptr);
|
|
lvs.symbols[addr] = parser.symbol();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else if(cmd != "." && cmd != ".dt") {
|
|
FxOS_log(
|
|
WRN, "skipping unrecognized command '%s' in fxosrc", cmd.c_str());
|
|
}
|
|
return false;
|
|
}
|