[preproc] support arbitrary expressions in enums
This commit is contained in:
parent
3f49c5cbaf
commit
5c55cc3748
1 changed files with 22 additions and 4 deletions
|
@ -520,6 +520,7 @@ bool AsmFile::ParseEnum()
|
||||||
long currentHeaderLine = SkipWhitespaceAndEol();
|
long currentHeaderLine = SkipWhitespaceAndEol();
|
||||||
std::string enumName = ReadIdentifier();
|
std::string enumName = ReadIdentifier();
|
||||||
currentHeaderLine += SkipWhitespaceAndEol();
|
currentHeaderLine += SkipWhitespaceAndEol();
|
||||||
|
std::string enumBase = "0";
|
||||||
long enumCounter = 0;
|
long enumCounter = 0;
|
||||||
long symbolCount = 0;
|
long symbolCount = 0;
|
||||||
|
|
||||||
|
@ -542,11 +543,28 @@ bool AsmFile::ParseEnum()
|
||||||
if (m_buffer[m_pos] == '=')
|
if (m_buffer[m_pos] == '=')
|
||||||
{
|
{
|
||||||
m_pos++;
|
m_pos++;
|
||||||
currentHeaderLine += SkipWhitespaceAndEol();
|
SkipWhitespace();
|
||||||
enumCounter = ReadInteger(headerFilename, currentHeaderLine);
|
enumBase.clear();
|
||||||
currentHeaderLine += SkipWhitespaceAndEol();
|
for (;;)
|
||||||
|
{
|
||||||
|
if (m_pos == m_size)
|
||||||
|
RaiseError("unexpected EOF");
|
||||||
|
if (m_buffer[m_pos] == ',')
|
||||||
|
break;
|
||||||
|
if (m_buffer[m_pos] == '\n')
|
||||||
|
{
|
||||||
|
currentHeaderLine++;
|
||||||
|
enumBase.push_back(' ');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enumBase.push_back(m_buffer[m_pos]);
|
||||||
|
}
|
||||||
|
m_pos++;
|
||||||
|
}
|
||||||
|
enumCounter = 0;
|
||||||
}
|
}
|
||||||
std::printf(".equiv %s, %ld\n", currentIdentName.c_str(), enumCounter);
|
std::printf(".equiv %s, (%s) + %ld\n", currentIdentName.c_str(), enumBase.c_str(), enumCounter);
|
||||||
enumCounter++;
|
enumCounter++;
|
||||||
symbolCount++;
|
symbolCount++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue