From 7a1cf8379e9154267b951884c484d6a35e78d2c4 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 3 Oct 2023 15:29:55 +0100 Subject: [PATCH] move repeated code block to mini function for reading indented lines --- src/openpower/decoder/pseudo/pagereader.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/openpower/decoder/pseudo/pagereader.py b/src/openpower/decoder/pseudo/pagereader.py index 80a1a4c9..d3f51cd5 100644 --- a/src/openpower/decoder/pseudo/pagereader.py +++ b/src/openpower/decoder/pseudo/pagereader.py @@ -85,6 +85,17 @@ def operands(opcode, desc): if operand: yield operand +def get_indented_lines(lines): + li = [] + while lines: + l = lines.pop(0).rstrip() + if len(l) == 0: + break + assert l.startswith(' '), ("4spcs not found in line %s" % l) + l = l[4:] # lose 4 spaces + li.append(l) + return li + class ISA: def __init__(self): @@ -328,14 +339,7 @@ class ISA: assert len(l) == 0, ("blank line not found %s" % l) # get special regs - li = [] - while lines: - l = lines.pop(0).rstrip() - if len(l) == 0: - break - assert l.startswith(' '), ("4spcs not found in line %s" % l) - l = l[4:] # lose 4 spaces - li.append(l) + li = get_indented_lines(lines) d['sregs'] = li # add in opcode -- 2.30.2