Changes in / [101e0bd:fc4a0fa]


Ignore:
Location:
src
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r101e0bd rfc4a0fa  
    3333#include "SymTab/Autogen.h"
    3434#include "GenPoly/PolyMutator.h"
     35#include "GenPoly/DeclMutator.h"
    3536#include "SynTree/AddStmtVisitor.h"
    3637#include "CodeGen/GenType.h"  // for warnings
     
    216217                        SymTab::Indexer & indexer;
    217218                };
     219
     220                class FixCtorExprs : public GenPoly::DeclMutator {
     221                  public:
     222                        /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument
     223                        static void fix( std::list< Declaration * > & translationUnit );
     224
     225                        virtual Expression * mutate( ConstructorExpr * ctorExpr );
     226                };
    218227        } // namespace
    219228
     
    221230                // fixes ConstructorInit for global variables. should happen before fixInitializers.
    222231                InitTweak::fixGlobalInit( translationUnit, filename, inLibrary );
     232
    223233
    224234                InsertImplicitCalls::insert( translationUnit );
     
    231241
    232242                GenStructMemberCalls::generate( translationUnit );
     243                // xxx - ctor expansion currently has to be after FixCopyCtors, because there is currently a
     244                // hack in the way untyped assignments are generated, where the first argument cannot have
     245                // its address taken because of the way codegeneration handles UntypedExpr vs. ApplicationExpr.
     246                // Thus such assignment exprs must never pushed through expression resolution (and thus should
     247                // not go through the FixCopyCtors pass), otherwise they will fail -- guaranteed.
     248                // Also needs to happen after GenStructMemberCalls, since otherwise member constructors exprs
     249                // don't look right, and a member can be constructed more than once.
     250                FixCtorExprs::fix( translationUnit );
    233251        }
    234252
     
    283301                                throw warner.errors;
    284302                        }
     303                }
     304
     305                void FixCtorExprs::fix( std::list< Declaration * > & translationUnit ) {
     306                        FixCtorExprs fixer;
     307                        fixer.mutateDeclarationList( translationUnit );
    285308                }
    286309
     
    480503                                        retExpr = deref;
    481504                                } // if
    482                                 // xxx - might need to set env on retExpr...
    483                                 // retExpr->set_env( env->clone() );
     505                                retExpr->set_env( env->clone() );
    484506                                return retExpr;
    485507                        } else {
     
    914936                        return safe_dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untypedExpr, indexer ) );
    915937                }
     938
     939                Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) {
     940                        static UniqueName tempNamer( "_tmp_ctor_expr" );
     941                        assert( ctorExpr->get_results().size() == 1 );
     942                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr );
     943                        addDeclaration( tmp );
     944
     945                        ApplicationExpr * callExpr = safe_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() );
     946                        TypeSubstitution * env = ctorExpr->get_env();
     947                        ctorExpr->set_callExpr( nullptr );
     948                        ctorExpr->set_env( nullptr );
     949
     950                        Expression *& firstArg = callExpr->get_args().front();
     951                        UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) );
     952                        assign->get_args().push_back( new VariableExpr( tmp ) );
     953                        assign->get_args().push_back( firstArg );
     954                        cloneAll( ctorExpr->get_results(), assign->get_results() );
     955                        firstArg = assign;
     956
     957                        CommaExpr * commaExpr = new CommaExpr( callExpr, new VariableExpr( tmp ) );
     958                        commaExpr->set_env( env );
     959                        delete ctorExpr;
     960                        return commaExpr;
     961                }
    916962        } // namespace
    917963} // namespace InitTweak
  • src/InitTweak/InitTweak.cc

    r101e0bd rfc4a0fa  
    358358                template<typename CallExpr>
    359359                Expression *& callArg( CallExpr * callExpr, unsigned int pos ) {
    360                         if ( pos >= callExpr->get_args().size() ) assert( false && "asking for argument that doesn't exist. Return NULL/throw exception?" );
     360                        if ( pos >= callExpr->get_args().size() ) assertf( false, "asking for argument that doesn't exist. Return NULL/throw exception?" );
    361361                        for ( Expression *& arg : callExpr->get_args() ) {
    362362                                if ( pos == 0 ) return arg;
     
    373373                        return callArg( untypedExpr, pos );
    374374                } else {
    375                         assert( false && "Unexpected expression type passed to getCallArg" );
     375                        assertf( false, "Unexpected expression type passed to getCallArg" );
    376376                }
    377377        }
     
    387387                        } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) {
    388388                                return memberExpr->get_member()->get_name();
     389                        } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) {
     390                                return memberExpr->get_member();
    389391                        } else {
    390                                 assert( false && "Unexpected expression type being called as a function in call expression" );
     392                                assertf( false, "Unexpected expression type being called as a function in call expression" );
    391393                        }
    392394                }
     
    400402                } else {
    401403                        std::cerr << expr << std::endl;
    402                         assert( false && "Unexpected expression type passed to getFunctionName" );
     404                        assertf( false, "Unexpected expression type passed to getFunctionName" );
    403405                }
    404406        }
  • src/Parser/parser.yy

    r101e0bd rfc4a0fa  
    389389                {
    390390                        Token fn;
    391                         fn.str = new std::string( "?{}" ); // location undefined
    392                         $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) );
     391                        fn.str = new std::string( "?{}" ); // location undefined - use location of '{'?
     392                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    393393                }
    394394        ;
  • src/ResolvExpr/AlternativeFinder.cc

    r101e0bd rfc4a0fa  
    197197        }
    198198
    199         void AlternativeFinder::find( Expression *expr, bool adjust ) {
     199        void AlternativeFinder::find( Expression *expr, bool adjust, bool prune ) {
    200200                expr->accept( *this );
    201201                if ( alternatives.empty() ) {
     
    207207                        }
    208208                }
    209                 PRINT(
    210                         std::cerr << "alternatives before prune:" << std::endl;
    211                         printAlts( alternatives, std::cerr );
    212                 )
    213                 AltList::iterator oldBegin = alternatives.begin();
    214                 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer );
    215                 if ( alternatives.begin() == oldBegin ) {
    216                         std::ostringstream stream;
    217                         stream << "Can't choose between alternatives for expression ";
    218                         expr->print( stream );
    219                         stream << "Alternatives are:";
    220                         AltList winners;
    221                         findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) );
    222                         printAlts( winners, stream, 8 );
    223                         throw SemanticError( stream.str() );
    224                 }
    225                 alternatives.erase( oldBegin, alternatives.end() );
    226                 PRINT(
    227                         std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
    228                 )
     209                if ( prune ) {
     210                        PRINT(
     211                                std::cerr << "alternatives before prune:" << std::endl;
     212                                printAlts( alternatives, std::cerr );
     213                        )
     214                        AltList::iterator oldBegin = alternatives.begin();
     215                        pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer );
     216                        if ( alternatives.begin() == oldBegin ) {
     217                                std::ostringstream stream;
     218                                stream << "Can't choose between alternatives for expression ";
     219                                expr->print( stream );
     220                                stream << "Alternatives are:";
     221                                AltList winners;
     222                                findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) );
     223                                printAlts( winners, stream, 8 );
     224                                throw SemanticError( stream.str() );
     225                        }
     226                        alternatives.erase( oldBegin, alternatives.end() );
     227                        PRINT(
     228                                std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
     229                        )
     230                }
    229231
    230232                // Central location to handle gcc extension keyword for all expression types.
     
    234236        }
    235237
    236         void AlternativeFinder::findWithAdjustment( Expression *expr ) {
    237                 find( expr, true );
     238        void AlternativeFinder::findWithAdjustment( Expression *expr, bool prune ) {
     239                find( expr, true, prune );
    238240        }
    239241
    240242        template< typename StructOrUnionType >
    241         void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name ) {
     243        void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) {
    242244                std::list< Declaration* > members;
    243245                aggInst->lookup( name, members );
     
    760762                        if ( agg->expr->get_results().size() == 1 ) {
    761763                                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) {
    762                                         addAggMembers( structInst, agg->expr, agg->cost, memberExpr->get_member() );
     764                                        addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    763765                                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) {
    764                                         addAggMembers( unionInst, agg->expr, agg->cost, memberExpr->get_member() );
     766                                        addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    765767                                } // if
    766768                        } // if
     
    789791                        renameTypes( alternatives.back().expr );
    790792                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) {
    791                                 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), "" );
     793                                addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
    792794                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) {
    793                                 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), "" );
     795                                addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
    794796                        } // if
    795797                } // for
     
    10121014                alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) );
    10131015        }
     1016
     1017        void AlternativeFinder::visit( ConstructorExpr * ctorExpr ) {
     1018                AlternativeFinder finder( indexer, env );
     1019                // don't prune here, since it's guaranteed all alternatives will have the same type
     1020                // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
     1021                finder.findWithAdjustment( ctorExpr->get_callExpr(), false );
     1022                for ( Alternative & alt : finder.alternatives ) {
     1023                        alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) );
     1024                }
     1025        }
    10141026} // namespace ResolvExpr
    10151027
  • src/ResolvExpr/AlternativeFinder.h

    r101e0bd rfc4a0fa  
    2929          public:
    3030                AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env );
    31                 void find( Expression *expr, bool adjust = false );
     31                void find( Expression *expr, bool adjust = false, bool prune = true );
    3232                /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types
    33                 void findWithAdjustment( Expression *expr );
     33                void findWithAdjustment( Expression *expr, bool prune = true );
    3434                AltList &get_alternatives() { return alternatives; }
    3535
     
    6666                virtual void visit( TupleExpr *tupleExpr );
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
     68                virtual void visit( ConstructorExpr * ctorExpr );
    6869          public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
    6970                template< typename InputIterator, typename OutputIterator >
     
    7273          private:
    7374                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    74                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name );
     75                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name );
    7576                /// Adds alternatives for offsetof expressions, given the base type and name of the member
    7677                template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
  • src/SymTab/Validate.cc

    r101e0bd rfc4a0fa  
    6060#include "ResolvExpr/typeops.h"
    6161#include <algorithm>
     62#include "InitTweak/InitTweak.h"
    6263
    6364#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
     
    171172        };
    172173
    173         class VerifyCtorDtor : public Visitor {
     174        class VerifyCtorDtorAssign : public Visitor {
    174175        public:
    175                 /// ensure that constructors and destructors have at least one
    176                 /// parameter, the first of which must be a pointer, and no
     176                /// ensure that constructors, destructors, and assignment have at least one
     177                /// parameter, the first of which must be a pointer, and that ctor/dtors have no
    177178                /// return values.
    178179                static void verify( std::list< Declaration * > &translationUnit );
     
    202203                compoundliteral.mutateDeclarationList( translationUnit );
    203204                acceptAll( translationUnit, pass3 );
    204                 VerifyCtorDtor::verify( translationUnit );
     205                VerifyCtorDtorAssign::verify( translationUnit );
    205206        }
    206207
     
    687688        }
    688689
    689         void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {
    690                 VerifyCtorDtor verifier;
     690        void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) {
     691                VerifyCtorDtorAssign verifier;
    691692                acceptAll( translationUnit, verifier );
    692693        }
    693694
    694         void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {
     695        void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) {
    695696                FunctionType * funcType = funcDecl->get_functionType();
    696697                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
    697698                std::list< DeclarationWithType * > &params = funcType->get_parameters();
    698699
    699                 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {
     700                if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) {
    700701                        if ( params.size() == 0 ) {
    701                                 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );
     702                                throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl );
    702703                        }
    703704                        if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {
    704                                 throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );
     705                                throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl );
    705706                        }
    706                         if ( returnVals.size() != 0 ) {
     707                        if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    707708                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
    708709                        }
  • src/SynTree/Expression.cc

    r101e0bd rfc4a0fa  
    2828#include "TypeSubstitution.h"
    2929#include "Common/utility.h"
     30#include "InitTweak/InitTweak.h"
    3031
    3132
     
    493494
    494495void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
    495         os << std::string( indent, ' ' ) << "Implicit Copy Constructor Expression: " << std::endl;
     496        os << "Implicit Copy Constructor Expression: " << std::endl;
    496497        assert( callExpr );
    497498        callExpr->print( os, indent + 2 );
     
    503504}
    504505
     506
     507ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) {
     508        // allow resolver to type a constructor used as an expression as if it has the same type as its first argument
     509        assert( callExpr );
     510        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
     511        assert( arg );
     512        cloneAll( arg->get_results(), results );
     513}
     514
     515ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
     516}
     517
     518ConstructorExpr::~ConstructorExpr() {
     519        delete callExpr;
     520}
     521
     522void ConstructorExpr::print( std::ostream &os, int indent ) const {
     523        os <<  "Constructor Expression: " << std::endl;
     524        assert( callExpr );
     525        os << std::string( indent+2, ' ' );
     526        callExpr->print( os, indent + 2 );
     527        Expression::print( os, indent );
     528}
     529
     530
     531CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     532        add_result( type->clone() );
     533}
     534
     535CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     536
     537CompoundLiteralExpr::~CompoundLiteralExpr() {
     538        delete initializer;
     539        delete type;
     540}
     541
     542void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
     543        os << "Compound Literal Expression: " << std::endl;
     544        if ( type ) type->print( os, indent + 2 );
     545        if ( initializer ) initializer->print( os, indent + 2 );
     546}
     547
    505548UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    506549
     
    511554        if ( get_body() != 0 )
    512555                get_body()->print( os, indent + 2 );
    513 }
    514 
    515 
    516 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    517         add_result( type->clone() );
    518 }
    519 
    520 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
    521 
    522 CompoundLiteralExpr::~CompoundLiteralExpr() {
    523         delete initializer;
    524         delete type;
    525 }
    526 
    527 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
    528         os << "Compound Literal Expression: " << std::endl;
    529         if ( type ) type->print( os, indent + 2 );
    530         if ( initializer ) initializer->print( os, indent + 2 );
    531556}
    532557
  • src/SynTree/Expression.h

    r101e0bd rfc4a0fa  
    595595};
    596596
     597/// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 };
     598class ConstructorExpr : public Expression {
     599public:
     600        ConstructorExpr( Expression * callExpr );
     601        ConstructorExpr( const ConstructorExpr & other );
     602        ~ConstructorExpr();
     603
     604        Expression *get_callExpr() const { return callExpr; }
     605        void set_callExpr( Expression *newValue ) { callExpr = newValue; }
     606
     607        virtual ConstructorExpr *clone() const { return new ConstructorExpr( *this ); }
     608        virtual void accept( Visitor &v ) { v.visit( this ); }
     609        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     610        virtual void print( std::ostream &os, int indent = 0 ) const;
     611private:
     612        Expression * callExpr;
     613};
     614
     615/// CompoundLiteralExpr represents a C99 'compound literal'
     616class CompoundLiteralExpr : public Expression {
     617  public:
     618        CompoundLiteralExpr( Type * type, Initializer * initializer );
     619        CompoundLiteralExpr( const CompoundLiteralExpr &other );
     620        ~CompoundLiteralExpr();
     621
     622        Type * get_type() const { return type; }
     623        void set_type( Type * t ) { type = t; }
     624
     625        Initializer * get_initializer() const { return initializer; }
     626        void set_initializer( Initializer * i ) { initializer = i; }
     627
     628        virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); }
     629        virtual void accept( Visitor &v ) { v.visit( this ); }
     630        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     631        virtual void print( std::ostream &os, int indent = 0 ) const;
     632  private:
     633        Type * type;
     634        Initializer * initializer;
     635};
     636
    597637/// ValofExpr represents a GCC 'lambda expression'
    598638class UntypedValofExpr : public Expression {
     
    613653};
    614654
    615 /// CompoundLiteralExpr represents a C99 'compound literal'
    616 class CompoundLiteralExpr : public Expression {
    617   public:
    618         CompoundLiteralExpr( Type * type, Initializer * initializer );
    619         CompoundLiteralExpr( const CompoundLiteralExpr &other );
    620         ~CompoundLiteralExpr();
    621 
    622         Type * get_type() const { return type; }
    623         void set_type( Type * t ) { type = t; }
    624 
    625         Initializer * get_initializer() const { return initializer; }
    626         void set_initializer( Initializer * i ) { initializer = i; }
    627 
    628         virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); }
    629         virtual void accept( Visitor &v ) { v.visit( this ); }
    630         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    631         virtual void print( std::ostream &os, int indent = 0 ) const;
    632   private:
    633         Type * type;
    634         Initializer * initializer;
    635 };
    636 
     655/// RangeExpr represents a range e.g. '3 ... 5' or '1~10'
    637656class RangeExpr : public Expression {
    638657  public:
  • src/SynTree/Mutator.cc

    r101e0bd rfc4a0fa  
    339339}
    340340
    341 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    342         mutateAll( valofExpr->get_results(), *this );
    343         return valofExpr;
     341Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
     342        mutateAll( ctorExpr->get_results(), *this );
     343        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
     344        return ctorExpr;
    344345}
    345346
     
    349350        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    350351        return compLitExpr;
     352}
     353
     354Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
     355        mutateAll( valofExpr->get_results(), *this );
     356        return valofExpr;
    351357}
    352358
  • src/SynTree/Mutator.h

    r101e0bd rfc4a0fa  
    7676        virtual Expression* mutate( AsmExpr *asmExpr );
    7777        virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr );
     78        virtual Expression* mutate( ConstructorExpr *ctorExpr );
     79        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    7880        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    79         virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    8081        virtual Expression* mutate( RangeExpr *rangeExpr );
    8182
  • src/SynTree/SynTree.h

    r101e0bd rfc4a0fa  
    8181class AsmExpr;
    8282class ImplicitCopyCtorExpr;
     83class ConstructorExpr;
     84class CompoundLiteralExpr;
    8385class UntypedValofExpr;
    84 class CompoundLiteralExpr;
    8586class RangeExpr;
    8687
  • src/SynTree/Visitor.cc

    r101e0bd rfc4a0fa  
    287287}
    288288
    289 void Visitor::visit( UntypedValofExpr *valofExpr ) {
    290         acceptAll( valofExpr->get_results(), *this );
    291         maybeAccept( valofExpr->get_body(), *this );
     289void Visitor::visit( ConstructorExpr * ctorExpr ) {
     290        acceptAll( ctorExpr->get_results(), *this );
     291        maybeAccept( ctorExpr->get_callExpr(), *this );
    292292}
    293293
     
    296296        maybeAccept( compLitExpr->get_type(), *this );
    297297        maybeAccept( compLitExpr->get_initializer(), *this );
     298}
     299
     300void Visitor::visit( UntypedValofExpr *valofExpr ) {
     301        acceptAll( valofExpr->get_results(), *this );
     302        maybeAccept( valofExpr->get_body(), *this );
    298303}
    299304
  • src/SynTree/Visitor.h

    r101e0bd rfc4a0fa  
    7676        virtual void visit( AsmExpr *asmExpr );
    7777        virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );
     78        virtual void visit( ConstructorExpr * ctorExpr );
     79        virtual void visit( CompoundLiteralExpr *compLitExpr );
    7880        virtual void visit( UntypedValofExpr *valofExpr );
    79         virtual void visit( CompoundLiteralExpr *compLitExpr );
    8081        virtual void visit( RangeExpr *rangeExpr );
    8182
  • src/include/assert.h

    r101e0bd rfc4a0fa  
    2222#define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ))
    2323
    24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... );
     24void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn));
    2525
    2626template<typename T, typename U>
  • src/libcfa/prelude.cf

    r101e0bd rfc4a0fa  
    636636
    637637// default ctor
    638 void    ?{}( _Bool * ),                         ?{}( volatile _Bool * );
    639 void    ?{}( char * ),  ?{}( volatile char * );
    640 void    ?{}( unsigned char * ), ?{}( volatile unsigned char * );
    641 void    ?{}( char signed * ),                   ?{}( volatile char signed * );
    642 void    ?{}( int short * ),                             ?{}( volatile int short * );
    643 void    ?{}( int short unsigned * ),    ?{}( volatile int short unsigned * );
    644 void    ?{}( signed int * ),                    ?{}( volatile signed int * );
    645 void    ?{}( unsigned int * ),                  ?{}( volatile unsigned int * );
    646 void    ?{}( signed long int * ),               ?{}( volatile signed long int * );
    647 void    ?{}( unsigned long int * ),             ?{}( volatile unsigned long int * );
    648 void    ?{}( signed long long int * ),          ?{}( volatile signed long long int * );
    649 void    ?{}( unsigned long long int * ),        ?{}( volatile unsigned long long int * );
    650 void    ?{}( float * ),                         ?{}( volatile float * );
    651 void    ?{}( double * ),                        ?{}( volatile double * );
    652 void    ?{}( long double * ),                   ?{}( volatile long double * );
    653 void    ?{}( float _Complex * ),                ?{}( volatile float _Complex * );
    654 void    ?{}( double _Complex * ),               ?{}( volatile double _Complex * );
    655 void    ?{}( long double _Complex * ),          ?{}( volatile long double _Complex * );
     638void    ?{}( _Bool * );
     639void    ?{}( char * );
     640void    ?{}( unsigned char * );
     641void    ?{}( char signed * );
     642void    ?{}( int short * );
     643void    ?{}( int short unsigned * );
     644void    ?{}( signed int * );
     645void    ?{}( unsigned int * );
     646void    ?{}( signed long int * );
     647void    ?{}( unsigned long int * );
     648void    ?{}( signed long long int * );
     649void    ?{}( unsigned long long int * );
     650void    ?{}( float * );
     651void    ?{}( double * );
     652void    ?{}( long double * );
     653void    ?{}( float _Complex * );
     654void    ?{}( double _Complex * );
     655void    ?{}( long double _Complex * );
    656656
    657657// copy ctor
    658 void    ?{}( _Bool *, _Bool ),                                  ?{}( volatile _Bool *, _Bool );
    659 void    ?{}( char *, char ),    ?{}( volatile char *, char );
    660 void    ?{}( unsigned char *, unsigned char ),                  ?{}( volatile unsigned char *, unsigned char );
    661 void    ?{}( char signed *, char signed ),                      ?{}( volatile char signed *, char signed );
    662 void    ?{}( int short *, int short ),                          ?{}( volatile int short *, int short );
    663 void    ?{}( int short unsigned *, int short unsigned ),        ?{}( volatile int short unsigned *, int short unsigned );
    664 void    ?{}( signed int *, signed int),                         ?{}( volatile signed int *, signed int );
    665 void    ?{}( unsigned int *, unsigned int),                     ?{}( volatile unsigned int *, unsigned int );
    666 void    ?{}( signed long int *, signed long int),               ?{}( volatile signed long int *, signed long int );
    667 void    ?{}( unsigned long int *, unsigned long int),           ?{}( volatile unsigned long int *, unsigned long int );
    668 void    ?{}( signed long long int *, signed long long int),     ?{}( volatile signed long long int *, signed long long int );
    669 void    ?{}( unsigned long long int *, unsigned long long int), ?{}( volatile unsigned long long int *, unsigned long long int );
    670 void    ?{}( float *, float),                                   ?{}( volatile float *, float );
    671 void    ?{}( double *, double),                                 ?{}( volatile double *, double );
    672 void    ?{}( long double *, long double),                       ?{}( volatile long double *, long double );
    673 void    ?{}( float _Complex *, float _Complex),                 ?{}( volatile float _Complex *, float _Complex );
    674 void    ?{}( double _Complex *, double _Complex),               ?{}( volatile double _Complex *, double _Complex );
    675 void    ?{}( long double _Complex *, long double _Complex),     ?{}( volatile long double _Complex *, long double _Complex );
     658void    ?{}( _Bool *, _Bool );
     659void    ?{}( char *, char );
     660void    ?{}( unsigned char *, unsigned char );
     661void    ?{}( char signed *, char signed );
     662void    ?{}( int short *, int short );
     663void    ?{}( int short unsigned *, int short unsigned );
     664void    ?{}( signed int *, signed int);
     665void    ?{}( unsigned int *, unsigned int);
     666void    ?{}( signed long int *, signed long int);
     667void    ?{}( unsigned long int *, unsigned long int);
     668void    ?{}( signed long long int *, signed long long int);
     669void    ?{}( unsigned long long int *, unsigned long long int);
     670void    ?{}( float *, float);
     671void    ?{}( double *, double);
     672void    ?{}( long double *, long double);
     673void    ?{}( float _Complex *, float _Complex);
     674void    ?{}( double _Complex *, double _Complex);
     675void    ?{}( long double _Complex *, long double _Complex);
    676676
    677677// dtor
    678 void    ^?{}( _Bool * ),                        ^?{}( volatile _Bool * );
    679 void    ^?{}( char * ), ^?{}( volatile char * );
    680 void    ^?{}( char unsigned * ),                        ^?{}( volatile char unsigned * );
    681 void    ^?{}( char signed * ),                  ^?{}( volatile char signed * );
    682 void    ^?{}( int short * ),                            ^?{}( volatile int short * );
    683 void    ^?{}( int short unsigned * ),   ^?{}( volatile int short unsigned * );
    684 void    ^?{}( signed int * ),                   ^?{}( volatile signed int * );
    685 void    ^?{}( unsigned int * ),                 ^?{}( volatile unsigned int * );
    686 void    ^?{}( signed long int * ),              ^?{}( volatile signed long int * );
    687 void    ^?{}( unsigned long int * ),            ^?{}( volatile unsigned long int * );
    688 void    ^?{}( signed long long int * ),         ^?{}( volatile signed long long int * );
    689 void    ^?{}( unsigned long long int * ),       ^?{}( volatile unsigned long long int * );
    690 void    ^?{}( float * ),                        ^?{}( volatile float * );
    691 void    ^?{}( double * ),                       ^?{}( volatile double * );
    692 void    ^?{}( long double * ),                  ^?{}( volatile long double * );
    693 void    ^?{}( float _Complex * ),               ^?{}( volatile float _Complex * );
    694 void    ^?{}( double _Complex * ),              ^?{}( volatile double _Complex * );
    695 void    ^?{}( long double _Complex * ),         ^?{}( volatile long double _Complex * );
     678void    ^?{}( _Bool * );
     679void    ^?{}( char * );
     680void    ^?{}( char unsigned * );
     681void    ^?{}( char signed * );
     682void    ^?{}( int short * );
     683void    ^?{}( int short unsigned * );
     684void    ^?{}( signed int * );
     685void    ^?{}( unsigned int * );
     686void    ^?{}( signed long int * );
     687void    ^?{}( unsigned long int * );
     688void    ^?{}( signed long long int * );
     689void    ^?{}( unsigned long long int * );
     690void    ^?{}( float * );
     691void    ^?{}( double * );
     692void    ^?{}( long double * );
     693void    ^?{}( float _Complex * );
     694void    ^?{}( double _Complex * );
     695void    ^?{}( long double _Complex * );
    696696
    697697// // default ctor
     
    719719
    720720forall( dtype DT ) void ?{}(                 DT *          *,                   DT * );
    721 forall( dtype DT ) void ?{}(                 DT * volatile *,                   DT * );
    722721forall( dtype DT ) void ?{}( const           DT *          *,                   DT * );
    723 forall( dtype DT ) void ?{}( const           DT * volatile *,                   DT * );
    724722forall( dtype DT ) void ?{}( const           DT *          *, const             DT * );
    725 forall( dtype DT ) void ?{}( const           DT * volatile *, const             DT * );
    726723forall( dtype DT ) void ?{}(       volatile  DT *          *,                   DT * );
    727 forall( dtype DT ) void ?{}(       volatile  DT * volatile *,                   DT * );
    728724forall( dtype DT ) void ?{}(       volatile  DT *          *,       volatile    DT * );
    729 forall( dtype DT ) void ?{}(       volatile  DT * volatile *,       volatile    DT * );
    730725
    731726forall( dtype DT ) void ?{}( const volatile  DT *          *,                   DT * );
    732 forall( dtype DT ) void ?{}( const volatile  DT * volatile *,                   DT * );
    733727forall( dtype DT ) void ?{}( const volatile  DT *          *, const             DT * );
    734 forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const             DT * );
    735728forall( dtype DT ) void ?{}( const volatile  DT *          *,       volatile    DT * );
    736 forall( dtype DT ) void ?{}( const volatile  DT * volatile *,       volatile    DT * );
    737729forall( dtype DT ) void ?{}( const volatile  DT *          *, const volatile    DT * );
    738 forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const volatile    DT * );
    739730
    740731forall( dtype DT ) void ?{}(                 DT *          *,                   void * );
    741 forall( dtype DT ) void ?{}(                 DT * volatile *,                   void * );
    742732forall( dtype DT ) void ?{}( const           DT *          *,                   void * );
    743 forall( dtype DT ) void ?{}( const           DT * volatile *,                   void * );
    744733forall( dtype DT ) void ?{}( const           DT *          *, const             void * );
    745 forall( dtype DT ) void ?{}( const           DT * volatile *, const             void * );
    746734forall( dtype DT ) void ?{}(       volatile  DT *          *,                   void * );
    747 forall( dtype DT ) void ?{}(       volatile  DT * volatile *,                   void * );
    748735forall( dtype DT ) void ?{}(       volatile  DT *          *,       volatile    void * );
    749 forall( dtype DT ) void ?{}(       volatile  DT * volatile *,       volatile    void * );
    750736
    751737forall( dtype DT ) void ?{}( const volatile  DT *          *,                   void * );
    752 forall( dtype DT ) void ?{}( const volatile  DT * volatile *,                   void * );
    753738forall( dtype DT ) void ?{}( const volatile  DT *          *, const             void * );
    754 forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const             void * );
    755739forall( dtype DT ) void ?{}( const volatile  DT *          *,       volatile    void * );
    756 forall( dtype DT ) void ?{}( const volatile  DT * volatile *,       volatile    void * );
    757740forall( dtype DT ) void ?{}( const volatile  DT *          *, const volatile    void * );
    758 forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const volatile    void * );
    759741
    760742forall( dtype DT ) void ?{}(                 void *          *,                 DT * );
    761 forall( dtype DT ) void ?{}(                 void * volatile *,                 DT * );
    762743forall( dtype DT ) void ?{}( const           void *          *,                 DT * );
    763 forall( dtype DT ) void ?{}( const           void * volatile *,                 DT * );
    764744forall( dtype DT ) void ?{}( const           void *          *, const           DT * );
    765 forall( dtype DT ) void ?{}( const           void * volatile *, const           DT * );
    766745forall( dtype DT ) void ?{}(        volatile void *          *,                 DT * );
    767 forall( dtype DT ) void ?{}(        volatile void * volatile *,                 DT * );
    768746forall( dtype DT ) void ?{}(        volatile void *          *,       volatile  DT * );
    769 forall( dtype DT ) void ?{}(        volatile void * volatile *,       volatile  DT * );
    770747forall( dtype DT ) void ?{}( const volatile void *           *,                 DT * );
    771 forall( dtype DT ) void ?{}( const volatile void * volatile *,                  DT * );
    772748forall( dtype DT ) void ?{}( const volatile void *           *, const           DT * );
    773 forall( dtype DT ) void ?{}( const volatile void * volatile *, const            DT * );
    774749forall( dtype DT ) void ?{}( const volatile void *           *,       volatile  DT * );
    775 forall( dtype DT ) void ?{}( const volatile void * volatile *,        volatile  DT * );
    776750forall( dtype DT ) void ?{}( const volatile void *           *, const volatile  DT * );
    777 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile   DT * );
    778751
    779752void    ?{}(                void *          *,                void * );
    780 void    ?{}(                void * volatile *,                void * );
    781753void    ?{}( const          void *          *,                void * );
    782 void    ?{}( const          void * volatile *,                void * );
    783754void    ?{}( const          void *          *, const          void * );
    784 void    ?{}( const          void * volatile *, const          void * );
    785755void    ?{}(       volatile void *          *,                void * );
    786 void    ?{}(       volatile void * volatile *,                void * );
    787756void    ?{}(       volatile void *          *,       volatile void * );
    788 void    ?{}(       volatile void * volatile *,       volatile void * );
    789757void    ?{}( const volatile void *          *,                void * );
    790 void    ?{}( const volatile void * volatile *,                void * );
    791758void    ?{}( const volatile void *          *, const          void * );
    792 void    ?{}( const volatile void * volatile *, const          void * );
    793759void    ?{}( const volatile void *          *,       volatile void * );
    794 void    ?{}( const volatile void * volatile *,       volatile void * );
    795760void    ?{}( const volatile void *          *, const volatile void * );
    796 void    ?{}( const volatile void * volatile *, const volatile void * );
    797761
    798762//forall( dtype DT ) void ?{}(              DT *          *, forall( dtype DT2 ) const DT2 * );
    799763//forall( dtype DT ) void ?{}(              DT * volatile *, forall( dtype DT2 ) const DT2 * );
    800764forall( dtype DT ) void ?{}( const          DT *          *, forall( dtype DT2 ) const DT2 * );
    801 forall( dtype DT ) void ?{}( const          DT * volatile *, forall( dtype DT2 ) const DT2 * );
    802765//forall( dtype DT ) void ?{}( volatile     DT *          *, forall( dtype DT2 ) const DT2 * );
    803766//forall( dtype DT ) void ?{}( volatile     DT * volatile *, forall( dtype DT2 ) const DT2 * );
    804767forall( dtype DT ) void ?{}( const volatile DT *          *, forall( dtype DT2 ) const DT2 * );
    805 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );
    806768
    807769forall( ftype FT ) void ?{}( FT *          *, forall( ftype FT2 ) FT2 * );
    808 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * );
    809770
    810771// default ctors
    811772forall( ftype FT ) void ?{}( FT *          * );
    812 forall( ftype FT ) void ?{}( FT * volatile * );
    813773
    814774forall( dtype DT ) void ?{}(                 DT *          *);
    815 forall( dtype DT ) void ?{}(                 DT * volatile *);
    816775forall( dtype DT ) void ?{}( const           DT *          *);
    817 forall( dtype DT ) void ?{}( const           DT * volatile *);
    818776forall( dtype DT ) void ?{}(       volatile  DT *          *);
    819 forall( dtype DT ) void ?{}(       volatile  DT * volatile *);
    820777forall( dtype DT ) void ?{}( const volatile  DT *          *);
    821 forall( dtype DT ) void ?{}( const volatile  DT * volatile *);
    822778
    823779void    ?{}(                void *          *);
    824 void    ?{}(                void * volatile *);
    825780void    ?{}( const          void *          *);
    826 void    ?{}( const          void * volatile *);
    827781void    ?{}(       volatile void *          *);
    828 void    ?{}(       volatile void * volatile *);
    829782void    ?{}( const volatile void *          *);
    830 void    ?{}( const volatile void * volatile *);
    831783
    832784// dtors
    833785forall( ftype FT ) void ^?{}( FT *         * );
    834 forall( ftype FT ) void ^?{}( FT * volatile * );
    835786
    836787forall( dtype DT ) void ^?{}(                DT *          *);
    837 forall( dtype DT ) void ^?{}(                DT * volatile *);
    838788forall( dtype DT ) void ^?{}( const          DT *          *);
    839 forall( dtype DT ) void ^?{}( const          DT * volatile *);
    840789forall( dtype DT ) void ^?{}(      volatile  DT *          *);
    841 forall( dtype DT ) void ^?{}(      volatile  DT * volatile *);
    842790forall( dtype DT ) void ^?{}( const volatile  DT *         *);
    843 forall( dtype DT ) void ^?{}( const volatile  DT * volatile *);
    844791
    845792void    ^?{}(               void *          *);
    846 void    ^?{}(               void * volatile *);
    847793void    ^?{}( const         void *          *);
    848 void    ^?{}( const         void * volatile *);
    849794void    ^?{}(      volatile void *          *);
    850 void    ^?{}(      volatile void * volatile *);
    851795void    ^?{}( const volatile void *         *);
    852 void    ^?{}( const volatile void * volatile *);
    853796
    854797// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.