diff options
author | 2019-06-27 16:26:55 -0700 | |
---|---|---|
committer | 2019-06-29 00:58:23 +0000 | |
commit | b839fbb52a3180bbac16a8f984cb11954a2a1837 (patch) | |
tree | d47ebc70705fee724b6f5519f5da80878f0d9341 | |
parent | 2ad19bc61d5f5a517ce95810ea326b8189f57262 (diff) |
ART: Allow arbitrary "expression" in generate_operator_out.py
Generalize the "literal" treatment to allow "expressions." As we lack a
real parser, define expression to be a comma-free string.
Bug: 121245951
Test: m test-art-host
Change-Id: If98cd9548359306daee05ed720667138ff1bb3a0
-rwxr-xr-x | tools/generate_operator_out.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/generate_operator_out.py b/tools/generate_operator_out.py index f909f8147b..921ae68bcb 100755 --- a/tools/generate_operator_out.py +++ b/tools/generate_operator_out.py @@ -149,26 +149,27 @@ def ProcessFile(filename): if enum_text.startswith('k'): enum_text = enum_text[1:] - # Lose literal values because we don't care; turn "= 123, // blah" into ", // blah". + # Check that we understand the line (and hopefully do not parse incorrectly), or should + # filter. rest = m.group(2).strip() - m_literal = re.search(r'= (0x[0-9a-f]+|-?[0-9]+|\'.\')', rest) - if m_literal: - rest = rest[(len(m_literal.group(0))):] # With "kSomeValue = kOtherValue," we take the original and skip later synonyms. # TODO: check that the rhs is actually an existing value. if rest.startswith('= k'): continue - # Remove any trailing comma and whitespace - if rest.startswith(','): - rest = rest[1:] - rest = rest.strip() + # Remove trailing comma. + if rest.endswith(','): + rest = rest[:-1] - # There shouldn't be anything left. + # We now expect rest to be empty, or an assignment to an "expression." if len(rest): - sys.stderr.write('%s\n' % (rest)) - Confused(filename, line_number, raw_line) + # We want to lose the expression "= [exp]". As we do not have a real C parser, just + # assume anything without a comma is valid. + m_exp = re.match('= [^,]+$', rest) + if m_exp is None: + sys.stderr.write('%s\n' % (rest)) + Confused(filename, line_number, raw_line) # If the enum is scoped, we must prefix enum value with enum name (which is already prefixed # by enclosing classes). |