136ac495dSmrg /* GNU Objective C Runtime nil receiver function
2*8feb0f0bSmrg Copyright (C) 1993-2020 Free Software Foundation, Inc.
336ac495dSmrg Contributed by Kresten Krab Thorup
436ac495dSmrg
536ac495dSmrg This file is part of GCC.
636ac495dSmrg
736ac495dSmrg GCC is free software; you can redistribute it and/or modify it under the
836ac495dSmrg terms of the GNU General Public License as published by the Free Software
936ac495dSmrg Foundation; either version 3, or (at your option) any later version.
1036ac495dSmrg
1136ac495dSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
1236ac495dSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1336ac495dSmrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1436ac495dSmrg details.
1536ac495dSmrg
1636ac495dSmrg Under Section 7 of GPL version 3, you are granted additional
1736ac495dSmrg permissions described in the GCC Runtime Library Exception, version
1836ac495dSmrg 3.1, as published by the Free Software Foundation.
1936ac495dSmrg
2036ac495dSmrg You should have received a copy of the GNU General Public License and
2136ac495dSmrg a copy of the GCC Runtime Library Exception along with this program;
2236ac495dSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2336ac495dSmrg <http://www.gnu.org/licenses/>. */
2436ac495dSmrg
2536ac495dSmrg
2636ac495dSmrg /* This is the nil method, the function that is called when the receiver
2736ac495dSmrg of a method is nil */
2836ac495dSmrg
2936ac495dSmrg #include "objc-private/common.h"
3036ac495dSmrg #include "objc/objc.h"
3136ac495dSmrg
3236ac495dSmrg /* When the receiver of a method invocation is nil, the runtime
3336ac495dSmrg returns nil_method() as the method implementation. This function
3436ac495dSmrg will be casted to whatever function was supposed to be executed to
3536ac495dSmrg execute that method (that function will take an id, followed by a
3636ac495dSmrg SEL, followed by who knows what arguments, depends on the method),
3736ac495dSmrg and executed.
3836ac495dSmrg
3936ac495dSmrg For this reason, nil_method() should be a function which can be
4036ac495dSmrg called in place of any function taking an 'id' argument followed by
4136ac495dSmrg a 'SEL' argument, followed by zero, or one, or any number of
4236ac495dSmrg arguments (both a fixed number, or a variable number !).
4336ac495dSmrg
4436ac495dSmrg There is no "proper" implementation of such a nil_method function
4536ac495dSmrg in C, however in all existing implementations it does not matter
4636ac495dSmrg when extra arguments are present, so we can simply create a function
4736ac495dSmrg taking a receiver and a selector, and all other arguments will be
4836ac495dSmrg ignored. :-)
4936ac495dSmrg */
5036ac495dSmrg
5136ac495dSmrg id
nil_method(id receiver,SEL op)5236ac495dSmrg nil_method (id receiver, SEL op __attribute__ ((__unused__)))
5336ac495dSmrg {
5436ac495dSmrg return receiver;
5536ac495dSmrg }
56