fxos/shell/m.cpp

42 lines
1011 B
C++

#include "parser.h"
#include "shell.h"
//---
// ma
//---
static FxOS::Symbol parse_ma(Session &, Parser &parser)
{
Token t = parser.expect({T::NUM, T::SYSCALL});
FxOS::Symbol s;
if(t.type == T::SYSCALL)
s.type = FxOS::Symbol::Syscall;
else
s.type = FxOS::Symbol::Address;
s.value = t.value.NUM;
s.name = parser.symbol();
parser.end();
return s;
}
void _ma(Session &session, Symbol s)
{
if(!session.current_space)
return;
session.current_space->symbols.add(s);
}
static ShellCommand _ma_cmd(
"ma", [](Session &s, Parser &p) { _ma(s, parse_ma(s, p)); },
[](Session &s, Parser &p) { parse_ma(s, p); }, "Metadata Add", R"(
ma <address|syscall> <symbol>
Defines a new symbol at the specified address or syscall number in the current
virtual space. If a syscall number is provided, the address is not resolved; the
same syscall symbol can be used accross multiple OS versions regardless of where
the functions are actually located.
)");