Changeset 3037384 in mainline for contrib/arch/hadlbppp.py
- Timestamp:
- 2009-09-17T20:36:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 82cf692
- Parents:
- 810860a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
r810860a r3037384 34 34 import os 35 35 36 # TODO:37 # - interface inheritance38 39 36 INC, POST_INC, BLOCK_COMMENT, LINE_COMMENT, SYSTEM, ARCH, HEAD, BODY, NULL, \ 40 INST, VAR, FIN, BIND, TO, SUBSUME, DELEGATE, IFACE, PROTOTYPE, PAR_LEFT, \ 41 PAR_RIGHT, SIGNATURE, PROTOCOL, FRAME, PROVIDES, REQUIRES = range(25) 37 INST, VAR, FIN, BIND, TO, SUBSUME, DELEGATE, IFACE, EXTENDS, PRE_BODY, \ 38 PROTOTYPE, PAR_LEFT, PAR_RIGHT, SIGNATURE, PROTOCOL, FRAME, PROVIDES, \ 39 REQUIRES = range(27) 42 40 43 41 def usage(prname): … … 356 354 return None 357 355 356 def inherited_protocols(iface): 357 "Get protocols inherited by an interface" 358 359 result = [] 360 361 if ('extends' in iface): 362 supiface = get_iface(iface['extends']) 363 if (not supiface is None): 364 if ('protocol' in supiface): 365 result.append(supiface['protocol']) 366 result.extend(inherited_protocols(supiface)) 367 else: 368 print "%s: Extends unknown interface '%s'" % (iface['name'], iface['extends']) 369 370 return result 371 358 372 def dump_frame(frame, outdir, var, archf): 359 373 "Dump Behavior Protocol of a given frame" … … 374 388 if ('protocol' in iface): 375 389 protocols.append(extend_bp(outname, iface['protocol'], iface['name'])) 390 for protocol in inherited_protocols(iface): 391 protocols.append(extend_bp(outname, protocol, iface['name'])) 376 392 else: 377 393 print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface']) … … 973 989 974 990 if (HEAD in context): 991 if (PRE_BODY in context): 992 if (token == "{"): 993 output += "%s" % token 994 indent += 2 995 context.remove(PRE_BODY) 996 context.remove(HEAD) 997 context.add(BODY) 998 continue 999 1000 if (token == ";"): 1001 output += "%s\n" % token 1002 context.remove(PRE_BODY) 1003 context.remove(HEAD) 1004 context.remove(IFACE) 1005 continue 1006 1007 print "%s: Expected '{' or ';' in interface head '%s'" % (inname, interface) 1008 continue 1009 1010 if (EXTENDS in context): 1011 if (not identifier(token)): 1012 print "%s: Expected inherited interface name in interface head '%s'" % (inname, interface) 1013 else: 1014 output += " %s" % token 1015 if (not interface in iface_properties): 1016 iface_properties[interface] = {} 1017 1018 iface_properties[interface]['extends'] = token 1019 1020 context.remove(EXTENDS) 1021 context.add(PRE_BODY) 1022 continue 1023 1024 if (token == "extends"): 1025 output += " %s" % token 1026 context.add(EXTENDS) 1027 continue 1028 975 1029 if (token == "{"): 976 1030 output += "%s" % token … … 986 1040 continue 987 1041 988 if (not word(token)): 989 print "%s: Expected word in interface head '%s'" % (inname, interface) 990 else: 991 output += "%s " % token 992 1042 print "%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface) 993 1043 continue 994 1044
Note:
See TracChangeset
for help on using the changeset viewer.