ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
Last change
on this file since 0c78741 was ae6f1ec, checked in by Thierry Delisle <tdelisle@…>, 8 years ago |
Some work on an exception prototype
|
-
Property mode
set to
100644
|
File size:
510 bytes
|
Rev | Line | |
---|
[ae6f1ec] | 1 | #include <stdio.h>
|
---|
| 2 | #include "except.h"
|
---|
| 3 |
|
---|
| 4 | struct raii_t {
|
---|
| 5 | char * msg;
|
---|
| 6 | };
|
---|
| 7 |
|
---|
| 8 | void ^?{}( type_raii_t * this ) {
|
---|
| 9 | printf("%s\n", this->msg);
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | void bar() {
|
---|
| 13 | raii_t a = { "Bar dtor" };
|
---|
| 14 |
|
---|
| 15 | throw( 3 );
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | void foo() {
|
---|
| 19 | raii_t a = { "Foo dtor" };
|
---|
| 20 |
|
---|
| 21 | try {
|
---|
| 22 | raii_t b = { "Foo try dtor" };
|
---|
| 23 |
|
---|
| 24 | bar();
|
---|
| 25 |
|
---|
| 26 | printf("Called bar successfully\n");
|
---|
| 27 | }
|
---|
| 28 | catch( 2 ) {
|
---|
| 29 | printf("Exception caught\n");
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | printf( "Foo exited normally\n" );
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | int main() {
|
---|
| 36 | raii_t a = { "Main dtor" };
|
---|
| 37 |
|
---|
| 38 | foo();
|
---|
| 39 |
|
---|
| 40 | printf("End of program reached\n");
|
---|
| 41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.