| 1 |
/* |
| 2 |
http://the-witness.net/news/2018/03/testing-the-jai-compiler/ |
| 3 |
with init_thing commented out |
| 4 |
*/ |
| 5 |
#import "Basic"; |
| 6 |
|
| 7 |
Thing :: struct { |
| 8 |
mem : *u8; |
| 9 |
value := 42; |
| 10 |
#constructor init_thing; |
| 11 |
#destructor free_thing; |
| 12 |
} |
| 13 |
|
| 14 |
// init_thing :: (using thing : *$T) { |
| 15 |
// mem = alloc(1000); |
| 16 |
// } |
| 17 |
|
| 18 |
free_thing :: (using thing: *$T) { |
| 19 |
free(mem); |
| 20 |
mem = null; |
| 21 |
print("Thing memory freed.\n"); |
| 22 |
} |
| 23 |
|
| 24 |
main :: () { |
| 25 |
{ |
| 26 |
our_thing : Thing; // Constructor fires off. |
| 27 |
print("%\n", our_thing); |
| 28 |
} // Destructor fires off. |
| 29 |
} |