FuncCallExprAST.py (6657:ef5fae93a3b2) FuncCallExprAST.py (7780:42da07116e12)
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;

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

35 self.exprs = exprs
36
37 def __repr__(self):
38 return "[FuncCallExpr: %s %s]" % (self.proc_name, self.exprs)
39
40 def generate(self, code):
41 machine = self.state_machine
42
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;

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

35 self.exprs = exprs
36
37 def __repr__(self):
38 return "[FuncCallExpr: %s %s]" % (self.proc_name, self.exprs)
39
40 def generate(self, code):
41 machine = self.state_machine
42
43 # DEBUG_EXPR is strange since it takes parameters of multiple types
44 if self.proc_name == "DEBUG_EXPR":
45 # FIXME - check for number of parameters
46 code('DEBUG_SLICC(MedPrio, "$0: ", $1)',
47 self.exprs[0].location, self.exprs[0].inline())
43 if self.proc_name == "DPRINTF":
44 # Code for inserting the location of the DPRINTF()
45 # statement in the .sm file in the statement it self.
46 # 'self.exprs[0].location' represents the location.
47 # 'format' represents the second argument of the
48 # original DPRINTF() call. It is left unmodified.
49 # str_list is used for concatenating the argument
50 # list following the format specifier. A DPRINTF()
51 # call may or may not contain any arguments following
52 # the format specifier. These two cases need to be
53 # handled differently. Hence the check whether or not
54 # the str_list is empty.
48
55
56 format = "%s" % (self.exprs[1].inline())
57 format_length = len(format)
58 str_list = []
59
60 for i in range(2, len(self.exprs)):
61 str_list.append("%s" % self.exprs[i].inline())
62
63 if len(str_list) == 0:
64 code('DPRINTF(RubySlicc, "$0: $1")',
65 self.exprs[0].location, format[2:format_length-2])
66 else:
67 code('DPRINTF(RubySlicc, "$0: $1", $2)',
68 self.exprs[0].location, format[2:format_length-2],
69 ', '.join(str_list))
70
49 return self.symtab.find("void", Type)
50
51 # hack for adding comments to profileTransition
52 if self.proc_name == "APPEND_TRANSITION_COMMENT":
53 # FIXME - check for number of parameters
54 code("APPEND_TRANSITION_COMMENT($0)", self.exprs[0].inline())
55 return self.symtab.find("void", Type)
56

--- 112 unchanged lines hidden ---
71 return self.symtab.find("void", Type)
72
73 # hack for adding comments to profileTransition
74 if self.proc_name == "APPEND_TRANSITION_COMMENT":
75 # FIXME - check for number of parameters
76 code("APPEND_TRANSITION_COMMENT($0)", self.exprs[0].inline())
77 return self.symtab.find("void", Type)
78

--- 112 unchanged lines hidden ---