Deleted Added
sdiff udiff text old ( 6657:ef5fae93a3b2 ) new ( 6999:f226c098c393 )
full compact
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;

--- 11 unchanged lines hidden (view full) ---

20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28from m5.util import code_formatter
29
30from slicc.ast.DeclAST import DeclAST
31from slicc.ast.TypeAST import TypeAST
32from slicc.symbols import Func, Type, Var
33
34class InPortDeclAST(DeclAST):
35 def __init__(self, slicc, ident, msg_type, var_expr, pairs, statements):
36 super(InPortDeclAST, self).__init__(slicc, pairs)
37

--- 5 unchanged lines hidden (view full) ---

43
44 def __repr__(self):
45 return "[InPortDecl: %s]" % self.ident
46
47 def generate(self):
48 symtab = self.symtab
49 void_type = symtab.find("void", Type)
50
51 code = code_formatter()
52 queue_type = self.var_expr.generate(code)
53 if not queue_type.isInPort:
54 self.error("The inport queue's type must have the 'inport' " + \
55 "attribute. Type '%s' does not have this attribute.",
56 queue_type)
57
58 type = self.queue_type.type
59 in_port = Var(self.symtab, self.ident, self.location, type, str(code),

--- 50 unchanged lines hidden (view full) ---

110
111 # Add the continueProcessing method - this hack supports
112 # messages that don't trigger events
113 func = Func(self.symtab, "continueProcessing", self.location,
114 void_type, [], [], "", pairs, None)
115 symtab.newSymbol(func)
116
117 if self.statements is not None:
118 rcode = code_formatter()
119 rcode.indent()
120 rcode.indent()
121 self.statements.generate(rcode, None)
122 in_port["c_code_in_port"] = str(rcode)
123 symtab.popFrame()
124
125 # Add port to state machine
126 machine = symtab.state_machine
127 if machine is None:
128 self.error("InPort declaration not part of a machine.")
129
130 machine.addInPort(in_port)