aboutsummaryrefslogtreecommitdiffstats
path: root/src/xtools
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2016-10-11 06:19:19 +0200
committerTristan Gingold <tgingold@free.fr>2016-10-11 06:19:19 +0200
commitec63ed6f4287ef5a0a19817f3803972899cf7648 (patch)
treebe459880175235d631ac0f5249440d63cfc7a3de /src/xtools
parent498665c5328fa2c2e0a0d114e39c545d04fbdfe9 (diff)
downloadghdl-ec63ed6f4287ef5a0a19817f3803972899cf7648.tar.gz
ghdl-ec63ed6f4287ef5a0a19817f3803972899cf7648.tar.bz2
ghdl-ec63ed6f4287ef5a0a19817f3803972899cf7648.zip
Rework AST to setup ownership and reference policy.
Check it with nodes_gc.
Diffstat (limited to 'src/xtools')
-rwxr-xr-xsrc/xtools/pnodes.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/xtools/pnodes.py b/src/xtools/pnodes.py
index fad0922be..ce37556ea 100755
--- a/src/xtools/pnodes.py
+++ b/src/xtools/pnodes.py
@@ -21,7 +21,7 @@ class FuncDesc:
self.field = field
self.conv = conv
self.acc = acc # access: Chain, Chain_Next, Ref, Of_Ref, Maybe_Ref,
- # Forward_Ref
+ # Forward_Ref, Maybe_Forward_Ref
self.pname = pname # Parameter mame
self.ptype = ptype # Parameter type
self.rname = rname # value name (for procedure)
@@ -231,7 +231,7 @@ def read_kinds(filename):
funcs = []
pat_field = re.compile(
' -- Field: (\w+)'
- + '( Of_Ref| Ref| Maybe_Ref| Forward_Ref| Chain_Next| Chain)?( .*)?\n')
+ + '( Of_Ref| Ref| Maybe_Ref| Forward_Ref| Maybe_Forward_Ref| Chain_Next| Chain)?( .*)?\n')
pat_conv = re.compile('^ \((\w+)\)$')
pat_func = \
re.compile(' function Get_(\w+) \((\w+) : (\w+)\) return (\w+);\n')
@@ -666,7 +666,8 @@ elif args.action == 'meta_body':
elif l == ' -- FIELDS_ARRAY':
last = None
nodes_types = [node_type, node_type + '_List']
- ref_names = ['Ref', 'Of_Ref', 'Maybe_Ref', 'Forward_Ref']
+ ref_names = ['Ref', 'Of_Ref', 'Maybe_Ref', 'Forward_Ref',
+ 'Maybe_Forward_Ref']
for k in kinds:
v = nodes[k]
if last:
@@ -675,6 +676,13 @@ elif args.action == 'meta_body':
print ' -- ' + prefix_name + k
if flag_keep_order:
flds = v.order
+ elif True:
+ # first non Iir and no Iir_List
+ flds = sorted([fk for fk, fv in v.fields.items() \
+ if fv and fv.rtype not in nodes_types])
+ # Then Iir and Iir_List in order of appearance
+ flds += (fv for fv in v.order
+ if v.fields[fv].rtype in nodes_types)
else:
# Sort fields: first non Iir and non Iir_List,
# then Iir and Iir_List that aren't references
@@ -691,7 +699,8 @@ elif args.action == 'meta_body':
flds += sorted([fk for fk, fv in v.fields.items() \
if fv and fv.rtype in nodes_types\
and fv.acc in ['Ref', 'Of_Ref',
- 'Forward_Ref']])
+ 'Forward_Ref',
+ 'Maybe_Forward_Ref']])
for fk in flds:
if last:
print last + ','