Changeset 3037384 in mainline


Ignore:
Timestamp:
2009-09-17T20:36:20Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
82cf692
Parents:
810860a
Message:

support interface inheritance on protocol level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/arch/hadlbppp.py

    r810860a r3037384  
    3434import os
    3535
    36 # TODO:
    37 #  - interface inheritance
    38 
    3936INC, 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)
    4240
    4341def usage(prname):
     
    356354        return None
    357355
     356def 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
    358372def dump_frame(frame, outdir, var, archf):
    359373        "Dump Behavior Protocol of a given frame"
     
    374388                                if ('protocol' in iface):
    375389                                        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']))
    376392                        else:
    377393                                print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])
     
    973989                       
    974990                        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                                       
    9751029                                if (token == "{"):
    9761030                                        output += "%s" % token
     
    9861040                                        continue
    9871041                               
    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)
    9931043                                continue
    9941044                       
Note: See TracChangeset for help on using the changeset viewer.