syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / src / metamodel / vararg.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 # Copyright 2006-2008 Floréal Morandat <morandat@lirmm.fr>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 # Handle multiple number of parameters in signatures
19 package vararg
20
21 import genericity
22
23 redef class MMSignature
24 # Position of the vararg parameter. -1 in no vararg parameter
25 readable writable var _vararg_rank: Int
26
27 # Is there a vararg parameter in the signature?
28 fun has_vararg: Bool
29 do
30 return _vararg_rank >= 0
31 end
32
33 redef fun adaptation_to(r)
34 do
35 var s = super(r)
36 s.vararg_rank = _vararg_rank
37 return s
38 end
39
40 redef fun not_for_self
41 do
42 var s = super
43 s.vararg_rank = _vararg_rank
44 return s
45 end
46
47 redef init(params, return_type, r)
48 do
49 super
50 _vararg_rank = -1
51 end
52 end