Type.py (7453:1a5db3dd0f62) | Type.py (7805:f249937228b5) |
---|---|
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 497 unchanged lines hidden (view full) --- 506/** \\file ${{self.c_ident}}.hh 507 * 508 * Auto generated C++ code started by $__file__:$__line__ 509 */ 510 511#include <iostream> 512#include <string> 513 | 1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 497 unchanged lines hidden (view full) --- 506/** \\file ${{self.c_ident}}.hh 507 * 508 * Auto generated C++ code started by $__file__:$__line__ 509 */ 510 511#include <iostream> 512#include <string> 513 |
514#include "base/misc.hh" |
|
514#include "mem/protocol/${{self.c_ident}}.hh" 515 516using namespace std; 517 518''') 519 520 if self.isMachineType: 521 for enum in self.enums.itervalues(): --- 21 unchanged lines hidden (view full) --- 543 for enum in self.enums.itervalues(): 544 code(' case ${{self.c_ident}}_${{enum.ident}}:') 545 code(' return "${{enum.ident}}";') 546 code.dedent() 547 548 # Trailer 549 code(''' 550 default: | 515#include "mem/protocol/${{self.c_ident}}.hh" 516 517using namespace std; 518 519''') 520 521 if self.isMachineType: 522 for enum in self.enums.itervalues(): --- 21 unchanged lines hidden (view full) --- 544 for enum in self.enums.itervalues(): 545 code(' case ${{self.c_ident}}_${{enum.ident}}:') 546 code(' return "${{enum.ident}}";') 547 code.dedent() 548 549 # Trailer 550 code(''' 551 default: |
551 ERROR_MSG("Invalid range for type ${{self.c_ident}}"); 552 return ""; | 552 panic("Invalid range for type ${{self.c_ident}}"); |
553 } 554} 555 556// Code to convert from a string to the enumeration 557${{self.c_ident}} 558string_to_${{self.c_ident}}(const string& str) 559{ 560''') --- 4 unchanged lines hidden (view full) --- 565 for enum in self.enums.itervalues(): 566 code('${start}if (str == "${{enum.ident}}") {') 567 code(' return ${{self.c_ident}}_${{enum.ident}};') 568 start = "} else " 569 code.dedent() 570 571 code(''' 572 } else { | 553 } 554} 555 556// Code to convert from a string to the enumeration 557${{self.c_ident}} 558string_to_${{self.c_ident}}(const string& str) 559{ 560''') --- 4 unchanged lines hidden (view full) --- 565 for enum in self.enums.itervalues(): 566 code('${start}if (str == "${{enum.ident}}") {') 567 code(' return ${{self.c_ident}}_${{enum.ident}};') 568 start = "} else " 569 code.dedent() 570 571 code(''' 572 } else { |
573 WARN_EXPR(str); 574 ERROR_MSG("Invalid string conversion for type ${{self.c_ident}}"); | 573 panic("Invalid string conversion for %s, type ${{self.c_ident}}", str); |
575 } 576} 577 578// Code to increment an enumeration type 579${{self.c_ident}}& 580operator++(${{self.c_ident}}& e) 581{ 582 assert(e < ${{self.c_ident}}_NUM); --- 25 unchanged lines hidden (view full) --- 608 code.dedent() 609 610 # total num 611 code(''' 612 case ${{self.c_ident}}_NUM: 613 return ${{len(self.enums)}}; 614 615 default: | 574 } 575} 576 577// Code to increment an enumeration type 578${{self.c_ident}}& 579operator++(${{self.c_ident}}& e) 580{ 581 assert(e < ${{self.c_ident}}_NUM); --- 25 unchanged lines hidden (view full) --- 607 code.dedent() 608 609 # total num 610 code(''' 611 case ${{self.c_ident}}_NUM: 612 return ${{len(self.enums)}}; 613 614 default: |
616 ERROR_MSG("Invalid range for type ${{self.c_ident}}"); 617 return -1; | 615 panic("Invalid range for type ${{self.c_ident}}"); |
618 } 619} 620 621/** \\brief returns the machine type for each base vector index used by NetDest 622 * 623 * \\return the MachineType 624 */ 625MachineType --- 7 unchanged lines hidden (view full) --- 633 for i,enum in enumerate(self.enums.itervalues()): 634 code(' case $i:') 635 code(' return ${{self.c_ident}}_${{enum.ident}};') 636 code.dedent() 637 638 # Trailer 639 code(''' 640 default: | 616 } 617} 618 619/** \\brief returns the machine type for each base vector index used by NetDest 620 * 621 * \\return the MachineType 622 */ 623MachineType --- 7 unchanged lines hidden (view full) --- 631 for i,enum in enumerate(self.enums.itervalues()): 632 code(' case $i:') 633 code(' return ${{self.c_ident}}_${{enum.ident}};') 634 code.dedent() 635 636 # Trailer 637 code(''' 638 default: |
641 ERROR_MSG("Invalid range for type ${{self.c_ident}}"); 642 return MachineType_NUM; | 639 panic("Invalid range for type ${{self.c_ident}}"); |
643 } 644} 645 646/** \\brief The return value indicates the number of components created 647 * before a particular machine\'s components 648 * 649 * \\return the base number of components for each machine 650 */ --- 10 unchanged lines hidden (view full) --- 661 for enum in reversed(self.enums.values()): 662 code(' base += ${{enum.ident}}_Controller::getNumControllers();') 663 code(' case ${{self.c_ident}}_${{enum.ident}}:') 664 code(' break;') 665 code.dedent() 666 667 code(''' 668 default: | 640 } 641} 642 643/** \\brief The return value indicates the number of components created 644 * before a particular machine\'s components 645 * 646 * \\return the base number of components for each machine 647 */ --- 10 unchanged lines hidden (view full) --- 658 for enum in reversed(self.enums.values()): 659 code(' base += ${{enum.ident}}_Controller::getNumControllers();') 660 code(' case ${{self.c_ident}}_${{enum.ident}}:') 661 code(' break;') 662 code.dedent() 663 664 code(''' 665 default: |
669 ERROR_MSG("Invalid range for type ${{self.c_ident}}"); 670 return -1; | 666 panic("Invalid range for type ${{self.c_ident}}"); |
671 } 672 673 return base; 674} 675 676/** \\brief returns the total number of components for each machine 677 * \\return the total number of components for each machine 678 */ --- 9 unchanged lines hidden (view full) --- 688 case ${{self.c_ident}}_${{enum.ident}}: 689 return ${{enum.ident}}_Controller::getNumControllers(); 690''') 691 692 # total num 693 code(''' 694 case ${{self.c_ident}}_NUM: 695 default: | 667 } 668 669 return base; 670} 671 672/** \\brief returns the total number of components for each machine 673 * \\return the total number of components for each machine 674 */ --- 9 unchanged lines hidden (view full) --- 684 case ${{self.c_ident}}_${{enum.ident}}: 685 return ${{enum.ident}}_Controller::getNumControllers(); 686''') 687 688 # total num 689 code(''' 690 case ${{self.c_ident}}_NUM: 691 default: |
696 ERROR_MSG("Invalid range for type ${{self.c_ident}}"); 697 return -1; | 692 panic("Invalid range for type ${{self.c_ident}}"); |
698 } 699} 700''') 701 702 # Write the file 703 code.write(path, "%s.cc" % self.c_ident) 704 705__all__ = [ "Type" ] | 693 } 694} 695''') 696 697 # Write the file 698 code.write(path, "%s.cc" % self.c_ident) 699 700__all__ = [ "Type" ] |