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