Deleted Added
sdiff udiff text old ( 6999:f226c098c393 ) new ( 7839:9e556fb25900 )
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;

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

92 code = self.slicc.codeFormatter()
93
94 # member method call
95 obj_type = self.obj_expr_ast.generate(code)
96 methodId = obj_type.methodId(self.proc_name, paramTypes)
97
98 prefix = ""
99 implements_interface = False
100 if methodId not in obj_type.methods:
101 #
102 # The initial method check has failed, but before generating an
103 # error we must check whether any of the paramTypes implement
104 # an interface. If so, we must check if the method ids using
105 # the inherited types exist.
106 #
107 # This code is a temporary fix and only checks for the methodId
108 # where all paramTypes are converted to their inherited type. The
109 # right way to do this is to replace slicc's simple string
110 # comparison for determining the correct overloaded method, with a
111 # more robust param by param check.
112 #
113 implemented_paramTypes = []
114 for paramType in paramTypes:
115 implemented_paramType = paramType
116 if paramType.isInterface:
117 implements_interface = True
118 implemented_paramType.abstract_ident = paramType["interface"]
119 else:
120 implemented_paramType.abstract_ident = paramType.c_ident
121
122 implemented_paramTypes.append(implemented_paramType)
123
124 if implements_interface:
125 implementedMethodId = obj_type.methodIdAbstract(self.proc_name,
126 implemented_paramTypes)
127 else:
128 implementedMethodId = ""
129
130 if implementedMethodId not in obj_type.methods:
131 self.error("Invalid method call: " \
132 "Type '%s' does not have a method '%s' nor '%s'",
133 obj_type, methodId, implementedMethodId)
134 else:
135 #
136 # Replace the methodId with the implementedMethodId found in
137 # the method list.
138 #
139 methodId = implementedMethodId
140
141 return_type = obj_type.methods[methodId].return_type
142 if return_type.isInterface:
143 prefix = "static_cast<%s &>" % return_type.c_ident
144 prefix = "%s((%s)." % (prefix, code)
145
146 return obj_type, methodId, prefix
147
148
149class ClassMethodCallExprAST(MethodCallExprAST):

--- 19 unchanged lines hidden ---