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 91fb850 was             1c01c58, checked in by Andrew Beach <ajbeach@…>, 5 years ago | 
        
          | 
Rather large commit to get coroutine cancellation working.
 
This includes what you would expect, like new code in exceptions and a newtest, but it also includes a bunch of other things.
 
 
New coroutine state, currently just marks that the stack was cancelled. Newhelpers for checking code structure and generating vtables. Changes to the
 coroutine interface so resume may throw exceptions on cancellation, plus the
 exception type that is thrown. Changes to the coroutine keyword generation to
 generate exception code for each type of coroutine.
 
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            643 bytes | 
      
      
| Line |  | 
|---|
| 1 | // Try cancelling a coroutine. | 
|---|
| 2 |  | 
|---|
| 3 | #include <stdio.h> | 
|---|
| 4 | #include <coroutine.hfa> | 
|---|
| 5 | #include <exception.hfa> | 
|---|
| 6 |  | 
|---|
| 7 | TRIVIAL_EXCEPTION(internal_error); | 
|---|
| 8 |  | 
|---|
| 9 | coroutine WillCancel {}; | 
|---|
| 10 |  | 
|---|
| 11 | const char * msg(CoroutineCancelled(WillCancel) * this) { | 
|---|
| 12 | return "CoroutineCancelled(WillCancel)"; | 
|---|
| 13 | } | 
|---|
| 14 |  | 
|---|
| 15 | void main(WillCancel & wc) { | 
|---|
| 16 | printf("1"); | 
|---|
| 17 | cancel_stack((internal_error){}); | 
|---|
| 18 | printf("!"); | 
|---|
| 19 | } | 
|---|
| 20 |  | 
|---|
| 21 | int main(int argc, char * argv[]) { | 
|---|
| 22 | WillCancel cancel; | 
|---|
| 23 | try { | 
|---|
| 24 | printf("0"); | 
|---|
| 25 | resume(cancel); | 
|---|
| 26 | printf("4"); | 
|---|
| 27 | } catchResume (CoroutineCancelled(WillCancel) * error) { | 
|---|
| 28 | printf("2"); | 
|---|
| 29 | if ((virtual internal_error *)error->the_exception) { | 
|---|
| 30 | printf("3"); | 
|---|
| 31 | } | 
|---|
| 32 | } | 
|---|
| 33 | printf("5\n"); | 
|---|
| 34 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.