ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since ddd473f was             ecfd758, checked in by Andrew Beach <ajbeach@…>, 5 years ago           | 
        
        
          | 
             
Major exception update, seperating type-ids from virtual tables. The major interface changes are done. There is a regression of ?Cancelled(T) to Some?Cancelled. There is some bits of code for the new verion of the ?Cancelled(T) interface already there. Not connected yet but I just reached the limit of what I wanted to do in one commit and then spent over a day cleaning up, so it will replace Some?Cancelled in a future commit. 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            859 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | // Conditional Catch Test
 | 
|---|
| 2 | 
 | 
|---|
| 3 | // I may fold this back into terminate.cfa and resume.cfa once setting
 | 
|---|
| 4 | // up the non-trivial exception is reasonable to do.
 | 
|---|
| 5 | 
 | 
|---|
| 6 | #include <exception.hfa>
 | 
|---|
| 7 | 
 | 
|---|
| 8 | EHM_EXCEPTION(num_error)(
 | 
|---|
| 9 |         int num;
 | 
|---|
| 10 | );
 | 
|---|
| 11 | 
 | 
|---|
| 12 | EHM_VIRTUAL_TABLE(num_error, num_error_vt);
 | 
|---|
| 13 | 
 | 
|---|
| 14 | void caught_num_error(int expect, num_error * actual) {
 | 
|---|
| 15 |         printf("Caught num_error: expected=%d actual=%d.\n", expect, actual->num);
 | 
|---|
| 16 | }
 | 
|---|
| 17 | 
 | 
|---|
| 18 | int main(int argc, char * argv[]) {
 | 
|---|
| 19 |         num_error exc = {&num_error_vt, 2};
 | 
|---|
| 20 | 
 | 
|---|
| 21 |         try {
 | 
|---|
| 22 |                 throw exc;
 | 
|---|
| 23 |         } catch (num_error * error ; 3 == error->num ) {
 | 
|---|
| 24 |                 caught_num_error(3, error);
 | 
|---|
| 25 |         } catch (num_error * error ; 2 == error->num ) {
 | 
|---|
| 26 |                 caught_num_error(2, error);
 | 
|---|
| 27 |         }
 | 
|---|
| 28 | 
 | 
|---|
| 29 |         try {
 | 
|---|
| 30 |                 throwResume exc;
 | 
|---|
| 31 |         } catchResume (num_error * error ; 3 == error->num ) {
 | 
|---|
| 32 |                 caught_num_error(3, error);
 | 
|---|
| 33 |         } catchResume (num_error * error ; 2 == error->num ) {
 | 
|---|
| 34 |                 caught_num_error(2, error);
 | 
|---|
| 35 |         }
 | 
|---|
| 36 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.