outputblock.isa revision 4679
14276SN/A// Copyright (c) 2007 The Hewlett-Packard Development Company 24276SN/A// All rights reserved. 34276SN/A// 44276SN/A// Redistribution and use of this software in source and binary forms, 54276SN/A// with or without modification, are permitted provided that the 64276SN/A// following conditions are met: 74276SN/A// 84276SN/A// The software must be used only for Non-Commercial Use which means any 94276SN/A// use which is NOT directed to receiving any direct monetary 104276SN/A// compensation for, or commercial advantage from such use. Illustrative 114276SN/A// examples of non-commercial use are academic research, personal study, 124276SN/A// teaching, education and corporate research & development. 134276SN/A// Illustrative examples of commercial use are distributing products for 144276SN/A// commercial advantage and providing services using the software for 154276SN/A// commercial advantage. 164276SN/A// 174276SN/A// If you wish to use this software or functionality therein that may be 184276SN/A// covered by patents for commercial use, please contact: 194276SN/A// Director of Intellectual Property Licensing 204276SN/A// Office of Strategy and Technology 214276SN/A// Hewlett-Packard Company 224276SN/A// 1501 Page Mill Road 234276SN/A// Palo Alto, California 94304 244276SN/A// 254276SN/A// Redistributions of source code must retain the above copyright notice, 264276SN/A// this list of conditions and the following disclaimer. Redistributions 274276SN/A// in binary form must reproduce the above copyright notice, this list of 284276SN/A// conditions and the following disclaimer in the documentation and/or 294276SN/A// other materials provided with the distribution. Neither the name of 304276SN/A// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 314276SN/A// contributors may be used to endorse or promote products derived from 324276SN/A// this software without specific prior written permission. No right of 334276SN/A// sublicense is granted herewith. Derivatives of the software and 344276SN/A// output created using the software may be prepared, but only for 354276SN/A// Non-Commercial Uses. Derivatives of the software may be shared with 364276SN/A// others provided: (i) the others agree to abide by the list of 374276SN/A// conditions herein which includes the Non-Commercial Use restrictions; 384276SN/A// and (ii) such Derivatives of the software include the above copyright 394276SN/A// notice to acknowledge the contribution from this software where 404276SN/A// applicable, this list of conditions and the disclaimer below. 414276SN/A// 424276SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 434276SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 444276SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 454276SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 464276SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 474276SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 484276SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 494276SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 504276SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 514276SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 524276SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 534276SN/A// 544276SN/A// Authors: Gabe Black 554276SN/A 564276SN/A//////////////////////////////////////////////////////////////////// 574276SN/A// 584679Sgblack@eecs.umich.edu// Output blocks which group together code generated by the parser. 594276SN/A// 604276SN/A 614366SN/Alet {{ 624366SN/A # This class will help make dealing with output a little less verbose 634366SN/A class OutputBlocks(object): 644366SN/A def __init__(self, header_output="", 654366SN/A decoder_output="", 664366SN/A decode_block="", 674366SN/A exec_output=""): 684366SN/A self.header_output = header_output 694366SN/A self.decoder_output = decoder_output 704366SN/A self.decode_block = decode_block 714366SN/A self.exec_output = exec_output 724366SN/A 734366SN/A def append(self, blocks): 744366SN/A if isinstance(blocks, list) or isinstance(blocks, tuple): 754366SN/A assert(len(blocks) == 4) 764366SN/A self.header_output += blocks[0] 774366SN/A self.decoder_output += blocks[1] 784366SN/A self.decode_block += blocks[2] 794366SN/A self.exec_output += blocks[3] 804366SN/A else: 814366SN/A self.header_output += blocks.header_output 824366SN/A self.decoder_output += blocks.decoder_output 834366SN/A self.decode_block += blocks.decode_block 844366SN/A self.exec_output += blocks.exec_output 854366SN/A 864366SN/A def makeList(self): 874366SN/A return (self.header_output, 884366SN/A self.decoder_output, 894366SN/A self.decode_block, 904366SN/A self.exec_output) 914366SN/A}}; 92