Changeset a35b458 in mainline for contrib/arch/hadlbppp.py
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
r3061bc1 ra35b458 41 41 def usage(prname): 42 42 "Print usage syntax" 43 43 44 44 print("%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname) 45 45 print() … … 53 53 def tabs(cnt): 54 54 "Return given number of tabs" 55 55 56 56 return ("\t" * cnt) 57 57 58 58 def cond_append(tokens, token, trim): 59 59 "Conditionally append token to tokens with trim" 60 60 61 61 if (trim): 62 62 token = token.strip(" \t") 63 63 64 64 if (token != ""): 65 65 tokens.append(token) 66 66 67 67 return tokens 68 68 69 69 def split_tokens(string, delimiters, trim = False, separate = False): 70 70 "Split string to tokens by delimiters, keep the delimiters" 71 71 72 72 tokens = [] 73 73 last = 0 74 74 i = 0 75 75 76 76 while (i < len(string)): 77 77 for delim in delimiters: 78 78 if (len(delim) > 0): 79 79 80 80 if (string[i:(i + len(delim))] == delim): 81 81 if (separate): … … 86 86 tokens = cond_append(tokens, string[last:i], trim) 87 87 last = i 88 88 89 89 i += len(delim) - 1 90 90 break 91 91 92 92 i += 1 93 93 94 94 tokens = cond_append(tokens, string[last:len(string)], trim) 95 95 96 96 return tokens 97 97 98 98 def identifier(token): 99 99 "Check whether the token is an identifier" 100 100 101 101 if (len(token) == 0): 102 102 return False 103 103 104 104 for i, char in enumerate(token): 105 105 if (i == 0): … … 109 109 if ((not char.isalnum()) and (char != "_")): 110 110 return False 111 111 112 112 return True 113 113 114 114 def descriptor(token): 115 115 "Check whether the token is an interface descriptor" 116 116 117 117 parts = token.split(":") 118 118 if (len(parts) != 2): 119 119 return False 120 120 121 121 return (identifier(parts[0]) and identifier(parts[1])) 122 122 123 123 def word(token): 124 124 "Check whether the token is a word" 125 125 126 126 if (len(token) == 0): 127 127 return False 128 128 129 129 for i, char in enumerate(token): 130 130 if ((not char.isalnum()) and (char != "_") and (char != ".")): 131 131 return False 132 132 133 133 return True 134 134 135 135 def tentative_bp(name, tokens): 136 136 "Preprocess tentative statements in Behavior Protocol" 137 137 138 138 result = [] 139 139 i = 0 140 140 141 141 while (i < len(tokens)): 142 142 if (tokens[i] == "tentative"): … … 145 145 start = i 146 146 level = 1 147 147 148 148 while ((i < len(tokens)) and (level > 0)): 149 149 if (tokens[i] == "{"): … … 151 151 elif (tokens[i] == "}"): 152 152 level -= 1 153 153 154 154 i += 1 155 155 156 156 if (level == 0): 157 157 result.append("(") … … 168 168 else: 169 169 result.append(tokens[i]) 170 170 171 171 i += 1 172 172 173 173 return result 174 174 175 175 def alternative_bp(name, tokens): 176 176 "Preprocess alternative statements in Behavior Protocol" 177 177 178 178 result = [] 179 179 i = 0 180 180 181 181 while (i < len(tokens)): 182 182 if (tokens[i] == "alternative"): … … 184 184 i += 2 185 185 reps = [] 186 186 187 187 while ((i < len(tokens)) and (tokens[i] != ")")): 188 188 reps.append(tokens[i]) … … 191 191 else: 192 192 i += 1 193 193 194 194 if (len(reps) >= 2): 195 195 if ((i + 1 < len(tokens)) and (tokens[i + 1] == "{")): 196 196 i += 2 197 197 198 198 start = i 199 199 level = 1 200 200 201 201 while ((i < len(tokens)) and (level > 0)): 202 202 if (tokens[i] == "{"): … … 204 204 elif (tokens[i] == "}"): 205 205 level -= 1 206 206 207 207 i += 1 208 208 209 209 if (level == 0): 210 210 first = True 211 211 212 212 for rep in reps[1:]: 213 213 retokens = [] … … 218 218 else: 219 219 retokens.append(token) 220 220 221 221 if (first): 222 222 first = False 223 223 else: 224 224 result.append("+") 225 225 226 226 result.append("(") 227 227 result.extend(alternative_bp(name, retokens)) 228 228 result.append(")") 229 229 230 230 if (i < len(tokens)): 231 231 result.append(tokens[i]) … … 240 240 else: 241 241 result.append(tokens[i]) 242 242 243 243 i += 1 244 244 245 245 return result 246 246 247 247 def split_bp(protocol): 248 248 "Convert Behavior Protocol to tokens" 249 249 250 250 return split_tokens(protocol, ["\n", " ", "\t", "(", ")", "{", "}", "*", ";", "+", "||", "|", "!", "?"], True, True) 251 251 252 252 def extend_bp(name, tokens, iface): 253 253 "Convert interface Behavior Protocol to generic protocol" 254 254 255 255 result = [] 256 256 i = 0 257 257 258 258 while (i < len(tokens)): 259 259 result.append(tokens[i]) 260 260 261 261 if (tokens[i] == "?"): 262 262 if (i + 1 < len(tokens)): 263 263 i += 1 264 264 parts = tokens[i].split(".") 265 265 266 266 if (len(parts) == 1): 267 267 result.append("%s.%s" % (iface, tokens[i])) … … 270 270 else: 271 271 print("%s: Unexpected end of protocol" % name) 272 272 273 273 i += 1 274 274 275 275 return result 276 276 277 277 def merge_bp(initialization, finalization, protocols): 278 278 "Merge several Behavior Protocols" 279 279 280 280 indep = [] 281 281 282 282 if (len(protocols) > 1): 283 283 first = True 284 284 285 285 for protocol in protocols: 286 286 if (first): … … 288 288 else: 289 289 indep.append("|") 290 290 291 291 indep.append("(") 292 292 indep.extend(protocol) … … 294 294 elif (len(protocols) == 1): 295 295 indep = protocols[0] 296 296 297 297 inited = [] 298 298 299 299 if (initialization != None): 300 300 if (len(indep) > 0): … … 310 310 else: 311 311 inited = indep 312 312 313 313 finited = [] 314 314 315 315 if (finalization != None): 316 316 if (len(inited) > 0): … … 326 326 else: 327 327 finited = inited 328 328 329 329 return finited 330 330 331 331 def parse_bp(name, tokens, base_indent): 332 332 "Parse Behavior Protocol" 333 333 334 334 tokens = tentative_bp(name, tokens) 335 335 tokens = alternative_bp(name, tokens) 336 336 337 337 indent = base_indent 338 338 output = "" 339 339 340 340 for token in tokens: 341 341 if (token == "\n"): 342 342 continue 343 343 344 344 if ((token == ";") or (token == "+") or (token == "||") or (token == "|")): 345 345 output += " %s" % token … … 350 350 if (indent < base_indent): 351 351 print("%s: Too many parentheses" % name) 352 352 353 353 indent -= 1 354 354 output += "\n%s%s" % (tabs(indent), token) … … 359 359 if (indent < base_indent): 360 360 print("%s: Too many parentheses" % name) 361 361 362 362 indent -= 1 363 363 output += "\n%s%s" % (tabs(indent), token) … … 368 368 else: 369 369 output += "%s" % token 370 370 371 371 if (indent > base_indent): 372 372 print("%s: Missing parentheses" % name) 373 373 374 374 output = output.strip() 375 375 if (output == ""): 376 376 return "NULL" 377 377 378 378 return output 379 379 380 380 def parse_ebp(component, name, tokens, base_indent): 381 381 "Parse Behavior Protocol and generate Extended Behavior Protocol output" 382 382 383 383 return "component %s {\n\tbehavior {\n\t\t%s\n\t}\n}" % (component, parse_bp(name, tokens, base_indent + 2)) 384 384 385 385 def get_iface(name): 386 386 "Get interface by name" 387 387 388 388 global iface_properties 389 389 390 390 if (name in iface_properties): 391 391 return iface_properties[name] 392 392 393 393 return None 394 394 395 395 def inherited_protocols(iface): 396 396 "Get protocols inherited by an interface" 397 397 398 398 result = [] 399 399 400 400 if ('extends' in iface): 401 401 supiface = get_iface(iface['extends']) … … 406 406 else: 407 407 print("%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])) 408 408 409 409 return result 410 410 411 411 def dump_frame(directed_binds, frame, outdir, var, archf): 412 412 "Dump Behavior Protocol of a given frame" 413 413 414 414 global opt_bp 415 415 global opt_ebp 416 416 417 417 if (opt_ebp): 418 418 fname = "%s.ebp" % frame['name'] 419 419 else: 420 420 fname = "%s.bp" % frame['name'] 421 421 422 422 if (archf != None): 423 423 archf.write("instantiate %s from \"%s\"\n" % (var, fname)) 424 424 425 425 outname = os.path.join(outdir, fname) 426 426 427 427 protocols = [] 428 428 if ('protocol' in frame): 429 429 protocols.append(frame['protocol']) 430 430 431 431 if ('initialization' in frame): 432 432 initialization = frame['initialization'] 433 433 else: 434 434 initialization = None 435 435 436 436 if ('finalization' in frame): 437 437 finalization = frame['finalization'] 438 438 else: 439 439 finalization = None 440 440 441 441 if ('provides' in frame): 442 442 for provides in frame['provides']: … … 448 448 else: 449 449 cnt = 1 450 450 451 451 if ('protocol' in iface): 452 452 proto = extend_bp(outname, iface['protocol'], iface['name']) 453 453 for _ in range(0, cnt): 454 454 protocols.append(proto) 455 455 456 456 for protocol in inherited_protocols(iface): 457 457 proto = extend_bp(outname, protocol, iface['name']) … … 460 460 else: 461 461 print("%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])) 462 462 463 463 if (opt_bp): 464 464 outf = open(outname, "w") 465 465 outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0)) 466 466 outf.close() 467 467 468 468 if (opt_ebp): 469 469 outf = open(outname, "w") … … 473 473 def get_system_arch(): 474 474 "Get system architecture" 475 475 476 476 global arch_properties 477 477 478 478 for arch, properties in arch_properties.items(): 479 479 if ('system' in properties): 480 480 return properties 481 481 482 482 return None 483 483 484 484 def get_arch(name): 485 485 "Get architecture by name" 486 486 487 487 global arch_properties 488 488 489 489 if (name in arch_properties): 490 490 return arch_properties[name] 491 491 492 492 return None 493 493 494 494 def get_frame(name): 495 495 "Get frame by name" 496 496 497 497 global frame_properties 498 498 499 499 if (name in frame_properties): 500 500 return frame_properties[name] 501 501 502 502 return None 503 503 504 504 def create_null_bp(fname, outdir, archf): 505 505 "Create null frame protocol" 506 506 507 507 global opt_bp 508 508 global opt_ebp 509 509 510 510 if (archf != None): 511 511 archf.write("frame \"%s\"\n" % fname) 512 512 513 513 outname = os.path.join(outdir, fname) 514 514 515 515 if (opt_bp): 516 516 outf = open(outname, "w") 517 517 outf.write("NULL") 518 518 outf.close() 519 519 520 520 if (opt_ebp): 521 521 outf = open(outname, "w") … … 525 525 def flatten_binds(binds, delegates, subsumes): 526 526 "Remove bindings which are replaced by delegation or subsumption" 527 527 528 528 result = [] 529 529 stable = True 530 530 531 531 for bind in binds: 532 532 keep = True 533 533 534 534 for delegate in delegates: 535 535 if (bind['to'] == delegate['to']): 536 536 keep = False 537 537 result.append({'from': bind['from'], 'to': delegate['rep']}) 538 538 539 539 for subsume in subsumes: 540 540 if (bind['from'] == subsume['from']): 541 541 keep = False 542 542 result.append({'from': subsume['rep'], 'to': bind['to']}) 543 543 544 544 if (keep): 545 545 result.append(bind) 546 546 else: 547 547 stable = False 548 548 549 549 if (stable): 550 550 return result … … 554 554 def direct_binds(binds): 555 555 "Convert bindings matrix to set of sources by destination" 556 556 557 557 result = {} 558 558 559 559 for bind in binds: 560 560 if (not bind['to'] in result): 561 561 result[bind['to']] = set() 562 562 563 563 result[bind['to']].add(bind['from']) 564 564 565 565 return result 566 566 567 567 def merge_arch(prefix, arch, outdir): 568 568 "Merge subarchitecture into architecture" 569 569 570 570 insts = [] 571 571 binds = [] 572 572 delegates = [] 573 573 subsumes = [] 574 574 575 575 if ('inst' in arch): 576 576 for inst in arch['inst']: … … 588 588 else: 589 589 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 590 590 591 591 if ('bind' in arch): 592 592 for bind in arch['bind']: 593 593 binds.append({'from': "%s_%s.%s" % (prefix, bind['from'][0], bind['from'][1]), 'to': "%s_%s.%s" % (prefix, bind['to'][0], bind['to'][1])}) 594 594 595 595 if ('delegate' in arch): 596 596 for delegate in arch['delegate']: 597 597 delegates.append({'to': "%s.%s" % (prefix, delegate['from']), 'rep': "%s_%s.%s" % (prefix, delegate['to'][0], delegate['to'][1])}) 598 598 599 599 if ('subsume' in arch): 600 600 for subsume in arch['subsume']: 601 601 subsumes.append({'from': "%s.%s" % (prefix, subsume['to']), 'rep': "%s_%s.%s" % (prefix, subsume['from'][0], subsume['from'][1])}) 602 602 603 603 return (insts, binds, delegates, subsumes) 604 604 605 605 def dump_archbp(outdir): 606 606 "Dump system architecture Behavior Protocol" 607 607 608 608 global opt_bp 609 609 global opt_ebp 610 610 611 611 arch = get_system_arch() 612 612 613 613 if (arch is None): 614 614 print("Unable to find system architecture") 615 615 return 616 616 617 617 insts = [] 618 618 binds = [] 619 619 delegates = [] 620 620 subsumes = [] 621 621 622 622 if ('inst' in arch): 623 623 for inst in arch['inst']: … … 635 635 else: 636 636 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 637 637 638 638 if ('bind' in arch): 639 639 for bind in arch['bind']: 640 640 binds.append({'from': "%s.%s" % (bind['from'][0], bind['from'][1]), 'to': "%s.%s" % (bind['to'][0], bind['to'][1])}) 641 641 642 642 if ('delegate' in arch): 643 643 for delegate in arch['delegate']: 644 644 print("Unable to delegate interface in system architecture") 645 645 break 646 646 647 647 if ('subsume' in arch): 648 648 for subsume in arch['subsume']: 649 649 print("Unable to subsume interface in system architecture") 650 650 break 651 651 652 652 directed_binds = direct_binds(flatten_binds(binds, delegates, subsumes)) 653 653 654 654 outname = os.path.join(outdir, "%s.archbp" % arch['name']) 655 655 if ((opt_bp) or (opt_ebp)): … … 657 657 else: 658 658 outf = None 659 659 660 660 create_null_bp("null.bp", outdir, outf) 661 661 662 662 for inst in insts: 663 663 dump_frame(directed_binds, inst['frame'], outdir, inst['var'], outf) 664 664 665 665 for dst, src in directed_binds.items(): 666 666 if (outf != None): 667 667 outf.write("bind %s to %s\n" % (", ".join(src), dst)) 668 668 669 669 if (outf != None): 670 670 outf.close() … … 672 672 def preproc_adl(raw, inarg): 673 673 "Preprocess %% statements in ADL" 674 674 675 675 return raw.replace("%%", inarg) 676 676 677 677 def parse_adl(base, root, inname, nested, indent): 678 678 "Parse Architecture Description Language" 679 679 680 680 global output 681 681 global context … … 686 686 global initialization 687 687 global finalization 688 688 689 689 global iface_properties 690 690 global frame_properties 691 691 global arch_properties 692 692 693 693 global arg0 694 694 695 695 if (nested): 696 696 parts = inname.split("%") 697 697 698 698 if (len(parts) > 1): 699 699 inarg = parts[1] 700 700 else: 701 701 inarg = "%%" 702 702 703 703 if (parts[0][0:1] == "/"): 704 704 path = os.path.join(base, ".%s" % parts[0]) … … 707 707 path = os.path.join(root, parts[0]) 708 708 nested_root = root 709 709 710 710 if (not os.path.isfile(path)): 711 711 print("%s: Unable to include file %s" % (inname, path)) … … 715 715 path = inname 716 716 nested_root = root 717 717 718 718 inf = open(path, "r") 719 719 720 720 raw = preproc_adl(inf.read(), inarg) 721 721 tokens = split_tokens(raw, ["\n", " ", "\t", "(", ")", "{", "}", "[", "]", "/*", "*/", "#", ";"], True, True) 722 722 723 723 for token in tokens: 724 724 725 725 # Includes 726 726 727 727 if (INC in context): 728 728 context.remove(INC) … … 730 730 context.add(POST_INC) 731 731 continue 732 732 733 733 if (POST_INC in context): 734 734 if (token != "]"): 735 735 print("%s: Expected ]" % inname) 736 736 737 737 context.remove(POST_INC) 738 738 continue 739 739 740 740 # Comments and newlines 741 741 742 742 if (BLOCK_COMMENT in context): 743 743 if (token == "*/"): 744 744 context.remove(BLOCK_COMMENT) 745 745 746 746 continue 747 747 748 748 if (LINE_COMMENT in context): 749 749 if (token == "\n"): 750 750 context.remove(LINE_COMMENT) 751 751 752 752 continue 753 753 754 754 # Any context 755 755 756 756 if (token == "/*"): 757 757 context.add(BLOCK_COMMENT) 758 758 continue 759 759 760 760 if (token == "#"): 761 761 context.add(LINE_COMMENT) 762 762 continue 763 763 764 764 if (token == "["): 765 765 context.add(INC) 766 766 continue 767 767 768 768 if (token == "\n"): 769 769 continue 770 770 771 771 # "frame" 772 772 773 773 if (FRAME in context): 774 774 if (NULL in context): … … 777 777 else: 778 778 output += "%s\n" % token 779 779 780 780 context.remove(NULL) 781 781 context.remove(FRAME) 782 782 frame = None 783 783 continue 784 784 785 785 if (BODY in context): 786 786 if (FINALIZATION in context): … … 789 789 elif (token == "}"): 790 790 indent -= 1 791 791 792 792 if (((token[-1] == ":") and (indent == 0)) or (indent == -1)): 793 793 bp = split_bp(finalization) 794 794 finalization = None 795 795 796 796 if (not frame in frame_properties): 797 797 frame_properties[frame] = {} 798 798 799 799 if ('finalization' in frame_properties[frame]): 800 800 print("%s: Finalization protocol for frame '%s' already defined" % (inname, frame)) 801 801 else: 802 802 frame_properties[frame]['finalization'] = bp 803 803 804 804 output += "\n%s" % tabs(2) 805 805 output += parse_bp(inname, bp, 2) 806 806 807 807 context.remove(FINALIZATION) 808 808 if (indent == -1): … … 817 817 finalization += token 818 818 continue 819 819 820 820 if (INITIALIZATION in context): 821 821 if (token == "{"): … … 823 823 elif (token == "}"): 824 824 indent -= 1 825 825 826 826 if (((token[-1] == ":") and (indent == 0)) or (indent == -1)): 827 827 bp = split_bp(initialization) 828 828 initialization = None 829 829 830 830 if (not frame in frame_properties): 831 831 frame_properties[frame] = {} 832 832 833 833 if ('initialization' in frame_properties[frame]): 834 834 print("%s: Initialization protocol for frame '%s' already defined" % (inname, frame)) 835 835 else: 836 836 frame_properties[frame]['initialization'] = bp 837 837 838 838 output += "\n%s" % tabs(2) 839 839 output += parse_bp(inname, bp, 2) 840 840 841 841 context.remove(INITIALIZATION) 842 842 if (indent == -1): … … 851 851 initialization += token 852 852 continue 853 853 854 854 if (PROTOCOL in context): 855 855 if (token == "{"): … … 857 857 elif (token == "}"): 858 858 indent -= 1 859 859 860 860 if (((token[-1] == ":") and (indent == 0)) or (indent == -1)): 861 861 bp = split_bp(protocol) 862 862 protocol = None 863 863 864 864 if (not frame in frame_properties): 865 865 frame_properties[frame] = {} 866 866 867 867 if ('protocol' in frame_properties[frame]): 868 868 print("%s: Protocol for frame '%s' already defined" % (inname, frame)) 869 869 else: 870 870 frame_properties[frame]['protocol'] = bp 871 871 872 872 output += "\n%s" % tabs(2) 873 873 output += parse_bp(inname, bp, 2) 874 874 875 875 context.remove(PROTOCOL) 876 876 if (indent == -1): … … 885 885 protocol += token 886 886 continue 887 887 888 888 if (REQUIRES in context): 889 889 if (FIN in context): … … 892 892 else: 893 893 output += "%s" % token 894 894 895 895 context.remove(FIN) 896 896 continue 897 897 898 898 if (VAR in context): 899 899 if (not identifier(token)): … … 902 902 if (not frame in frame_properties): 903 903 frame_properties[frame] = {} 904 904 905 905 if (not 'requires' in frame_properties[frame]): 906 906 frame_properties[frame]['requires'] = [] 907 907 908 908 frame_properties[frame]['requires'].append({'iface': arg0, 'var': token}) 909 909 arg0 = None 910 910 911 911 output += "%s" % token 912 912 913 913 context.remove(VAR) 914 914 context.add(FIN) 915 915 continue 916 916 917 917 if ((token == "}") or (token[-1] == ":")): 918 918 context.remove(REQUIRES) … … 923 923 arg0 = token 924 924 output += "\n%s%s " % (tabs(indent), token) 925 925 926 926 context.add(VAR) 927 927 continue 928 928 929 929 if (PROVIDES in context): 930 930 if (FIN in context): … … 933 933 else: 934 934 output += "%s" % token 935 935 936 936 context.remove(FIN) 937 937 continue 938 938 939 939 if (VAR in context): 940 940 if (not identifier(token)): … … 943 943 if (not frame in frame_properties): 944 944 frame_properties[frame] = {} 945 945 946 946 if (not 'provides' in frame_properties[frame]): 947 947 frame_properties[frame]['provides'] = [] 948 948 949 949 frame_properties[frame]['provides'].append({'iface': arg0, 'var': token}) 950 950 arg0 = None 951 951 952 952 output += "%s" % token 953 953 954 954 context.remove(VAR) 955 955 context.add(FIN) 956 956 continue 957 957 958 958 if ((token == "}") or (token[-1] == ":")): 959 959 context.remove(PROVIDES) … … 964 964 arg0 = token 965 965 output += "\n%s%s " % (tabs(indent), token) 966 966 967 967 context.add(VAR) 968 968 continue 969 969 970 970 if (token == "}"): 971 971 if (indent != 2): … … 974 974 indent = 0 975 975 output += "\n%s" % token 976 976 977 977 context.remove(BODY) 978 978 context.add(NULL) 979 979 continue 980 980 981 981 if (token == "provides:"): 982 982 output += "\n%s%s" % (tabs(indent - 1), token) 983 983 context.add(PROVIDES) 984 984 continue 985 985 986 986 if (token == "requires:"): 987 987 output += "\n%s%s" % (tabs(indent - 1), token) 988 988 context.add(REQUIRES) 989 989 continue 990 990 991 991 if (token == "initialization:"): 992 992 output += "\n%s%s" % (tabs(indent - 1), token) … … 995 995 initialization = "" 996 996 continue 997 997 998 998 if (token == "finalization:"): 999 999 output += "\n%s%s" % (tabs(indent - 1), token) … … 1002 1002 finalization = "" 1003 1003 continue 1004 1004 1005 1005 if (token == "protocol:"): 1006 1006 output += "\n%s%s" % (tabs(indent - 1), token) … … 1009 1009 protocol = "" 1010 1010 continue 1011 1011 1012 1012 print("%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)) 1013 1013 continue 1014 1014 1015 1015 if (HEAD in context): 1016 1016 if (token == "{"): … … 1020 1020 context.add(BODY) 1021 1021 continue 1022 1022 1023 1023 if (token == ";"): 1024 1024 output += "%s\n" % token … … 1026 1026 context.remove(FRAME) 1027 1027 continue 1028 1028 1029 1029 print("%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)) 1030 1030 1031 1031 continue 1032 1032 1033 1033 if (not identifier(token)): 1034 1034 print("%s: Expected frame name" % inname) … … 1036 1036 frame = token 1037 1037 output += "%s " % token 1038 1038 1039 1039 if (not frame in frame_properties): 1040 1040 frame_properties[frame] = {} 1041 1041 1042 1042 frame_properties[frame]['name'] = frame 1043 1043 1044 1044 context.add(HEAD) 1045 1045 continue 1046 1046 1047 1047 # "interface" 1048 1048 1049 1049 if (IFACE in context): 1050 1050 if (NULL in context): … … 1053 1053 else: 1054 1054 output += "%s\n" % token 1055 1055 1056 1056 context.remove(NULL) 1057 1057 context.remove(IFACE) 1058 1058 interface = None 1059 1059 continue 1060 1060 1061 1061 if (BODY in context): 1062 1062 if (PROTOCOL in context): … … 1065 1065 elif (token == "}"): 1066 1066 indent -= 1 1067 1067 1068 1068 if (indent == -1): 1069 1069 bp = split_bp(protocol) 1070 1070 protocol = None 1071 1071 1072 1072 if (not interface in iface_properties): 1073 1073 iface_properties[interface] = {} 1074 1074 1075 1075 if ('protocol' in iface_properties[interface]): 1076 1076 print("%s: Protocol for interface '%s' already defined" % (inname, interface)) 1077 1077 else: 1078 1078 iface_properties[interface]['protocol'] = bp 1079 1079 1080 1080 output += "\n%s" % tabs(2) 1081 1081 output += parse_bp(inname, bp, 2) 1082 1082 output += "\n%s" % token 1083 1083 indent = 0 1084 1084 1085 1085 context.remove(PROTOCOL) 1086 1086 context.remove(BODY) … … 1088 1088 else: 1089 1089 protocol += token 1090 1091 continue 1092 1090 1091 continue 1092 1093 1093 if (PROTOTYPE in context): 1094 1094 if (FIN in context): … … 1097 1097 else: 1098 1098 output += "%s" % token 1099 1099 1100 1100 context.remove(FIN) 1101 1101 context.remove(PROTOTYPE) 1102 1102 continue 1103 1103 1104 1104 if (PAR_RIGHT in context): 1105 1105 if (token == ")"): … … 1109 1109 else: 1110 1110 output += " %s" % token 1111 1112 continue 1113 1111 1112 continue 1113 1114 1114 if (SIGNATURE in context): 1115 1115 output += "%s" % token … … 1117 1117 context.remove(SIGNATURE) 1118 1118 context.add(FIN) 1119 1119 1120 1120 context.remove(SIGNATURE) 1121 1121 context.add(PAR_RIGHT) 1122 1122 continue 1123 1123 1124 1124 if (PAR_LEFT in context): 1125 1125 if (token != "("): … … 1127 1127 else: 1128 1128 output += "%s" % token 1129 1129 1130 1130 context.remove(PAR_LEFT) 1131 1131 context.add(SIGNATURE) 1132 1132 continue 1133 1133 1134 1134 if (not identifier(token)): 1135 1135 print("%s: Method identifier expected in interface '%s'" % (inname, interface)) 1136 1136 else: 1137 1137 output += "%s" % token 1138 1138 1139 1139 context.add(PAR_LEFT) 1140 1140 continue 1141 1141 1142 1142 if (token == "}"): 1143 1143 if (indent != 2): … … 1146 1146 indent = 0 1147 1147 output += "\n%s" % token 1148 1148 1149 1149 context.remove(BODY) 1150 1150 context.add(NULL) 1151 1151 continue 1152 1152 1153 1153 if (token == "sysarg_t"): 1154 1154 output += "\n%s%s " % (tabs(indent), token) 1155 1155 context.add(PROTOTYPE) 1156 1156 continue 1157 1157 1158 1158 if (token == "protocol:"): 1159 1159 output += "\n%s%s" % (tabs(indent - 1), token) … … 1162 1162 protocol = "" 1163 1163 continue 1164 1164 1165 1165 print("%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)) 1166 1166 continue 1167 1167 1168 1168 if (HEAD in context): 1169 1169 if (PRE_BODY in context): … … 1175 1175 context.add(BODY) 1176 1176 continue 1177 1177 1178 1178 if (token == ";"): 1179 1179 output += "%s\n" % token … … 1182 1182 context.remove(IFACE) 1183 1183 continue 1184 1184 1185 1185 print("%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)) 1186 1186 continue 1187 1187 1188 1188 if (EXTENDS in context): 1189 1189 if (not identifier(token)): … … 1193 1193 if (not interface in iface_properties): 1194 1194 iface_properties[interface] = {} 1195 1195 1196 1196 iface_properties[interface]['extends'] = token 1197 1197 1198 1198 context.remove(EXTENDS) 1199 1199 context.add(PRE_BODY) 1200 1200 continue 1201 1201 1202 1202 if (token == "extends"): 1203 1203 output += "%s " % token 1204 1204 context.add(EXTENDS) 1205 1205 continue 1206 1206 1207 1207 if (token == "{"): 1208 1208 output += "%s" % token … … 1211 1211 context.add(BODY) 1212 1212 continue 1213 1213 1214 1214 if (token == ";"): 1215 1215 output += "%s\n" % token … … 1217 1217 context.remove(IFACE) 1218 1218 continue 1219 1219 1220 1220 print("%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)) 1221 1221 continue 1222 1222 1223 1223 if (not identifier(token)): 1224 1224 print("%s: Expected interface name" % inname) … … 1226 1226 interface = token 1227 1227 output += "%s " % token 1228 1228 1229 1229 if (not interface in iface_properties): 1230 1230 iface_properties[interface] = {} 1231 1231 1232 1232 iface_properties[interface]['name'] = interface 1233 1233 1234 1234 context.add(HEAD) 1235 1235 continue 1236 1236 1237 1237 # "architecture" 1238 1238 1239 1239 if (ARCH in context): 1240 1240 if (NULL in context): … … 1243 1243 else: 1244 1244 output += "%s\n" % token 1245 1245 1246 1246 context.remove(NULL) 1247 1247 context.remove(ARCH) … … 1249 1249 architecture = None 1250 1250 continue 1251 1251 1252 1252 if (BODY in context): 1253 1253 if (DELEGATE in context): … … 1257 1257 else: 1258 1258 output += "%s" % token 1259 1259 1260 1260 context.remove(FIN) 1261 1261 context.remove(DELEGATE) 1262 1262 continue 1263 1263 1264 1264 if (VAR in context): 1265 1265 if (not descriptor(token)): … … 1268 1268 if (not architecture in arch_properties): 1269 1269 arch_properties[architecture] = {} 1270 1270 1271 1271 if (not 'delegate' in arch_properties[architecture]): 1272 1272 arch_properties[architecture]['delegate'] = [] 1273 1273 1274 1274 arch_properties[architecture]['delegate'].append({'from': arg0, 'to': token.split(":")}) 1275 1275 arg0 = None 1276 1276 1277 1277 output += "%s" % token 1278 1278 1279 1279 context.add(FIN) 1280 1280 context.remove(VAR) 1281 1281 continue 1282 1282 1283 1283 if (TO in context): 1284 1284 if (token != "to"): … … 1286 1286 else: 1287 1287 output += "%s " % token 1288 1288 1289 1289 context.add(VAR) 1290 1290 context.remove(TO) 1291 1291 continue 1292 1292 1293 1293 if (not identifier(token)): 1294 1294 print("%s: Expected interface name in architecture '%s'" % (inname, architecture)) … … 1296 1296 output += "%s " % token 1297 1297 arg0 = token 1298 1298 1299 1299 context.add(TO) 1300 1300 continue 1301 1301 1302 1302 if (SUBSUME in context): 1303 1303 if (FIN in context): … … 1306 1306 else: 1307 1307 output += "%s" % token 1308 1308 1309 1309 context.remove(FIN) 1310 1310 context.remove(SUBSUME) 1311 1311 continue 1312 1312 1313 1313 if (VAR in context): 1314 1314 if (not identifier(token)): … … 1317 1317 if (not architecture in arch_properties): 1318 1318 arch_properties[architecture] = {} 1319 1319 1320 1320 if (not 'subsume' in arch_properties[architecture]): 1321 1321 arch_properties[architecture]['subsume'] = [] 1322 1322 1323 1323 arch_properties[architecture]['subsume'].append({'from': arg0.split(":"), 'to': token}) 1324 1324 arg0 = None 1325 1325 1326 1326 output += "%s" % token 1327 1327 1328 1328 context.add(FIN) 1329 1329 context.remove(VAR) 1330 1330 continue 1331 1331 1332 1332 if (TO in context): 1333 1333 if (token != "to"): … … 1335 1335 else: 1336 1336 output += "%s " % token 1337 1337 1338 1338 context.add(VAR) 1339 1339 context.remove(TO) 1340 1340 continue 1341 1341 1342 1342 if (not descriptor(token)): 1343 1343 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) … … 1345 1345 output += "%s " % token 1346 1346 arg0 = token 1347 1347 1348 1348 context.add(TO) 1349 1349 continue 1350 1350 1351 1351 if (BIND in context): 1352 1352 if (FIN in context): … … 1355 1355 else: 1356 1356 output += "%s" % token 1357 1357 1358 1358 context.remove(FIN) 1359 1359 context.remove(BIND) 1360 1360 continue 1361 1361 1362 1362 if (VAR in context): 1363 1363 if (not descriptor(token)): … … 1366 1366 if (not architecture in arch_properties): 1367 1367 arch_properties[architecture] = {} 1368 1368 1369 1369 if (not 'bind' in arch_properties[architecture]): 1370 1370 arch_properties[architecture]['bind'] = [] 1371 1371 1372 1372 arch_properties[architecture]['bind'].append({'from': arg0.split(":"), 'to': token.split(":")}) 1373 1373 arg0 = None 1374 1374 1375 1375 output += "%s" % token 1376 1376 1377 1377 context.add(FIN) 1378 1378 context.remove(VAR) 1379 1379 continue 1380 1380 1381 1381 if (TO in context): 1382 1382 if (token != "to"): … … 1384 1384 else: 1385 1385 output += "%s " % token 1386 1386 1387 1387 context.add(VAR) 1388 1388 context.remove(TO) 1389 1389 continue 1390 1390 1391 1391 if (not descriptor(token)): 1392 1392 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) … … 1394 1394 output += "%s " % token 1395 1395 arg0 = token 1396 1396 1397 1397 context.add(TO) 1398 1398 continue 1399 1399 1400 1400 if (INST in context): 1401 1401 if (FIN in context): … … 1404 1404 else: 1405 1405 output += "%s" % token 1406 1406 1407 1407 context.remove(FIN) 1408 1408 context.remove(INST) 1409 1409 continue 1410 1410 1411 1411 if (VAR in context): 1412 1412 if (not identifier(token)): … … 1415 1415 if (not architecture in arch_properties): 1416 1416 arch_properties[architecture] = {} 1417 1417 1418 1418 if (not 'inst' in arch_properties[architecture]): 1419 1419 arch_properties[architecture]['inst'] = [] 1420 1420 1421 1421 arch_properties[architecture]['inst'].append({'type': arg0, 'var': token}) 1422 1422 arg0 = None 1423 1423 1424 1424 output += "%s" % token 1425 1425 1426 1426 context.add(FIN) 1427 1427 context.remove(VAR) 1428 1428 continue 1429 1429 1430 1430 if (not identifier(token)): 1431 1431 print("%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)) … … 1433 1433 output += "%s " % token 1434 1434 arg0 = token 1435 1435 1436 1436 context.add(VAR) 1437 1437 continue 1438 1438 1439 1439 if (token == "}"): 1440 1440 if (indent != 1): … … 1443 1443 indent -= 1 1444 1444 output += "\n%s" % token 1445 1445 1446 1446 context.remove(BODY) 1447 1447 context.add(NULL) 1448 1448 continue 1449 1449 1450 1450 if (token == "inst"): 1451 1451 output += "\n%s%s " % (tabs(indent), token) 1452 1452 context.add(INST) 1453 1453 continue 1454 1454 1455 1455 if (token == "bind"): 1456 1456 output += "\n%s%s " % (tabs(indent), token) 1457 1457 context.add(BIND) 1458 1458 continue 1459 1459 1460 1460 if (token == "subsume"): 1461 1461 output += "\n%s%s " % (tabs(indent), token) 1462 1462 context.add(SUBSUME) 1463 1463 continue 1464 1464 1465 1465 if (token == "delegate"): 1466 1466 output += "\n%s%s " % (tabs(indent), token) 1467 1467 context.add(DELEGATE) 1468 1468 continue 1469 1469 1470 1470 print("%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)) 1471 1471 continue 1472 1472 1473 1473 if (HEAD in context): 1474 1474 if (token == "{"): … … 1478 1478 context.add(BODY) 1479 1479 continue 1480 1480 1481 1481 if (token == ";"): 1482 1482 output += "%s\n" % token … … 1485 1485 context.discard(SYSTEM) 1486 1486 continue 1487 1487 1488 1488 if (not word(token)): 1489 1489 print("%s: Expected word in architecture head '%s'" % (inname, architecture)) 1490 1490 else: 1491 1491 output += "%s " % token 1492 1492 1493 1493 continue 1494 1494 1495 1495 if (not identifier(token)): 1496 1496 print("%s: Expected architecture name" % inname) … … 1498 1498 architecture = token 1499 1499 output += "%s " % token 1500 1500 1501 1501 if (not architecture in arch_properties): 1502 1502 arch_properties[architecture] = {} 1503 1503 1504 1504 arch_properties[architecture]['name'] = architecture 1505 1505 1506 1506 if (SYSTEM in context): 1507 1507 arch_properties[architecture]['system'] = True 1508 1508 1509 1509 context.add(HEAD) 1510 1510 continue 1511 1511 1512 1512 # "system architecture" 1513 1513 1514 1514 if (SYSTEM in context): 1515 1515 if (token != "architecture"): … … 1517 1517 else: 1518 1518 output += "%s " % token 1519 1519 1520 1520 context.add(ARCH) 1521 1521 continue 1522 1522 1523 1523 if (token == "frame"): 1524 1524 output += "\n%s " % token 1525 1525 context.add(FRAME) 1526 1526 continue 1527 1527 1528 1528 if (token == "interface"): 1529 1529 output += "\n%s " % token 1530 1530 context.add(IFACE) 1531 1531 continue 1532 1532 1533 1533 if (token == "system"): 1534 1534 output += "\n%s " % token 1535 1535 context.add(SYSTEM) 1536 1536 continue 1537 1537 1538 1538 if (token == "architecture"): 1539 1539 output += "\n%s " % token 1540 1540 context.add(ARCH) 1541 1541 continue 1542 1542 1543 1543 print("%s: Unknown token '%s'" % (inname, token)) 1544 1544 1545 1545 inf.close() 1546 1546 1547 1547 def open_adl(base, root, inname, outdir, outname): 1548 1548 "Open Architecture Description file" 1549 1549 1550 1550 global output 1551 1551 global context … … 1556 1556 global initialization 1557 1557 global finalization 1558 1558 1559 1559 global arg0 1560 1560 1561 1561 global opt_adl 1562 1562 1563 1563 output = "" 1564 1564 context = set() … … 1570 1570 finalization = None 1571 1571 arg0 = None 1572 1572 1573 1573 parse_adl(base, root, inname, False, 0) 1574 1574 output = output.strip() 1575 1575 1576 1576 if ((output != "") and (opt_adl)): 1577 1577 outf = open(outname, "w") … … 1581 1581 def recursion(base, root, output, level): 1582 1582 "Recursive directory walk" 1583 1583 1584 1584 for name in os.listdir(root): 1585 1585 canon = os.path.join(root, name) 1586 1586 1587 1587 if (os.path.isfile(canon)): 1588 1588 fcomp = split_tokens(canon, ["."]) 1589 1589 cname = canon.split("/") 1590 1590 1591 1591 if (fcomp[-1] == ".adl"): 1592 1592 output_path = os.path.join(output, cname[-1]) 1593 1593 open_adl(base, root, canon, output, output_path) 1594 1594 1595 1595 if (os.path.isdir(canon)): 1596 1596 recursion(base, canon, output, level + 1) … … 1598 1598 def merge_dot_frame(prefix, name, frame, outf, indent): 1599 1599 "Dump Dot frame" 1600 1600 1601 1601 outf.write("%ssubgraph cluster_%s {\n" % (tabs(indent), prefix)) 1602 1602 outf.write("%s\tlabel=\"%s\";\n" % (tabs(indent), name)) … … 1605 1605 outf.write("%s\tfillcolor=yellow;\n" % tabs(indent)) 1606 1606 outf.write("%s\t\n" % tabs(indent)) 1607 1607 1608 1608 if ('provides' in frame): 1609 1609 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, style=filled, color=green, fillcolor=yellow];\n" % (tabs(indent), prefix)) 1610 1610 1611 1611 if ('requires' in frame): 1612 1612 outf.write("%s\t%s__requires [label=\"\", shape=circle, style=filled, color=red, fillcolor=yellow];\n" % (tabs(indent), prefix)) 1613 1613 1614 1614 outf.write("%s}\n" % tabs(indent)) 1615 1615 outf.write("%s\n" % tabs(indent)) … … 1617 1617 def merge_dot_arch(prefix, name, arch, outf, indent): 1618 1618 "Dump Dot subarchitecture" 1619 1619 1620 1620 outf.write("%ssubgraph cluster_%s {\n" % (tabs(indent), prefix)) 1621 1621 outf.write("%s\tlabel=\"%s\";\n" % (tabs(indent), name)) 1622 1622 outf.write("%s\tcolor=red;\n" % tabs(indent)) 1623 1623 outf.write("%s\t\n" % tabs(indent)) 1624 1624 1625 1625 if ('inst' in arch): 1626 1626 for inst in arch['inst']: … … 1634 1634 else: 1635 1635 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1636 1636 1637 1637 if ('bind' in arch): 1638 1638 labels = {} … … 1642 1642 else: 1643 1643 label = bind['from'][1] 1644 1644 1645 1645 if (not (bind['from'][0], bind['to'][0]) in labels): 1646 1646 labels[(bind['from'][0], bind['to'][0])] = [] 1647 1647 1648 1648 labels[(bind['from'][0], bind['to'][0])].append(label) 1649 1649 1650 1650 for bind in arch['bind']: 1651 1651 if (not (bind['from'][0], bind['to'][0]) in labels): 1652 1652 continue 1653 1653 1654 1654 attrs = [] 1655 1655 1656 1656 if (bind['from'][0] != bind['to'][0]): 1657 1657 attrs.append("ltail=cluster_%s_%s" % (prefix, bind['from'][0])) 1658 1658 attrs.append("lhead=cluster_%s_%s" % (prefix, bind['to'][0])) 1659 1659 1660 1660 attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])])) 1661 1661 del labels[(bind['from'][0], bind['to'][0])] 1662 1662 1663 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 1664 1665 1665 if ('delegate' in arch): 1666 1666 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, color=green];\n" % (tabs(indent), prefix)) 1667 1667 1668 1668 labels = {} 1669 1669 for delegate in arch['delegate']: … … 1672 1672 else: 1673 1673 label = delegate['from'] 1674 1674 1675 1675 if (not delegate['to'][0] in labels): 1676 1676 labels[delegate['to'][0]] = [] 1677 1677 1678 1678 labels[delegate['to'][0]].append(label) 1679 1679 1680 1680 for delegate in arch['delegate']: 1681 1681 if (not delegate['to'][0] in labels): 1682 1682 continue 1683 1683 1684 1684 attrs = [] 1685 1685 attrs.append("color=gray") … … 1687 1687 attrs.append("label=\"%s\"" % "\\n".join(labels[delegate['to'][0]])) 1688 1688 del labels[delegate['to'][0]] 1689 1689 1690 1690 outf.write("%s\t%s__provides -> %s_%s__provides [%s];\n" % (tabs(indent), prefix, prefix, delegate['to'][0], ", ".join(attrs))) 1691 1691 1692 1692 if ('subsume' in arch): 1693 1693 outf.write("%s\t%s__requires [label=\"\", shape=circle, color=red];\n" % (tabs(indent), prefix)) 1694 1694 1695 1695 labels = {} 1696 1696 for subsume in arch['subsume']: … … 1699 1699 else: 1700 1700 label = subsume['to'] 1701 1701 1702 1702 if (not subsume['from'][0] in labels): 1703 1703 labels[subsume['from'][0]] = [] 1704 1704 1705 1705 labels[subsume['from'][0]].append(label) 1706 1706 1707 1707 for subsume in arch['subsume']: 1708 1708 if (not subsume['from'][0] in labels): 1709 1709 continue 1710 1710 1711 1711 attrs = [] 1712 1712 attrs.append("color=gray") … … 1714 1714 attrs.append("label=\"%s\"" % "\\n".join(labels[subsume['from'][0]])) 1715 1715 del labels[subsume['from'][0]] 1716 1716 1717 1717 outf.write("%s\t%s_%s__requires -> %s__requires [%s];\n" % (tabs(indent), prefix, subsume['from'][0], prefix, ", ".join(attrs))) 1718 1718 1719 1719 outf.write("%s}\n" % tabs(indent)) 1720 1720 outf.write("%s\n" % tabs(indent)) … … 1722 1722 def dump_dot(outdir): 1723 1723 "Dump Dot architecture" 1724 1724 1725 1725 global opt_dot 1726 1726 1727 1727 arch = get_system_arch() 1728 1728 1729 1729 if (arch is None): 1730 1730 print("Unable to find system architecture") 1731 1731 return 1732 1732 1733 1733 if (opt_dot): 1734 1734 outname = os.path.join(outdir, "%s.dot" % arch['name']) 1735 1735 outf = open(outname, "w") 1736 1736 1737 1737 outf.write("digraph {\n") 1738 1738 outf.write("\tlabel=\"%s\";\n" % arch['name']) … … 1741 1741 outf.write("\tedge [fontsize=8];\n") 1742 1742 outf.write("\t\n") 1743 1743 1744 1744 if ('inst' in arch): 1745 1745 for inst in arch['inst']: … … 1753 1753 else: 1754 1754 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1755 1755 1756 1756 if ('bind' in arch): 1757 1757 labels = {} … … 1761 1761 else: 1762 1762 label = bind['from'][1] 1763 1763 1764 1764 if (not (bind['from'][0], bind['to'][0]) in labels): 1765 1765 labels[(bind['from'][0], bind['to'][0])] = [] 1766 1766 1767 1767 labels[(bind['from'][0], bind['to'][0])].append(label) 1768 1768 1769 1769 for bind in arch['bind']: 1770 1770 if (not (bind['from'][0], bind['to'][0]) in labels): 1771 1771 continue 1772 1772 1773 1773 attrs = [] 1774 1774 1775 1775 if (bind['from'][0] != bind['to'][0]): 1776 1776 attrs.append("ltail=cluster_%s" % bind['from'][0]) 1777 1777 attrs.append("lhead=cluster_%s" % bind['to'][0]) 1778 1778 1779 1779 attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])])) 1780 1780 del labels[(bind['from'][0], bind['to'][0])] 1781 1781 1782 1782 outf.write("\t%s__requires -> %s__provides [%s];\n" % (bind['from'][0], bind['to'][0], ", ".join(attrs))) 1783 1783 1784 1784 if ('delegate' in arch): 1785 1785 for delegate in arch['delegate']: 1786 1786 print("Unable to delegate interface in system architecture") 1787 1787 break 1788 1788 1789 1789 if ('subsume' in arch): 1790 1790 for subsume in arch['subsume']: 1791 1791 print("Unable to subsume interface in system architecture") 1792 1792 break 1793 1793 1794 1794 outf.write("}\n") 1795 1795 1796 1796 outf.close() 1797 1797 … … 1804 1804 global opt_adl 1805 1805 global opt_dot 1806 1806 1807 1807 if (len(sys.argv) < 3): 1808 1808 usage(sys.argv[0]) 1809 1809 return 1810 1810 1811 1811 opt_bp = False 1812 1812 opt_ebp = False 1813 1813 opt_adl = False 1814 1814 opt_dot = False 1815 1815 1816 1816 for arg in sys.argv[1:(len(sys.argv) - 1)]: 1817 1817 if (arg == "--bp"): … … 1828 1828 print("Error: Unknown command line option '%s'" % arg) 1829 1829 return 1830 1830 1831 1831 if ((opt_bp) and (opt_ebp)): 1832 1832 print("Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols") 1833 1833 return 1834 1834 1835 1835 path = os.path.abspath(sys.argv[-1]) 1836 1836 if (not os.path.isdir(path)): 1837 1837 print("Error: <OUTPUT> is not a directory") 1838 1838 return 1839 1839 1840 1840 iface_properties = {} 1841 1841 frame_properties = {} 1842 1842 arch_properties = {} 1843 1843 1844 1844 recursion(".", ".", path, 0) 1845 1845 dump_archbp(path)
Note:
See TracChangeset
for help on using the changeset viewer.