From c9647f6e28ee464928f44a03c8b4d859ed95f2c3 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 6 Jan 2017 15:37:43 +1100 Subject: [PATCH] debugger: use 0o for octal prefix, and add support for binary with 0b a la C++, also support uppercase radix speifier --- 3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h | 1 + src/emu/debug/express.cpp | 69 +++++++++++++++--------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h b/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h index c0b84ef1b13..4482b82602f 100644 --- a/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h +++ b/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h @@ -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 *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. diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 16d69411179..a9f9e38816f 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -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); + } }