InPortDeclAST.py (7567:238f99c9f441) InPortDeclAST.py (7839:9e556fb25900)
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;

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

46
47 def __repr__(self):
48 return "[InPortDecl: %s]" % self.ident
49
50 def generate(self):
51 symtab = self.symtab
52 void_type = symtab.find("void", Type)
53
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;

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

46
47 def __repr__(self):
48 return "[InPortDecl: %s]" % self.ident
49
50 def generate(self):
51 symtab = self.symtab
52 void_type = symtab.find("void", Type)
53
54 machine = symtab.state_machine
55 if machine is None:
56 self.error("InPort declaration not part of a machine.")
57
54 code = self.slicc.codeFormatter()
55 queue_type = self.var_expr.generate(code)
56 if not queue_type.isInPort:
57 self.error("The inport queue's type must have the 'inport' " + \
58 "attribute. Type '%s' does not have this attribute.",
59 queue_type)
60
61 type = self.queue_type.type

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

74
75 # Check for Address
76 type = symtab.find("Address", Type)
77 if type is None:
78 self.error("in_port decls require 'Address' type to be defined")
79
80 param_types.append(type)
81
58 code = self.slicc.codeFormatter()
59 queue_type = self.var_expr.generate(code)
60 if not queue_type.isInPort:
61 self.error("The inport queue's type must have the 'inport' " + \
62 "attribute. Type '%s' does not have this attribute.",
63 queue_type)
64
65 type = self.queue_type.type

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

78
79 # Check for Address
80 type = symtab.find("Address", Type)
81 if type is None:
82 self.error("in_port decls require 'Address' type to be defined")
83
84 param_types.append(type)
85
86 if machine.EntryType != None:
87 param_types.append(machine.EntryType)
88 if machine.TBEType != None:
89 param_types.append(machine.TBEType)
90
82 # Add the trigger method - FIXME, this is a bit dirty
83 pairs = { "external" : "yes" }
84 func = Func(self.symtab, "trigger", self.location, void_type,
85 param_types, [], "", pairs, None)
86 symtab.newSymbol(func)
87
88 param_types = []
89 # Check for Event2

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

118 symtab.newSymbol(func)
119
120 if self.statements is not None:
121 rcode = self.slicc.codeFormatter()
122 rcode.indent()
123 rcode.indent()
124 self.statements.generate(rcode, None)
125 in_port["c_code_in_port"] = str(rcode)
91 # Add the trigger method - FIXME, this is a bit dirty
92 pairs = { "external" : "yes" }
93 func = Func(self.symtab, "trigger", self.location, void_type,
94 param_types, [], "", pairs, None)
95 symtab.newSymbol(func)
96
97 param_types = []
98 # Check for Event2

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

127 symtab.newSymbol(func)
128
129 if self.statements is not None:
130 rcode = self.slicc.codeFormatter()
131 rcode.indent()
132 rcode.indent()
133 self.statements.generate(rcode, None)
134 in_port["c_code_in_port"] = str(rcode)
135
126 symtab.popFrame()
127
128 # Add port to state machine
136 symtab.popFrame()
137
138 # Add port to state machine
129 machine = symtab.state_machine
130 if machine is None:
131 self.error("InPort declaration not part of a machine.")
132
133 machine.addInPort(in_port)
134
135 # Include max_rank to be used by StateMachine.py
136 in_port["max_port_rank"] = InPortDeclAST.max_port_rank
139 machine.addInPort(in_port)
140
141 # Include max_rank to be used by StateMachine.py
142 in_port["max_port_rank"] = InPortDeclAST.max_port_rank