MethodCallExprAST.py (6999:f226c098c393) | MethodCallExprAST.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; --- 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 | 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: | 100 101 if methodId in obj_type.methods: 102 return_type = obj_type.methods[methodId].return_type 103 104 else: |
101 # | 105 # |
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"] | 106 # Check whether the method is implemented by the super class 107 if "interface" in obj_type: 108 interface_type = self.symtab.find(obj_type["interface"]); 109 110 if methodId in interface_type.methods: 111 return_type = interface_type.methods[methodId].return_type 112 obj_type = interface_type 113 |
119 else: | 114 else: |
120 implemented_paramType.abstract_ident = paramType.c_ident 121 122 implemented_paramTypes.append(implemented_paramType) | 115 self.error("Invalid method call: " \ 116 "Type '%s' does not have a method %s, '%s'", 117 obj_type, self.proc_name, methodId) |
123 | 118 |
124 if implements_interface: 125 implementedMethodId = obj_type.methodIdAbstract(self.proc_name, 126 implemented_paramTypes) | |
127 else: | 119 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 | 120 # 121 # The initial method check has failed, but before generating an 122 # error we must check whether any of the paramTypes implement 123 # an interface. If so, we must check if the method ids using 124 # the inherited types exist. 125 # 126 # This code is a temporary fix and only checks for the methodId 127 # where all paramTypes are converted to their inherited type. The 128 # right way to do this is to replace slicc's simple string 129 # comparison for determining the correct overloaded method, with a 130 # more robust param by param check. 131 # 132 implemented_paramTypes = [] 133 for paramType in paramTypes: 134 implemented_paramType = paramType 135 if paramType.isInterface: 136 implements_interface = True 137 implemented_paramType.abstract_ident = paramType["interface"] 138 else: 139 implemented_paramType.abstract_ident = paramType.c_ident 140 141 implemented_paramTypes.append(implemented_paramType) 142 143 if implements_interface: 144 implementedMethodId = obj_type.methodIdAbstract(self.proc_name, 145 implemented_paramTypes) 146 else: 147 implementedMethodId = "" 148 149 if implementedMethodId not in obj_type.methods: 150 self.error("Invalid method call: " \ 151 "Type '%s' does not have a method %s, '%s' nor '%s'", 152 obj_type, self.proc_name, methodId, implementedMethodId) 153 else: 154 # 155 # Replace the methodId with the implementedMethodId found in 156 # the method list. 157 # 158 methodId = implementedMethodId 159 return_type = obj_type.methods[methodId].return_type 160 |
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 --- | 161 if return_type.isInterface: 162 prefix = "static_cast<%s &>" % return_type.c_ident 163 prefix = "%s((%s)." % (prefix, code) 164 165 return obj_type, methodId, prefix 166 167 168class ClassMethodCallExprAST(MethodCallExprAST): --- 19 unchanged lines hidden --- |