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; --- 29 unchanged lines hidden (view full) --- 38 self.type = type 39 self.init_code = init_code 40 41class Enumeration(PairContainer): 42 def __init__(self, ident, pairs): 43 super(Enumeration, self).__init__(pairs) 44 self.ident = ident 45 |
46class Type(Symbol): 47 def __init__(self, table, ident, location, pairs, machine=None): 48 super(Type, self).__init__(table, ident, location, pairs) 49 self.c_ident = ident 50 self.abstract_ident = "" 51 if machine: 52 if self.isExternal or self.isPrimitive: 53 if "external_name" in self: --- 32 unchanged lines hidden (view full) --- 86 self["prefetcher"] = "yes" 87 88 self.isMachineType = (ident == "MachineType") 89 90 self.isStateDecl = ("state_decl" in self) 91 self.statePermPairs = [] 92 93 self.data_members = orderdict() |
94 self.methods = {} |
95 self.enums = orderdict() 96 97 @property 98 def isPrimitive(self): 99 return "primitive" in self 100 @property 101 def isNetworkMessage(self): 102 return "networkmessage" in self --- 42 unchanged lines hidden (view full) --- 145 return '_'.join([name] + [ pt.c_ident for pt in param_type_vec ]) 146 147 def methodIdAbstract(self, name, param_type_vec): 148 return '_'.join([name] + [ pt.abstract_ident for pt in param_type_vec ]) 149 150 def statePermPairAdd(self, state_name, perm_name): 151 self.statePermPairs.append([state_name, perm_name]) 152 |
153 def addFunc(self, func): 154 ident = self.methodId(func.ident, func.param_types) |
155 if ident in self.methods: |
156 return False 157 |
158 self.methods[ident] = func |
159 return True 160 161 def addEnum(self, ident, pairs): 162 if ident in self.enums: 163 return False 164 165 self.enums[ident] = Enumeration(ident, pairs) 166 --- 186 unchanged lines hidden (view full) --- 353 assert self.isGlobal 354 init = " = %s" % (dm.init_code) 355 356 if "desc" in dm: 357 code('/** ${{dm["desc"]}} */') 358 359 code('$const${{dm.type.c_ident}} m_${{dm.ident}}$init;') 360 |
361 # Prototypes for methods defined for the Type 362 for item in self.methods: 363 proto = self.methods[item].prototype |
364 if proto: 365 code('$proto') 366 367 code.dedent() 368 code('};') 369 370 code(''' 371inline std::ostream& --- 44 unchanged lines hidden (view full) --- 416 code('out << "Time = " << g_system_ptr->clockPeriod() * getTime() << " ";') 417 code.dedent() 418 419 # Trailer 420 code(''' 421 out << "]"; 422}''') 423 |
424 # print the code for the methods in the type 425 for item in self.methods: 426 code(self.methods[item].generateCode()) |
427 428 code.write(path, "%s.cc" % self.c_ident) 429 430 def printEnumHH(self, path): 431 code = self.symtab.codeFormatter() 432 code(''' 433/** \\file ${{self.c_ident}}.hh 434 * --- 336 unchanged lines hidden --- |