Ignore:
Timestamp:
Oct 20, 2017, 2:00:55 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0b9be4d
Parents:
72f85de
Message:

Add Destructor type and updated handling for member destructor calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/prelude/builtins.c

    r72f85de r88e79ad  
    9191static inline unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; }
    9292
     93// type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
     94forall(dtype T)
     95struct __Destructor {
     96  T * object;
     97  void (*dtor)(T *);
     98};
     99
     100// defined destructor in the case that non-generated code wants to use __Destructor
     101forall(dtype T)
     102static inline void ^?{}(__Destructor(T) & x) {
     103  x.dtor(x.object);
     104}
     105
     106// easy interface into __Destructor's destructor for easy codegen purposes
     107extern "C" {
     108  forall(dtype T)
     109  static inline void __destroy_Destructor(__Destructor(T) * dtor) {
     110    ^(*dtor){};
     111  }
     112}
     113
    93114// Local Variables: //
    94115// mode: c //
Note: See TracChangeset for help on using the changeset viewer.