mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
reggen-ng: add support for floating instances and nochild flag
Change-Id: I790149587b622f95f575964cd29caab4a0cff6d4
This commit is contained in:
parent
bcee6318f0
commit
89a9b5cf39
1 changed files with 33 additions and 7 deletions
|
@ -73,11 +73,14 @@ class Node:
|
||||||
return node
|
return node
|
||||||
|
|
||||||
class Instance:
|
class Instance:
|
||||||
def __init__(self, name, addr, stride=None, count=None):
|
def __init__(self, name, addr=None, stride=None, count=None,
|
||||||
|
floating=False, nochild=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.address = addr
|
self.address = addr
|
||||||
self.stride = stride
|
self.stride = stride
|
||||||
self.count = count
|
self.count = count
|
||||||
|
self.floating = floating
|
||||||
|
self.nochild = nochild
|
||||||
|
|
||||||
def gen(self):
|
def gen(self):
|
||||||
node = E("instance", E("name", self.name))
|
node = E("instance", E("name", self.name))
|
||||||
|
@ -88,9 +91,15 @@ class Instance:
|
||||||
E("count", self.count),
|
E("count", self.count),
|
||||||
E("base", self.address),
|
E("base", self.address),
|
||||||
E("stride", self.stride)))
|
E("stride", self.stride)))
|
||||||
else:
|
elif self.address is not None:
|
||||||
node.append(E("address", self.address))
|
node.append(E("address", self.address))
|
||||||
|
|
||||||
|
if self.floating:
|
||||||
|
node.append(E("floating", "1"))
|
||||||
|
|
||||||
|
if self.nochild:
|
||||||
|
node.append(E("nochild", "1"))
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
class Field:
|
class Field:
|
||||||
|
@ -262,19 +271,36 @@ class Parser:
|
||||||
|
|
||||||
def parse_instance(self, default_name):
|
def parse_instance(self, default_name):
|
||||||
words = self.parse_wordline(False)[0]
|
words = self.parse_wordline(False)[0]
|
||||||
|
is_floating = False
|
||||||
|
is_nochild = False
|
||||||
|
|
||||||
if len(words) == 1:
|
while len(words) > 0:
|
||||||
|
if words[0] == 'floating':
|
||||||
|
is_floating = True
|
||||||
|
elif words[0] == 'nochild':
|
||||||
|
is_nochild = True
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
words = words[1:]
|
||||||
|
|
||||||
|
if is_floating:
|
||||||
|
if len(words) != 0:
|
||||||
|
self.err('malformed instance statement')
|
||||||
|
return Instance(default_name, floating=True)
|
||||||
|
elif len(words) == 1:
|
||||||
# instance ADDR
|
# instance ADDR
|
||||||
return Instance(default_name, words[0])
|
return Instance(default_name, words[0], nochild=is_nochild)
|
||||||
elif len(words) == 2:
|
elif len(words) == 2:
|
||||||
# instance NAME ADDR
|
# instance NAME ADDR
|
||||||
return Instance(words[0], words[1])
|
return Instance(words[0], words[1], nochild=is_nochild)
|
||||||
elif len(words) == 3:
|
elif len(words) == 3:
|
||||||
# instance ADDR STRIDE COUNT
|
# instance ADDR STRIDE COUNT
|
||||||
return Instance(default_name, words[0], words[1], words[2])
|
return Instance(default_name, words[0], words[1], words[2],
|
||||||
|
nochild=is_nochild)
|
||||||
elif len(words) == 4:
|
elif len(words) == 4:
|
||||||
# instance NAME ADDR STRIDE COUNT
|
# instance NAME ADDR STRIDE COUNT
|
||||||
return Instance(words[0], words[1], words[2], words[3])
|
return Instance(words[0], words[1], words[2], words[3],
|
||||||
|
nochild=is_nochild)
|
||||||
else:
|
else:
|
||||||
self.err('malformed instance statement')
|
self.err('malformed instance statement')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue