Changeset 80d9e49 for src/tests


Ignore:
Timestamp:
Dec 7, 2016, 2:47:53 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Coroutines no longer require virtual pointers or any code beyond the get_coroutine routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine.c

    ra68caae r80d9e49  
    44struct Fibonacci {
    55      int fn; // used for communication
    6       covptr_t v;
    76      coroutine c;
    8 };
    9 
    10 void co_main(Fibonacci* this);
    11 covptr_t* vtable(Fibonacci* this);
    12 
    13 //GENERATED in proposal for virtuals
    14 void co_main_fib(void* this) {
    15       co_main( (Fibonacci*) this );
    16 }
    17 
    18 //GENERATED in proposal for virtuals
    19 static coVtable_t FibonacciVtable = {
    20       co_main_fib,
    21       VPTR_OFFSET(Fibonacci, v, c),
    22       VPTR_OFFSET(Fibonacci, v, fn)     
    237};
    248
    259void ?{}(Fibonacci* this) {
    2610      this->fn = 0;
    27       this->v = &FibonacciVtable;  //GENERATED in proposal for virtuals
    28       (&this->c) { &this->v };
     11}
     12
     13coroutine* get_coroutine(Fibonacci* this) {
     14      return &this->c;
    2915}
    3016
     
    5743}
    5844
    59 covptr_t* vtable(Fibonacci* this) {
    60       return &this->v;
    61 }
    62 
    6345int main() {
    6446      Fibonacci f1, f2;
Note: See TracChangeset for help on using the changeset viewer.