Mercurial > projects > dang
annotate tests/code/array_1.d @ 96:438e6ed4cda1 new_gen
Now D-Mangling the function types. Still need to mangle "scopes" - by that i mean structs, classes and modules.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 06 May 2008 18:51:08 +0200 |
parents | 9f66771fb1a3 |
children | 857f0d530789 |
rev | line source |
---|---|
73
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
1 |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
2 struct Array |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
3 { |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
4 int[] data; |
96
438e6ed4cda1
Now D-Mangling the function types. Still need to mangle "scopes" - by that i mean structs, classes and modules.
Anders Johnsen <skabet@gmail.com>
parents:
73
diff
changeset
|
5 int length; |
73
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
6 } |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
7 |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
8 void insert(Array a, int v) |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
9 { |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
10 a.length = a.length + 1; |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
11 a.data[a.length - 1] = v; |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
12 } |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
13 |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
14 int main() |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
15 { |
96
438e6ed4cda1
Now D-Mangling the function types. Still need to mangle "scopes" - by that i mean structs, classes and modules.
Anders Johnsen <skabet@gmail.com>
parents:
73
diff
changeset
|
16 Array a; |
73
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
17 a.length = 0; |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
18 |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
19 insert(a, 5); |
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
20 |
96
438e6ed4cda1
Now D-Mangling the function types. Still need to mangle "scopes" - by that i mean structs, classes and modules.
Anders Johnsen <skabet@gmail.com>
parents:
73
diff
changeset
|
21 return a.data[0]; |
73
9f66771fb1a3
Forgot a test file for arrays...
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
22 } |