Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/ApplicationExpr.cc

    r462a7c7 raaeacf4  
    2828#include "Type.h"                // for Type, PointerType, FunctionType
    2929
    30 ParamEntry::ParamEntry( UniqueId decl, Declaration * declptr, Type * actualType, Type * formalType, Expression* expr )
    31                 : decl( decl ), declptr( declptr ), actualType( actualType ), formalType( formalType ), expr( expr ) {
    32         }
     30ParamEntry::ParamEntry( const ParamEntry &other ) :
     31                decl( other.decl ), declptr( maybeClone( other.declptr ) ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )/*, inferParams( new InferredParams( *other.inferParams ) )*/ {
     32}
    3333
    34 ParamEntry::ParamEntry( const ParamEntry &other ) :
    35                 decl( other.decl ), declptr( maybeClone( other.declptr ) ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ) {
     34ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
     35        if ( &other == this ) return *this;
     36        const_cast<UniqueId &>(decl) = other.decl;
     37        const_cast<Declaration * &>(declptr) = maybeClone( other.declptr );
     38        // xxx - this looks like a memory leak
     39        const_cast<Type * &>(actualType) = maybeClone( other.actualType );
     40        const_cast<Type * &>(formalType) = maybeClone( other.formalType );
     41        expr = maybeClone( other.expr );
     42        // *inferParams = *other.inferParams;
     43        return *this;
    3644}
    3745
     
    4452
    4553ParamEntry::ParamEntry( ParamEntry && other ) :
    46                 decl( other.decl ), declptr( other.declptr ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr ) {
    47         new (&other) ParamEntry();
     54                decl( other.decl ), declptr( other.declptr ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr )/*, inferParams( std::move( other.inferParams ) )*/ {
     55        const_cast<Declaration * &>(other.declptr) = nullptr;
     56        const_cast<Type * &>(other.actualType) = nullptr;
     57        const_cast<Type * &>(other.formalType) = nullptr;
     58        other.expr = nullptr;
    4859}
    4960
    5061ParamEntry & ParamEntry::operator=( ParamEntry && other ) {
    5162        if ( &other == this ) return *this;
    52         this->~ParamEntry();
    53         new (this) ParamEntry(other.decl, other.declptr, other.actualType, other.formalType, other.expr);
    54         new (&other) ParamEntry();
    55 
     63        delete declptr;
     64        delete actualType;
     65        delete formalType;
     66        delete expr;
     67        const_cast<UniqueId &>(decl) = other.decl;
     68        const_cast<Declaration * &>(declptr) = other.declptr;
     69        const_cast<Type * &>(actualType) = other.actualType;
     70        const_cast<Type * &>(formalType) = other.formalType;
     71        expr = other.expr;
     72        const_cast<Declaration * &>(other.declptr) = nullptr;
     73        const_cast<Type * &>(other.actualType) = nullptr;
     74        const_cast<Type * &>(other.formalType) = nullptr;
     75        other.expr = nullptr;
     76        // inferParams = std::move( other.inferParams );
    5677        return *this;
    5778}
Note: See TracChangeset for help on using the changeset viewer.