Changes in / [0638c44:a1d6d80]


Ignore:
Location:
src
Files:
6 added
2 deleted
59 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CodeGenerator.cc -- 
     7// CodeGenerator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:32:16 2016
    13 // Update Count     : 243
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 11:59:36 2016
     13// Update Count     : 255
    1414//
    1515
     
    6767        string mangleName( DeclarationWithType *decl ) {
    6868                if ( decl->get_mangleName() != "" ) {
    69                         return decl->get_mangleName();
     69                        // need to incorporate scope level in order to differentiate names for destructors
     70                        return decl->get_scopedMangleName();
    7071                } else {
    7172                        return decl->get_name();
     
    99100                handleStorageClass( objectDecl );
    100101                output << genType( objectDecl->get_type(), mangleName( objectDecl ) );
    101        
     102
    102103                if ( objectDecl->get_init() ) {
    103104                        output << " = ";
     
    113114                if ( aggDecl->get_name() != "" )
    114115                        output << aggDecl->get_name();
    115        
     116
    116117                std::list< Declaration * > &memb = aggDecl->get_members();
    117118
     
    119120                        output << " {" << endl;
    120121
    121                         cur_indent += CodeGenerator::tabsize; 
     122                        cur_indent += CodeGenerator::tabsize;
    122123                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    123                                 output << indent; 
     124                                output << indent;
    124125                                (*i)->accept( *this );
    125126                                output << ";" << endl;
    126127                        }
    127128
    128                         cur_indent -= CodeGenerator::tabsize; 
     129                        cur_indent -= CodeGenerator::tabsize;
    129130
    130131                        output << indent << "}";
     
    141142                handleAggregate( aggregateDecl );
    142143        }
    143  
     144
    144145        void CodeGenerator::visit( EnumDecl *aggDecl ) {
    145146                output << "enum ";
     
    147148                if ( aggDecl->get_name() != "" )
    148149                        output << aggDecl->get_name();
    149        
     150
    150151                std::list< Declaration* > &memb = aggDecl->get_members();
    151152
     
    153154                        output << " {" << endl;
    154155
    155                         cur_indent += CodeGenerator::tabsize; 
     156                        cur_indent += CodeGenerator::tabsize;
    156157                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    157158                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    158159                                assert( obj );
    159                                 output << indent << mangleName( obj ); 
     160                                output << indent << mangleName( obj );
    160161                                if ( obj->get_init() ) {
    161162                                        output << " = ";
     
    165166                        } // for
    166167
    167                         cur_indent -= CodeGenerator::tabsize; 
     168                        cur_indent -= CodeGenerator::tabsize;
    168169
    169170                        output << indent << "}";
    170171                } // if
    171172        }
    172  
     173
    173174        void CodeGenerator::visit( TraitDecl *aggregateDecl ) {}
    174  
     175
    175176        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
    176177                output << "typedef ";
    177178                output << genType( typeDecl->get_base(), typeDecl->get_name() );
    178179        }
    179  
     180
    180181        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    181182                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
     
    213214                printDesignators( init->get_designators() );
    214215                output << "{ ";
    215                 genCommaList( init->begin_initializers(), init->end_initializers() );
     216                if ( init->begin_initializers() == init->end_initializers() ) {
     217                        // illegal to leave initializer list empty for scalar initializers,
     218                        // but always legal to have 0
     219                        output << "0";
     220                } else {
     221                        genCommaList( init->begin_initializers(), init->end_initializers() );
     222                }
    216223                output << " }";
    217224        }
    218225
    219         void CodeGenerator::visit( Constant *constant ) { 
     226        void CodeGenerator::visit( Constant *constant ) {
    220227                output << constant->get_value() ;
    221228        }
     
    231238                                  case OT_POSTFIXASSIGN:
    232239                                  case OT_INFIXASSIGN:
     240                                  case OT_CTOR:
     241                                  case OT_DTOR:
    233242                                        {
    234243                                                assert( arg != applicationExpr->get_args().end() );
    235244                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    236                
     245                                                        // remove & from first assignment/ctor argument
    237246                                                        *arg = addrExpr->get_arg();
    238247                                                } else {
     248                                                        // no address-of operator, so must be a pointer - add dereference
    239249                                                        UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    240250                                                        newExpr->get_args().push_back( *arg );
     
    243253                                                break;
    244254                                        }
    245              
     255
    246256                                  default:
    247257                                        // do nothing
    248258                                        ;
    249259                                }
    250            
     260
    251261                                switch ( opInfo.type ) {
    252262                                  case OT_INDEX:
     
    257267                                        output << "]";
    258268                                        break;
    259              
     269
    260270                                  case OT_CALL:
    261271                                        // there are no intrinsic definitions of the function call operator
    262272                                        assert( false );
    263273                                        break;
    264              
     274
     275                                  case OT_CTOR:
     276                                  case OT_DTOR:
     277                                        if ( applicationExpr->get_args().size() == 1 ) {
     278                                                // the expression fed into a single parameter constructor or destructor
     279                                                // may contain side effects - output as a void expression
     280                                                output << "((void)(";
     281                                                (*arg++)->accept( *this );
     282                                                output << ")) /* " << opInfo.inputName << " */";
     283                                        } else if ( applicationExpr->get_args().size() == 2 ) {
     284                                                // intrinsic two parameter constructors are essentially bitwise assignment
     285                                                output << "(";
     286                                                (*arg++)->accept( *this );
     287                                                output << opInfo.symbol;
     288                                                (*arg)->accept( *this );
     289                                                output << ") /* " << opInfo.inputName << " */";
     290                                        } else {
     291                                                // no constructors with 0 or more than 2 parameters
     292                                                assert( false );
     293                                        }
     294                                        break;
     295
    265296                                  case OT_PREFIX:
    266297                                  case OT_PREFIXASSIGN:
     
    271302                                        output << ")";
    272303                                        break;
    273              
     304
    274305                                  case OT_POSTFIX:
    275306                                  case OT_POSTFIXASSIGN:
     
    278309                                        output << opInfo.symbol;
    279310                                        break;
     311
    280312
    281313                                  case OT_INFIX:
     
    288320                                        output << ")";
    289321                                        break;
    290              
     322
    291323                                  case OT_CONSTANT:
    292324                                  case OT_LABELADDRESS:
     
    307339                } // if
    308340        }
    309  
     341
    310342        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    311343                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
     
    321353                                        output << "]";
    322354                                        break;
    323              
     355
    324356                                  case OT_CALL:
    325357                                        assert( false );
    326                                         break;
    327              
     358
     359
     360                                  case OT_CTOR:
     361                                  case OT_DTOR:
     362                                        if ( untypedExpr->get_args().size() == 1 ) {
     363                                                // the expression fed into a single parameter constructor or destructor
     364                                                // may contain side effects - output as a void expression
     365                                                output << "((void)(";
     366                                                (*arg++)->accept( *this );
     367                                                output << ")) /* " << opInfo.inputName << " */";
     368                                        } else if ( untypedExpr->get_args().size() == 2 ) {
     369                                                // intrinsic two parameter constructors are essentially bitwise assignment
     370                                                output << "(";
     371                                                (*arg++)->accept( *this );
     372                                                output << opInfo.symbol;
     373                                                (*arg)->accept( *this );
     374                                                output << ") /* " << opInfo.inputName << " */";
     375                                        } else {
     376                                                // no constructors with 0 or more than 2 parameters
     377                                                assert( false );
     378                                        }
     379                                        break;
     380
    328381                                  case OT_PREFIX:
    329382                                  case OT_PREFIXASSIGN:
     
    335388                                        output << ")";
    336389                                        break;
    337              
     390
    338391                                  case OT_POSTFIX:
    339392                                  case OT_POSTFIXASSIGN:
     
    342395                                        output << opInfo.symbol;
    343396                                        break;
    344  
     397
    345398                                  case OT_INFIX:
    346399                                  case OT_INFIXASSIGN:
     
    352405                                        output << ")";
    353406                                        break;
    354                                        
     407
    355408                                  case OT_CONSTANT:
    356409                                        // there are no intrinsic definitions of 0 or 1 as functions
     
    370423                } // if
    371424        }
    372  
     425
    373426        void CodeGenerator::visit( NameExpr *nameExpr ) {
    374427                OperatorInfo opInfo;
     
    380433                } // if
    381434        }
    382  
     435
    383436        void CodeGenerator::visit( AddressExpr *addressExpr ) {
    384437                output << "(&";
     
    409462                output << ")";
    410463        }
    411  
     464
    412465        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    413466                assert( false );
    414467        }
    415  
     468
    416469        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    417470                memberExpr->get_aggregate()->accept( *this );
    418471                output << "." << mangleName( memberExpr->get_member() );
    419472        }
    420  
     473
    421474        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    422475                OperatorInfo opInfo;
     
    427480                } // if
    428481        }
    429  
     482
    430483        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    431484                assert( constantExpr->get_constant() );
    432485                constantExpr->get_constant()->accept( *this );
    433486        }
    434  
     487
    435488        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
    436489                output << "sizeof(";
     
    469522                assert( false && "OffsetPackExpr should not reach code generation" );
    470523        }
    471  
     524
    472525        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
    473526                output << "(";
     
    481534                output << ")";
    482535        }
    483  
     536
    484537        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
    485538                output << "(";
     
    491544                output << ")";
    492545        }
    493  
     546
    494547        void CodeGenerator::visit( CommaExpr *commaExpr ) {
    495548                output << "(";
     
    499552                output << ")";
    500553        }
    501  
     554
    502555        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
    503  
     556
    504557        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
    505558
     
    532585                        }
    533586                }
    534                 cur_indent -= CodeGenerator::tabsize; 
     587                cur_indent -= CodeGenerator::tabsize;
    535588
    536589                output << indent << "}";
     
    538591
    539592        void CodeGenerator::visit( ExprStmt *exprStmt ) {
    540                 // I don't see why this check is necessary. 
    541                 // If this starts to cause problems then put it back in, 
     593                // I don't see why this check is necessary.
     594                // If this starts to cause problems then put it back in,
    542595                // with an explanation
    543596                assert( exprStmt );
     
    589642                switchStmt->get_condition()->accept( *this );
    590643                output << " ) ";
    591                
     644
    592645                output << "{" << std::endl;
    593646                cur_indent += CodeGenerator::tabsize;
     
    609662                } // if
    610663                output << ":\n";
    611                
     664
    612665                std::list<Statement *> sts = caseStmt->get_statements();
    613666
     
    626679                        if ( ! branchStmt->get_target().empty() )
    627680                                output << "goto " << branchStmt->get_target();
    628                         else { 
     681                        else {
    629682                                if ( branchStmt->get_computedTarget() != 0 ) {
    630683                                        output << "goto *";
     
    677730
    678731        void CodeGenerator::visit( ForStmt *forStmt ) {
    679                 // initialization is always hoisted, so don't 
    680                 // bother doing anything with that 
     732                // initialization is always hoisted, so don't
     733                // bother doing anything with that
    681734                output << "for (;";
    682735
     
    702755        void CodeGenerator::visit( DeclStmt *declStmt ) {
    703756                declStmt->get_decl()->accept( *this );
    704        
     757
    705758                if ( doSemicolon( declStmt->get_decl() ) ) {
    706759                        output << ";";
  • src/CodeGen/FixNames.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixNames.cc -- 
     7// FixNames.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:36:42 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Apr 11 15:38:10 2016
    1313// Update Count     : 1
    1414//
     
    2626                virtual void visit( ObjectDecl *objectDecl );
    2727                virtual void visit( FunctionDecl *functionDecl );
     28
     29                virtual void visit( CompoundStmt *compoundStmt );
     30
     31          private:
     32                int scopeLevel = 1;
     33
     34                void fixDWT( DeclarationWithType *dwt );
    2835        };
    2936
     
    3340        }
    3441
    35         void fixDWT( DeclarationWithType *dwt ) {
     42        void FixNames::fixDWT( DeclarationWithType *dwt ) {
    3643                if ( dwt->get_name() != "" ) {
    3744                        if ( LinkageSpec::isDecoratable( dwt->get_linkage() ) ) {
    3845                                dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) );
     46                                dwt->set_scopeLevel( scopeLevel );
    3947                        } // if
    4048                } // if
     
    5058                fixDWT( functionDecl );
    5159        }
     60
     61        void FixNames::visit( CompoundStmt *compoundStmt ) {
     62                scopeLevel++;
     63                Visitor::visit( compoundStmt );
     64                scopeLevel--;
     65        }
    5266} // namespace CodeGen
    5367
  • src/CodeGen/OperatorTable.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // OperatorTable.cc -- 
     7// OperatorTable.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 17:41:14 2015
    13 // Update Count     : 5
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 16:48:27 2016
     13// Update Count     : 9
    1414//
    1515
     
    2121                const OperatorInfo tableValues[] = {
    2222                        {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        },
     23                        {       "?{}",          "=",            "_constructor",                                 OT_CTOR                         },
     24                        {       "^?{}",         "",             "_destructor",                                  OT_DTOR                         },
    2325                        {       "?()",          "",             "_operator_call",                               OT_CALL                         },
    2426                        {       "?++",          "++",   "_operator_postincr",                   OT_POSTFIXASSIGN        },
  • src/CodeGen/OperatorTable.h

    r0638c44 ra1d6d80  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 16:09:27 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:17:57 2015
     13// Update Count     : 5
    1414//
    1515
     
    2222        enum OperatorType {
    2323                OT_INDEX,
     24                OT_CTOR,
     25                OT_DTOR,
    2426                OT_CALL,
    2527                OT_PREFIX,
  • src/Common/utility.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // utility.h -- 
     7// utility.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  2 18:04:41 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 28 13:18:24 2016
    1313// Update Count     : 16
    1414//
     
    6262                        os << std::string( indent,  ' ' );
    6363                        (*i)->print( os, indent + 2 );
     64                        // need an endl after each element because it's not easy to know when each individual item should end
    6465                        os << std::endl;
    6566                } // if
     
    128129}
    129130
    130 template < typename T > 
     131template < typename T >
    131132std::string toString ( T value ) {
    132133        std::ostringstream os;
  • src/GenPoly/Box.cc

    r0638c44 ra1d6d80  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  5 16:45:07 2016
    13 // Update Count     : 286
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue May 03 16:44:47 2016
     13// Update Count     : 295
    1414//
    1515
     
    133133                        Value *lookup( Key *key, const std::list< TypeExpr* >& params ) const {
    134134                                TypeList typeList( params );
    135                                
     135
    136136                                // scan scopes for matches to the key
    137137                                for ( typename InnerMap::const_iterator insts = instantiations.find( key ); insts != instantiations.end(); insts = instantiations.findNext( insts, key ) ) {
     
    160160                        virtual Declaration *mutate( UnionDecl *unionDecl );
    161161                };
    162                
     162
    163163                /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call
    164164                class Pass1 : public PolyMutator {
     
    208208                        ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps;  ///< Currently known assignment operators
    209209                        ScopedMap< std::string, DeclarationWithType* > adapters;     ///< Set of adapter functions in the current scope
    210                        
     210
    211211                        DeclarationWithType *retval;
    212212                        bool useRetval;
     
    226226                        virtual Type *mutate( PointerType *pointerType );
    227227                        virtual Type *mutate( FunctionType *funcType );
    228                        
     228
    229229                  private:
    230230                        void addAdapters( FunctionType *functionType );
     
    297297                        /// Exits the type-variable scope
    298298                        void endTypeScope();
    299                        
     299
    300300                        ScopedSet< std::string > knownLayouts;          ///< Set of generic type layouts known in the current scope, indexed by sizeofName
    301301                        ScopedSet< std::string > knownOffsets;          ///< Set of non-generic types for which the offset array exists in the current scope, indexed by offsetofName
     
    351351                PolyGenericCalculator polyCalculator;
    352352                Pass3 pass3;
    353                
     353
    354354                layoutBuilder.mutateDeclarationList( translationUnit );
    355355                mutateTranslationUnit/*All*/( translationUnit, pass1 );
     
    370370                return functionDecl;
    371371        }
    372        
     372
    373373        /// Get a list of type declarations that will affect a layout function
    374374        std::list< TypeDecl* > takeOtypeOnly( std::list< TypeDecl* > &decls ) {
     
    380380                        }
    381381                }
    382                
     382
    383383                return otypeDecls;
    384384        }
     
    387387        void addOtypeParams( FunctionType *layoutFnType, std::list< TypeDecl* > &otypeParams ) {
    388388                BasicType sizeAlignType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    389                
     389
    390390                for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin(); param != otypeParams.end(); ++param ) {
    391391                        TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param );
     
    444444                return makeCond( ifCond, ifExpr );
    445445        }
    446        
     446
    447447        /// adds an expression to a compound statement
    448448        void addExpr( CompoundStmt *stmts, Expression *expr ) {
     
    454454                stmts->get_kids().push_back( stmt );
    455455        }
    456        
     456
    457457        Declaration *LayoutFunctionBuilder::mutate( StructDecl *structDecl ) {
    458458                // do not generate layout function for "empty" tag structs
     
    467467                BasicType *sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    468468                PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType );
    469                
     469
    470470                ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
    471471                layoutFnType->get_parameters().push_back( sizeParam );
     
    497497                                addStmt( layoutDecl->get_statements(), makeAlignTo( derefVar( sizeParam ), new AlignofExpr( memberType->clone() ) ) );
    498498                        }
    499                        
     499
    500500                        // place current size in the current offset index
    501501                        addExpr( layoutDecl->get_statements(), makeOp( "?=?", makeOp( "?[?]", new VariableExpr( offsetParam ), new ConstantExpr( Constant::from( n_members ) ) ),
     
    505505                        // add member size to current size
    506506                        addExpr( layoutDecl->get_statements(), makeOp( "?+=?", derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
    507                        
     507
    508508                        // take max of member alignment and global alignment
    509509                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
     
    515515                return structDecl;
    516516        }
    517        
     517
    518518        Declaration *LayoutFunctionBuilder::mutate( UnionDecl *unionDecl ) {
    519519                // do not generate layout function for "empty" tag unions
    520520                if ( unionDecl->get_members().empty() ) return unionDecl;
    521                
     521
    522522                // get parameters that can change layout, exiting early if none
    523523                std::list< TypeDecl* > otypeParams = takeOtypeOnly( unionDecl->get_parameters() );
     
    528528                BasicType *sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    529529                PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType );
    530                
     530
    531531                ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
    532532                layoutFnType->get_parameters().push_back( sizeParam );
     
    545545                        assert( dwt );
    546546                        Type *memberType = dwt->get_type();
    547                        
     547
    548548                        // take max member size and global size
    549549                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
    550                        
     550
    551551                        // take max of member alignment and global alignment
    552552                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
     
    558558                return unionDecl;
    559559        }
    560        
     560
    561561        ////////////////////////////////////////// Pass1 ////////////////////////////////////////////////////
    562562
     
    619619                        return 0;
    620620                }
    621                
     621
    622622                /// returns T if the given declaration is: (*?=?)(T *, T) for some type T (return not checked, but maybe should be), NULL otherwise
    623623                /// Only picks assignments where neither parameter is cv-qualified
     
    631631                                                Type *paramType2 = funType->get_parameters().back()->get_type();
    632632                                                if ( paramType2->get_qualifiers() != defaultQualifiers ) return 0;
    633                                                
     633
    634634                                                if ( PointerType *pointerType = dynamic_cast< PointerType* >( paramType1 ) ) {
    635635                                                        Type *baseType1 = pointerType->get_base();
     
    784784                                                arg++;
    785785                                        } else {
    786                                                 throw SemanticError( "unbound type variable in application ", appExpr );
     786                                                /// xxx - should this be an assertion?
     787                                                throw SemanticError( "unbound type variable: " + tyParm->first + " in application ", appExpr );
    787788                                        } // if
    788789                                } // if
     
    803804                                passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes );
    804805                        }
    805                        
     806
    806807                        // add type information args for presently unseen types in parameter list
    807808                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
     
    882883                        assert( env );
    883884                        Type *concrete = replaceWithConcrete( appExpr, polyType );
    884                         // add out-parameter for return value   
     885                        // add out-parameter for return value
    885886                        return addRetParam( appExpr, function, concrete, arg );
    886887                }
     
    910911                                } else if ( arg->get_results().front()->get_isLvalue() ) {
    911912                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
     913                                        // xxx - need to test that this code is still reachable
    912914                                        if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) {
    913915                                                commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) );
     
    12911293                        } else if ( needsAdapter( function, scopeTyVars ) ) {
    12921294                                // std::cerr << "needs adapter: ";
    1293                                 // for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
    1294                                 //      std::cerr << i->first << " ";
    1295                                 // }
    1296                                 // std::cerr << "\n";
     1295                                // printTyVarMap( std::cerr, scopeTyVars );
     1296                                // std::cerr << *env << std::endl;
    12971297                                // change the application so it calls the adapter rather than the passed function
    12981298                                ret = applyAdapter( appExpr, function, arg, scopeTyVars );
     
    13451345                                } // if
    13461346                        } // if
     1347                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
     1348                        // out of the if condition.
     1349                        bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
    13471350                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    1348                         if ( isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env ) || needs ) {
     1351                        if ( polytype || needs ) {
    13491352                                Expression *ret = addrExpr->get_arg();
    13501353                                delete ret->get_results().front();
     
    13661369                        return new VariableExpr( functionObj );
    13671370                }
    1368                
     1371
    13691372                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13701373                        if ( retval && returnStmt->get_expr() ) {
     
    18861889                                }
    18871890                        }
    1888                        
     1891
    18891892                        Type *ret = Mutator::mutate( funcType );
    18901893
     
    19051908
    19061909                                        std::list<Expression*> designators;
    1907                                         objectDecl->set_init( new SingleInit( alloc, designators ) );
     1910                                        objectDecl->set_init( new SingleInit( alloc, designators, false ) ); // not constructed
    19081911                                }
    19091912                        }
     
    19461949                        return derefdVar;
    19471950                }
    1948                
     1951
    19491952                Expression *PolyGenericCalculator::mutate( MemberExpr *memberExpr ) {
    19501953                        // mutate, exiting early if no longer MemberExpr
     
    21442147                        Type *ty = offsetofExpr->get_type();
    21452148                        if ( ! findGeneric( ty ) ) return offsetofExpr;
    2146                        
     2149
    21472150                        if ( StructInstType *structType = dynamic_cast< StructInstType* >( ty ) ) {
    21482151                                // replace offsetof expression by index into offset array
  • src/GenPoly/CopyParams.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CopyParams.cc -- 
     7// CopyParams.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
     11// Last Modified By : Rob Schluntz
    1212// Last Modified On : Tue May 19 07:33:31 2015
    1313// Update Count     : 1
     
    2929          public:
    3030                CopyParams();
    31  
     31
    3232                virtual void visit( FunctionDecl *funcDecl );
    3333                virtual void visit( AddressExpr *addrExpr );
     
    5050                if ( funcDecl->get_statements() ) {
    5151                        funcDecl->get_statements()->accept( *this );
    52        
     52
    5353                        if ( ! modVars.empty() ) {
    5454                                std::map< std::string, DeclarationWithType* > assignOps;
     
    5757                                        if ( (*tyVar)->get_kind() == TypeDecl::Any ) {
    5858                                                assert( !(*tyVar)->get_assertions().empty() );
     59                                                assert( (*tyVar)->get_assertions().front()->get_name() == "?=?" );
    5960                                                assignOps[ (*tyVar)->get_name() ] = (*tyVar)->get_assertions().front();
    6061                                        } // if
  • src/GenPoly/GenPoly.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenPoly.cc -- 
     7// GenPoly.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 15 16:11:18 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 14:53:33 2016
    1313// Update Count     : 13
    1414//
     
    8181                return 0;
    8282        }
    83        
     83
    8484        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    8585                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     
    112112                return 0;
    113113        }
    114        
     114
    115115        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    116116                if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
     
    146146                return isPolyType( type, env );
    147147        }
    148        
     148
    149149        Type * hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels, const TypeSubstitution *env ) {
    150150                int dummy;
     
    192192                                if ( ! fn || fn->get_name() != std::string("*?") ) return 0;
    193193                                expr = *untypedExpr->begin_args();
     194                        } else if ( CommaExpr *commaExpr = dynamic_cast< CommaExpr* >( expr ) ) {
     195                                // copy constructors insert comma exprs, look at second argument which contains the variable
     196                                expr = commaExpr->get_arg2();
     197                                continue;
    194198                        } else break;
    195199
     
    209213                }
    210214        }
    211        
     215
    212216        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
    213217                for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
  • src/GenPoly/PolyMutator.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // PolyMutator.cc -- 
     7// PolyMutator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Aug 14 15:28:50 2015
     12// Last Modified On : Mon May 02 14:50:58 2016
    1313// Update Count     : 11
    1414//
     
    6363                                env = expr->get_env();
    6464                        }
     65                        // xxx - should env be cloned (or moved) onto the result of the mutate?
    6566                        return expr->acceptMutator( *this );
    6667                } else {
     
    144145                return untypedExpr;
    145146        }
    146  
    147  
     147
     148
    148149        Initializer *PolyMutator::mutate( SingleInit *singleInit ) {
    149150                singleInit->set_value( mutateExpression( singleInit->get_value() ) );
  • src/GenPoly/Specialize.cc

    r0638c44 ra1d6d80  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 20 12:40:33 2016
    13 // Update Count     : 18
     12// Last Modified On : Thu Apr 28 15:17:45 2016
     13// Update Count     : 24
    1414//
    1515
     
    4141                virtual Expression * mutate( AddressExpr *castExpr );
    4242                virtual Expression * mutate( CastExpr *castExpr );
    43                 virtual Expression * mutate( LogicalExpr *logicalExpr );
    44                 virtual Expression * mutate( ConditionalExpr *conditionalExpr );
    45                 virtual Expression * mutate( CommaExpr *commaExpr );
     43                // virtual Expression * mutate( LogicalExpr *logicalExpr );
     44                // virtual Expression * mutate( ConditionalExpr *conditionalExpr );
     45                // virtual Expression * mutate( CommaExpr *commaExpr );
    4646
    4747          private:
     
    142142
    143143        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    144                 assert( ! actual->get_results().empty() );
     144                assert( ! actual->get_results().empty() ); // using front, should have this assert
    145145                if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
    146146                        FunctionType *funType;
     
    212212        }
    213213
    214         Expression * Specialize::mutate( LogicalExpr *logicalExpr ) {
    215                 return logicalExpr;
    216         }
    217 
    218         Expression * Specialize::mutate( ConditionalExpr *condExpr ) {
    219                 return condExpr;
    220         }
    221 
    222         Expression * Specialize::mutate( CommaExpr *commaExpr ) {
    223                 return commaExpr;
    224         }
     214        // Removing these for now. Richard put these in for some reason, but it's not clear why.
     215        // In particular, copy constructors produce a comma expression, and with this code the parts
     216        // of that comma expression are not specialized, which causes problems.
     217
     218        // Expression * Specialize::mutate( LogicalExpr *logicalExpr ) {
     219        //      return logicalExpr;
     220        // }
     221
     222        // Expression * Specialize::mutate( ConditionalExpr *condExpr ) {
     223        //      return condExpr;
     224        // }
     225
     226        // Expression * Specialize::mutate( CommaExpr *commaExpr ) {
     227        //      return commaExpr;
     228        // }
    225229} // namespace GenPoly
    226230
  • src/InitTweak/InitModel.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InitModel.cc -- 
     7// InitModel.cc --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:37:08 2015
    13 // Update Count     : 1
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Jan 07 13:38:46 2016
     13// Update Count     : 5
    1414//
    1515
     
    198198                assert(init == 0 && single != 0);
    199199                std::list< Expression * > empty;
    200                 init = new SingleInit( single->get_expr(), empty );
     200                init = new SingleInit( single->get_expr(), empty, false ); // cannot be constructed
    201201                return;
    202202        }
     
    214214                        } // if
    215215
    216                 init = new ListInit( contents );
     216                std::list< Expression * > desig;
     217                init = new ListInit( contents, desig, false ); // cannot be constructed
    217218                return;
    218219        }
  • src/InitTweak/module.mk

    r0638c44 ra1d6d80  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Mon Jan 11 14:40:16 2016
    14 ## Update Count     : 2
     13## Last Modified On : Thu Apr 28 12:23:17 2016
     14## Update Count     : 3
    1515###############################################################################
    1616
    17 SRC += InitTweak/RemoveInit.cc
    18 
     17SRC += InitTweak/GenInit.cc \
     18        InitTweak/FixInit.cc
  • src/MakeLibCfa.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // MakeLibCfa.cc -- 
     7// MakeLibCfa.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 10:33:33 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 26 16:52:59 2015
    13 // Update Count     : 14
    14 // 
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Apr 22 13:54:15 2016
     13// Update Count     : 40
     14//
    1515
    1616#include "MakeLibCfa.h"
     
    2929                void visit( FunctionDecl* funcDecl );
    3030                void visit( ObjectDecl* objDecl );
    31  
     31
    3232                std::list< Declaration* > &get_newDecls() { return newDecls; }
    3333          private:
     
    4343        void MakeLibCfa::visit( FunctionDecl* origFuncDecl ) {
    4444                if ( origFuncDecl->get_linkage() != LinkageSpec::Intrinsic ) return;
    45  
     45                if ( origFuncDecl->get_statements() ) return;
     46
    4647                FunctionDecl *funcDecl = origFuncDecl->clone();
    4748                CodeGen::OperatorInfo opInfo;
     
    5455                assert( param != funcDecl->get_functionType()->get_parameters().end() );
    5556
    56                 if ( (*param)->get_name() == "" ) {
    57                         (*param)->set_name( paramNamer.newName() );
    58                         (*param)->set_linkage( LinkageSpec::C );
    59                 } // if
     57                for ( ; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {
     58                        if ( (*param)->get_name() == "" ) {
     59                                (*param)->set_name( paramNamer.newName() );
     60                                (*param)->set_linkage( LinkageSpec::C );
     61                        }
     62                        newExpr->get_args().push_back( new VariableExpr( *param ) );
     63                } // for
     64
     65                funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) );
     66                newDecls.push_back( funcDecl );
    6067
    6168                switch ( opInfo.type ) {
     
    6572                  case CodeGen::OT_POSTFIX:
    6673                  case CodeGen::OT_INFIX:
    67                         newExpr->get_args().push_back( new VariableExpr( *param ) );
    68                         break;
    6974                  case CodeGen::OT_PREFIXASSIGN:
    7075                  case CodeGen::OT_POSTFIXASSIGN:
    7176                  case CodeGen::OT_INFIXASSIGN:
    72                         {
    73                                 newExpr->get_args().push_back( new VariableExpr( *param ) );
    74                                 // UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    75                                 // deref->get_args().push_back( new VariableExpr( *param ) );
    76                                 // newExpr->get_args().push_back( deref );
     77                                funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
    7778                                break;
    78                         }
     79                  case CodeGen::OT_CTOR:
     80                        // ctors don't return a value
     81                        if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) {
     82                                // intrinsic default constructors should do nothing
     83                                // delete newExpr;
     84                                break;
     85                        } else {
     86                                assert( funcDecl->get_functionType()->get_parameters().size() == 2 );
     87                                // anything else is a single parameter constructor that is effectively a C-style assignment
     88                                // delete newExpr->get_function();
     89                                assert(newExpr->get_args().size()==2);
     90                                newExpr->set_function( new NameExpr( "?=?" ) );
     91                                funcDecl->get_statements()->get_kids().push_back( new ExprStmt( std::list< Label >(), newExpr ) );
     92                        }
     93                        break;
     94                  case CodeGen::OT_DTOR:
     95                        // intrinsic destructors should do nothing
     96                        // delete newExpr;
     97                        break;
    7998                  case CodeGen::OT_CONSTANT:
    8099                  case CodeGen::OT_LABELADDRESS:
     
    82101                        assert( false );
    83102                } // switch
    84 
    85                 for ( param++; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {
    86                         if ( (*param)->get_name() == "" ) {
    87                                 (*param)->set_name( paramNamer.newName() );
    88                                 (*param)->set_linkage( LinkageSpec::C );
    89                         }
    90                         newExpr->get_args().push_back( new VariableExpr( *param ) );
    91                 } // for
    92                 funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) );
    93                 funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
    94                 newDecls.push_back( funcDecl );
    95103        }
    96104
    97105        void MakeLibCfa::visit( ObjectDecl* origObjDecl ) {
    98106                if ( origObjDecl->get_linkage() != LinkageSpec::Intrinsic ) return;
    99  
     107
    100108                ObjectDecl *objDecl = origObjDecl->clone();
    101109                assert( ! objDecl->get_init() );
    102110                std::list< Expression* > noDesignators;
    103                 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators ) );
     111                objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators, false ) ); // cannot be constructed
    104112                newDecls.push_back( objDecl );
    105113        }
    106114} // namespace LibCfa
    107 
    108 // Local Variables: //
    109 // tab-width: 4 //
    110 // mode: c++ //
    111 // compile-command: "make install" //
    112 // End: //
  • src/Makefile.in

    r0638c44 ra1d6d80  
    123123        GenPoly/driver_cfa_cpp-FindFunction.$(OBJEXT) \
    124124        GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \
    125         InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \
     125        InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) \
     126        InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) \
    126127        Parser/driver_cfa_cpp-parser.$(OBJEXT) \
    127128        Parser/driver_cfa_cpp-lex.$(OBJEXT) \
     
    159160        SymTab/driver_cfa_cpp-ImplementationType.$(OBJEXT) \
    160161        SymTab/driver_cfa_cpp-TypeEquality.$(OBJEXT) \
     162        SymTab/driver_cfa_cpp-Autogen.$(OBJEXT) \
    161163        SynTree/driver_cfa_cpp-Type.$(OBJEXT) \
    162164        SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) \
     
    345347        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
    346348        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    347         GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \
    348         Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
    349         Parser/ParseNode.cc Parser/DeclarationNode.cc \
    350         Parser/ExpressionNode.cc Parser/StatementNode.cc \
    351         Parser/InitializerNode.cc Parser/TypeData.cc \
    352         Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \
     349        GenPoly/DeclMutator.cc InitTweak/GenInit.cc \
     350        InitTweak/FixInit.cc Parser/parser.yy Parser/lex.ll \
     351        Parser/TypedefTable.cc Parser/ParseNode.cc \
     352        Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
     353        Parser/StatementNode.cc Parser/InitializerNode.cc \
     354        Parser/TypeData.cc Parser/LinkageSpec.cc \
     355        Parser/parseutility.cc Parser/Parser.cc \
    353356        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    354357        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    362365        SymTab/Mangler.cc SymTab/Validate.cc SymTab/FixFunction.cc \
    363366        SymTab/ImplementationType.cc SymTab/TypeEquality.cc \
    364         SynTree/Type.cc SynTree/VoidType.cc SynTree/BasicType.cc \
    365         SynTree/PointerType.cc SynTree/ArrayType.cc \
    366         SynTree/FunctionType.cc SynTree/ReferenceToType.cc \
    367         SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \
     367        SymTab/Autogen.cc SynTree/Type.cc SynTree/VoidType.cc \
     368        SynTree/BasicType.cc SynTree/PointerType.cc \
     369        SynTree/ArrayType.cc SynTree/FunctionType.cc \
     370        SynTree/ReferenceToType.cc SynTree/TupleType.cc \
     371        SynTree/TypeofType.cc SynTree/AttrType.cc \
    368372        SynTree/VarArgsType.cc SynTree/Constant.cc \
    369373        SynTree/Expression.cc SynTree/TupleExpr.cc \
     
    561565        @$(MKDIR_P) InitTweak/$(DEPDIR)
    562566        @: > InitTweak/$(DEPDIR)/$(am__dirstamp)
    563 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT):  \
    564         InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
     567InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
     568        InitTweak/$(DEPDIR)/$(am__dirstamp)
     569InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
     570        InitTweak/$(DEPDIR)/$(am__dirstamp)
    565571Parser/parser.h: Parser/parser.cc
    566572        @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi
     
    670676SymTab/driver_cfa_cpp-TypeEquality.$(OBJEXT): SymTab/$(am__dirstamp) \
    671677        SymTab/$(DEPDIR)/$(am__dirstamp)
     678SymTab/driver_cfa_cpp-Autogen.$(OBJEXT): SymTab/$(am__dirstamp) \
     679        SymTab/$(DEPDIR)/$(am__dirstamp)
    672680SynTree/$(am__dirstamp):
    673681        @$(MKDIR_P) SynTree
     
    792800        -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT)
    793801        -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT)
    794         -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT)
     802        -rm -f InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT)
     803        -rm -f InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT)
    795804        -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT)
    796805        -rm -f Parser/driver_cfa_cpp-ExpressionNode.$(OBJEXT)
     
    822831        -rm -f ResolvExpr/driver_cfa_cpp-TypeEnvironment.$(OBJEXT)
    823832        -rm -f ResolvExpr/driver_cfa_cpp-Unify.$(OBJEXT)
     833        -rm -f SymTab/driver_cfa_cpp-Autogen.$(OBJEXT)
    824834        -rm -f SymTab/driver_cfa_cpp-FixFunction.$(OBJEXT)
    825835        -rm -f SymTab/driver_cfa_cpp-ImplementationType.$(OBJEXT)
     
    897907@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@
    898908@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@
    899 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@
     909@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po@am__quote@
     910@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po@am__quote@
    900911@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@
    901912@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-ExpressionNode.Po@am__quote@
     
    927938@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-TypeEnvironment.Po@am__quote@
    928939@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Unify.Po@am__quote@
     940@AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po@am__quote@
    929941@AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-FixFunction.Po@am__quote@
    930942@AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-ImplementationType.Po@am__quote@
     
    13661378@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/driver_cfa_cpp-DeclMutator.obj `if test -f 'GenPoly/DeclMutator.cc'; then $(CYGPATH_W) 'GenPoly/DeclMutator.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/DeclMutator.cc'; fi`
    13671379
    1368 InitTweak/driver_cfa_cpp-RemoveInit.o: InitTweak/RemoveInit.cc
    1369 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc
    1370 @am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po
    1371 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.o' libtool=no @AMDEPBACKSLASH@
    1372 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1373 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc
    1374 
    1375 InitTweak/driver_cfa_cpp-RemoveInit.obj: InitTweak/RemoveInit.cc
    1376 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
    1377 @am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po
    1378 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.obj' libtool=no @AMDEPBACKSLASH@
    1379 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1380 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
     1380InitTweak/driver_cfa_cpp-GenInit.o: InitTweak/GenInit.cc
     1381@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc
     1382@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po
     1383@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.o' libtool=no @AMDEPBACKSLASH@
     1384@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1385@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc
     1386
     1387InitTweak/driver_cfa_cpp-GenInit.obj: InitTweak/GenInit.cc
     1388@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi`
     1389@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po
     1390@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.obj' libtool=no @AMDEPBACKSLASH@
     1391@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1392@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi`
     1393
     1394InitTweak/driver_cfa_cpp-FixInit.o: InitTweak/FixInit.cc
     1395@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc
     1396@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po
     1397@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixInit.cc' object='InitTweak/driver_cfa_cpp-FixInit.o' libtool=no @AMDEPBACKSLASH@
     1398@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1399@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc
     1400
     1401InitTweak/driver_cfa_cpp-FixInit.obj: InitTweak/FixInit.cc
     1402@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi`
     1403@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po
     1404@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixInit.cc' object='InitTweak/driver_cfa_cpp-FixInit.obj' libtool=no @AMDEPBACKSLASH@
     1405@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1406@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi`
    13811407
    13821408Parser/driver_cfa_cpp-parser.o: Parser/parser.cc
     
    18691895@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    18701896@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-TypeEquality.obj `if test -f 'SymTab/TypeEquality.cc'; then $(CYGPATH_W) 'SymTab/TypeEquality.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/TypeEquality.cc'; fi`
     1897
     1898SymTab/driver_cfa_cpp-Autogen.o: SymTab/Autogen.cc
     1899@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Autogen.o -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo -c -o SymTab/driver_cfa_cpp-Autogen.o `test -f 'SymTab/Autogen.cc' || echo '$(srcdir)/'`SymTab/Autogen.cc
     1900@am__fastdepCXX_TRUE@   $(am__mv) SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po
     1901@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='SymTab/Autogen.cc' object='SymTab/driver_cfa_cpp-Autogen.o' libtool=no @AMDEPBACKSLASH@
     1902@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1903@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-Autogen.o `test -f 'SymTab/Autogen.cc' || echo '$(srcdir)/'`SymTab/Autogen.cc
     1904
     1905SymTab/driver_cfa_cpp-Autogen.obj: SymTab/Autogen.cc
     1906@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Autogen.obj -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo -c -o SymTab/driver_cfa_cpp-Autogen.obj `if test -f 'SymTab/Autogen.cc'; then $(CYGPATH_W) 'SymTab/Autogen.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/Autogen.cc'; fi`
     1907@am__fastdepCXX_TRUE@   $(am__mv) SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po
     1908@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='SymTab/Autogen.cc' object='SymTab/driver_cfa_cpp-Autogen.obj' libtool=no @AMDEPBACKSLASH@
     1909@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1910@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-Autogen.obj `if test -f 'SymTab/Autogen.cc'; then $(CYGPATH_W) 'SymTab/Autogen.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/Autogen.cc'; fi`
    18711911
    18721912SynTree/driver_cfa_cpp-Type.o: SynTree/Type.cc
  • src/Parser/DeclarationNode.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // DeclarationNode.cc -- 
     7// DeclarationNode.cc --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 12:34:05 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 13 16:53:17 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:38:09 2016
    1313// Update Count     : 161
    1414//
     
    9797                os << endl << string( indent + 2, ' ' ) << "with initializer ";
    9898                initializer->printOneLine( os );
     99                os << " maybe constructed? " << initializer->get_maybeConstructed();
     100
    99101        } // if
    100102
     
    353355        } // if
    354356}
    355          
     357
    356358DeclarationNode *DeclarationNode::addQualifiers( DeclarationNode *q ) {
    357359        if ( q ) {
     
    504506                assert( false );
    505507        } // switch
    506        
     508
    507509        return this;
    508510}
     
    615617                assert( a->type->kind == TypeData::Array );
    616618                TypeData *lastArray = findLast( a->type );
    617                 if ( type ) { 
     619                if ( type ) {
    618620                        switch ( type->kind ) {
    619621                          case TypeData::Aggregate:
     
    659661        } // if
    660662}
    661        
     663
    662664DeclarationNode *DeclarationNode::addIdList( DeclarationNode *ids ) {
    663665        type = addIdListToType( type, ids );
     
    864866Type *DeclarationNode::buildType() const {
    865867        assert( type );
    866  
     868
    867869        switch ( type->kind ) {
    868870          case TypeData::Enum:
  • src/Parser/InitializerNode.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InitializerNode.cc -- 
    8 // 
     7// InitializerNode.cc --
     8//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:20:24 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 17:18:55 2015
    13 // Update Count     : 4
    14 // 
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Jan 07 13:32:57 2016
     13// Update Count     : 13
     14//
    1515
    1616#include <cassert>
     
    2323
    2424InitializerNode::InitializerNode( ExpressionNode *_expr, bool aggrp, ExpressionNode *des )
    25         : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ) {
     25        : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
    2626        if ( aggrp )
    2727                kids = dynamic_cast< InitializerNode *>( get_link() );
     
    3232
    3333InitializerNode::InitializerNode( InitializerNode *init, bool aggrp, ExpressionNode *des )
    34         : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ) {
     34        : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
    3535        if ( init != 0 )
    3636                set_link(init);
     
    9191                } // if
    9292
    93                 return new ListInit( initlist, designlist );
     93                return new ListInit( initlist, designlist, maybeConstructed );
    9494        } else {
    9595                std::list< Expression *> designators;
     
    9999
    100100                if ( get_expression() != 0)
    101                         return new SingleInit( get_expression()->build(), designators );
     101                        return new SingleInit( get_expression()->build(), designators, maybeConstructed );
    102102        } // if
    103103
  • src/Parser/ParseNode.h

    r0638c44 ra1d6d80  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 11 11:50:52 2016
     12// Last Modified On : Thu Apr 14 15:37:52 2016
    1313// Update Count     : 205
    1414//
     
    185185                                // monadic
    186186                                UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
     187                                Ctor, Dtor,
    187188        };
    188189
     
    525526        ExpressionNode *get_designators() const { return designator; }
    526527
     528        InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
     529        bool get_maybeConstructed() const { return maybeConstructed; }
     530
    527531        InitializerNode *next_init() const { return kids; }
    528532
     
    536540        ExpressionNode *designator; // may be list
    537541        InitializerNode *kids;
     542        bool maybeConstructed;
    538543};
    539544
  • src/Parser/TypeData.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeData.cc -- 
     7// TypeData.cc --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:26:45 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 06 16:57:53 2016
    1313// Update Count     : 49
    1414//
     
    449449        for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    450450                if ( (*i)->get_kind() == TypeDecl::Any ) {
     451                        // add assertion parameters to `type' tyvars in reverse order
     452                        // add dtor:  void ^?{}(T *)
     453                        FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false );
     454                        dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     455                        (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) );
     456
     457                        // add copy ctor:  void ?{}(T *, T)
     458                        FunctionType *copyCtorType = new FunctionType( Type::Qualifiers(), false );
     459                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     460                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );
     461                        (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, 0, false, false ) );
     462
     463                        // add default ctor:  void ?{}(T *)
     464                        FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false );
     465                        ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     466                        (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) );
     467
     468                        // add assignment operator:  T * ?=?(T *, T)
    451469                        FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    452470                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     
    902920                if ( cur->get_enumeratorValue() != NULL ) {
    903921                        ObjectDecl *member = dynamic_cast<ObjectDecl *>(*members);
    904                         member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ) ) );
     922                        member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ), std::list< Expression * >() ) );
    905923                } // if
    906924        } // for
  • src/Parser/parser.cc

    r0638c44 ra1d6d80  
    74687468/* Line 1806 of yacc.c  */
    74697469#line 1704 "parser.yy"
    7470     { (yyval.in) = (yyvsp[(2) - (2)].in); }
     7470    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); }
    74717471    break;
    74727472
  • src/Parser/parser.yy

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // cfa.y -- 
    8 // 
     7// cfa.y --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
     
    1212// Last Modified On : Wed Apr 13 16:58:43 2016
    1313// Update Count     : 1519
    14 // 
     14//
    1515
    1616// This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on the C
     
    17021702                { $$ = $2; }
    17031703        | ATassign initializer
    1704                 { $$ = $2; }
     1704                { $$ = $2->set_maybeConstructed( false ); }
    17051705        ;
    17061706
  • src/ResolvExpr/AlternativeFinder.cc

    r0638c44 ra1d6d80  
    1010// Created On       : Sat May 16 23:52:08 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Feb 10 17:00:04 2016
     12// Last Modified On : Wed Apr 20 14:24:03 2016
    1313// Update Count     : 24
    1414//
     
    982982                } // for
    983983        }
     984
     985        void AlternativeFinder::visit( ImplicitCopyCtorExpr * impCpCtorExpr ) {
     986                alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) );
     987        }
    984988} // namespace ResolvExpr
    985989
  • src/ResolvExpr/AlternativeFinder.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AlternativeFinder.h -- 
     7// AlternativeFinder.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:56:12 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 23:58:43 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 19 11:44:53 2016
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#ifndef ALTERNATIVEFINDER_H
     
    5454                virtual void visit( NameExpr *variableExpr );
    5555                virtual void visit( VariableExpr *variableExpr );
    56                 virtual void visit( ConstantExpr *constantExpr ); 
     56                virtual void visit( ConstantExpr *constantExpr );
    5757                virtual void visit( SizeofExpr *sizeofExpr );
    5858                virtual void visit( AlignofExpr *alignofExpr );
     
    6565                virtual void visit( CommaExpr *commaExpr );
    6666                virtual void visit( TupleExpr *tupleExpr );
     67                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6768          public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
    6869                template< typename InputIterator, typename OutputIterator >
  • src/ResolvExpr/Resolver.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Resolver.cc -- 
     7// Resolver.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 24 16:43:11 2016
    13 // Update Count     : 181
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 26 16:08:21 2016
     13// Update Count     : 203
    1414//
    1515
     
    3333          public:
    3434                Resolver() : SymTab::Indexer( false ), switchType( 0 ) {}
    35  
     35
    3636                virtual void visit( FunctionDecl *functionDecl );
    3737                virtual void visit( ObjectDecl *functionDecl );
     
    5454                virtual void visit( SingleInit *singleInit );
    5555                virtual void visit( ListInit *listInit );
     56                virtual void visit( ConstructorInit *ctorInit );
    5657          private:
    5758        typedef std::list< Initializer * >::iterator InitIterator;
     
    5960          void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & );
    6061          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    61 
     62          void fallbackInit( ConstructorInit * ctorInit );
    6263                std::list< Type * > functionReturn;
    6364                Type *initContext;
     
    8283        }
    8384
     85
    8486        namespace {
    8587                void finishExpr( Expression *expr, const TypeEnvironment &env ) {
     
    8789                        env.makeSubstitution( *expr->get_env() );
    8890                }
    89 
    90                 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
    91                         global_renamer.reset();
    92                         TypeEnvironment env;
    93                         Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
    94                         finishExpr( newExpr, env );
    95                         return newExpr;
    96                 }
    97  
     91        } // namespace
     92
     93        Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
     94                global_renamer.reset();
     95                TypeEnvironment env;
     96                Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
     97                finishExpr( newExpr, env );
     98                return newExpr;
     99        }
     100
     101        namespace {
    98102                Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
    99103                        TypeEnvironment env;
     
    126130                        } // if
    127131                }
    128  
     132
    129133                Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
    130134                        TypeEnvironment env;
     
    159163                        return newExpr;
    160164                }
    161  
    162         }
    163  
     165
     166        }
     167
    164168        void Resolver::visit( ObjectDecl *objectDecl ) {
    165169                Type *new_type = resolveTypeof( objectDecl->get_type(), *this );
     
    258262                        forStmt->set_condition( newExpr );
    259263                } // if
    260                
     264
    261265                if ( forStmt->get_increment() ) {
    262266                        Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this );
     
    272276                delete switchStmt->get_condition();
    273277                switchStmt->set_condition( newExpr );
    274  
     278
    275279                visitor.Visitor::visit( switchStmt );
    276280        }
     
    314318        bool isCharType( T t ) {
    315319                if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) {
    316                         return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 
     320                        return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar ||
    317321                                bt->get_kind() == BasicType::UnsignedChar;
    318322                }
     
    326330                                string n = ne->get_name();
    327331                                if (n == "0") {
    328                                         initContext = new BasicType(Type::Qualifiers(), 
     332                                        initContext = new BasicType(Type::Qualifiers(),
    329333                                                                                                BasicType::SignedInt);
    330334                                } else {
     
    332336                                        initContext = decl->get_type();
    333337                                }
    334                         } else if (ConstantExpr * e = 
     338                        } else if (ConstantExpr * e =
    335339                                           dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
    336340                                Constant *c = e->get_constant();
     
    355359                                                        singleInit->set_value( ce->get_arg() );
    356360                                                        ce->set_arg( NULL );
    357                                                         delete ce;                                                                     
     361                                                        delete ce;
    358362                                                }
    359363                                        }
     
    471475#endif
    472476        }
     477
     478        // ConstructorInit - fall back on C-style initializer
     479        void Resolver::fallbackInit( ConstructorInit * ctorInit ) {
     480                // could not find valid constructor, or found an intrinsic constructor
     481                // fall back on C-style initializer
     482                delete ctorInit->get_ctor();
     483                ctorInit->set_ctor( NULL );
     484                maybeAccept( ctorInit->get_init(), *this );
     485        }
     486
     487        void Resolver::visit( ConstructorInit *ctorInit ) {
     488                try {
     489                        maybeAccept( ctorInit->get_ctor(), *this );
     490                        maybeAccept( ctorInit->get_dtor(), *this );
     491                } catch ( SemanticError ) {
     492                        // no alternatives for the constructor initializer - fallback on C-style initializer
     493                        // xxx- not sure if this makes a ton of sense - should maybe never be able to have this situation?
     494                        fallbackInit( ctorInit );
     495                        return;
     496                }
     497
     498                // found a constructor - can get rid of C-style initializer
     499                delete ctorInit->get_init();
     500                ctorInit->set_init( NULL );
     501        }
    473502} // namespace ResolvExpr
    474503
  • src/ResolvExpr/Resolver.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Resolver.h -- 
     7// Resolver.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:18:34 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 12:19:32 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:06:53 2016
    1313// Update Count     : 2
    1414//
     
    2424        void resolve( std::list< Declaration * > translationUnit );
    2525        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
     26        Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
    2627} // namespace ResolvExpr
    2728
  • src/SymTab/AddVisit.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AddVisit.h -- 
     7// AddVisit.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 16:14:32 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Apr  7 14:42:21 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:52:42 2016
    1313// Update Count     : 5
    1414//
     
    4848        //      maybeAccept( caseStmt->get_condition(), visitor );
    4949        // }
     50
     51        template< typename Visitor >
     52        void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {
     53                std::list< Declaration * >::iterator i = translationUnit.begin();
     54                while ( i != translationUnit.end() ) {
     55                        (*i)->accept( visitor );
     56                        std::list< Declaration * >::iterator next = i;
     57                        next++;
     58                        if ( ! visitor.get_declsToAdd().empty() ) {
     59                                translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() );
     60                        } // if
     61                        i = next;
     62                } // while
     63        }
     64
    5065} // namespace SymTab
    5166
  • src/SymTab/Validate.cc

    r0638c44 ra1d6d80  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 13 16:39:30 2016
    13 // Update Count     : 251
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:37:23 2016
     13// Update Count     : 297
    1414//
    1515
     
    5656#include "MakeLibCfa.h"
    5757#include "TypeEquality.h"
     58#include "Autogen.h"
    5859#include "ResolvExpr/typeops.h"
    5960
     
    122123
    123124                const Indexer *indexer;
    124         };
    125 
    126         class AutogenerateRoutines : public Visitor {
    127           public:
    128                 /// Generates assignment operators for aggregate types as required
    129                 static void autogenerateRoutines( std::list< Declaration * > &translationUnit );
    130 
    131                 std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
    132 
    133                 virtual void visit( EnumDecl *enumDecl );
    134                 virtual void visit( StructDecl *structDecl );
    135                 virtual void visit( UnionDecl *structDecl );
    136                 virtual void visit( TypeDecl *typeDecl );
    137                 virtual void visit( TraitDecl *ctxDecl );
    138                 virtual void visit( FunctionDecl *functionDecl );
    139 
    140                 virtual void visit( FunctionType *ftype );
    141                 virtual void visit( PointerType *ftype );
    142 
    143                 virtual void visit( CompoundStmt *compoundStmt );
    144                 virtual void visit( SwitchStmt *switchStmt );
    145                 virtual void visit( ChooseStmt *chooseStmt );
    146                 // virtual void visit( CaseStmt *caseStmt );
    147 
    148                 AutogenerateRoutines() : functionNesting( 0 ) {}
    149           private:
    150                 template< typename StmtClass > void visitStatement( StmtClass *stmt );
    151 
    152                 std::list< Declaration * > declsToAdd;
    153                 std::set< std::string > structsDone;
    154                 unsigned int functionNesting;                   // current level of nested functions
    155125        };
    156126
     
    192162                template<typename AggDecl>
    193163                void addImplicitTypedef( AggDecl * aggDecl );
    194                
     164
    195165                typedef std::map< std::string, std::pair< TypedefDecl *, int > > TypedefMap;
    196166                TypedefMap typedefNames;
    197167                int scopeLevel;
    198168        };
     169
     170        class VerifyCtorDtor : public Visitor {
     171        public:
     172                /// ensure that constructors and destructors have at least one
     173                /// parameter, the first of which must be a pointer, and no
     174                /// return values.
     175                static void verify( std::list< Declaration * > &translationUnit );
     176
     177                virtual void visit( FunctionDecl *funcDecl );
     178};
    199179
    200180        class CompoundLiteral : public GenPoly::DeclMutator {
     
    217197                ReturnChecker::checkFunctionReturns( translationUnit );
    218198                mutateAll( translationUnit, compoundliteral );
    219                 AutogenerateRoutines::autogenerateRoutines( translationUnit );
     199                autogenerateRoutines( translationUnit );
    220200                acceptAll( translationUnit, pass3 );
     201                VerifyCtorDtor::verify( translationUnit );
    221202        }
    222203
     
    228209                type->accept( pass2 );
    229210                type->accept( pass3 );
    230         }
    231 
    232         template< typename Visitor >
    233         void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {
    234                 std::list< Declaration * >::iterator i = translationUnit.begin();
    235                 while ( i != translationUnit.end() ) {
    236                         (*i)->accept( visitor );
    237                         std::list< Declaration * >::iterator next = i;
    238                         next++;
    239                         if ( ! visitor.get_declsToAdd().empty() ) {
    240                                 translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() );
    241                         } // if
    242                         i = next;
    243                 } // while
    244211        }
    245212
     
    503470        }
    504471
    505         static const std::list< std::string > noLabels;
    506 
    507         void AutogenerateRoutines::autogenerateRoutines( std::list< Declaration * > &translationUnit ) {
    508                 AutogenerateRoutines visitor;
    509                 acceptAndAdd( translationUnit, visitor, false );
    510         }
    511 
    512         template< typename OutputIterator >
    513         void makeScalarAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, OutputIterator out ) {
    514                 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member );
    515                 // unnamed bit fields are not copied as they cannot be accessed
    516                 if ( obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL ) return;
    517 
    518                 UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) );
    519 
    520                 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
    521                 derefExpr->get_args().push_back( new VariableExpr( dstParam ) );
    522 
    523                 // do something special for unnamed members
    524                 Expression *dstselect = new AddressExpr( new MemberExpr( member, derefExpr ) );
    525                 assignExpr->get_args().push_back( dstselect );
    526 
    527                 Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) );
    528                 assignExpr->get_args().push_back( srcselect );
    529 
    530                 *out++ = new ExprStmt( noLabels, assignExpr );
    531         }
    532 
    533         template< typename OutputIterator >
    534         void makeArrayAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, ArrayType *array, OutputIterator out ) {
    535                 static UniqueName indexName( "_index" );
    536 
    537                 // for a flexible array member nothing is done -- user must define own assignment
    538                 if ( ! array->get_dimension() ) return;
    539 
    540                 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );
    541                 *out++ = new DeclStmt( noLabels, index );
    542 
    543                 UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) );
    544                 init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    545                 init->get_args().push_back( new NameExpr( "0" ) );
    546                 Statement *initStmt = new ExprStmt( noLabels, init );
    547                 std::list<Statement *> initList;
    548                 initList.push_back( initStmt );
    549 
    550                 UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) );
    551                 cond->get_args().push_back( new VariableExpr( index ) );
    552                 cond->get_args().push_back( array->get_dimension()->clone() );
    553 
    554                 UntypedExpr *inc = new UntypedExpr( new NameExpr( "++?" ) );
    555                 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    556 
    557                 UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) );
    558 
    559                 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
    560                 derefExpr->get_args().push_back( new VariableExpr( dstParam ) );
    561 
    562                 Expression *dstselect = new MemberExpr( member, derefExpr );
    563                 UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?+?" ) );
    564                 dstIndex->get_args().push_back( dstselect );
    565                 dstIndex->get_args().push_back( new VariableExpr( index ) );
    566                 assignExpr->get_args().push_back( dstIndex );
    567 
    568                 Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) );
    569                 UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
    570                 srcIndex->get_args().push_back( srcselect );
    571                 srcIndex->get_args().push_back( new VariableExpr( index ) );
    572                 assignExpr->get_args().push_back( srcIndex );
    573 
    574                 *out++ = new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, assignExpr ) );
    575         }
    576 
    577         template< typename OutputIterator >
    578         void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType, OutputIterator out ) {
    579                 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );
    580                 copy->get_args().push_back( new VariableExpr( dstParam ) );
    581                 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) );
    582                 copy->get_args().push_back( new SizeofExpr( unionType ) );
    583 
    584                 *out++ = new ExprStmt( noLabels, copy );
    585         }
    586 
    587         //E ?=?(E volatile*, int),
    588         //  ?=?(E _Atomic volatile*, int);
    589         void makeEnumAssignment( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
    590                 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    591 
    592                 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
    593                 assignType->get_returnVals().push_back( returnVal );
    594 
    595                 // need two assignment operators with different types
    596                 FunctionType * assignType2 = assignType->clone();
    597 
    598                 // E ?=?(E volatile *, E)
    599                 Type *etype = refType->clone();
    600                 // etype->get_qualifiers() += Type::Qualifiers(false, true, false, false, false, false);
    601 
    602                 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), etype ), 0 );
    603                 assignType->get_parameters().push_back( dstParam );
    604 
    605                 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, etype->clone(), 0 );
    606                 assignType->get_parameters().push_back( srcParam );
    607 
    608                 // E ?=?(E volatile *, int)
    609                 assignType2->get_parameters().push_back( dstParam->clone() );
    610                 BasicType * paramType = new BasicType(Type::Qualifiers(), BasicType::SignedInt);
    611                 ObjectDecl *srcParam2 = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, paramType, 0 );
    612                 assignType2->get_parameters().push_back( srcParam2 );
    613 
    614                 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    615                 // because each unit generates copies of the default routines for each aggregate.
    616 
    617                 // since there is no definition, these should not be inline
    618                 // make these intrinsic so that the code generator does not make use of them
    619                 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType, 0, false, false );
    620                 assignDecl->fixUniqueId();
    621                 FunctionDecl *assignDecl2 = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType2, 0, false, false );
    622                 assignDecl2->fixUniqueId();
    623 
    624                 // these should be built in the same way that the prelude
    625                 // functions are, so build a list containing the prototypes
    626                 // and allow MakeLibCfa to autogenerate the bodies.
    627                 std::list< Declaration * > assigns;
    628                 assigns.push_back( assignDecl );
    629                 assigns.push_back( assignDecl2 );
    630 
    631                 LibCfa::makeLibCfa( assigns );
    632 
    633                 // need to remove the prototypes, since this may be nested in a routine
    634                 for (int start = 0, end = assigns.size()/2; start < end; start++) {
    635                         delete assigns.front();
    636                         assigns.pop_front();
    637                 } // for
    638 
    639                 declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() );
    640         }
    641 
    642         /// Clones a reference type, replacing any parameters it may have with a clone of the provided list
    643         template< typename GenericInstType >
    644         GenericInstType *cloneWithParams( GenericInstType *refType, const std::list< Expression* >& params ) {
    645                 GenericInstType *clone = refType->clone();
    646                 clone->get_parameters().clear();
    647                 cloneAll( params, clone->get_parameters() );
    648                 return clone;
    649         }
    650 
    651         /// Creates a new type decl that's the same as src, but renamed and with only the ?=? assertion (for complete types only)
    652         TypeDecl *cloneAndRename( TypeDecl *src, const std::string &name ) {
    653                 TypeDecl *dst = new TypeDecl( name, src->get_storageClass(), 0, src->get_kind() );
    654 
    655                 if ( src->get_kind() == TypeDecl::Any ) {
    656                         // just include assignment operator assertion
    657                         TypeInstType *assignParamType = new TypeInstType( Type::Qualifiers(), name, dst );
    658                         FunctionType *assignFunctionType = new FunctionType( Type::Qualifiers(), false );
    659                         assignFunctionType->get_returnVals().push_back(
    660                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType->clone(), 0 ) );
    661                         assignFunctionType->get_parameters().push_back(
    662                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), assignParamType->clone() ), 0 ) );
    663                         assignFunctionType->get_parameters().push_back(
    664                                 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType, 0 ) );
    665                         FunctionDecl *assignAssert = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignFunctionType, 0, false, false );
    666                         dst->get_assertions().push_back( assignAssert );
    667                 }
    668 
    669                 return dst;
    670         }
    671 
    672         Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) {
    673                 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    674 
    675                 // Make function polymorphic in same parameters as generic struct, if applicable
    676                 bool isGeneric = false;  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union)
    677                 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    678                 std::list< Expression* > structParams;  // List of matching parameters to put on types
    679                 TypeSubstitution genericSubs; // Substitutions to make to member types of struct
    680                 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
    681                         isGeneric = true;
    682                         TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() );
    683                         assignType->get_forall().push_back( typeParam );
    684                         TypeInstType *newParamType = new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam );
    685                         genericSubs.add( (*param)->get_name(), newParamType );
    686                         structParams.push_back( new TypeExpr( newParamType ) );
    687                 }
    688 
    689                 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
    690                 assignType->get_returnVals().push_back( returnVal );
    691 
    692                 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, structParams ) ), 0 );
    693                 assignType->get_parameters().push_back( dstParam );
    694 
    695                 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
    696                 assignType->get_parameters().push_back( srcParam );
    697 
    698                 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    699                 // because each unit generates copies of the default routines for each aggregate.
    700                 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
    701                 assignDecl->fixUniqueId();
    702 
    703                 for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
    704                         if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) {
    705                                 // query the type qualifiers of this field and skip assigning it if it is marked const.
    706                                 // If it is an array type, we need to strip off the array layers to find its qualifiers.
    707                                 Type * type = dwt->get_type();
    708                                 while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    709                                         type = at->get_base();
    710                                 }
    711 
    712                                 if ( type->get_qualifiers().isConst ) {
    713                                         // don't assign const members
    714                                         continue;
    715                                 }
    716 
    717                                 if ( isGeneric ) {
    718                                         // rewrite member type in terms of the type variables on this operator
    719                                         DeclarationWithType *fixedMember = dwt->clone();
    720                                         genericSubs.apply( fixedMember );
    721 
    722                                         // assign to both destination and return value
    723                                         if ( ArrayType *array = dynamic_cast< ArrayType * >( fixedMember->get_type() ) ) {
    724                                                 makeArrayAssignment( srcParam, dstParam, fixedMember, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
    725                                                 makeArrayAssignment( srcParam, returnVal, fixedMember, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
    726                                         } else {
    727                                                 makeScalarAssignment( srcParam, dstParam, fixedMember, back_inserter( assignDecl->get_statements()->get_kids() ) );
    728                                                 makeScalarAssignment( srcParam, returnVal, fixedMember, back_inserter( assignDecl->get_statements()->get_kids() ) );
    729                                         } // if
    730                                 } else {
    731                                         // assign to destination
    732                                         if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
    733                                                 makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
    734                                         } else {
    735                                                 makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );
    736                                         } // if
    737                                 } // if
    738                         } // if
    739                 } // for
    740                 if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    741 
    742                 return assignDecl;
    743         }
    744 
    745         Declaration *makeUnionAssignment( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting ) {
    746                 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    747 
    748                 // Make function polymorphic in same parameters as generic union, if applicable
    749                 bool isGeneric = false;  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)
    750                 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    751                 std::list< Expression* > unionParams;  // List of matching parameters to put on types
    752                 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
    753                         isGeneric = true;
    754                         TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() );
    755                         assignType->get_forall().push_back( typeParam );
    756                         unionParams.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ) ) );
    757                 }
    758 
    759                 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
    760                 assignType->get_returnVals().push_back( returnVal );
    761 
    762                 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, unionParams ) ), 0 );
    763                 assignType->get_parameters().push_back( dstParam );
    764 
    765                 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
    766                 assignType->get_parameters().push_back( srcParam );
    767 
    768                 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    769                 // because each unit generates copies of the default routines for each aggregate.
    770                 FunctionDecl *assignDecl = new FunctionDecl( "?=?",  functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
    771                 assignDecl->fixUniqueId();
    772 
    773                 makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
    774                 if ( isGeneric ) makeUnionFieldsAssignment( srcParam, returnVal, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
    775                
    776                 if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    777 
    778                 return assignDecl;
    779         }
    780 
    781         void AutogenerateRoutines::visit( EnumDecl *enumDecl ) {
    782                 if ( ! enumDecl->get_members().empty() ) {
    783                         EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
    784                         // enumInst->set_baseEnum( enumDecl );
    785                         // declsToAdd.push_back(
    786                         makeEnumAssignment( enumDecl, enumInst, functionNesting, declsToAdd );
    787                 }
    788         }
    789 
    790         void AutogenerateRoutines::visit( StructDecl *structDecl ) {
    791                 if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
    792                         StructInstType structInst( Type::Qualifiers(), structDecl->get_name() );
    793                         structInst.set_baseStruct( structDecl );
    794                         declsToAdd.push_back( makeStructAssignment( structDecl, &structInst, functionNesting ) );
    795                         structsDone.insert( structDecl->get_name() );
    796                 } // if
    797         }
    798 
    799         void AutogenerateRoutines::visit( UnionDecl *unionDecl ) {
    800                 if ( ! unionDecl->get_members().empty() ) {
    801                         UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
    802                         unionInst.set_baseUnion( unionDecl );
    803                         declsToAdd.push_back( makeUnionAssignment( unionDecl, &unionInst, functionNesting ) );
    804                 } // if
    805         }
    806 
    807         void AutogenerateRoutines::visit( TypeDecl *typeDecl ) {
    808                 CompoundStmt *stmts = 0;
    809                 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
    810                 typeInst->set_baseType( typeDecl );
    811                 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );
    812                 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );
    813                 if ( typeDecl->get_base() ) {
    814                         stmts = new CompoundStmt( std::list< Label >() );
    815                         UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
    816                         assign->get_args().push_back( new CastExpr( new VariableExpr( dst ), new PointerType( Type::Qualifiers(), typeDecl->get_base()->clone() ) ) );
    817                         assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) );
    818                         stmts->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) );
    819                 } // if
    820                 FunctionType *type = new FunctionType( Type::Qualifiers(), false );
    821                 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
    822                 type->get_parameters().push_back( dst );
    823                 type->get_parameters().push_back( src );
    824                 FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false );
    825                 declsToAdd.push_back( func );
    826         }
    827 
    828         void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
    829                 for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
    830                         statements.insert( i, new DeclStmt( noLabels, *decl ) );
    831                 } // for
    832                 declsToAdd.clear();
    833         }
    834 
    835         void AutogenerateRoutines::visit( FunctionType *) {
    836                 // ensure that we don't add assignment ops for types defined as part of the function
    837         }
    838 
    839         void AutogenerateRoutines::visit( PointerType *) {
    840                 // ensure that we don't add assignment ops for types defined as part of the pointer
    841         }
    842 
    843         void AutogenerateRoutines::visit( TraitDecl *) {
    844                 // ensure that we don't add assignment ops for types defined as part of the context
    845         }
    846 
    847         template< typename StmtClass >
    848         inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) {
    849                 std::set< std::string > oldStructs = structsDone;
    850                 addVisit( stmt, *this );
    851                 structsDone = oldStructs;
    852         }
    853 
    854         void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) {
    855                 maybeAccept( functionDecl->get_functionType(), *this );
    856                 acceptAll( functionDecl->get_oldDecls(), *this );
    857                 functionNesting += 1;
    858                 maybeAccept( functionDecl->get_statements(), *this );
    859                 functionNesting -= 1;
    860         }
    861 
    862         void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) {
    863                 visitStatement( compoundStmt );
    864         }
    865 
    866         void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) {
    867                 visitStatement( switchStmt );
    868         }
    869 
    870         void AutogenerateRoutines::visit( ChooseStmt *switchStmt ) {
    871                 visitStatement( switchStmt );
    872         }
    873 
    874         // void AutogenerateRoutines::visit( CaseStmt *caseStmt ) {
    875         //      visitStatement( caseStmt );
    876         // }
    877 
    878472        void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) {
    879473                ReturnChecker checker;
     
    1033627                return aggDecl;
    1034628        }
    1035        
     629
    1036630        template<typename AggDecl>
    1037631        void EliminateTypedef::addImplicitTypedef( AggDecl * aggDecl ) {
     
    1072666        }
    1073667
     668        void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {
     669                VerifyCtorDtor verifier;
     670                acceptAll( translationUnit, verifier );
     671        }
     672
     673        void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {
     674                FunctionType * funcType = funcDecl->get_functionType();
     675                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
     676                std::list< DeclarationWithType * > &params = funcType->get_parameters();
     677
     678                if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {
     679                        if ( params.size() == 0 ) {
     680                                throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );
     681                        }
     682                        if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {
     683                                throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );
     684                        }
     685                        if ( returnVals.size() != 0 ) {
     686                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
     687                        }
     688                }
     689
     690                Visitor::visit( funcDecl );
     691                // original idea: modify signature of ctor/dtors and insert appropriate return statements
     692                // to cause desired behaviour
     693                // new idea: add comma exprs to every ctor call to produce first parameter.
     694                // this requires some memoization of the first parameter, because it can be a
     695                // complicated expression with side effects (see: malloc). idea: add temporary variable
     696                // that is assigned address of constructed object in ctor argument position and
     697                // return the temporary. It should also be done after all implicit ctors are
     698                // added, so not in this pass!
     699        }
     700
    1074701        DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) {
    1075702                storageclass = objectDecl->get_storageClass();
  • src/SymTab/module.mk

    r0638c44 ra1d6d80  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    2020       SymTab/FixFunction.cc \
    2121       SymTab/ImplementationType.cc \
    22        SymTab/TypeEquality.cc
     22       SymTab/TypeEquality.cc \
     23       SymTab/Autogen.cc
  • src/SynTree/AddressExpr.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AddressExpr.cc -- 
     7// AddressExpr.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 23:54:44 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:52:51 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 26 12:35:13 2016
    1313// Update Count     : 6
    1414//
     
    3232
    3333void AddressExpr::print( std::ostream &os, int indent ) const {
    34         os << std::string( indent, ' ' ) << "Address of:" << std::endl;
     34        os << "Address of:" << std::endl;
    3535        if ( arg ) {
    36                 arg->print( os, indent+2 );
     36                os << std::string( indent+2, ' ' );
     37    arg->print( os, indent+2 );
    3738        } // if
    3839}
  • src/SynTree/ApplicationExpr.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ApplicationExpr.cc.cc -- 
     7// ApplicationExpr.cc.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 07:54:17 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 26 12:41:06 2016
    1313// Update Count     : 4
    1414//
     
    4747        FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    4848        assert( function );
    49        
     49
    5050        for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    5151                get_results().push_back( (*i)->get_type()->clone() );
     
    6464
    6565void ApplicationExpr::print( std::ostream &os, int indent ) const {
    66         os << std::string( indent, ' ' ) << "Application of" << std::endl;
     66        os << "Application of" << std::endl << std::string(indent, ' ');
    6767        function->print( os, indent+2 );
    6868        if ( ! args.empty() ) {
  • src/SynTree/CommaExpr.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CommaExpr.cc -- 
     7// CommaExpr.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 08:09:58 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 15:19:44 2016
    1313// Update Count     : 1
    1414//
     
    2020CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname )
    2121                : Expression( _aname ), arg1( arg1 ), arg2( arg2 ) {
     22        // xxx - result of a comma expression is never an lvalue, so should set lvalue
     23        // to false on all result types. Actually doing this causes some strange things
     24        // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    2225        cloneAll( arg2->get_results(), get_results() );
     26        // for ( Type *& type : get_results() ) {
     27        //      type->set_isLvalue( false );
     28        // }
    2329}
    2430
     
    3339
    3440void CommaExpr::print( std::ostream &os, int indent ) const {
    35         os << std::string( indent, ' ' ) << "Comma Expression:" << std::endl;
     41        os << "Comma Expression:" << std::endl;
     42        os << std::string( indent+2, ' ' );
    3643        arg1->print( os, indent+2 );
    3744        os << std::endl;
     45        os << std::string( indent+2, ' ' );
    3846        arg2->print( os, indent+2 );
    3947        Expression::print( os, indent );
  • src/SynTree/CompoundStmt.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc -- 
     7// XXX.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 11:37:49 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 15:19:17 2016
    1313// Update Count     : 3
    1414//
     
    1818#include <algorithm>
    1919#include <functional>
     20#include "Expression.h"
     21#include "Declaration.h"
    2022
    2123using std::string;
    2224using std::endl;
     25
     26class VarExprReplacer : public Visitor {
     27public:
     28  typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
     29private:
     30  const DeclMap & declMap;
     31public:
     32  VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {}
     33
     34  // replace variable with new node from decl map
     35  virtual void visit( VariableExpr * varExpr ) {
     36    if ( declMap.count( varExpr->get_var() ) ) {
     37      varExpr->set_var( declMap.at( varExpr->get_var() ) );
     38    }
     39  }
     40};
     41
    2342
    2443CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) {
     
    2746CompoundStmt::CompoundStmt( const CompoundStmt &other ) : Statement( other ) {
    2847        cloneAll( other.kids, kids );
     48
     49  // when cloning a compound statement, we may end up cloning declarations which
     50  // are referred to by VariableExprs throughout the block. Cloning a VariableExpr
     51  // does a shallow copy, so the VariableExpr will end up pointing to the original
     52  // declaration. If the original declaration is deleted, e.g. because the original
     53  // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case,
     54  // find all DeclarationWithType nodes (since a VariableExpr must point to a
     55  // DeclarationWithType) in the original CompoundStmt and map them to the cloned
     56  // node in the new CompoundStmt ('this'), then replace the Declarations referred to
     57  // by each VariableExpr according to the constructed map. Note that only the declarations
     58  // in the current level are collected into the map, because child CompoundStmts will
     59  // recursively execute this routine. There may be more efficient ways of doing
     60  // this.
     61  VarExprReplacer::DeclMap declMap;
     62  std::list< Statement * >::const_iterator origit = other.kids.begin();
     63  for ( Statement * s : kids ) {
     64    assert( origit != other.kids.end() );
     65    if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) {
     66      DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( *origit );
     67      assert( origDeclStmt );
     68      if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) {
     69        DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
     70        assert( origdwt );
     71        declMap[ origdwt ] = dwt;
     72      }
     73    }
     74  }
     75  if ( ! declMap.empty() ) {
     76    VarExprReplacer replacer( declMap );
     77    accept( replacer );
     78  }
    2979}
    3080
     
    3484
    3585void CompoundStmt::print( std::ostream &os, int indent ) const {
    36         os << string( indent, ' ' ) << "CompoundStmt" << endl ;
     86        os << "CompoundStmt" << endl ;
    3787        printAll( kids, os, indent + 2 );
    3888}
  • src/SynTree/Declaration.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Declaration.h -- 
     7// Declaration.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:11 2016
    13 // Update Count     : 33
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Apr 11 16:55:12 2016
     13// Update Count     : 36
    1414//
    1515
     
    2222#include "Parser/LinkageSpec.h"
    2323#include "Parser/ParseNode.h"
     24#include <string>
    2425
    2526class Declaration {
     
    6768        void set_mangleName( std::string newValue ) { mangleName = newValue; }
    6869
     70        std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
     71
     72        int get_scopeLevel() const { return scopeLevel; }
     73        void set_scopeLevel( int newValue ) { scopeLevel = newValue; }
     74
    6975        virtual DeclarationWithType *clone() const = 0;
    7076        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     
    7581        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    7682        std::string mangleName;
     83        // need to remember the scope level at which the variable was declared, so that
     84        // shadowed identifiers can be accessed
     85        int scopeLevel = 0;
    7786};
    7887
  • src/SynTree/DeclarationWithType.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // DeclarationWithType.cc -- 
     7// DeclarationWithType.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 08:08:07 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Apr 11 15:35:27 2016
    1313// Update Count     : 3
    1414//
     
    2323
    2424DeclarationWithType::DeclarationWithType( const DeclarationWithType &other )
    25                 : Declaration( other ), mangleName( other.mangleName ) {
     25                : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) {
    2626}
    2727
  • src/SynTree/Expression.cc

    r0638c44 ra1d6d80  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 17:16:23 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed May 04 12:17:51 2016
    1313// Update Count     : 40
    1414//
     
    7272
    7373void ConstantExpr::print( std::ostream &os, int indent ) const {
    74         os << std::string( indent, ' ' ) << "constant expression " ;
     74        os << "constant expression " ;
    7575        constant.print( os );
    7676        Expression::print( os, indent );
     
    7979
    8080VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     81        assert( var );
     82        assert( var->get_type() );
    8183        add_result( var->get_type()->clone() );
    8284        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     
    9395
    9496void VariableExpr::print( std::ostream &os, int indent ) const {
    95         os << std::string( indent, ' ' ) << "Variable Expression: ";
     97        os << "Variable Expression: ";
    9698
    9799        Declaration *decl = get_var();
     
    122124
    123125void SizeofExpr::print( std::ostream &os, int indent) const {
    124         os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
     126        os << "Sizeof Expression on: ";
    125127
    126128        if (isType)
     
    295297
    296298void CastExpr::print( std::ostream &os, int indent ) const {
    297         os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
     299        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
    298300        arg->print(os, indent+2);
    299301        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     
    318320
    319321void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    320         os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
     322        os << "Untyped Member Expression, with field: " << get_member();
    321323
    322324        Expression *agg = get_aggregate();
    323         os << std::string( indent, ' ' ) << "from aggregate: ";
    324         if (agg != 0) agg->print(os, indent + 2);
     325        os << ", from aggregate: ";
     326        if (agg != 0) {
     327                agg->print(os, indent + 2);
     328        }
     329        os << std::string( indent+2, ' ' );
    325330        Expression::print( os, indent );
    326331}
     
    345350
    346351void MemberExpr::print( std::ostream &os, int indent ) const {
    347         os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
     352        os << "Member Expression, with field: " << std::endl;
    348353
    349354        assert( member );
     
    354359        Expression *agg = get_aggregate();
    355360        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
    356         if (agg != 0) agg->print(os, indent + 2);
     361        if (agg != 0) {
     362                agg->print(os, indent + 2);
     363        }
     364        os << std::string( indent+2, ' ' );
    357365        Expression::print( os, indent );
    358366}
     
    372380
    373381void UntypedExpr::print( std::ostream &os, int indent ) const {
    374         os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
     382        os << "Applying untyped: " << std::endl;
     383        os << std::string( indent+4, ' ' );
    375384        function->print(os, indent + 4);
    376385        os << std::string( indent, ' ' ) << "...to: " << std::endl;
    377         printArgs(os, indent + 4);
     386        printAll(args, os, indent + 4);
    378387        Expression::print( os, indent );
    379388}
     
    381390void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
    382391        std::list<Expression *>::const_iterator i;
    383         for (i = args.begin(); i != args.end(); i++)
     392        for (i = args.begin(); i != args.end(); i++) {
     393                os << std::string(indent, ' ' );
    384394                (*i)->print(os, indent);
     395        }
    385396}
    386397
     
    393404
    394405void NameExpr::print( std::ostream &os, int indent ) const {
    395         os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
     406        os << "Name: " << get_name() << std::endl;
    396407        Expression::print( os, indent );
    397408}
     
    454465}
    455466
     467
     468ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
     469        assert( callExpr );
     470        cloneAll( callExpr->get_results(), results );
     471}
     472
     473ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
     474        cloneAll( other.tempDecls, tempDecls );
     475        cloneAll( other.returnDecls, returnDecls );
     476        cloneAll( other.dtors, dtors );
     477}
     478
     479ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
     480        delete callExpr;
     481        deleteAll( tempDecls );
     482        deleteAll( returnDecls );
     483        deleteAll( dtors );
     484}
     485
     486void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
     487        os << std::string( indent, ' ' ) <<  "Implicit Copy Constructor Expression: " << std::endl;
     488        assert( callExpr );
     489        callExpr->print( os, indent + 2 );
     490        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
     491        printAll(tempDecls, os, indent+2);
     492        os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
     493        printAll(returnDecls, os, indent+2);
     494        Expression::print( os, indent );
     495}
     496
    456497UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    457498
  • src/SynTree/Expression.h

    r0638c44 ra1d6d80  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 17:18:06 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:06:49 2016
    1313// Update Count     : 21
    1414//
     
    2222#include "Mutator.h"
    2323#include "Constant.h"
     24#include "Common/UniqueName.h"
    2425
    2526/// Expression is the root type for all expressions
     
    559560};
    560561
     562/// ImplicitCopyCtorExpr represents the application of a function to a set of parameters,
     563/// along with a set of copy constructor calls, one for each argument.
     564class ImplicitCopyCtorExpr : public Expression {
     565public:
     566        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
     567        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
     568        virtual ~ImplicitCopyCtorExpr();
     569
     570        ApplicationExpr *get_callExpr() const { return callExpr; }
     571        void set_callExpr( ApplicationExpr *newValue ) { callExpr = newValue; }
     572
     573        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     574        void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }
     575
     576        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     577        void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; }
     578
     579        std::list< Expression * > & get_dtors() { return dtors; }
     580        void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; }
     581
     582        virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); }
     583        virtual void accept( Visitor &v ) { v.visit( this ); }
     584        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     585        virtual void print( std::ostream &os, int indent = 0 ) const;
     586  private:
     587        ApplicationExpr * callExpr;
     588        std::list< ObjectDecl * > tempDecls;
     589        std::list< ObjectDecl * > returnDecls;
     590        std::list< Expression * > dtors;
     591};
     592
    561593/// ValofExpr represents a GCC 'lambda expression'
    562594class UntypedValofExpr : public Expression {
  • src/SynTree/FunctionDecl.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FunctionDecl.cc -- 
     7// FunctionDecl.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 13 18:11:44 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue May 03 15:37:43 2016
    1313// Update Count     : 19
    1414//
     
    5252        using std::endl;
    5353        using std::string;
    54        
     54
    5555        if ( get_name() != "" ) {
    5656                os << get_name() << ": ";
     
    8787        if ( statements ) {
    8888                os << string( indent + 2, ' ' ) << "with body " << endl;
     89                os << string( indent + 4, ' ' );
    8990                statements->print( os, indent + 4 );
    9091        } // if
     
    9495        using std::endl;
    9596        using std::string;
    96        
     97
    9798        if ( get_name() != "" ) {
    9899                os << get_name() << ": ";
  • src/SynTree/Initializer.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Initializer.cc -- 
     7// Initializer.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:05:25 2015
    13 // Update Count     : 14
     12// Last Modified On : Tue Apr 26 15:51:35 2016
     13// Update Count     : 28
    1414//
    1515
    1616#include "Initializer.h"
    1717#include "Expression.h"
     18#include "Statement.h"
    1819#include "Common/utility.h"
    1920
    20 Initializer::Initializer() {}
     21Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
    2122
    2223Initializer::~Initializer() {}
     
    3132void Initializer::print( std::ostream &os, int indent ) {}
    3233
    33 SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators ) : value ( v ), designators( _designators ) {
     34SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) {
    3435}
    3536
    36 SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) {
     37SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) {
    3738        cloneAll(other.designators, designators );
    3839}
     
    4445void SingleInit::print( std::ostream &os, int indent ) {
    4546        os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
     47        os << std::string(indent+4, ' ' );
    4648        value->print( os, indent+4 );
    4749
     
    5456}
    5557
    56 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
    57         : initializers( _initializers ), designators( _designators ) {
     58ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed )
     59        : Initializer( maybeConstructed), initializers( _initializers ), designators( _designators ) {
    5860}
    5961
     
    6567
    6668void ListInit::print( std::ostream &os, int indent ) {
    67         os << std::endl << std::string(indent, ' ') << "Compound initializer:  "; 
     69        os << std::endl << std::string(indent, ' ') << "Compound initializer:  ";
    6870        if ( ! designators.empty() ) {
    6971                os << std::string(indent + 2, ' ' ) << "designated by: [";
    7072                for ( std::list < Expression * >::iterator i = designators.begin();
    7173                          i != designators.end(); i++ ) {
    72                         ( *i )->print(os, indent + 4 ); 
     74                        ( *i )->print(os, indent + 4 );
    7375                } // for
    74        
     76
    7577                os << std::string(indent + 2, ' ' ) << "]";
    7678        } // if
    7779
    78         for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 
     80        for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ )
    7981                (*i)->print( os, indent + 2 );
    8082}
     83
     84
     85ConstructorInit::ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ) : Initializer( true ), ctor( ctor ), dtor( dtor ), init( init ) {}
     86ConstructorInit::~ConstructorInit() {
     87        delete ctor;
     88        delete init;
     89}
     90
     91ConstructorInit *ConstructorInit::clone() const {
     92        return new ConstructorInit( *this );
     93}
     94
     95void ConstructorInit::print( std::ostream &os, int indent ) {
     96        os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl;
     97        if ( ctor ) {
     98                os << std::string(indent+2, ' ');
     99                os << "initially constructed with ";
     100                ctor->print( os, indent+4 );
     101        } // if
     102
     103        if ( dtor ) {
     104                os << std::string(indent+2, ' ');
     105                os << "destructed with ";
     106                dtor->print( os, indent+4 );
     107        }
     108
     109        if ( init ) {
     110                os << std::string(indent+2, ' ');
     111                os << "with fallback C-style initializer: ";
     112                init->print( os, indent+4 );
     113        }
     114}
     115
     116std::ostream & operator<<( std::ostream & out, Initializer * init ) {
     117        init->print( out );
     118        return out;
     119}
     120
    81121// Local Variables: //
    82122// tab-width: 4 //
  • src/SynTree/Initializer.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Initializer.h -- 
     7// Initializer.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 09:03:48 2015
    13 // Update Count     : 1
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 12 13:49:13 2016
     13// Update Count     : 19
    1414//
    1515
     
    2727  public:
    2828        //      Initializer( std::string _name = std::string(""), int _pos = 0 );
    29         Initializer( );
     29        Initializer( bool maybeConstructed );
    3030        virtual ~Initializer();
    3131
     
    4343        }
    4444
     45        bool get_maybeConstructed() { return maybeConstructed; }
     46
    4547        virtual Initializer *clone() const = 0;
    4648        virtual void accept( Visitor &v ) = 0;
     
    5052        //      std::string name;
    5153        //      int pos;
     54        bool maybeConstructed;
    5255};
    5356
     
    5558class SingleInit : public Initializer {
    5659  public:
    57         SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()) );
     60        SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
    5861        SingleInit( const SingleInit &other );
    5962        virtual ~SingleInit();
    60        
     63
    6164        Expression *get_value() { return value; }
    6265        void set_value( Expression *newValue ) { value = newValue; }
     
    7982class ListInit : public Initializer {
    8083  public:
    81         ListInit( std::list<Initializer*> &,
    82                           std::list<Expression *> &designators = *(new std::list<Expression *>()) );
     84        ListInit( const std::list<Initializer*> &initializers,
     85                          const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
    8386        virtual ~ListInit();
    8487
     
    100103};
    101104
     105// ConstructorInit represents an initializer that is either a constructor expression or
     106// a C-style initializer.
     107class ConstructorInit : public Initializer {
     108  public:
     109        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
     110        virtual ~ConstructorInit();
     111
     112        void set_ctor( Statement * newValue ) { ctor = newValue; }
     113        Statement * get_ctor() const { return ctor; }
     114        void set_dtor( Statement * newValue ) { dtor = newValue; }
     115        Statement * get_dtor() const { return dtor; }
     116        void set_init( Initializer * newValue ) { init = newValue; }
     117        Initializer * get_init() const { return init; }
     118
     119        virtual ConstructorInit *clone() const;
     120        virtual void accept( Visitor &v ) { v.visit( this ); }
     121        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     122        virtual void print( std::ostream &os, int indent = 0 );
     123
     124  private:
     125        Statement * ctor;
     126        Statement * dtor;
     127        // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
     128        // if an appropriate constructor definition is not found by the resolver
     129        Initializer * init;
     130};
     131
     132std::ostream & operator<<( std::ostream & out, Initializer * init );
     133
    102134#endif // INITIALIZER_H
    103135
  • src/SynTree/Mutator.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Mutator.cc -- 
     7// Mutator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  1 18:05:16 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:07:29 2016
    1313// Update Count     : 16
    1414//
     
    337337}
    338338
     339Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
     340        impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
     341        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
     342        mutateAll( impCpCtorExpr->get_returnDecls(), *this );
     343        return impCpCtorExpr;
     344}
     345
    339346Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    340347        mutateAll( valofExpr->get_results(), *this );
     
    450457}
    451458
     459Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {
     460        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
     461        ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
     462        return ctorInit;
     463}
     464
    452465Subrange *Mutator::mutate( Subrange *subrange ) {
    453466        return subrange;
  • src/SynTree/Mutator.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Mutator.h -- 
     7// Mutator.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  1 17:26:56 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:32:00 2016
    1313// Update Count     : 10
    1414//
     
    6262        virtual Expression* mutate( MemberExpr *memberExpr );
    6363        virtual Expression* mutate( VariableExpr *variableExpr );
    64         virtual Expression* mutate( ConstantExpr *constantExpr ); 
     64        virtual Expression* mutate( ConstantExpr *constantExpr );
    6565        virtual Expression* mutate( SizeofExpr *sizeofExpr );
    6666        virtual Expression* mutate( AlignofExpr *alignofExpr );
     
    7676        virtual Expression* mutate( TypeExpr *typeExpr );
    7777        virtual Expression* mutate( AsmExpr *asmExpr );
     78        virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr );
    7879        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    7980        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
     
    9697        virtual Initializer* mutate( SingleInit *singleInit );
    9798        virtual Initializer* mutate( ListInit *listInit );
     99        virtual Initializer* mutate( ConstructorInit *ctorInit );
    98100
    99101        virtual Subrange *mutate( Subrange *subrange );
  • src/SynTree/ObjectDecl.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ObjectDecl.cc -- 
     7// ObjectDecl.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Sep 29 14:13:01 2015
    13 // Update Count     : 18
     12// Last Modified On : Wed May 04 12:18:28 2016
     13// Update Count     : 30
    1414//
    1515
     
    1919#include "Expression.h"
    2020#include "Common/utility.h"
     21#include "Statement.h"
    2122
    2223ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )
     
    5657
    5758        if ( init ) {
     59                os << std::string(indent, ' ');
    5860                os << " with initializer ";
    5961                init->print( os, indent );
     62                os << std::string(indent, ' ') << "maybeConstructed? " << init->get_maybeConstructed();
    6063        } // if
    6164
    6265        if ( bitfieldWidth ) {
     66                os << std::string(indent, ' ');
    6367                os << " with bitfield width ";
    6468                bitfieldWidth->print( os );
     
    6973#if 0
    7074        if ( get_mangleName() != "") {
    71                 os << get_mangleName() << ": "; 
    72         } else 
     75                os << get_mangleName() << ": ";
     76        } else
    7377#endif
    7478        if ( get_name() != "" ) {
  • src/SynTree/Statement.cc

    r0638c44 ra1d6d80  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:09:34 2015
     12// Last Modified On : Thu Apr 28 13:34:32 2016
    1313// Update Count     : 54
    1414//
     
    4343
    4444void ExprStmt::print( std::ostream &os, int indent ) const {
    45         os << string( indent, ' ' ) << "Expression Statement:" << endl;
     45        os << "Expression Statement:" << endl << std::string( indent, ' ' );
    4646        expr->print( os, indent + 2 );
    4747}
     
    110110
    111111void ReturnStmt::print( std::ostream &os, int indent ) const {
    112         os << std::string( indent, ' ' ) << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
    113         if ( expr != 0 ) expr->print( os );
     112        os << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
     113        if ( expr != 0 ) {
     114                os << endl << string( indent+2, ' ' );
     115                expr->print( os, indent + 2 );
     116        }
    114117        os << endl;
    115118}
     
    124127
    125128void IfStmt::print( std::ostream &os, int indent ) const {
    126         os << string( indent, ' ' ) << "If on condition: " << endl ;
     129        os << "If on condition: " << endl ;
     130        os << string( indent+4, ' ' );
    127131        condition->print( os, indent + 4 );
    128132
    129         os << string( indent, ' ' ) << ".... and branches: " << endl;
    130 
     133        os << string( indent+2, ' ' ) << "... then: " << endl;
     134
     135        os << string( indent+4, ' ' );
    131136        thenPart->print( os, indent + 4 );
    132137
    133138        if ( elsePart != 0 ) {
     139                os << string( indent+2, ' ' ) << "... else: " << endl;
     140                os << string( indent+4, ' ' );
    134141                elsePart->print( os, indent + 4 );
    135142        } // if
     
    153160
    154161void SwitchStmt::print( std::ostream &os, int indent ) const {
    155         os << string( indent, ' ' ) << "Switch on condition: ";
     162        os << "Switch on condition: ";
    156163        condition->print( os );
    157164        os << endl;
     
    218225
    219226void ChooseStmt::print( std::ostream &os, int indent ) const {
    220         os << string( indent, ' ' ) << "Choose on condition: ";
     227        os << "Choose on condition: ";
    221228        condition->print( os );
    222229        os << endl;
     
    247254
    248255void WhileStmt::print( std::ostream &os, int indent ) const {
    249         os << string( indent, ' ' ) << "While on condition: " << endl ;
     256        os << "While on condition: " << endl ;
    250257        condition->print( os, indent + 4 );
    251258
     
    273280
    274281void ForStmt::print( std::ostream &os, int indent ) const {
    275         os << string( indent, ' ' ) << "Labels: {";
     282        os << "Labels: {";
    276283        for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) {
    277284                os << *it << ",";
     
    314321
    315322void TryStmt::print( std::ostream &os, int indent ) const {
    316         os << string( indent, ' ' ) << "Try Statement" << endl;
     323        os << "Try Statement" << endl;
    317324        os << string( indent + 2, ' ' ) << "with block: " << endl;
    318325        block->print( os, indent + 4 );
     
    378385
    379386void NullStmt::print( std::ostream &os, int indent ) const {
    380         os << string( indent, ' ' ) << "Null Statement" << endl ;
     387        os << "Null Statement" << endl ;
    381388}
    382389
  • src/SynTree/SynTree.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SynTree.h -- 
     7// SynTree.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  1 16:47:44 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:31:36 2016
    1313// Update Count     : 5
    1414//
     
    8181class TypeExpr;
    8282class AsmExpr;
     83class ImplicitCopyCtorExpr;
    8384class UntypedValofExpr;
    8485class CompoundLiteralExpr;
     
    104105class SingleInit;
    105106class ListInit;
     107class ConstructorInit;
    106108
    107109class Subrange;
  • src/SynTree/TypeSubstitution.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeSubstitution.cc -- 
     7// TypeSubstitution.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:29:15 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 26 11:15:29 2016
    1313// Update Count     : 3
    1414//
     
    9696        BoundVarsType::const_iterator bound = boundVars.find( inst->get_name() );
    9797        if ( bound != boundVars.end() ) return inst;
    98        
     98
    9999        TypeEnvType::const_iterator i = typeEnv.find( inst->get_name() );
    100100        if ( i == typeEnv.end() ) {
     
    217217}
    218218
     219std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub ) {
     220        sub.print( out );
     221        return out;
     222}
     223
     224
    219225// Local Variables: //
    220226// tab-width: 4 //
  • src/SynTree/TypeSubstitution.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeSubstitution.h -- 
     7// TypeSubstitution.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:33:19 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Apr 29 15:00:20 2016
    1313// Update Count     : 2
    1414//
     
    3333        TypeSubstitution( const TypeSubstitution &other );
    3434        virtual ~TypeSubstitution();
    35        
     35
    3636        TypeSubstitution &operator=( const TypeSubstitution &other );
    37        
     37
    3838        template< typename SynTreeClass > int apply( SynTreeClass *&input );
    3939        template< typename SynTreeClass > int applyFree( SynTreeClass *&input );
    40        
     40
    4141        void add( std::string formalType, Type *actualType );
    4242        void add( const TypeSubstitution &other );
     
    4444        Type *lookup( std::string formalType ) const;
    4545        bool empty() const;
    46        
     46
    4747        template< typename FormalIterator, typename ActualIterator >
    4848        void add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );
    49        
     49
     50        /// this function is unused...
    5051        template< typename TypeInstListIterator >
    5152        void extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result );
    52        
     53
    5354        void normalize();
    5455
     
    6364        /// Records type variable bindings from forall-statements and instantiations of generic types
    6465        template< typename TypeClass > Type *handleAggregateType( TypeClass *type );
    65        
     66
    6667        virtual Type* mutate(VoidType *basicType);
    6768        virtual Type* mutate(BasicType *basicType);
     
    7576        virtual Type* mutate(TupleType *tupleType);
    7677        virtual Type* mutate(VarArgsType *varArgsType);
    77        
     78
    7879        // TODO: worry about traversing into a forall-qualified function type or type decl with assertions
    79        
     80
    8081        void initialize( const TypeSubstitution &src, TypeSubstitution &dest );
    8182
     
    136137        return subCount;
    137138}
    138        
     139
    139140template< typename SynTreeClass >
    140141int TypeSubstitution::applyFree( SynTreeClass *&input ) {
     
    149150        return subCount;
    150151}
    151        
     152
    152153template< typename TypeInstListIterator >
    153154void TypeSubstitution::extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result ) {
     155        // xxx - this function doesn't extract varEnv - is this intentional?
    154156        while ( begin != end ) {
    155157                TypeEnvType::iterator cur = typeEnv.find( (*begin++)->get_name() );
     
    173175}
    174176
     177std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub );
     178
    175179#endif // TYPESUBSTITUTION_H
    176180
  • src/SynTree/Visitor.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Visitor.cc -- 
     7// Visitor.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  1 18:05:13 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:07:40 2016
    1313// Update Count     : 18
    1414//
     
    284284}
    285285
     286void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
     287        maybeAccept( impCpCtorExpr->get_callExpr(), *this );
     288        acceptAll( impCpCtorExpr->get_tempDecls(), *this );
     289        acceptAll( impCpCtorExpr->get_returnDecls(), *this );
     290}
     291
    286292void Visitor::visit( UntypedValofExpr *valofExpr ) {
    287293        acceptAll( valofExpr->get_results(), *this );
     
    379385}
    380386
     387void Visitor::visit( ConstructorInit *ctorInit ) {
     388        maybeAccept( ctorInit->get_ctor(), *this );
     389        maybeAccept( ctorInit->get_init(), *this );
     390}
     391
    381392void Visitor::visit( Subrange *subrange ) {}
    382393
  • src/SynTree/Visitor.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Visitor.h -- 
     7// Visitor.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  1 17:26:55 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:30:58 2016
    1313// Update Count     : 7
    1414//
     
    6262        virtual void visit( MemberExpr *memberExpr );
    6363        virtual void visit( VariableExpr *variableExpr );
    64         virtual void visit( ConstantExpr *constantExpr ); 
     64        virtual void visit( ConstantExpr *constantExpr );
    6565        virtual void visit( SizeofExpr *sizeofExpr );
    6666        virtual void visit( AlignofExpr *alignofExpr );
     
    7676        virtual void visit( TypeExpr *typeExpr );
    7777        virtual void visit( AsmExpr *asmExpr );
     78        virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );
    7879        virtual void visit( UntypedValofExpr *valofExpr );
    7980        virtual void visit( CompoundLiteralExpr *compLitExpr );
     
    9697        virtual void visit( SingleInit *singleInit );
    9798        virtual void visit( ListInit *listInit );
     99        virtual void visit( ConstructorInit *ctorInit );
    98100
    99101        virtual void visit( Subrange *subrange );
  • src/examples/array.c

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // array.c -- 
     7// array.c --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:13:52 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:21:52 2016
    1313// Update Count     : 3
    1414//
     
    2626// The first element is always at index 0.
    2727forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    28 elt_type * begin( array_type array ) {
     28elt_type * begin( array_type * array ) {
    2929        return &array[ 0 ];
    3030}
     
    3232// The end iterator should point one past the last element.
    3333forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    34 elt_type * end( array_type array ) {
     34elt_type * end( array_type * array ) {
    3535        return &array[ last( array ) ] + 1;
    3636}
  • src/examples/array.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // array.h -- 
     7// array.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:13:35 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:26:04 2016
    1313// Update Count     : 5
    1414//
     
    2626
    2727// A bounded array is an array that carries its maximum index with it.
    28 trait bounded_array( otype array_type, otype elt_type | array( array_type, elt_type ) ) {
    29         int last( array_type );
     28trait bounded_array( otype array_type, otype elt_type | array( array_type *, elt_type ) ) {
     29        int last( array_type * );
    3030};
    3131
     
    4141// return iterators corresponding to the first element and the one-past-the-end element, STL-style.
    4242forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    43 elt_type *begin( array_type );
     43elt_type * begin( array_type * array );
    4444
     45// The end iterator should point one past the last element.
    4546forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    46 elt_type *end( array_type );
     47elt_type * end( array_type * array );
    4748
    4849#endif // ARRAY_H
  • src/examples/vector_int.c

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // vector_int.c -- 
     7// vector_int.c --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:38:05 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:27:12 2016
    1313// Update Count     : 3
    1414//
     
    2222#define DEFAULT_CAPACITY 20
    2323
    24 vector_int vector_int_allocate() {
    25         return vector_int_allocate( DEFAULT_CAPACITY );
     24void ?{}( vector_int * vec ) {
     25        vec { DEFAULT_CAPACITY };
    2626}
    2727
    28 vector_int vector_int_allocate( int reserve ) {
    29         vector_int new_vector;
    30         new_vector.last = -1;
    31         new_vector.capacity = reserve;
    32         new_vector.data = malloc( sizeof( int ) * reserve );
    33         return new_vector;
     28void ?{}( vector_int * vec, int reserve ) {
     29        vec->last = -1;
     30        vec->capacity = reserve;
     31        vec->data = malloc( sizeof( int ) * reserve );
    3432}
    3533
    36 void vector_int_deallocate( vector_int vec ) {
    37         free( vec.data );
     34void ?{}( vector_int * vec, vector_int other ) {
     35        vec->last = other.last;
     36        vec->capacity = other.capacity;
     37        vec->data = malloc( sizeof( int ) * other.capacity );
     38        for (int i = 0; i < vec->last; i++) {
     39                vec->data[i] = other.data[i];
     40        }
     41}
     42
     43void ^?{}( vector_int * vec ) {
     44        free( vec->data );
    3845}
    3946
     
    5663// implement bounded_array
    5764
    58 lvalue int ?[?]( vector_int vec, int index ) {
    59         return vec.data[ index ];
     65lvalue int ?[?]( vector_int * vec, int index ) {
     66        return vec->data[ index ];
    6067}
    6168
    62 int last( vector_int vec ) {
    63         return vec.last;
     69int last( vector_int * vec ) {
     70        return vec->last;
    6471}
    6572
  • src/examples/vector_int.h

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // vector_int.h -- 
     7// vector_int.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:39:05 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:26:59 2016
    1313// Update Count     : 2
    1414//
     
    2525} vector_int;
    2626
    27 vector_int vector_int_allocate();                                               // allocate vector with default capacity
    28 vector_int vector_int_allocate( int reserve );                  // allocate vector with specified capacity
    29 void vector_int_deallocate( vector_int );                               // deallocate vector's storage
     27void ?{}( vector_int * );                                                               // allocate vector with default capacity
     28void ?{}( vector_int *, int reserve );          // allocate vector with specified capacity
     29void ?{}( vector_int * vec, vector_int other ); // copy constructor
     30void ^?{}( vector_int * );                                                              // deallocate vector's storage
    3031
    3132void reserve( vector_int *vec, int reserve );                   // reserve more capacity
     
    3435// implement bounded_array
    3536
    36 lvalue int ?[?]( vector_int vec, int index );                   // access to arbitrary element (does not resize)
    37 int last( vector_int vec );                                                             // return last element
     37lvalue int ?[?]( vector_int * vec, int index );                 // access to arbitrary element (does not resize)
     38int last( vector_int * vec );                                                           // return last element
    3839
    3940#endif // VECTOR_INT_H
  • src/examples/vector_test.c

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // vector_test.c -- 
     7// vector_test.c --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 17 12:23:55 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:31:27 2016
    1313// Update Count     : 18
    1414//
     
    2020
    2121int main( void ) {
    22         vector_int vec = vector_int_allocate();
     22        vector_int vec;
    2323
    2424        // read in numbers until EOF or error
     
    3434
    3535        sout | "Array elements:" | endl;
    36         write( begin( vec ), end( vec ), sout );
     36        write( begin( &vec ), end( &vec ), sout );
    3737        sout | endl;
    3838
    3939        sout | "Array elements reversed:" | endl;
    40         write_reverse( begin( vec ), end( vec ), sout );
     40        write_reverse( begin( &vec ), end( &vec ), sout );
    4141        sout | endl;
    4242}
  • src/initialization.txt

    r0638c44 ra1d6d80  
    3434sure that resolved initializers for all declarations are being
    3535generated.
     36
     37
     38------
     39
     40More recent email: (I am quoted; Richard is the responder)
     41> As far as I'm aware, the only way that I could currently get the correct
     42> results from the unification engine is by feeding it an expression that
     43> looks like "?=?( ((struct Y)x.y).a, 10 )", then picking out the pieces that
     44> I need (namely the correct choice for a). Does this seem like a reasonable
     45> approach to solve this problem?
     46
     47No, unfortunately. Initialization isn't being rewritten as assignment,
     48so you shouldn't allow the particular selection of assignment
     49operators that happen to be in scope (and which may include
     50user-defined operators) to guide the type resolution.
     51
     52I don't think there is any way to rewrite an initializer as a single
     53expression and have the resolver just do the right thing. I see the
     54algorithm as:
     55
     56For each alternative interpretation of the designator:
     57  Construct an expression that casts the initializer to the type of
     58    the designator
     59  Construct an AlternativeFinder and use it to find the lowest cost
     60    interpretation of the expression
     61  Add this interpretation to a list of possibilities
     62Go through the list of possibilities and pick the lowest cost
     63
     64As with many things in the resolver, it's conceptually simple but the
     65implementation may be a bit of a pain. It fits in with functions like
     66findSingleExpression, findIntegralExpression in Resolver.cc, although
     67it will be significantly more complicated than any of the existing
     68ones.
     69
     70
     71
  • src/libcfa/Makefile.am

    r0638c44 ra1d6d80  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## Makefile.am -- 
     8## Makefile.am --
    99##
    1010## Author           : Peter A. Buhr
     
    5151
    5252CFLAGS = -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t  # TEMPORARY: does not build with -O2
    53 CC = ${abs_top_srcdir}/src/driver/cfa 
     53CC = ${abs_top_srcdir}/src/driver/cfa
    5454
    5555# extension-less header files are overridden by default make rules => explicitly override rule
     
    6767include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
    6868
     69CLEANFILES = libcfa-prelude.c
    6970MAINTAINERCLEANFILES += ${includedir}/*
  • src/libcfa/Makefile.in

    r0638c44 ra1d6d80  
    111111AWK = @AWK@
    112112BACKEND_CC = @BACKEND_CC@
    113 CC = ${abs_top_srcdir}/src/driver/cfa 
     113CC = ${abs_top_srcdir}/src/driver/cfa
    114114CCDEPMODE = @CCDEPMODE@
    115115CFA_BINDIR = @CFA_BINDIR@
     
    219219cfaheaders = # limits
    220220include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
     221CLEANFILES = libcfa-prelude.c
    221222all: all-am
    222223
     
    457458
    458459clean-generic:
     460        -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
    459461
    460462distclean-generic:
  • src/libcfa/fstream.c

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fstream.c -- 
     7// fstream.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 27 18:20:30 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 15:14:52 2016
    1313// Update Count     : 187
    1414//
     
    7575        if ( fclose( (FILE *)(os->file) ) == EOF ) {
    7676                perror( IO_MSG "close output" );
    77         } // if 
     77        } // if
    7878} // close
    7979
     
    140140        if ( fclose( (FILE *)(is->file) ) == EOF ) {
    141141                perror( IO_MSG "close input" );
    142         } // if 
     142        } // if
    143143} // close
    144144
     
    155155        return is;
    156156} // read
    157  
     157
    158158ifstream *ungetc( ifstream * is, char c ) {
    159159        if ( fail( is ) ) {
  • src/libcfa/iostream.c

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // iostream.c -- 
     7// iostream.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 30 14:00:53 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon May 02 15:13:55 2016
    1313// Update Count     : 302
    1414//
     
    184184} // ?|?
    185185
    186 forall( dtype ostype | ostream( ostype ) )
     186
     187forall( dtype ostype | ostream( ostype ) )
    187188ostype * ?|?( ostype *os, ostype * (* manip)( ostype * ) ) {
    188189        return manip( os );
    189190} // ?|?
    190191
    191 forall( dtype ostype | ostream( ostype ) ) 
     192forall( dtype ostype | ostream( ostype ) )
    192193ostype * endl( ostype * os ) {
    193194        os | '\n';
     
    197198} // endl
    198199
    199 forall( dtype ostype | ostream( ostype ) ) 
     200forall( dtype ostype | ostream( ostype ) )
    200201ostype * sepOn( ostype * os ) {
    201202        sepOn( os );
     
    203204} // sepOn
    204205
    205 forall( dtype ostype | ostream( ostype ) ) 
     206forall( dtype ostype | ostream( ostype ) )
    206207ostype * sepOff( ostype * os ) {
    207208        sepOff( os );
     
    209210} // sepOff
    210211
    211 forall( dtype ostype | ostream( ostype ) ) 
     212forall( dtype ostype | ostream( ostype ) )
    212213ostype * sepEnable( ostype * os ) {
    213214        sepEnable( os );
     
    215216} // sepEnable
    216217
    217 forall( dtype ostype | ostream( ostype ) ) 
     218forall( dtype ostype | ostream( ostype ) )
    218219ostype * sepDisable( ostype * os ) {
    219220        sepDisable( os );
     
    335336} // ?|?
    336337
    337 _Istream_cstrUC cstr( char * s ) { _Istream_cstrUC s = { s }; return s; }
     338_Istream_cstrUC cstr( char * str ) { _Istream_cstrUC s = { str }; return s; }
    338339forall( dtype istype | istream( istype ) )
    339340istype * ?|?( istype * is, _Istream_cstrUC cstr ) {
     
    342343} // cstr
    343344
    344 _Istream_cstrC cstr( char * s, int size ) { _Istream_cstrC s = { s, size }; return s; }
     345_Istream_cstrC cstr( char * str, int size ) { _Istream_cstrC s = { str, size }; return s; }
    345346forall( dtype istype | istream( istype ) )
    346347istype * ?|?( istype * is, _Istream_cstrC cstr ) {
  • src/libcfa/prelude.cf

    r0638c44 ra1d6d80  
    11# 2 "prelude.cf"  // needed for error messages from this file
    2 //                               -*- Mode: C -*- 
    3 // 
     2//                               -*- Mode: C -*-
     3//
    44// Copyright (C) Glen Ditchfield 1994, 1999
    5 // 
     5//
    66// prelude.cf -- Standard Cforall Preample for C99
    7 // 
     7//
    88// Author           : Glen Ditchfield
    99// Created On       : Sat Nov 29 07:23:41 2014
     
    117117forall( ftype FT ) lvalue FT             *?( FT * );
    118118
    119 _Bool                   +?( _Bool ),                    -?( _Bool ),                    ~?( _Bool );         
    120 signed int              +?( signed int ),               -?( signed int ),               ~?( signed int );           
    121 unsigned int            +?( unsigned int ),             -?( unsigned int ),             ~?( unsigned int );         
    122 signed long int         +?( signed long int ),          -?( signed long int ),          ~?( signed long int );       
    123 unsigned long int       +?( unsigned long int ),        -?( unsigned long int ),        ~?( unsigned long int );             
    124 signed long long int    +?( signed long long int ),     -?( signed long long int ),     ~?( signed long long int );   
    125 unsigned long long int  +?( unsigned long long int ),   -?( unsigned long long int ),   ~?( unsigned long long int ); 
     119_Bool                   +?( _Bool ),                    -?( _Bool ),                    ~?( _Bool );
     120signed int              +?( signed int ),               -?( signed int ),               ~?( signed int );
     121unsigned int            +?( unsigned int ),             -?( unsigned int ),             ~?( unsigned int );
     122signed long int         +?( signed long int ),          -?( signed long int ),          ~?( signed long int );
     123unsigned long int       +?( unsigned long int ),        -?( unsigned long int ),        ~?( unsigned long int );
     124signed long long int    +?( signed long long int ),     -?( signed long long int ),     ~?( signed long long int );
     125unsigned long long int  +?( unsigned long long int ),   -?( unsigned long long int ),   ~?( unsigned long long int );
    126126float                   +?( float ),                    -?( float );
    127127double                  +?( double ),                   -?( double );
     
    627627                        ?+=?( long double _Complex *, long double _Complex ), ?+=?( volatile long double _Complex *, long double _Complex ),
    628628                        ?-=?( long double _Complex *, long double _Complex ), ?-=?( volatile long double _Complex *, long double _Complex );
     629
     630
     631
     632
     633
     634// ------------------------------------------------------------
     635//
     636// Section ??? Constructors and Destructors
     637//
     638// ------------------------------------------------------------
     639
     640// default ctor
     641void    ?{}( _Bool * ),                         ?{}( volatile _Bool * );
     642void    ?{}( char * ),  ?{}( volatile char * );
     643void    ?{}( unsigned char * ), ?{}( volatile unsigned char * );
     644void    ?{}( char signed * ),                   ?{}( volatile char signed * );
     645void    ?{}( int short * ),                             ?{}( volatile int short * );
     646void    ?{}( int short unsigned * ),    ?{}( volatile int short unsigned * );
     647void    ?{}( signed int * ),                    ?{}( volatile signed int * );
     648void    ?{}( unsigned int * ),                  ?{}( volatile unsigned int * );
     649void    ?{}( signed long int * ),               ?{}( volatile signed long int * );
     650void    ?{}( unsigned long int * ),             ?{}( volatile unsigned long int * );
     651void    ?{}( signed long long int * ),          ?{}( volatile signed long long int * );
     652void    ?{}( unsigned long long int * ),        ?{}( volatile unsigned long long int * );
     653void    ?{}( float * ),                         ?{}( volatile float * );
     654void    ?{}( double * ),                        ?{}( volatile double * );
     655void    ?{}( long double * ),                   ?{}( volatile long double * );
     656void    ?{}( float _Complex * ),                ?{}( volatile float _Complex * );
     657void    ?{}( double _Complex * ),               ?{}( volatile double _Complex * );
     658void    ?{}( long double _Complex * ),          ?{}( volatile long double _Complex * );
     659
     660// copy ctor
     661void    ?{}( _Bool *, _Bool ),                                  ?{}( volatile _Bool *, _Bool );
     662void    ?{}( char *, char ),    ?{}( volatile char *, char );
     663void    ?{}( unsigned char *, unsigned char ),                  ?{}( volatile unsigned char *, unsigned char );
     664void    ?{}( char signed *, char signed ),                      ?{}( volatile char signed *, char signed );
     665void    ?{}( int short *, int short ),                          ?{}( volatile int short *, int short );
     666void    ?{}( int short unsigned *, int short unsigned ),        ?{}( volatile int short unsigned *, int short unsigned );
     667void    ?{}( signed int *, signed int),                         ?{}( volatile signed int *, signed int );
     668void    ?{}( unsigned int *, unsigned int),                     ?{}( volatile unsigned int *, unsigned int );
     669void    ?{}( signed long int *, signed long int),               ?{}( volatile signed long int *, signed long int );
     670void    ?{}( unsigned long int *, unsigned long int),           ?{}( volatile unsigned long int *, unsigned long int );
     671void    ?{}( signed long long int *, signed long long int),     ?{}( volatile signed long long int *, signed long long int );
     672void    ?{}( unsigned long long int *, unsigned long long int), ?{}( volatile unsigned long long int *, unsigned long long int );
     673void    ?{}( float *, float),                                   ?{}( volatile float *, float );
     674void    ?{}( double *, double),                                 ?{}( volatile double *, double );
     675void    ?{}( long double *, long double),                       ?{}( volatile long double *, long double );
     676void    ?{}( float _Complex *, float _Complex),                 ?{}( volatile float _Complex *, float _Complex );
     677void    ?{}( double _Complex *, double _Complex),               ?{}( volatile double _Complex *, double _Complex );
     678void    ?{}( long double _Complex *, long double _Complex),     ?{}( volatile long double _Complex *, long double _Complex );
     679
     680// dtor
     681void    ^?{}( _Bool * ),                        ^?{}( volatile _Bool * );
     682void    ^?{}( char * ), ^?{}( volatile char * );
     683void    ^?{}( char unsigned * ),                        ^?{}( volatile char unsigned * );
     684void    ^?{}( char signed * ),                  ^?{}( volatile char signed * );
     685void    ^?{}( int short * ),                            ^?{}( volatile int short * );
     686void    ^?{}( int short unsigned * ),   ^?{}( volatile int short unsigned * );
     687void    ^?{}( signed int * ),                   ^?{}( volatile signed int * );
     688void    ^?{}( unsigned int * ),                 ^?{}( volatile unsigned int * );
     689void    ^?{}( signed long int * ),              ^?{}( volatile signed long int * );
     690void    ^?{}( unsigned long int * ),            ^?{}( volatile unsigned long int * );
     691void    ^?{}( signed long long int * ),         ^?{}( volatile signed long long int * );
     692void    ^?{}( unsigned long long int * ),       ^?{}( volatile unsigned long long int * );
     693void    ^?{}( float * ),                        ^?{}( volatile float * );
     694void    ^?{}( double * ),                       ^?{}( volatile double * );
     695void    ^?{}( long double * ),                  ^?{}( volatile long double * );
     696void    ^?{}( float _Complex * ),               ^?{}( volatile float _Complex * );
     697void    ^?{}( double _Complex * ),              ^?{}( volatile double _Complex * );
     698void    ^?{}( long double _Complex * ),         ^?{}( volatile long double _Complex * );
     699
     700// // default ctor
     701// forall( dtype DT ) void       ?{}(                DT ** );
     702// forall( dtype DT ) void       ?{}( const          DT ** );
     703// forall( dtype DT ) void       ?{}(       volatile DT ** );
     704// forall( dtype DT ) void       ?{}( const volatile DT ** );
     705
     706// // copy ctor
     707// forall( dtype DT ) void       ?{}(                DT **, DT* );
     708// forall( dtype DT ) void       ?{}( const          DT **, DT* );
     709// forall( dtype DT ) void       ?{}(       volatile DT **, DT* );
     710// forall( dtype DT ) void       ?{}( const volatile DT **, DT* );
     711
     712// // dtor
     713// forall( dtype DT ) void      ^?{}(                DT ** );
     714// forall( dtype DT ) void      ^?{}( const          DT ** );
     715// forall( dtype DT ) void      ^?{}(       volatile DT ** );
     716// forall( dtype DT ) void      ^?{}( const volatile DT ** );
     717
     718// copied from assignment section
     719// copy constructors
     720forall( ftype FT ) void ?{}( FT **, FT * );
     721forall( ftype FT ) void ?{}( FT * volatile *, FT * );
     722
     723forall( dtype DT ) void ?{}(                 DT *          *,                   DT * );
     724forall( dtype DT ) void ?{}(                 DT * volatile *,                   DT * );
     725forall( dtype DT ) void ?{}( const           DT *          *,                   DT * );
     726forall( dtype DT ) void ?{}( const           DT * volatile *,                   DT * );
     727forall( dtype DT ) void ?{}( const           DT *          *, const             DT * );
     728forall( dtype DT ) void ?{}( const           DT * volatile *, const             DT * );
     729forall( dtype DT ) void ?{}(       volatile  DT *          *,                   DT * );
     730forall( dtype DT ) void ?{}(       volatile  DT * volatile *,                   DT * );
     731forall( dtype DT ) void ?{}(       volatile  DT *          *,       volatile    DT * );
     732forall( dtype DT ) void ?{}(       volatile  DT * volatile *,       volatile    DT * );
     733
     734forall( dtype DT ) void ?{}( const volatile  DT *          *,                   DT * );
     735forall( dtype DT ) void ?{}( const volatile  DT * volatile *,                   DT * );
     736forall( dtype DT ) void ?{}( const volatile  DT *          *, const             DT * );
     737forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const             DT * );
     738forall( dtype DT ) void ?{}( const volatile  DT *          *,       volatile    DT * );
     739forall( dtype DT ) void ?{}( const volatile  DT * volatile *,       volatile    DT * );
     740forall( dtype DT ) void ?{}( const volatile  DT *          *, const volatile    DT * );
     741forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const volatile    DT * );
     742
     743forall( dtype DT ) void ?{}(                 DT *          *,                   void * );
     744forall( dtype DT ) void ?{}(                 DT * volatile *,                   void * );
     745forall( dtype DT ) void ?{}( const           DT *          *,                   void * );
     746forall( dtype DT ) void ?{}( const           DT * volatile *,                   void * );
     747forall( dtype DT ) void ?{}( const           DT *          *, const             void * );
     748forall( dtype DT ) void ?{}( const           DT * volatile *, const             void * );
     749forall( dtype DT ) void ?{}(       volatile  DT *          *,                   void * );
     750forall( dtype DT ) void ?{}(       volatile  DT * volatile *,                   void * );
     751forall( dtype DT ) void ?{}(       volatile  DT *          *,       volatile    void * );
     752forall( dtype DT ) void ?{}(       volatile  DT * volatile *,       volatile    void * );
     753
     754forall( dtype DT ) void ?{}( const volatile  DT *          *,                   void * );
     755forall( dtype DT ) void ?{}( const volatile  DT * volatile *,                   void * );
     756forall( dtype DT ) void ?{}( const volatile  DT *          *, const             void * );
     757forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const             void * );
     758forall( dtype DT ) void ?{}( const volatile  DT *          *,       volatile    void * );
     759forall( dtype DT ) void ?{}( const volatile  DT * volatile *,       volatile    void * );
     760forall( dtype DT ) void ?{}( const volatile  DT *          *, const volatile    void * );
     761forall( dtype DT ) void ?{}( const volatile  DT * volatile *, const volatile    void * );
     762
     763forall( dtype DT ) void ?{}(                 void *          *,                 DT * );
     764forall( dtype DT ) void ?{}(                 void * volatile *,                 DT * );
     765forall( dtype DT ) void ?{}( const           void *          *,                 DT * );
     766forall( dtype DT ) void ?{}( const           void * volatile *,                 DT * );
     767forall( dtype DT ) void ?{}( const           void *          *, const           DT * );
     768forall( dtype DT ) void ?{}( const           void * volatile *, const           DT * );
     769forall( dtype DT ) void ?{}(        volatile void *          *,                 DT * );
     770forall( dtype DT ) void ?{}(        volatile void * volatile *,                 DT * );
     771forall( dtype DT ) void ?{}(        volatile void *          *,       volatile  DT * );
     772forall( dtype DT ) void ?{}(        volatile void * volatile *,       volatile  DT * );
     773forall( dtype DT ) void ?{}( const volatile void *           *,                 DT * );
     774forall( dtype DT ) void ?{}( const volatile void * volatile *,                  DT * );
     775forall( dtype DT ) void ?{}( const volatile void *           *, const           DT * );
     776forall( dtype DT ) void ?{}( const volatile void * volatile *, const            DT * );
     777forall( dtype DT ) void ?{}( const volatile void *           *,       volatile  DT * );
     778forall( dtype DT ) void ?{}( const volatile void * volatile *,        volatile  DT * );
     779forall( dtype DT ) void ?{}( const volatile void *           *, const volatile  DT * );
     780forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile   DT * );
     781
     782void    ?{}(                void *          *,                void * );
     783void    ?{}(                void * volatile *,                void * );
     784void    ?{}( const          void *          *,                void * );
     785void    ?{}( const          void * volatile *,                void * );
     786void    ?{}( const          void *          *, const          void * );
     787void    ?{}( const          void * volatile *, const          void * );
     788void    ?{}(       volatile void *          *,                void * );
     789void    ?{}(       volatile void * volatile *,                void * );
     790void    ?{}(       volatile void *          *,       volatile void * );
     791void    ?{}(       volatile void * volatile *,       volatile void * );
     792void    ?{}( const volatile void *          *,                void * );
     793void    ?{}( const volatile void * volatile *,                void * );
     794void    ?{}( const volatile void *          *, const          void * );
     795void    ?{}( const volatile void * volatile *, const          void * );
     796void    ?{}( const volatile void *          *,       volatile void * );
     797void    ?{}( const volatile void * volatile *,       volatile void * );
     798void    ?{}( const volatile void *          *, const volatile void * );
     799void    ?{}( const volatile void * volatile *, const volatile void * );
     800
     801//forall( dtype DT ) void ?{}(              DT *          *, forall( dtype DT2 ) const DT2 * );
     802//forall( dtype DT ) void ?{}(              DT * volatile *, forall( dtype DT2 ) const DT2 * );
     803forall( dtype DT ) void ?{}( const          DT *          *, forall( dtype DT2 ) const DT2 * );
     804forall( dtype DT ) void ?{}( const          DT * volatile *, forall( dtype DT2 ) const DT2 * );
     805//forall( dtype DT ) void ?{}( volatile     DT *          *, forall( dtype DT2 ) const DT2 * );
     806//forall( dtype DT ) void ?{}( volatile     DT * volatile *, forall( dtype DT2 ) const DT2 * );
     807forall( dtype DT ) void ?{}( const volatile DT *          *, forall( dtype DT2 ) const DT2 * );
     808forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );
     809
     810forall( ftype FT ) void ?{}( FT *          *, forall( ftype FT2 ) FT2 * );
     811forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * );
     812
     813// default ctors
     814forall( ftype FT ) void ?{}( FT *          * );
     815forall( ftype FT ) void ?{}( FT * volatile * );
     816
     817forall( dtype DT ) void ?{}(                 DT *          *);
     818forall( dtype DT ) void ?{}(                 DT * volatile *);
     819forall( dtype DT ) void ?{}( const           DT *          *);
     820forall( dtype DT ) void ?{}( const           DT * volatile *);
     821forall( dtype DT ) void ?{}(       volatile  DT *          *);
     822forall( dtype DT ) void ?{}(       volatile  DT * volatile *);
     823forall( dtype DT ) void ?{}( const volatile  DT *          *);
     824forall( dtype DT ) void ?{}( const volatile  DT * volatile *);
     825
     826void    ?{}(                void *          *);
     827void    ?{}(                void * volatile *);
     828void    ?{}( const          void *          *);
     829void    ?{}( const          void * volatile *);
     830void    ?{}(       volatile void *          *);
     831void    ?{}(       volatile void * volatile *);
     832void    ?{}( const volatile void *          *);
     833void    ?{}( const volatile void * volatile *);
     834
     835// dtors
     836forall( ftype FT ) void ^?{}( FT *         * );
     837forall( ftype FT ) void ^?{}( FT * volatile * );
     838
     839forall( dtype DT ) void ^?{}(                DT *          *);
     840forall( dtype DT ) void ^?{}(                DT * volatile *);
     841forall( dtype DT ) void ^?{}( const          DT *          *);
     842forall( dtype DT ) void ^?{}( const          DT * volatile *);
     843forall( dtype DT ) void ^?{}(      volatile  DT *          *);
     844forall( dtype DT ) void ^?{}(      volatile  DT * volatile *);
     845forall( dtype DT ) void ^?{}( const volatile  DT *         *);
     846forall( dtype DT ) void ^?{}( const volatile  DT * volatile *);
     847
     848void    ^?{}(               void *          *);
     849void    ^?{}(               void * volatile *);
     850void    ^?{}( const         void *          *);
     851void    ^?{}( const         void * volatile *);
     852void    ^?{}(      volatile void *          *);
     853void    ^?{}(      volatile void * volatile *);
     854void    ^?{}( const volatile void *         *);
     855void    ^?{}( const volatile void * volatile *);
  • src/main.cc

    r0638c44 ra1d6d80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // main.cc -- 
     7// main.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 27 22:20:20 2016
    13 // Update Count     : 199
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Apr 29 12:02:21 2016
     13// Update Count     : 200
    1414//
    1515
     
    4040#include "MakeLibCfa.h"
    4141#include "InitTweak/Mutate.h"
    42 #include "InitTweak/RemoveInit.h"
     42#include "InitTweak/GenInit.h"
     43#include "InitTweak/FixInit.h"
    4344//#include "Explain/GenProlog.h"
    4445//#include "Try/Visit.h"
     
    5556
    5657static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false );
    57 static void dump( std::list< Declaration * > & translationUnit );
     58static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    5859
    5960bool
    6061        astp = false,
    6162        bresolvep = false,
     63        bboxp = false,
     64        ctorinitp = false,
    6265        exprp = false,
    6366        expraltp = false,
     
    7477        codegenp = false;
    7578
    76 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
     79enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
    7780
    7881static struct option long_opts[] = {
    7982        { "ast", no_argument, 0, Ast },
     83        { "before-box", no_argument, 0, Bbox },
    8084        { "before-resolver", no_argument, 0, Bresolver },
     85        { "ctorinitfix", no_argument, 0, CtorInitFix },
    8186        { "expr", no_argument, 0, Expr },
    8287        { "expralt", no_argument, 0, ExprAlt },
     
    100105
    101106        opterr = 0;                                                                                     // prevent getopt from printing error messages
    102        
     107
    103108        int c;
    104         while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     109        while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    105110                switch ( c ) {
    106111                  case Ast:
     
    111116                  case 'b':                                                                             // print before resolver steps
    112117                        bresolvep = true;
     118                        break;
     119                  case 'B':                                                                             // print before resolver steps
     120                        bboxp = true;
     121                        break;
     122                  case CtorInitFix:
     123                  case 'c':
     124                        ctorinitp = true;
    113125                        break;
    114126                  case Expr:
     
    187199                        output = new ofstream( argv[ optind ] );
    188200                } // if
    189        
     201
    190202                Parser::get_parser().set_debug( grammarp );
    191203
     
    208220                                        exit( 1 );
    209221                                } // if
    210                    
     222
    211223                                parse( prelude, LinkageSpec::Intrinsic );
    212224                        } // if
    213225                } // if
    214226
    215                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
    216  
     227                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
     228
    217229                if ( parsep ) {
    218230                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    249261                OPTPRINT( "mutate" )
    250262                ControlStruct::mutate( translationUnit );
    251                 OPTPRINT( "fixNames" ) 
     263                OPTPRINT( "fixNames" )
    252264                CodeGen::fixNames( translationUnit );
    253                 OPTPRINT( "tweak" )
    254                 InitTweak::tweak( translationUnit );
     265                OPTPRINT( "tweakInit" )
     266                InitTweak::genInit( translationUnit );
    255267
    256268                if ( libcfap ) {
     
    268280                if ( exprp ) {
    269281                        dump( translationUnit );
     282                        return 0;
     283                }
     284
     285                OPTPRINT( "fixInit" )
     286                // fix ObjectDecl - replaces ConstructorInit nodes
     287                InitTweak::fix( translationUnit );
     288                if ( ctorinitp ) {
     289                        dump ( translationUnit );
     290                        return 0;
    270291                }
    271292
     
    276297                OPTPRINT( "convertLvalue" )
    277298                GenPoly::convertLvalue( translationUnit );
     299
     300                if ( bboxp ) {
     301                        dump( translationUnit );
     302                        return 0;
     303                }
    278304                OPTPRINT( "box" )
    279305                GenPoly::box( translationUnit );
    280                
     306
    281307                // print tree right before code generation
    282308                if ( codegenp ) {
     
    292318        } catch ( SemanticError &e ) {
    293319                if ( errorp ) {
    294                         dump( translationUnit );
     320                        std::cerr << "---AST at error:---" << std::endl;
     321                        dump( translationUnit, std::cerr );
     322                        std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl;
    295323                }
    296324                e.print( std::cerr );
     
    314342        } // try
    315343
     344        deleteAll( translationUnit );
    316345        return 0;
    317346} // main
     
    331360}
    332361
    333 static void dump( std::list< Declaration * > & translationUnit ) {
     362static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
    334363        std::list< Declaration * > decls;
    335364        if ( noprotop ) {
    336                 filter( translationUnit.begin(), translationUnit.end(), 
     365                filter( translationUnit.begin(), translationUnit.end(),
    337366                                std::back_inserter( decls ), notPrelude );
    338367        } else {
     
    340369        }
    341370
    342         printAll( decls, std::cout );
     371        printAll( decls, out );
    343372        deleteAll( translationUnit );
    344373}
Note: See TracChangeset for help on using the changeset viewer.