Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r13d326ec r720f2fe2  
    2727#include "AST/Stmt.hpp"
    2828#include "AST/Type.hpp"
    29 #include "CodeGen/OperatorTable.h" // for isConstructor, isDestructor, isCto...
    3029#include "Common/PassVisitor.h"
    3130#include "Common/SemanticError.h"  // for SemanticError
     
    771770                        std::list< Expression * > callExprs;
    772771                        collectCtorDtorCalls( stmt, callExprs );
     772                        // if ( callExprs.empty() ) return false; // xxx - do I still need this check?
    773773                        return std::all_of( callExprs.begin(), callExprs.end(), pred);
    774774                }
     
    901901                        } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) {
    902902                                return varExpr->get_var()->get_name();
    903                         } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
     903                        }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
    904904                                return funcName( castExpr->get_arg() );
    905905                        } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) {
     
    923923                        } else if ( const ast::VariableExpr * varExpr = dynamic_cast< const ast::VariableExpr * >( func ) ) {
    924924                                return varExpr->var->name;
    925                         } else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) {
     925                        }       else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) {
    926926                                return funcName( castExpr->arg );
    927927                        } else if ( const ast::MemberExpr * memberExpr = dynamic_cast< const ast::MemberExpr * >( func ) ) {
     
    991991
    992992        Type * isPointerType( Type * type ) {
    993                 return getPointerBase( type ) ? type : nullptr;
     993                if ( getPointerBase( type ) ) return type;
     994                else return nullptr;
    994995        }
    995996
     
    10131014                                src = new AddressExpr( src );
    10141015                        }
     1016                        // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
    10151017                }
    10161018                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
     
    11651167        }
    11661168
     1169        bool isConstructor( const std::string & str ) { return str == "?{}"; }
     1170        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
     1171        bool isAssignment( const std::string & str ) { return str == "?=?"; }
     1172        bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
     1173        bool isCtorDtorAssign( const std::string & str ) { return isCtorDtor( str ) || isAssignment( str ); }
     1174
    11671175        const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname ) {
    11681176                const FunctionDecl * function = dynamic_cast< const FunctionDecl * >( decl );
     
    11841192
    11851193bool isAssignment( const ast::FunctionDecl * decl ) {
    1186         return CodeGen::isAssignment( decl->name ) && isCopyFunction( decl );
     1194        return isAssignment( decl->name ) && isCopyFunction( decl );
    11871195}
    11881196
    11891197bool isDestructor( const ast::FunctionDecl * decl ) {
    1190         return CodeGen::isDestructor( decl->name );
     1198        return isDestructor( decl->name );
    11911199}
    11921200
    11931201bool isDefaultConstructor( const ast::FunctionDecl * decl ) {
    1194         return CodeGen::isConstructor( decl->name ) && 1 == decl->params.size();
     1202        return isConstructor( decl->name ) && 1 == decl->params.size();
    11951203}
    11961204
    11971205bool isCopyConstructor( const ast::FunctionDecl * decl ) {
    1198         return CodeGen::isConstructor( decl->name ) && 2 == decl->params.size();
     1206        return isConstructor( decl->name ) && 2 == decl->params.size();
    11991207}
    12001208
     
    12141222        }
    12151223        const FunctionDecl * isDestructor( const Declaration * decl ) {
    1216                 if ( CodeGen::isDestructor( decl->name ) ) {
     1224                if ( isDestructor( decl->name ) ) {
    12171225                        return dynamic_cast< const FunctionDecl * >( decl );
    12181226                }
     
    12201228        }
    12211229        const FunctionDecl * isDefaultConstructor( const Declaration * decl ) {
    1222                 if ( CodeGen::isConstructor( decl->name ) ) {
     1230                if ( isConstructor( decl->name ) ) {
    12231231                        if ( const FunctionDecl * func = dynamic_cast< const FunctionDecl * >( decl ) ) {
    12241232                                if ( func->type->parameters.size() == 1 ) {
Note: See TracChangeset for help on using the changeset viewer.