Changeset b867278 for libcfa/prelude


Ignore:
Timestamp:
Sep 6, 2018, 10:44:46 AM (6 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:
7ba1324
Parents:
7b10ea9
Message:

Move Destructor to beginning of builtins.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    r7b10ea9 rb867278  
    1313// Update Count     : 20
    1414//
     15
     16// type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
     17// Note: needs to occur early, because it is used to generate destructor calls during code generation
     18forall(dtype T)
     19struct __Destructor {
     20        T * object;
     21        void (*dtor)(T *);
     22};
     23
     24// defined destructor in the case that non-generated code wants to use __Destructor
     25forall(dtype T)
     26static inline void ^?{}(__Destructor(T) & x) {
     27        if (x.object && x.dtor) {
     28                x.dtor(x.object);
     29        }
     30}
     31
     32// easy interface into __Destructor's destructor for easy codegen purposes
     33extern "C" {
     34        forall(dtype T)
     35        static inline void __destroy_Destructor(__Destructor(T) * dtor) {
     36                ^(*dtor){};
     37        }
     38}
    1539
    1640// exception implementation
     
    111135static inline unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; }
    112136
    113 // type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
    114 forall(dtype T)
    115 struct __Destructor {
    116   T * object;
    117   void (*dtor)(T *);
    118 };
    119 
    120 // defined destructor in the case that non-generated code wants to use __Destructor
    121 forall(dtype T)
    122 static inline void ^?{}(__Destructor(T) & x) {
    123         if (x.object && x.dtor) {
    124           x.dtor(x.object);
    125         }
    126 }
    127 
    128 // easy interface into __Destructor's destructor for easy codegen purposes
    129 extern "C" {
    130   forall(dtype T)
    131   static inline void __destroy_Destructor(__Destructor(T) * dtor) {
    132     ^(*dtor){};
    133   }
    134 }
    135 
    136137// Local Variables: //
    137138// mode: c //
Note: See TracChangeset for help on using the changeset viewer.