ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since 39fc03e was             3f06c05, checked in by Andrew Beach <ajbeach@…>, 5 years ago           | 
        
        
          | 
             
Fixed InstantiateGeneric so that it can handle cyclic type references (fixes #198). Does produce some extra code now (see (#199). 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            473 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [3f06c05] | 1 | // Check that a cycle of polymorphic data structures can be instancated.
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | #include <stdio.h>
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | forall(otype T)
 | 
|---|
 | 6 | struct func_table;
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | forall(otype U)
 | 
|---|
 | 9 | struct object {
 | 
|---|
 | 10 |         func_table(U) * virtual_table;
 | 
|---|
 | 11 | };
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | forall(otype T)
 | 
|---|
 | 14 | struct func_table {
 | 
|---|
 | 15 |         void (*object_func)(object(T) *);
 | 
|---|
 | 16 | };
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | void func(object(int) *) {
 | 
|---|
 | 19 |         printf("Success!\n");
 | 
|---|
 | 20 | }
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | func_table(int) an_instance = { func };
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | int main(int argc, char * argv[]) {
 | 
|---|
 | 25 |         object(int) x = { 0p };
 | 
|---|
 | 26 |         an_instance.object_func( &x );
 | 
|---|
 | 27 |         return 0;
 | 
|---|
 | 28 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.