- Timestamp:
- Dec 7, 2016, 2:47:53 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 550a3385
- Parents:
- a68caae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/coroutine.c
ra68caae r80d9e49 4 4 struct Fibonacci { 5 5 int fn; // used for communication 6 covptr_t v;7 6 coroutine c; 8 };9 10 void co_main(Fibonacci* this);11 covptr_t* vtable(Fibonacci* this);12 13 //GENERATED in proposal for virtuals14 void co_main_fib(void* this) {15 co_main( (Fibonacci*) this );16 }17 18 //GENERATED in proposal for virtuals19 static coVtable_t FibonacciVtable = {20 co_main_fib,21 VPTR_OFFSET(Fibonacci, v, c),22 VPTR_OFFSET(Fibonacci, v, fn)23 7 }; 24 8 25 9 void ?{}(Fibonacci* this) { 26 10 this->fn = 0; 27 this->v = &FibonacciVtable; //GENERATED in proposal for virtuals 28 (&this->c) { &this->v }; 11 } 12 13 coroutine* get_coroutine(Fibonacci* this) { 14 return &this->c; 29 15 } 30 16 … … 57 43 } 58 44 59 covptr_t* vtable(Fibonacci* this) {60 return &this->v;61 }62 63 45 int main() { 64 46 Fibonacci f1, f2;
Note: See TracChangeset
for help on using the changeset viewer.