MethodCallExprAST.py (11029:32604f9e190b) MethodCallExprAST.py (11049:dfb0aa3f0649)
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;

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

51 code("$prefix${{self.proc_name}}(${{', '.join(params)}}))")
52 code.fix(fix)
53
54 # Verify that this is a method of the object
55 if methodId not in obj_type.methods:
56 self.error("Invalid method call: Type '%s' does not have a method '%s'",
57 obj_type, methodId)
58
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;

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

51 code("$prefix${{self.proc_name}}(${{', '.join(params)}}))")
52 code.fix(fix)
53
54 # Verify that this is a method of the object
55 if methodId not in obj_type.methods:
56 self.error("Invalid method call: Type '%s' does not have a method '%s'",
57 obj_type, methodId)
58
59 func = obj_type.methods[methodId]
60 func.checkArguments(self.expr_ast_vec)
59 if len(self.expr_ast_vec) != \
60 len(obj_type.methods[methodId].param_types):
61 # Right number of parameters
62 self.error("Wrong number of parameters for function name: '%s', " + \
63 "expected: , actual: ", proc_name,
64 len(obj_type.methods[methodId].param_types),
65 len(self.expr_ast_vec))
61
66
67 for actual_type, expected_type in \
68 zip(paramTypes, obj_type.methods[methodId].param_types):
69 if actual_type != expected_type and \
70 str(actual_type["interface"]) != str(expected_type):
71 self.error("Type mismatch: expected: %s actual: %s",
72 expected_type, actual_type)
73
62 # Return the return type of the method
63 return obj_type.methods[methodId].return_type
64
65 def findResources(self, resources):
66 pass
67
68class MemberMethodCallExprAST(MethodCallExprAST):
74 # Return the return type of the method
75 return obj_type.methods[methodId].return_type
76
77 def findResources(self, resources):
78 pass
79
80class MemberMethodCallExprAST(MethodCallExprAST):
69 def __init__(self, slicc, obj_expr_ast, func_call):
81 def __init__(self, slicc, obj_expr_ast, proc_name, expr_ast_vec):
70 s = super(MemberMethodCallExprAST, self)
82 s = super(MemberMethodCallExprAST, self)
71 s.__init__(slicc, func_call.proc_name, func_call.exprs)
83 s.__init__(slicc, proc_name, expr_ast_vec)
84
72 self.obj_expr_ast = obj_expr_ast
73
74 def __repr__(self):
75 return "[MethodCallExpr: %r%r %r]" % (self.proc_name,
76 self.obj_expr_ast,
77 self.expr_ast_vec)
78 def generate_prefix(self, paramTypes):
79 code = self.slicc.codeFormatter()

--- 98 unchanged lines hidden ---
85 self.obj_expr_ast = obj_expr_ast
86
87 def __repr__(self):
88 return "[MethodCallExpr: %r%r %r]" % (self.proc_name,
89 self.obj_expr_ast,
90 self.expr_ast_vec)
91 def generate_prefix(self, paramTypes):
92 code = self.slicc.codeFormatter()

--- 98 unchanged lines hidden ---