Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/arch/hadlbppp.py

    raf6cad4 r3037384  
    3636INC, POST_INC, BLOCK_COMMENT, LINE_COMMENT, SYSTEM, ARCH, HEAD, BODY, NULL, \
    3737        INST, VAR, FIN, BIND, TO, SUBSUME, DELEGATE, IFACE, EXTENDS, PRE_BODY, \
    38         PROTOTYPE, PAR_LEFT, PAR_RIGHT, SIGNATURE, PROTOCOL, INITIALIZATION, \
    39         FINALIZATION, FRAME, PROVIDES, REQUIRES = range(29)
     38        PROTOTYPE, PAR_LEFT, PAR_RIGHT, SIGNATURE, PROTOCOL, FRAME, PROVIDES, \
     39        REQUIRES = range(27)
    4040
    4141def usage(prname):
    4242        "Print usage syntax"
    4343       
    44         print "%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname
    45         print
    46         print "--bp   Dump original Behavior Protocols (dChecker, BPSlicer)"
    47         print "--ebp  Dump Extended Behavior Protocols (bp2promela)"
    48         print "--adl  Dump Architecture Description Language (modified SOFA ADL/CDL)"
    49         print "--dot  Dump Dot architecture diagram (GraphViz)"
    50         print "--nop  Do not dump anything (just input files syntax check)"
    51         print
     44        print "%s <OUTPUT>" % prname
    5245
    5346def tabs(cnt):
     
    253246        "Convert interface Behavior Protocol to generic protocol"
    254247       
    255         result = []
     248        result = ["("]
    256249        i = 0
    257250       
     
    273266                i += 1
    274267       
     268        result.append(")")
     269        result.append("*")
     270       
    275271        return result
    276272
    277 def merge_bp(initialization, finalization, protocols):
     273def merge_bp(protocols):
    278274        "Merge several Behavior Protocols"
    279275       
    280         indep = []
    281        
    282276        if (len(protocols) > 1):
     277                result = []
    283278                first = True
    284279               
     
    287282                                first = False
    288283                        else:
    289                                 indep.append("|")
    290                        
    291                         indep.append("(")
    292                         indep.extend(protocol)
    293                         indep.append(")")
    294         elif (len(protocols) == 1):
    295                 indep = protocols[0]
    296        
    297         inited = []
    298        
    299         if (initialization != None):
    300                 if (len(indep) > 0):
    301                         inited.append("(")
    302                         inited.extend(initialization)
    303                         inited.append(")")
    304                         inited.append(";")
    305                         inited.append("(")
    306                         inited.extend(indep)
    307                         inited.append(")")
    308                 else:
    309                         inited = initialization
    310         else:
    311                 inited = indep
    312        
    313         finited = []
    314        
    315         if (finalization != None):
    316                 if (len(inited) > 0):
    317                         finited.append("(")
    318                         finited.extend(inited)
    319                         finited.append(")")
    320                         finited.append(";")
    321                         finited.append("(")
    322                         finited.extend(finalization)
    323                         finited.append(")")
    324                 else:
    325                         finited = finalization
    326         else:
    327                 finited = inited
    328        
    329         return finited
     284                                result.append("|")
     285                       
     286                        result.append("(")
     287                        result.extend(protocol)
     288                        result.append(")")
     289               
     290                return result
     291       
     292        if (len(protocols) == 1):
     293                return protocols[0]
     294       
     295        return []
    330296
    331297def parse_bp(name, tokens, base_indent):
     
    378344        return output
    379345
    380 def parse_ebp(component, name, tokens, base_indent):
    381         "Parse Behavior Protocol and generate Extended Behavior Protocol output"
    382        
    383         return "component %s {\n\tbehavior {\n\t\t%s\n\t}\n}" % (component, parse_bp(name, tokens, base_indent + 2))
    384 
    385346def get_iface(name):
    386347        "Get interface by name"
     
    409370        return result
    410371
    411 def dump_frame(directed_binds, frame, outdir, var, archf):
     372def dump_frame(frame, outdir, var, archf):
    412373        "Dump Behavior Protocol of a given frame"
    413374       
    414         global opt_bp
    415         global opt_ebp
    416        
    417         if (opt_ebp):
    418                 fname = "%s.ebp" % frame['name']
    419         else:
    420                 fname = "%s.bp" % frame['name']
    421        
    422         if (archf != None):
    423                 archf.write("instantiate %s from \"%s\"\n" % (var, fname))
    424        
     375        fname = "%s.bp" % frame['name']
     376       
     377        archf.write("instantiate %s from \"%s\"\n" % (var, fname))
    425378        outname = os.path.join(outdir, fname)
    426379       
     
    428381        if ('protocol' in frame):
    429382                protocols.append(frame['protocol'])
    430        
    431         if ('initialization' in frame):
    432                 initialization = frame['initialization']
    433         else:
    434                 initialization = None
    435        
    436         if ('finalization' in frame):
    437                 finalization = frame['finalization']
    438         else:
    439                 finalization = None
    440383       
    441384        if ('provides' in frame):
     
    443386                        iface = get_iface(provides['iface'])
    444387                        if (not iface is None):
    445                                 binds = directed_binds['%s.%s' % (var, provides['iface'])]
    446                                 if (not binds is None):
    447                                         cnt = len(binds)
    448                                 else:
    449                                         cnt = 1
    450                                
    451388                                if ('protocol' in iface):
    452                                         proto = extend_bp(outname, iface['protocol'], iface['name'])
    453                                         for _ in range(0, cnt):
    454                                                 protocols.append(proto)
    455                                
     389                                        protocols.append(extend_bp(outname, iface['protocol'], iface['name']))
    456390                                for protocol in inherited_protocols(iface):
    457                                         proto = extend_bp(outname, protocol, iface['name'])
    458                                         for _ in range(0, cnt):
    459                                                 protocols.append(proto)
     391                                        protocols.append(extend_bp(outname, protocol, iface['name']))
    460392                        else:
    461393                                print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])
    462394       
    463         if (opt_bp):
    464                 outf = file(outname, "w")
    465                 outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0))
    466                 outf.close()
    467        
    468         if (opt_ebp):
    469                 outf = file(outname, "w")
    470                 outf.write(parse_ebp(frame['name'], outname, merge_bp(initialization, finalization, protocols), 0))
    471                 outf.close()
     395        outf = file(outname, "w")
     396        outf.write(parse_bp(outname, merge_bp(protocols), 0))
     397        outf.close()
    472398
    473399def get_system_arch():
     
    505431        "Create null frame protocol"
    506432       
    507         global opt_bp
    508         global opt_ebp
    509        
    510         if (archf != None):
    511                 archf.write("frame \"%s\"\n" % fname)
    512        
     433        archf.write("frame \"%s\"\n" % fname)
    513434        outname = os.path.join(outdir, fname)
    514435       
    515         if (opt_bp):
    516                 outf = file(outname, "w")
    517                 outf.write("NULL")
    518                 outf.close()
    519        
    520         if (opt_ebp):
    521                 outf = file(outname, "w")
    522                 outf.write("component null {\n\tbehavior {\n\t\tNULL\n\t}\n}")
    523                 outf.close()
     436        outf = file(outname, "w")
     437        outf.write("NULL")
     438        outf.close()
    524439
    525440def flatten_binds(binds, delegates, subsumes):
     
    565480        return result
    566481
    567 def merge_arch(prefix, arch, outdir):
    568         "Merge subarchitecture into architecture"
     482def merge_subarch(prefix, arch, outdir):
     483        "Merge subarchitecture into architexture"
    569484       
    570485        insts = []
     
    577492                        subarch = get_arch(inst['type'])
    578493                        if (not subarch is None):
    579                                 (subinsts, subbinds, subdelegates, subsubsumes) = merge_arch("%s_%s" % (prefix, subarch['name']), subarch, outdir)
     494                                (subinsts, subbinds, subdelegates, subsubsumes) = merge_subarch("%s_%s" % (prefix, subarch['name']), subarch, outdir)
    580495                                insts.extend(subinsts)
    581496                                binds.extend(subbinds)
     
    606521        "Dump system architecture Behavior Protocol"
    607522       
    608         global opt_bp
    609         global opt_ebp
    610        
    611523        arch = get_system_arch()
    612524       
     
    624536                        subarch = get_arch(inst['type'])
    625537                        if (not subarch is None):
    626                                 (subinsts, subbinds, subdelegates, subsubsumes) = merge_arch(subarch['name'], subarch, outdir)
     538                                (subinsts, subbinds, subdelegates, subsubsumes) = merge_subarch(subarch['name'], subarch, outdir)
    627539                                insts.extend(subinsts)
    628540                                binds.extend(subbinds)
     
    650562                        break
    651563       
     564        outname = os.path.join(outdir, "%s.archbp" % arch['name'])
     565        outf = file(outname, "w")
     566       
     567        create_null_bp("null.bp", outdir, outf)
     568       
     569        for inst in insts:
     570                dump_frame(inst['frame'], outdir, inst['var'], outf)
     571       
    652572        directed_binds = direct_binds(flatten_binds(binds, delegates, subsumes))
    653573       
    654         outname = os.path.join(outdir, "%s.archbp" % arch['name'])
    655         if ((opt_bp) or (opt_ebp)):
    656                 outf = file(outname, "w")
    657         else:
    658                 outf = None
    659        
    660         create_null_bp("null.bp", outdir, outf)
    661        
    662         for inst in insts:
    663                 dump_frame(directed_binds, inst['frame'], outdir, inst['var'], outf)
    664        
    665574        for dst, src in directed_binds.items():
    666                 if (outf != None):
    667                         outf.write("bind %s to %s\n" % (", ".join(src), dst))
    668        
    669         if (outf != None):
    670                 outf.close()
     575                outf.write("bind %s to %s\n" % (", ".join(src), dst))
     576       
     577        outf.close()
    671578
    672579def preproc_adl(raw, inarg):
     
    684591        global frame
    685592        global protocol
    686         global initialization
    687         global finalization
    688593       
    689594        global iface_properties
     
    784689                       
    785690                        if (BODY in context):
    786                                 if (FINALIZATION in context):
    787                                         if (token == "{"):
    788                                                 indent += 1
    789                                         elif (token == "}"):
    790                                                 indent -= 1
    791                                        
    792                                         if (((token[-1] == ":") and (indent == 0)) or (indent == -1)):
    793                                                 bp = split_bp(finalization)
    794                                                 finalization = None
    795                                                
    796                                                 if (not frame in frame_properties):
    797                                                         frame_properties[frame] = {}
    798                                                
    799                                                 if ('finalization' in frame_properties[frame]):
    800                                                         print "%s: Finalization protocol for frame '%s' already defined" % (inname, frame)
    801                                                 else:
    802                                                         frame_properties[frame]['finalization'] = bp
    803                                                
    804                                                 output += "\n%s" % tabs(2)
    805                                                 output += parse_bp(inname, bp, 2)
    806                                                
    807                                                 context.remove(FINALIZATION)
    808                                                 if (indent == -1):
    809                                                         output += "\n%s" % token
    810                                                         context.remove(BODY)
    811                                                         context.add(NULL)
    812                                                         indent = 0
    813                                                         continue
    814                                                 else:
    815                                                         indent = 2
    816                                         else:
    817                                                 finalization += token
    818                                                 continue
    819                                
    820                                 if (INITIALIZATION in context):
    821                                         if (token == "{"):
    822                                                 indent += 1
    823                                         elif (token == "}"):
    824                                                 indent -= 1
    825                                        
    826                                         if (((token[-1] == ":") and (indent == 0)) or (indent == -1)):
    827                                                 bp = split_bp(initialization)
    828                                                 initialization = None
    829                                                
    830                                                 if (not frame in frame_properties):
    831                                                         frame_properties[frame] = {}
    832                                                
    833                                                 if ('initialization' in frame_properties[frame]):
    834                                                         print "%s: Initialization protocol for frame '%s' already defined" % (inname, frame)
    835                                                 else:
    836                                                         frame_properties[frame]['initialization'] = bp
    837                                                
    838                                                 output += "\n%s" % tabs(2)
    839                                                 output += parse_bp(inname, bp, 2)
    840                                                
    841                                                 context.remove(INITIALIZATION)
    842                                                 if (indent == -1):
    843                                                         output += "\n%s" % token
    844                                                         context.remove(BODY)
    845                                                         context.add(NULL)
    846                                                         indent = 0
    847                                                         continue
    848                                                 else:
    849                                                         indent = 2
    850                                         else:
    851                                                 initialization += token
    852                                                 continue
    853                                
    854691                                if (PROTOCOL in context):
    855692                                        if (token == "{"):
     
    858695                                                indent -= 1
    859696                                       
    860                                         if (((token[-1] == ":") and (indent == 0)) or (indent == -1)):
     697                                        if (indent == -1):
    861698                                                bp = split_bp(protocol)
    862699                                                protocol = None
     
    872709                                                output += "\n%s" % tabs(2)
    873710                                                output += parse_bp(inname, bp, 2)
     711                                                output += "\n%s" % token
     712                                                indent = 0
    874713                                               
    875714                                                context.remove(PROTOCOL)
    876                                                 if (indent == -1):
    877                                                         output += "\n%s" % token
    878                                                         context.remove(BODY)
    879                                                         context.add(NULL)
    880                                                         indent = 0
    881                                                         continue
    882                                                 else:
    883                                                         indent = 2
     715                                                context.remove(BODY)
     716                                                context.add(NULL)
    884717                                        else:
    885718                                                protocol += token
    886                                                 continue
     719                                       
     720                                        continue
    887721                               
    888722                                if (REQUIRES in context):
     
    982816                                        output += "\n%s%s" % (tabs(indent - 1), token)
    983817                                        context.add(PROVIDES)
     818                                        protocol = ""
    984819                                        continue
    985820                               
     
    987822                                        output += "\n%s%s" % (tabs(indent - 1), token)
    988823                                        context.add(REQUIRES)
    989                                         continue
    990                                
    991                                 if (token == "initialization:"):
    992                                         output += "\n%s%s" % (tabs(indent - 1), token)
    993                                         indent = 0
    994                                         context.add(INITIALIZATION)
    995                                         initialization = ""
    996                                         continue
    997                                
    998                                 if (token == "finalization:"):
    999                                         output += "\n%s%s" % (tabs(indent - 1), token)
    1000                                         indent = 0
    1001                                         context.add(FINALIZATION)
    1002                                         finalization = ""
     824                                        protocol = ""
    1003825                                        continue
    1004826                               
     
    11901012                                                print "%s: Expected inherited interface name in interface head '%s'" % (inname, interface)
    11911013                                        else:
    1192                                                 output += "%s " % token
     1014                                                output += " %s" % token
    11931015                                                if (not interface in iface_properties):
    11941016                                                        iface_properties[interface] = {}
     
    12011023                               
    12021024                                if (token == "extends"):
    1203                                         output += "%s " % token
     1025                                        output += " %s" % token
    12041026                                        context.add(EXTENDS)
    12051027                                        continue
     
    15541376        global frame
    15551377        global protocol
    1556         global initialization
    1557         global finalization
    15581378       
    15591379        global arg0
    1560        
    1561         global opt_adl
    15621380       
    15631381        output = ""
     
    15671385        frame = None
    15681386        protocol = None
    1569         initialization = None
    1570         finalization = None
    15711387        arg0 = None
    15721388       
     
    15741390        output = output.strip()
    15751391       
    1576         if ((output != "") and (opt_adl)):
     1392        if (output != ""):
    15771393                outf = file(outname, "w")
    15781394                outf.write(output)
     
    15951411                if (os.path.isdir(canon)):
    15961412                        recursion(base, canon, output, level + 1)
    1597 
    1598 def merge_dot_frame(prefix, name, frame, outf, indent):
    1599         "Dump Dot frame"
    1600        
    1601         outf.write("%ssubgraph cluster_%s {\n" % (tabs(indent), prefix))
    1602         outf.write("%s\tlabel=\"%s\";\n" % (tabs(indent), name))
    1603         outf.write("%s\tstyle=filled;\n" % tabs(indent))
    1604         outf.write("%s\tcolor=red;\n" % tabs(indent))
    1605         outf.write("%s\tfillcolor=yellow;\n" % tabs(indent))
    1606         outf.write("%s\t\n" % tabs(indent))
    1607        
    1608         if ('provides' in frame):
    1609                 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, style=filled, color=green, fillcolor=yellow];\n" % (tabs(indent), prefix))
    1610        
    1611         if ('requires' in frame):
    1612                 outf.write("%s\t%s__requires [label=\"\", shape=circle, style=filled, color=red, fillcolor=yellow];\n" % (tabs(indent), prefix))
    1613        
    1614         outf.write("%s}\n" % tabs(indent))
    1615         outf.write("%s\n" % tabs(indent))
    1616 
    1617 def merge_dot_arch(prefix, name, arch, outf, indent):
    1618         "Dump Dot subarchitecture"
    1619        
    1620         outf.write("%ssubgraph cluster_%s {\n" % (tabs(indent), prefix))
    1621         outf.write("%s\tlabel=\"%s\";\n" % (tabs(indent), name))
    1622         outf.write("%s\tcolor=red;\n" % tabs(indent))
    1623         outf.write("%s\t\n" % tabs(indent))
    1624        
    1625         if ('inst' in arch):
    1626                 for inst in arch['inst']:
    1627                         subarch = get_arch(inst['type'])
    1628                         if (not subarch is None):
    1629                                 merge_dot_arch("%s_%s" % (prefix, inst['var']), inst['var'], subarch, outf, indent + 1)
    1630                         else:
    1631                                 subframe = get_frame(inst['type'])
    1632                                 if (not subframe is None):
    1633                                         merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1)
    1634                                 else:
    1635                                         print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
    1636        
    1637         if ('bind' in arch):
    1638                 labels = {}
    1639                 for bind in arch['bind']:
    1640                         if (bind['from'][1] != bind['to'][1]):
    1641                                 label = "%s:%s" % (bind['from'][1], bind['to'][1])
    1642                         else:
    1643                                 label = bind['from'][1]
    1644                        
    1645                         if (not (bind['from'][0], bind['to'][0]) in labels):
    1646                                 labels[(bind['from'][0], bind['to'][0])] = []
    1647                        
    1648                         labels[(bind['from'][0], bind['to'][0])].append(label)
    1649                
    1650                 for bind in arch['bind']:
    1651                         if (not (bind['from'][0], bind['to'][0]) in labels):
    1652                                 continue
    1653                        
    1654                         attrs = []
    1655                        
    1656                         if (bind['from'][0] != bind['to'][0]):
    1657                                 attrs.append("ltail=cluster_%s_%s" % (prefix, bind['from'][0]))
    1658                                 attrs.append("lhead=cluster_%s_%s" % (prefix, bind['to'][0]))
    1659                        
    1660                         attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])]))
    1661                         del labels[(bind['from'][0], bind['to'][0])]
    1662                        
    1663                         outf.write("%s\t%s_%s__requires -> %s_%s__provides [%s];\n" % (tabs(indent), prefix, bind['from'][0], prefix, bind['to'][0], ", ".join(attrs)))
    1664        
    1665         if ('delegate' in arch):
    1666                 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, color=green];\n" % (tabs(indent), prefix))
    1667                
    1668                 labels = {}
    1669                 for delegate in arch['delegate']:
    1670                         if (delegate['from'] != delegate['to'][1]):
    1671                                 label = "%s:%s" % (delegate['from'], delegate['to'][1])
    1672                         else:
    1673                                 label = delegate['from']
    1674                        
    1675                         if (not delegate['to'][0] in labels):
    1676                                 labels[delegate['to'][0]] = []
    1677                        
    1678                         labels[delegate['to'][0]].append(label)
    1679                
    1680                 for delegate in arch['delegate']:
    1681                         if (not delegate['to'][0] in labels):
    1682                                 continue
    1683                        
    1684                         attrs = []
    1685                         attrs.append("color=gray")
    1686                         attrs.append("lhead=cluster_%s_%s" % (prefix, delegate['to'][0]))
    1687                         attrs.append("label=\"%s\"" % "\\n".join(labels[delegate['to'][0]]))
    1688                         del labels[delegate['to'][0]]
    1689                        
    1690                         outf.write("%s\t%s__provides -> %s_%s__provides [%s];\n" % (tabs(indent), prefix, prefix, delegate['to'][0], ", ".join(attrs)))
    1691        
    1692         if ('subsume' in arch):
    1693                 outf.write("%s\t%s__requires [label=\"\", shape=circle, color=red];\n" % (tabs(indent), prefix))
    1694                
    1695                 labels = {}
    1696                 for subsume in arch['subsume']:
    1697                         if (subsume['from'][1] != subsume['to']):
    1698                                 label = "%s:%s" % (subsume['from'][1], subsume['to'])
    1699                         else:
    1700                                 label = subsume['to']
    1701                        
    1702                         if (not subsume['from'][0] in labels):
    1703                                 labels[subsume['from'][0]] = []
    1704                        
    1705                         labels[subsume['from'][0]].append(label)
    1706                
    1707                 for subsume in arch['subsume']:
    1708                         if (not subsume['from'][0] in labels):
    1709                                 continue
    1710                        
    1711                         attrs = []
    1712                         attrs.append("color=gray")
    1713                         attrs.append("ltail=cluster_%s_%s" % (prefix, subsume['from'][0]))
    1714                         attrs.append("label=\"%s\"" % "\\n".join(labels[subsume['from'][0]]))
    1715                         del labels[subsume['from'][0]]
    1716                        
    1717                         outf.write("%s\t%s_%s__requires -> %s__requires [%s];\n" % (tabs(indent), prefix, subsume['from'][0], prefix, ", ".join(attrs)))
    1718        
    1719         outf.write("%s}\n" % tabs(indent))
    1720         outf.write("%s\n" % tabs(indent))
    1721 
    1722 def dump_dot(outdir):
    1723         "Dump Dot architecture"
    1724        
    1725         global opt_dot
    1726        
    1727         arch = get_system_arch()
    1728        
    1729         if (arch is None):
    1730                 print "Unable to find system architecture"
    1731                 return
    1732        
    1733         if (opt_dot):
    1734                 outname = os.path.join(outdir, "%s.dot" % arch['name'])
    1735                 outf = file(outname, "w")
    1736                
    1737                 outf.write("digraph {\n")
    1738                 outf.write("\tlabel=\"%s\";\n" % arch['name'])
    1739                 outf.write("\tcompound=true;\n")
    1740                 outf.write("\tsplines=\"polyline\";\n")
    1741                 outf.write("\tedge [fontsize=8];\n")
    1742                 outf.write("\t\n")
    1743                
    1744                 if ('inst' in arch):
    1745                         for inst in arch['inst']:
    1746                                 subarch = get_arch(inst['type'])
    1747                                 if (not subarch is None):
    1748                                         merge_dot_arch(inst['var'], inst['var'], subarch, outf, 1)
    1749                                 else:
    1750                                         subframe = get_frame(inst['type'])
    1751                                         if (not subframe is None):
    1752                                                 merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1)
    1753                                         else:
    1754                                                 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
    1755                
    1756                 if ('bind' in arch):
    1757                         labels = {}
    1758                         for bind in arch['bind']:
    1759                                 if (bind['from'][1] != bind['to'][1]):
    1760                                         label = "%s:%s" % (bind['from'][1], bind['to'][1])
    1761                                 else:
    1762                                         label = bind['from'][1]
    1763                                
    1764                                 if (not (bind['from'][0], bind['to'][0]) in labels):
    1765                                         labels[(bind['from'][0], bind['to'][0])] = []
    1766                                
    1767                                 labels[(bind['from'][0], bind['to'][0])].append(label)
    1768                        
    1769                         for bind in arch['bind']:
    1770                                 if (not (bind['from'][0], bind['to'][0]) in labels):
    1771                                         continue
    1772                                
    1773                                 attrs = []
    1774                                
    1775                                 if (bind['from'][0] != bind['to'][0]):
    1776                                         attrs.append("ltail=cluster_%s" % bind['from'][0])
    1777                                         attrs.append("lhead=cluster_%s" % bind['to'][0])
    1778                                
    1779                                 attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])]))
    1780                                 del labels[(bind['from'][0], bind['to'][0])]
    1781                                
    1782                                 outf.write("\t%s__requires -> %s__provides [%s];\n" % (bind['from'][0], bind['to'][0], ", ".join(attrs)))
    1783                
    1784                 if ('delegate' in arch):
    1785                         for delegate in arch['delegate']:
    1786                                 print "Unable to delegate interface in system architecture"
    1787                                 break
    1788                
    1789                 if ('subsume' in arch):
    1790                         for subsume in arch['subsume']:
    1791                                 print "Unable to subsume interface in system architecture"
    1792                                 break
    1793                
    1794                 outf.write("}\n")
    1795                
    1796                 outf.close()
    17971413
    17981414def main():
     
    18001416        global frame_properties
    18011417        global arch_properties
    1802         global opt_bp
    1803         global opt_ebp
    1804         global opt_adl
    1805         global opt_dot
    1806        
    1807         if (len(sys.argv) < 3):
     1418       
     1419        if (len(sys.argv) < 2):
    18081420                usage(sys.argv[0])
    18091421                return
    18101422       
    1811         opt_bp = False
    1812         opt_ebp = False
    1813         opt_adl = False
    1814         opt_dot = False
    1815        
    1816         for arg in sys.argv[1:(len(sys.argv) - 1)]:
    1817                 if (arg == "--bp"):
    1818                         opt_bp = True
    1819                 elif (arg == "--ebp"):
    1820                         opt_ebp = True
    1821                 elif (arg == "--adl"):
    1822                         opt_adl = True
    1823                 elif (arg == "--dot"):
    1824                         opt_dot = True
    1825                 elif (arg == "--nop"):
    1826                         pass
    1827                 else:
    1828                         print "Error: Unknown command line option '%s'" % arg
    1829                         return
    1830        
    1831         if ((opt_bp) and (opt_ebp)):
    1832                 print "Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols"
    1833                 return
    1834        
    1835         path = os.path.abspath(sys.argv[-1])
     1423        path = os.path.abspath(sys.argv[1])
    18361424        if (not os.path.isdir(path)):
    18371425                print "Error: <OUTPUT> is not a directory"
     
    18441432        recursion(".", ".", path, 0)
    18451433        dump_archbp(path)
    1846         dump_dot(path)
    18471434
    18481435if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.