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 0285efe was             4d23dd2, checked in by Thierry Delisle <tdelisle@…>, 5 years ago           | 
        
        
          | 
             
Added tests cases for some of the opened tickets 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            657 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | // Trac ticket
 | 
|---|
| 2 | // https://cforall.uwaterloo.ca/trac/ticket/7
 | 
|---|
| 3 | 
 | 
|---|
| 4 | #include <stdlib.hfa>
 | 
|---|
| 5 | extern "C" {
 | 
|---|
| 6 | #include <stdbool.h>
 | 
|---|
| 7 | }
 | 
|---|
| 8 | 
 | 
|---|
| 9 | // (Bug 1 unresolved as of this test.)
 | 
|---|
| 10 | forall(otype T)
 | 
|---|
| 11 | struct stack_node;
 | 
|---|
| 12 | 
 | 
|---|
| 13 | forall(otype T)
 | 
|---|
| 14 | struct stack_node {
 | 
|---|
| 15 |     stack_node(T) * next;
 | 
|---|
| 16 |     T item;
 | 
|---|
| 17 | };
 | 
|---|
| 18 | 
 | 
|---|
| 19 | forall(otype T)
 | 
|---|
| 20 | struct stack {
 | 
|---|
| 21 |     stack_node(T) * head;
 | 
|---|
| 22 | };
 | 
|---|
| 23 | 
 | 
|---|
| 24 | trait stack_errors(otype T) {
 | 
|---|
| 25 |     T emptyStackHandler (stack(T) * this);
 | 
|---|
| 26 | };
 | 
|---|
| 27 | 
 | 
|---|
| 28 | forall(otype T | stack_errors(T))
 | 
|---|
| 29 | T pop (stack(T) * this) {
 | 
|---|
| 30 |     return (T){};
 | 
|---|
| 31 | }
 | 
|---|
| 32 | 
 | 
|---|
| 33 | int emptyStackHandler (stack(int) * this) {
 | 
|---|
| 34 |     return 0;
 | 
|---|
| 35 | }
 | 
|---|
| 36 | 
 | 
|---|
| 37 | int main (int argc, char * argv[]) {
 | 
|---|
| 38 |     stack(int) stackOfInts;
 | 
|---|
| 39 |     pop(&stackOfInts);
 | 
|---|
| 40 |     return 0;
 | 
|---|
| 41 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.