MemberExprAST.py (6999:f226c098c393) MemberExprAST.py (8192:be38f7b6ad9e)
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.field = field
36
37 def __repr__(self):
38 return "[MemberExprAST: %r.%r]" % (self.expr_ast, self.field)
39
40 def generate(self, code):
41 return_type, gcode = self.expr_ast.inline(True)
42 fix = code.nofix()
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.field = field
36
37 def __repr__(self):
38 return "[MemberExprAST: %r.%r]" % (self.expr_ast, self.field)
39
40 def generate(self, code):
41 return_type, gcode = self.expr_ast.inline(True)
42 fix = code.nofix()
43 code("($gcode).m_${{self.field}}")
43
44 if str(return_type) == "TBE" or ("interface" in return_type and return_type["interface"] == "AbstractCacheEntry"):
45 code("(*$gcode).m_${{self.field}}")
46 else:
47 code("($gcode).m_${{self.field}}")
48
44 code.fix(fix)
45
46 # Verify that this is a valid field name for this type
47 if self.field not in return_type.data_members:
48 self.error("Invalid object field: " +
49 "Type '%s' does not have data member %s" % \
50 (return_type, self.field))
51
52 # Return the type of the field
53 return return_type.data_members[self.field].type
49 code.fix(fix)
50
51 # Verify that this is a valid field name for this type
52 if self.field not in return_type.data_members:
53 self.error("Invalid object field: " +
54 "Type '%s' does not have data member %s" % \
55 (return_type, self.field))
56
57 # Return the type of the field
58 return return_type.data_members[self.field].type