mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +03:00
debugger: use 0o for octal prefix, and add support for binary with 0b a la C++, also support uppercase radix speifier
This commit is contained in:
parent
c399b811ea
commit
c9647f6e28
1
3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h
vendored
1
3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h
vendored
@ -7076,6 +7076,7 @@ static const char *ReadString(std::string *s, const char *ptr) {
|
||||
static bool ReadAttribute(std::string *name, std::string *type,
|
||||
std::vector<unsigned char> *data, size_t *marker_size,
|
||||
const char *marker, size_t size) {
|
||||
using namespace bx;
|
||||
size_t name_len = strnlen(marker, size);
|
||||
if (name_len == size) {
|
||||
// String does not have a terminating character.
|
||||
|
@ -925,38 +925,59 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *&
|
||||
if (buffer.compare("rshift") == 0)
|
||||
{ token.configure_operator(TVL_RSHIFT, 5); return; }
|
||||
|
||||
// if we have an 0x prefix, we must be a hex value
|
||||
if (buffer[0] == '0' && buffer[1] == 'x')
|
||||
return parse_number(token, buffer.c_str() + 2, 16, expression_error::INVALID_NUMBER);
|
||||
// if we have an 0 prefix, we must be an octal value
|
||||
else if (buffer[0] == '0')
|
||||
return parse_number(token, buffer.c_str() + 1, 8, expression_error::INVALID_NUMBER);
|
||||
|
||||
switch (buffer[0])
|
||||
{
|
||||
// if we have a # prefix, we must be a decimal value
|
||||
if (buffer[0] == '#')
|
||||
case '#':
|
||||
return parse_number(token, buffer.c_str() + 1, 10, expression_error::INVALID_NUMBER);
|
||||
|
||||
// if we have a $ prefix, we are a hex value
|
||||
if (buffer[0] == '$')
|
||||
case '$':
|
||||
return parse_number(token, buffer.c_str() + 1, 16, expression_error::INVALID_NUMBER);
|
||||
|
||||
// check for a symbol match
|
||||
symbol_entry *symbol = m_symtable->find_deep(buffer.c_str());
|
||||
if (symbol != nullptr)
|
||||
{
|
||||
token.configure_symbol(*symbol);
|
||||
|
||||
// if this is a function symbol, synthesize an execute function operator
|
||||
if (symbol->is_function())
|
||||
case '0':
|
||||
switch (buffer[1])
|
||||
{
|
||||
parse_token &newtoken = m_tokenlist.append(*global_alloc(parse_token(string - stringstart)));
|
||||
newtoken.configure_operator(TVL_EXECUTEFUNC, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// if we have an 0x prefix, we must be a hex value
|
||||
case 'x':
|
||||
case 'X':
|
||||
return parse_number(token, buffer.c_str() + 2, 16, expression_error::INVALID_NUMBER);
|
||||
|
||||
// attempt to parse as a number in the default base
|
||||
parse_number(token, buffer.c_str(), DEFAULT_BASE, expression_error::UNKNOWN_SYMBOL);
|
||||
// if we have an 0o prefix, we must be an octal value
|
||||
case 'o':
|
||||
case 'O':
|
||||
return parse_number(token, buffer.c_str() + 2, 8, expression_error::INVALID_NUMBER);
|
||||
|
||||
// if we have an 0b prefix, we must be a binary value
|
||||
case 'b':
|
||||
case 'B':
|
||||
return parse_number(token, buffer.c_str() + 2, 2, expression_error::INVALID_NUMBER);
|
||||
|
||||
// TODO: for octal address spaces, treat 0123 as octal
|
||||
default:
|
||||
; // fall through
|
||||
}
|
||||
// fall through
|
||||
|
||||
default:
|
||||
// check for a symbol match
|
||||
symbol_entry *symbol = m_symtable->find_deep(buffer.c_str());
|
||||
if (symbol != nullptr)
|
||||
{
|
||||
token.configure_symbol(*symbol);
|
||||
|
||||
// if this is a function symbol, synthesize an execute function operator
|
||||
if (symbol->is_function())
|
||||
{
|
||||
parse_token &newtoken = m_tokenlist.append(*global_alloc(parse_token(string - stringstart)));
|
||||
newtoken.configure_operator(TVL_EXECUTEFUNC, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// attempt to parse as a number in the default base
|
||||
parse_number(token, buffer.c_str(), DEFAULT_BASE, expression_error::UNKNOWN_SYMBOL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user