OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [userdef.cc] - Blame information for rev 157

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* This test script is part of GDB, the GNU debugger.
2
 
3
   Copyright 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
   Free Software Foundation, Inc.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
   */
19
 
20
#include <iostream>
21
 
22
using namespace std;
23
 
24
void marker1()
25
{
26
  return;
27
}
28
 
29
class A1 {
30
  int x;
31
  int y;
32
 
33
friend ostream& operator<<(ostream& outs, A1 one);
34
 
35
public:
36
 
37
  A1(int a, int b)
38
  {
39
   x=a;
40
   y=b;
41
  }
42
 
43
A1 operator+=(int value);
44
A1 operator+(const A1&);
45
A1 operator-(const A1&);
46
A1 operator%(const A1&);
47
int operator==(const A1&);
48
int operator!=(const A1&);
49
int operator&&(const A1&);
50
int operator||(const A1&);
51
A1 operator<<(int);
52
A1 operator>>(int);
53
A1 operator|(const A1&);
54
A1 operator^(const A1&);
55
A1 operator&(const A1&);
56
int operator<(const A1&);
57
int operator<=(const A1&);
58
int operator>=(const A1&);
59
int operator>(const A1&);
60
A1 operator*(const A1&);
61
A1 operator/(const A1&);
62
A1 operator=(const A1&);
63
 
64
A1 operator~();
65
A1 operator+();
66
A1 operator-();
67
int operator!();
68
A1 operator++();
69
A1 operator++(int);
70
A1 operator--();
71
A1 operator--(int);
72
 
73
};
74
 
75
 
76
A1 A1::operator+(const A1& second)
77
{
78
 A1 sum(0,0);
79
 sum.x = x + second.x;
80
 sum.y = y + second.y;
81
 
82
 return (sum);
83
}
84
 
85
A1 A1::operator*(const A1& second)
86
{
87
 A1 product(0,0);
88
 product.x = this->x * second.x;
89
 product.y = this->y * second.y;
90
 
91
 return product;
92
}
93
 
94
A1 A1::operator-(const A1& second)
95
{
96
 A1 diff(0,0);
97
 diff.x = x - second.x;
98
 diff.y = y - second.y;
99
 
100
 return diff;
101
}
102
 
103
A1 A1::operator/(const A1& second)
104
{
105
 A1 div(0,0);
106
 div.x = x / second.x;
107
 div.y = y / second.y;
108
 
109
 return div;
110
}
111
 
112
A1 A1::operator%(const A1& second)
113
{
114
 A1 rem(0,0);
115
 rem.x = x % second.x;
116
 rem.y = y % second.y;
117
 
118
 return rem;
119
}
120
 
121
int A1::operator==(const A1& second)
122
{
123
 int a = (x == second.x);
124
 int b = (y == second.y);
125
 
126
 return (a && b);
127
}
128
 
129
int A1::operator!=(const A1& second)
130
{
131
 int a = (x != second.x);
132
 int b = (y != second.y);
133
 
134
 return (a || b);
135
}
136
 
137
int A1::operator&&(const A1& second)
138
{
139
 return ( x && second.x);
140
}
141
 
142
int A1::operator||(const A1& second)
143
{
144
 return ( x || second.x);
145
}
146
 
147
A1 A1::operator<<(int value)
148
{
149
 A1 lshft(0,0);
150
 lshft.x = x << value;
151
 lshft.y = y << value;
152
 
153
 return lshft;
154
}
155
 
156
A1 A1::operator>>(int value)
157
{
158
 A1 rshft(0,0);
159
 rshft.x = x >> value;
160
 rshft.y = y >> value;
161
 
162
 return rshft;
163
}
164
 
165
A1 A1::operator|(const A1& second)
166
{
167
 A1 abitor(0,0);
168
 abitor.x = x | second.x;
169
 abitor.y = y | second.y;
170
 
171
 return abitor;
172
}
173
 
174
A1 A1::operator^(const A1& second)
175
{
176
 A1 axor(0,0);
177
 axor.x = x ^ second.x;
178
 axor.y = y ^ second.y;
179
 
180
 return axor;
181
}
182
 
183
A1 A1::operator&(const A1& second)
184
{
185
 A1 abitand(0,0);
186
 abitand.x = x & second.x;
187
 abitand.y = y & second.y;
188
 
189
 return abitand;
190
}
191
 
192
int A1::operator<(const A1& second)
193
{
194
 A1 b(0,0);
195
 b.x = 3;
196
 return (x < second.x);
197
}
198
 
199
int A1::operator<=(const A1& second)
200
{
201
 return (x <= second.x);
202
}
203
 
204
int A1::operator>=(const A1& second)
205
{
206
 return (x >= second.x);
207
}
208
 
