move symbol lookup of sumof expr to the parser

replace the complicated symboltable lookup for sumof expr
by accessing the lenfield of the expr-object.

This requires the corresponding patch for xcb/proto
which sets the lenfield accordingly.

This should be OK because for official releases we define
that dependency in the build system.

For getting versions off the HEAD of the git repo, it should
be obvious that xcb/proto and xcb/libxcb have to be updated together.

I have tested this patch and it generates exactly the same code
as before.

Tested-by: Christian Linhart <chris@demorecorder.com>
Signed-off-by: Christian Linhart <chris@demorecorder.com>
This commit is contained in:
Christian Linhart 2017-01-20 14:40:25 +01:00
parent 65b298c7ca
commit 9bce1f72e3

View File

@ -1661,14 +1661,7 @@ def _c_accessor_get_expr(expr, field_mapping):
return c_name
elif expr.op == 'sumof':
# locate the referenced list object
field = None
for f in expr.lenfield_parent.fields:
if f.field_name == expr.lenfield_name:
field = f
break
if field is None:
raise Exception("list field '%s' referenced by sumof not found" % expr.lenfield_name)
field = expr.lenfield
list_name = field_mapping[field.c_field_name][0]
c_length_func = "%s(%s)" % (field.c_length_name, list_name)
c_length_func = _c_accessor_get_expr(field.type.expr, field_mapping)