xcbgen: new expr-type listelement-ref

Add parser-support for the new expression-type "listelement-ref"
which represents the current list-element when used inside
a list-iteration expression such as <sumof>.

This patch includes computation of the flag "contains_listelement_ref"
which is set to True when an expression or any of its
subexpressions is a listelement-ref.
(This is needed by the generator)

Message-ID: <1409845742-38797-2-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] support popcount of a list and associated xml changes
Patch-Set: PopcountList
Patch-Number: proto 2/8
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
This commit is contained in:
Christian Linhart 2014-09-04 17:48:56 +02:00
parent c9b1523b23
commit 408feddde3

View file

@ -53,6 +53,8 @@ class Expression(object):
self.lhs = None
self.rhs = None
self.contains_listelement_ref = False
if elt.tag == 'list':
# List going into a request, which has no length field (inferred by server)
self.lenfield_name = elt.get('name') + '_len'
@ -111,6 +113,11 @@ class Expression(object):
# sumof then returns the sum of the results of these evaluations
self.rhs = Expression(subexpressions[0], parent)
elif elt.tag == 'listelement-ref':
# current list element inside iterating expressions such as sumof
self.op = 'listelement-ref'
self.contains_listelement_ref = True
else:
# Notreached
raise Exception("undefined tag '%s'" % elt.tag)
@ -118,6 +125,12 @@ class Expression(object):
def fixed_size(self):
return self.nmemb != None
def recursive_resolve_tasks(self, module, parents):
for subexpr in (self.lhs, self.rhs):
if subexpr != None:
subexpr.recursive_resolve_tasks(module, parents)
self.contains_listelement_ref |= subexpr.contains_listelement_ref
def resolve(self, module, parents):
if self.op == 'enumref':
self.lenfield_type = module.get_type(self.lenfield_name[0])
@ -134,4 +147,6 @@ class Expression(object):
self.lenfield_parent = p
self.lenfield_type = fields[self.lenfield_name].field_type
break
self.recursive_resolve_tasks(module, parents)