ChangeLog: Updated ChangeLog.
[mono.git] / mcs / tests / vararg-lib.cs
1 using System;
2
3 public struct Result {
4         public int res;
5         // big enough that it won't be returned in registers
6         double duh;
7         long bah;
8
9         public Result (int val) {
10                 res = val;
11                 bah = val;
12                 duh = val;
13         }
14 }
15
16 public class Vararg
17 {
18         public static int AddABunchOfInts (__arglist)
19         {
20                 int result = 0;
21
22                 System.ArgIterator iter = new System.ArgIterator (__arglist);
23                 int argCount = iter.GetRemainingCount();
24
25                 for (int i = 0; i < argCount; i++) {
26                         System.TypedReference typedRef = iter.GetNextArg();
27                         result += (int)TypedReference.ToObject( typedRef );
28                 }
29                 
30                 return result;
31         }
32
33         public static int AddASecondBunchOfInts (int a, __arglist)
34         {
35                 int result = 0;
36
37                 System.ArgIterator iter = new System.ArgIterator (__arglist);
38                 int argCount = iter.GetRemainingCount();
39
40                 for (int i = 0; i < argCount; i++) {
41                         System.TypedReference typedRef = iter.GetNextArg();
42                         result += (int)TypedReference.ToObject( typedRef );
43                 }
44                 
45                 return result;
46         }
47
48         public static Result VtAddABunchOfInts (__arglist)
49         {
50                 int result = 0;
51
52                 System.ArgIterator iter = new System.ArgIterator (__arglist);
53                 int argCount = iter.GetRemainingCount();
54
55                 for (int i = 0; i < argCount; i++) {
56                         System.TypedReference typedRef = iter.GetNextArg();
57                         result += (int)TypedReference.ToObject( typedRef );
58                 }
59                 
60                 return new Result (result);
61         }
62
63         public static Result VtAddASecondBunchOfInts (int a, __arglist)
64         {
65                 int result = 0;
66
67                 System.ArgIterator iter = new System.ArgIterator (__arglist);
68                 int argCount = iter.GetRemainingCount();
69
70                 for (int i = 0; i < argCount; i++) {
71                         System.TypedReference typedRef = iter.GetNextArg();
72                         result += (int)TypedReference.ToObject( typedRef );
73                 }
74                 
75                 return new Result (result);
76         }
77
78         public int InstAddABunchOfInts (__arglist)
79         {
80                 int result = 0;
81
82                 System.ArgIterator iter = new System.ArgIterator (__arglist);
83                 int argCount = iter.GetRemainingCount();
84
85                 for (int i = 0; i < argCount; i++) {
86                         System.TypedReference typedRef = iter.GetNextArg();
87                         result += (int)TypedReference.ToObject( typedRef );
88                 }
89                 
90                 return result;
91         }
92
93         public int InstAddASecondBunchOfInts (int a, __arglist)
94         {
95                 int result = 0;
96
97                 System.ArgIterator iter = new System.ArgIterator (__arglist);
98                 int argCount = iter.GetRemainingCount();
99
100                 for (int i = 0; i < argCount; i++) {
101                         System.TypedReference typedRef = iter.GetNextArg();
102                         result += (int)TypedReference.ToObject( typedRef );
103                 }
104                 
105                 return result;
106         }
107
108         public Result InstVtAddABunchOfInts (__arglist)
109         {
110                 int result = 0;
111
112                 System.ArgIterator iter = new System.ArgIterator (__arglist);
113                 int argCount = iter.GetRemainingCount();
114
115                 for (int i = 0; i < argCount; i++) {
116                         System.TypedReference typedRef = iter.GetNextArg();
117                         result += (int)TypedReference.ToObject( typedRef );
118                 }
119                 
120                 return new Result (result);
121         }
122
123         public Result InstVtAddASecondBunchOfInts (int a, __arglist)
124         {
125                 int result = 0;
126
127                 System.ArgIterator iter = new System.ArgIterator (__arglist);
128                 int argCount = iter.GetRemainingCount();
129
130                 for (int i = 0; i < argCount; i++) {
131                         System.TypedReference typedRef = iter.GetNextArg();
132                         result += (int)TypedReference.ToObject( typedRef );
133                 }
134                 
135                 return new Result (result);
136         }
137 }