209
int A1::operator>(const A1& second)
210
{
211
 return (x > second.x);
212
}
213
 
214
int A1::operator!(void)
215
{
216
 return (!x);
217
}
218
 
219
A1 A1::operator-(void)
220
{
221
 A1 neg(0,0);
222
 neg.x = -x;
223
 neg.y = -y;
224
 
225
 return (neg);
226
}
227
 
228
A1 A1::operator+(void)
229
{
230
 A1 pos(0,0);
231
 pos.x = +x;
232
 pos.y = +y;
233
 
234
 return (pos);
235
}
236
 
237
A1 A1::operator~(void)
238
{
239
 A1 acompl(0,0);
240
 acompl.x = ~x;
241
 acompl.y = ~y;
242
 
243
 return (acompl);
244
}
245
 
246
A1 A1::operator++() // pre increment
247
{
248
 x = x +1;
249
 
250
 return (*this);
251
}
252
 
253
A1 A1::operator++(int) // post increment
254
{
255
 y = y +1;
256
 
257
 return (*this);
258
}
259
 
260
A1 A1::operator--() // pre decrement
261
{
262
 x = x -1;
263
 
264
 return (*this);
265
}
266
 
267
A1 A1::operator--(int) // post decrement
268
{
269
 y = y -1;
270
 
271
 return (*this);
272
}
273
 
274
 
275
A1 A1::operator=(const A1& second)
276
{
277
 
278
 x = second.x;
279
 y = second.y;
280
 
281
 return (*this);
282
}
283
 
284
A1 A1::operator+=(int value)
285
{
286
 
287
 x += value;
288
 y += value;
289
 
290
 return (*this);
291
}
292
 
293
ostream& operator<<(ostream& outs, A1 one)
294
{
295
 return (outs << endl << "x = " << one.x << endl << "y = " << one.y << endl << "-------" << endl);
296
}
297
 
298
class A2 {
299
  public:
300
A2 operator+();
301
};
302
 
303
A2 A2::operator+()
304
{
305
  return A2 ();
306
}
307
 
308
class Member
309
{
310
public:
311
  int z;
312
};
313
 
314
class Container
315
{
316
public:
317
  Member m;
318
 
319
  Member& operator* ();
320
};
321
 
322
Member& Container::operator* ()
323
{
324
  return this->m;
325
}
326
 
327
int main (void)
328
{
329
 A1 one(2,3);
330
 A1 two(4,5);
331
 A1 three(0,0);
332
 Container c;
333
 int val;
334
 
335
 marker1(); // marker1-returns-here
336
 cout << one; // marker1-returns-here
337
 cout << two;
338
 three = one + two;
339
 cout << "+ " <<  three;
340
 three = one - two;
341
 cout <<  "- " << three;
342
 three = one * two;
343
 cout <<"* " <<  three;
344
 three = one / two;
345
 cout << "/ " << three;
346
 three = one % two;
347
 cout << "% " << three;
348
 three = one | two;
349
 cout << "| " <<three;
350
 three = one ^ two;
351
 cout << "^ " <<three;
352
 three = one & two;
353
 cout << "& "<< three;
354
 
355
 val = one && two;
356
 cout << "&& " << val << endl << "-----"<<endl;
357
 val = one || two;
358
 cout << "|| " << val << endl << "-----"<<endl;
359
 val = one == two;
360
 cout << " == " << val << endl << "-----"<<endl;
361
 val = one != two;
362
 cout << "!= " << val << endl << "-----"<<endl;
363
 val = one >= two;
364
 cout << ">= " << val << endl << "-----"<<endl;
365
 val = one <= two;
366
 cout << "<= " << val << endl << "-----"<<endl;
367
 val = one < two;
368
 cout << "< " << val << endl << "-----"<<endl;
369
 val = one > two;
370
 cout << "> " << val << endl << "-----"<<endl;
371
 
372
 three = one << 2;
373
 cout << "lsh " << three;
374
 three = one >> 2;
375
 cout << "rsh " << three;
376
 
377
 three = one;
378
 cout << " = "<< three;
379
 three += 5;
380
 cout << " += "<< three;
381
 
382
 val = (!one);
383
 cout << "! " << val << endl << "-----"<<endl;
384
 three = (+one);
385
 cout << "+ " << three;
386
 three = (-one);
387
 cout << "- " << three;
388
 three = (~one);
389
 cout << " ~" << three;
390
 three++;
391
 cout << "postinc " << three;
392
 three--;
393
 cout << "postdec " << three;
394
 
395
 --three;
396
 cout << "predec " << three;
397
 ++three;
398
 cout << "preinc " << three;
399
 
400
 (*c).z = 1;
401
 
402
 return 0;
403
 
404
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.