Changes in / [fe7b281:a1e67dd]


Ignore:
Location:
src
Files:
2 added
5 deleted
60 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rfe7b281 ra1e67dd  
    309309                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    310310                                                        newExpr->get_args().push_back( *arg );
    311                                                         assert( (*arg)->get_results().size() == 1 );
    312                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
     311                                                        Type * type = InitTweak::getPointerBase( (*arg)->get_result() );
    313312                                                        assert( type );
    314                                                         newExpr->get_results().push_back( type->clone() );
     313                                                        newExpr->set_result( type->clone() );
    315314                                                        *arg = newExpr;
    316315                                                } // if
     
    527526                extension( castExpr );
    528527                output << "(";
    529                 if ( castExpr->get_results().empty() ) {
     528                if ( castExpr->get_result()->isVoid() ) {
    530529                        output << "(void)" ;
    531                 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
     530                } else if ( ! castExpr->get_result()->get_isLvalue() ) {
    532531                        // at least one result type of cast, but not an lvalue
    533532                        output << "(";
    534                         output << genType( castExpr->get_results().front(), "" );
     533                        output << genType( castExpr->get_result(), "" );
    535534                        output << ")";
    536535                } else {
     
    640639        }
    641640
    642         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
     641        void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
    643642
    644643        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    654653                asmExpr->get_operand()->accept( *this );
    655654                output << " )";
     655        }
     656
     657        void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
     658                assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
     659                output << "(" << genType( compLitExpr->get_type(), "" ) << ")";
     660                compLitExpr->get_initializer()->accept( *this );
     661        }
     662
     663        void CodeGenerator::visit( StmtExpr * stmtExpr ) {
     664                std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     665                output << "({" << std::endl;
     666                cur_indent += CodeGenerator::tabsize;
     667                unsigned int numStmts = stmts.size();
     668                unsigned int i = 0;
     669                for ( Statement * stmt : stmts ) {
     670                        output << indent << printLabels( stmt->get_labels() );
     671                        if ( i+1 == numStmts ) {
     672                                // last statement in a statement expression needs to be handled specially -
     673                                // cannot cast to void, otherwise the expression statement has no value
     674                                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
     675                                        exprStmt->get_expr()->accept( *this );
     676                                        output << ";" << endl;
     677                                        ++i;
     678                                        break;
     679                                }
     680                        }
     681                        stmt->accept( *this );
     682                        output << endl;
     683                        if ( wantSpacing( stmt ) ) {
     684                                output << endl;
     685                        } // if
     686                        ++i;
     687                }
     688                cur_indent -= CodeGenerator::tabsize;
     689                output << indent << "})";
    656690        }
    657691
  • src/CodeGen/CodeGenerator.h

    rfe7b281 ra1e67dd  
    7070                virtual void visit( ConditionalExpr *conditionalExpr );
    7171                virtual void visit( CommaExpr *commaExpr );
     72                virtual void visit( CompoundLiteralExpr *compLitExpr );
    7273                virtual void visit( TupleExpr *tupleExpr );
    7374                virtual void visit( TypeExpr *typeExpr );
    7475                virtual void visit( AsmExpr * );
     76                virtual void visit( StmtExpr * );
    7577
    7678                //*** Statements
  • src/CodeGen/GenType.cc

    rfe7b281 ra1e67dd  
    227227                        typeString = "_Atomic " + typeString;
    228228                } // if
    229                 if ( type->get_isAttribute() ) {
    230                         typeString = "__attribute(( )) " + typeString;
    231                 } // if
    232229        }
    233230} // namespace CodeGen
  • src/Common/utility.h

    rfe7b281 ra1e67dd  
    148148}
    149149
     150// replace element of list with all elements of another list
    150151template< typename T >
    151152void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
     
    158159
    159160        return;
     161}
     162
     163// replace range of a list with a single element
     164template< typename T >
     165void replace( std::list< T > &org, typename std::list< T >::iterator begin, typename std::list< T >::iterator end, const T & with ) {
     166        org.insert( begin, with );
     167        org.erase( begin, end );
    160168}
    161169
  • src/ControlStruct/Mutate.cc

    rfe7b281 ra1e67dd  
    2323#include "MLEMutator.h"
    2424#include "ForExprMutator.h"
    25 #include "LabelTypeChecker.h"
    2625//#include "ExceptMutator.h"
    2726
     
    4140
    4241                //ExceptMutator exc;
    43                 // LabelTypeChecker lbl;
    4442
    4543                mutateAll( translationUnit, formut );
    4644                acceptAll( translationUnit, lfix );
    4745                //mutateAll( translationUnit, exc );
    48                 //acceptAll( translationUnit, lbl );
    4946        }
    5047} // namespace CodeGen
  • src/ControlStruct/module.mk

    rfe7b281 ra1e67dd  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    1919        ControlStruct/MLEMutator.cc \
    2020        ControlStruct/Mutate.cc \
    21         ControlStruct/ForExprMutator.cc \
    22         ControlStruct/LabelTypeChecker.cc
     21        ControlStruct/ForExprMutator.cc
    2322
  • src/GenPoly/Box.cc

    rfe7b281 ra1e67dd  
    110110                        void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars );
    111111                        /// Stores assignment operators from assertion list in local map of assignment operations
    112                         void findTypeOps( const std::list< TypeDecl *> &forall );
     112                        void findTypeOps( const Type::ForallList &forall );
    113113                        void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars );
    114114                        FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars );
     
    612612                }
    613613
    614                 void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) {
     614                void Pass1::findTypeOps( const Type::ForallList &forall ) {
    615615                        // what if a nested function uses an assignment operator?
    616616                        // assignOps.clear();
    617                         for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     617                        for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    618618                                for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    619619                                        std::string typeName;
     
    680680                                std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    681681                                std::list< FunctionType *> functions;
    682                                 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     682                                for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    683683                                        for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    684684                                                findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
     
    782782
    783783                        // add size/align for generic types to parameter list
    784                         if ( appExpr->get_function()->get_results().empty() ) return;
    785                         FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
     784                        if ( ! appExpr->get_function()->has_result() ) return;
     785                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() );
    786786                        assert( funcType );
    787787
     
    799799                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    800800                                VariableExpr *fnArgBase = getBaseVar( *fnArg );
    801                                 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
    802                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes );
     801                                if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results
     802                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );
    803803                        }
    804804                }
     
    890890                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    891891                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    892                         appExpr->set_function( new NameExpr( adapterName ) );
     892                        appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr
    893893
    894894                        return ret;
     
    896896
    897897                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    898                         assert( ! arg->get_results().empty() );
     898                        assert( arg->has_result() );
    899899                        if ( isPolyType( param, exprTyVars ) ) {
    900                                 if ( isPolyType( arg->get_results().front() ) ) {
     900                                if ( isPolyType( arg->get_result() ) ) {
    901901                                        // if the argument's type is polymorphic, we don't need to box again!
    902902                                        return;
    903                                 } else if ( arg->get_results().front()->get_isLvalue() ) {
     903                                } else if ( arg->get_result()->get_isLvalue() ) {
    904904                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    905905                                        // xxx - need to test that this code is still reachable
     
    946946                void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    947947                        std::list< Expression *>::iterator cur = arg;
    948                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     948                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    949949                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    950950                                        InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() );
     
    987987                                        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    988988                                        deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
    989                                         deref->get_results().push_back( arg->get_type()->clone() );
     989                                        deref->set_result( arg->get_type()->clone() );
    990990                                        return deref;
    991991                                } // if
     
    10131013                        Statement *bodyStmt;
    10141014
    1015                         std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();
    1016                         std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();
    1017                         std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin();
     1015                        Type::ForallList::iterator tyArg = realType->get_forall().begin();
     1016                        Type::ForallList::iterator tyParam = adapterType->get_forall().begin();
     1017                        Type::ForallList::iterator realTyParam = adaptee->get_forall().begin();
    10181018                        for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
    10191019                                assert( tyArg != realType->get_forall().end() );
     
    10641064                        std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    10651065                        std::list< FunctionType *> functions;
    1066                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     1066                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    10671067                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    10681068                                        findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter );
     
    11241124                        } // if
    11251125                        addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) );
    1126                         addAssign->get_results().front() = appExpr->get_results().front()->clone();
     1126                        addAssign->set_result( appExpr->get_result()->clone() );
    11271127                        if ( appExpr->get_env() ) {
    11281128                                addAssign->set_env( appExpr->get_env() );
     
    11381138                                if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    11391139                                        if ( varExpr->get_var()->get_name() == "?[?]" ) {
    1140                                                 assert( ! appExpr->get_results().empty() );
     1140                                                assert( appExpr->has_result() );
    11411141                                                assert( appExpr->get_args().size() == 2 );
    1142                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
    1143                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
     1142                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1143                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    11441144                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11451145                                                UntypedExpr *ret = 0;
     
    11611161                                                } // if
    11621162                                                if ( baseType1 || baseType2 ) {
    1163                                                         ret->get_results().push_front( appExpr->get_results().front()->clone() );
     1163                                                        ret->set_result( appExpr->get_result()->clone() );
    11641164                                                        if ( appExpr->get_env() ) {
    11651165                                                                ret->set_env( appExpr->get_env() );
     
    11711171                                                } // if
    11721172                                        } else if ( varExpr->get_var()->get_name() == "*?" ) {
    1173                                                 assert( ! appExpr->get_results().empty() );
     1173                                                assert( appExpr->has_result() );
    11741174                                                assert( ! appExpr->get_args().empty() );
    1175                                                 if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1175                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
    11761176                                                        Expression *ret = appExpr->get_args().front();
    1177                                                         delete ret->get_results().front();
    1178                                                         ret->get_results().front() = appExpr->get_results().front()->clone();
     1177                                                        delete ret->get_result();
     1178                                                        ret->set_result( appExpr->get_result()->clone() );
    11791179                                                        if ( appExpr->get_env() ) {
    11801180                                                                ret->set_env( appExpr->get_env() );
     
    11861186                                                } // if
    11871187                                        } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) {
    1188                                                 assert( ! appExpr->get_results().empty() );
     1188                                                assert( appExpr->has_result() );
    11891189                                                assert( appExpr->get_args().size() == 1 );
    1190                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
    1191                                                         Type *tempType = appExpr->get_results().front()->clone();
     1190                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1191                                                        Type *tempType = appExpr->get_result()->clone();
    11921192                                                        if ( env ) {
    11931193                                                                env->apply( tempType );
     
    12061206                                                } // if
    12071207                                        } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) {
    1208                                                 assert( ! appExpr->get_results().empty() );
     1208                                                assert( appExpr->has_result() );
    12091209                                                assert( appExpr->get_args().size() == 1 );
    1210                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1210                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    12111211                                                        return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" );
    12121212                                                } // if
    12131213                                        } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) {
    1214                                                 assert( ! appExpr->get_results().empty() );
     1214                                                assert( appExpr->has_result() );
    12151215                                                assert( appExpr->get_args().size() == 2 );
    1216                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
    1217                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
     1216                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1217                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    12181218                                                if ( baseType1 && baseType2 ) {
    12191219                                                        UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) );
    12201220                                                        divide->get_args().push_back( appExpr );
    12211221                                                        divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) );
    1222                                                         divide->get_results().push_front( appExpr->get_results().front()->clone() );
     1222                                                        divide->set_result( appExpr->get_result()->clone() );
    12231223                                                        if ( appExpr->get_env() ) {
    12241224                                                                divide->set_env( appExpr->get_env() );
     
    12381238                                                } // if
    12391239                                        } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) {
    1240                                                 assert( ! appExpr->get_results().empty() );
     1240                                                assert( appExpr->has_result() );
    12411241                                                assert( appExpr->get_args().size() == 2 );
    1242                                                 Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
     1242                                                Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
    12431243                                                if ( baseType ) {
    12441244                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12661266                        useRetval = oldUseRetval;
    12671267
    1268                         assert( ! appExpr->get_function()->get_results().empty() );
    1269                         PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
    1270                         assert( pointer );
    1271                         FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
    1272                         assert( function );
     1268                        assert( appExpr->get_function()->has_result() );
     1269                        PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1270                        FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    12731271
    12741272                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13081306
    13091307                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1310                         if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1308                        if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13111309                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13121310                                        if ( name->get_name() == "*?" ) {
     
    13221320
    13231321                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1324                         assert( ! addrExpr->get_arg()->get_results().empty() );
     1322                        assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
    13251323
    13261324                        bool needs = false;
    13271325                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1328                                 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1326                                if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13291327                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13301328                                                if ( name->get_name() == "*?" ) {
    13311329                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    1332                                                                 assert( ! appExpr->get_function()->get_results().empty() );
    1333                                                                 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
    1334                                                                 assert( pointer );
    1335                                                                 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
    1336                                                                 assert( function );
     1330                                                                assert( appExpr->get_function()->has_result() );
     1331                                                                PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1332                                                                FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    13371333                                                                needs = needsAdapter( function, scopeTyVars );
    13381334                                                        } // if
     
    13431339                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13441340                        // out of the if condition.
    1345                         bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
     1341                        bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    13461342                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13471343                        if ( polytype || needs ) {
    13481344                                Expression *ret = addrExpr->get_arg();
    1349                                 delete ret->get_results().front();
    1350                                 ret->get_results().front() = addrExpr->get_results().front()->clone();
     1345                                delete ret->get_result();
     1346                                ret->set_result( addrExpr->get_result()->clone() );
    13511347                                addrExpr->set_arg( 0 );
    13521348                                delete addrExpr;
     
    13861382                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13871383                        if ( retval && returnStmt->get_expr() ) {
    1388                                 assert( ! returnStmt->get_expr()->get_results().empty() );
     1384                                assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
    13891385                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13901386                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14201416                                        // find each of its needed secondary assignment operators
    14211417                                        std::list< Expression* > &tyParams = refType->get_parameters();
    1422                                         std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall();
     1418                                        Type::ForallList &forallParams = functionDecl->get_type()->get_forall();
    14231419                                        std::list< Expression* >::const_iterator tyIt = tyParams.begin();
    1424                                         std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();
     1420                                        Type::ForallList::const_iterator forallIt = forallParams.begin();
    14251421                                        for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) {
    14261422                                                // Add appropriate mapping to assignment expression environment
     
    14661462                                // replace return statement with appropriate assignment to out parameter
    14671463                                Expression *retParm = new NameExpr( retval->get_name() );
    1468                                 retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1464                                retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14691465                                assignExpr->get_args().push_back( retParm );
    14701466                                assignExpr->get_args().push_back( returnStmt->get_expr() );
     
    15961592                        ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0,
    15971593                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1598                         for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1594                        for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    15991595                                ObjectDecl *sizeParm, *alignParm;
    16001596                                // add all size and alignment parameters to parameter list
  • src/GenPoly/CopyParams.cc

    rfe7b281 ra1e67dd  
    5454                                std::map< std::string, DeclarationWithType* > assignOps;
    5555                                // assume the assignment operator is the first assert param after any "type" parameter
    56                                 for ( std::list< TypeDecl* >::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
     56                                for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
    5757                                        if ( (*tyVar)->get_kind() == TypeDecl::Any ) {
    5858                                                assert( !(*tyVar)->get_assertions().empty() );
  • src/GenPoly/FindFunction.cc

    rfe7b281 ra1e67dd  
    2929                virtual Type *mutate( PointerType *pointerType );
    3030          private:
    31                 void handleForall( const std::list< TypeDecl* > &forall );
     31                void handleForall( const Type::ForallList &forall );
    3232
    3333                std::list< FunctionType* > &functions;
     
    5151        }
    5252
    53         void FindFunction::handleForall( const std::list< TypeDecl* > &forall ) {
    54                 for ( std::list< TypeDecl* >::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     53        void FindFunction::handleForall( const Type::ForallList &forall ) {
     54                for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    5555                        TyVarMap::iterator var = tyVars.find( (*i)->get_name() );
    5656                        if ( var != tyVars.end() ) {
  • src/GenPoly/GenPoly.cc

    rfe7b281 ra1e67dd  
    110110        ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) {
    111111                if ( function->get_returnVals().empty() ) return 0;
    112                
     112
    113113                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
    114114        }
     
    127127//              } // if
    128128                if ( isDynRet( adaptee, tyVars ) ) return true;
    129                
     129
    130130                for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
    131131//                      if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {
     
    228228
    229229        void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) {
    230                 for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
     230                for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
    231231                        assert( *tyVar );
    232232                        tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
  • src/GenPoly/Lvalue.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Lvalue.cc -- 
     7// Lvalue.cc --
    88//
    99// Author           : Richard C. Bilson
     
    4141                  public:
    4242                        Pass1();
    43  
     43
    4444                        virtual Expression *mutate( ApplicationExpr *appExpr );
    4545                        virtual Statement *mutate( ReturnStmt *appExpr );
     
    9999                        appExpr->get_function()->acceptMutator( *this );
    100100                        mutateAll( appExpr->get_args(), *this );
    101  
    102                         assert( ! appExpr->get_function()->get_results().empty() );
    103101
    104                         PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    105                         assert( pointer );
    106                         FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    107                         assert( function );
     102                        PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     103                        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    108104
    109105                        Type *funType = isLvalueRet( function );
    110106                        if ( funType && ! isIntrinsicApp( appExpr ) ) {
    111107                                Expression *expr = appExpr;
    112                                 Type *appType = appExpr->get_results().front();
     108                                Type *appType = appExpr->get_result();
    113109                                if ( isPolyType( funType ) && ! isPolyType( appType ) ) {
    114110                                        // make sure cast for polymorphic type is inside dereference
     
    116112                                }
    117113                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    118                                 deref->get_results().push_back( appType->clone() );
    119                                 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
     114                                deref->set_result( appType->clone() );
     115                                appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) );
    120116                                deref->get_args().push_back( expr );
    121117                                return deref;
     
    127123                Statement * Pass1::mutate(ReturnStmt *retStmt) {
    128124                        if ( retval && retStmt->get_expr() ) {
    129                                 assert( ! retStmt->get_expr()->get_results().empty() );
    130                                 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     125                                if ( retStmt->get_expr()->get_result()->get_isLvalue() ) {
    131126                                        // ***** Code Removal ***** because casts may be stripped already
    132127
     
    155150                                retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) );
    156151                        } // if
    157  
     152
    158153                        Visitor::visit( funType );
    159154                }
  • src/GenPoly/Specialize.cc

    rfe7b281 ra1e67dd  
    147147
    148148        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    149                 assert( ! actual->get_results().empty() ); // using front, should have this assert
    150                 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
     149                assert( actual->has_result() );
     150                if ( needsSpecialization( formalType, actual->get_result(), env ) ) {
    151151                        FunctionType *funType;
    152152                        if ( ( funType = getFunctionType( formalType ) ) ) {
     
    171171        void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) {
    172172                // create thunks for the explicit parameters
    173                 assert( ! appExpr->get_function()->get_results().empty() );
    174                 FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() );
     173                assert( appExpr->get_function()->has_result() );
     174                FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
    175175                assert( function );
    176176                std::list< DeclarationWithType* >::iterator formal;
     
    200200        Expression * Specialize::mutate( AddressExpr *addrExpr ) {
    201201                addrExpr->get_arg()->acceptMutator( *this );
    202                 assert( ! addrExpr->get_results().empty() );
    203                 addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) );
     202                assert( addrExpr->has_result() );
     203                addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) );
    204204                return addrExpr;
    205205        }
     
    207207        Expression * Specialize::mutate( CastExpr *castExpr ) {
    208208                castExpr->get_arg()->acceptMutator( *this );
    209                 if ( castExpr->get_results().empty() ) {
     209                if ( castExpr->get_result()->isVoid() ) {
    210210                        // can't specialize if we don't have a return value
    211211                        return castExpr;
    212212                }
    213                 Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
     213                Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() );
    214214                if ( specialized != castExpr->get_arg() ) {
    215215                        // assume here that the specialization incorporates the cast
  • src/InitTweak/FixInit.cc

    rfe7b281 ra1e67dd  
    3535#include "GenPoly/DeclMutator.h"
    3636#include "SynTree/AddStmtVisitor.h"
    37 #include "CodeGen/GenType.h"  // for warnings
    38 
    39 bool ctordtorp = false;
    40 bool ctorp = false;
    41 bool cpctorp = false;
    42 bool dtorp = false;
     37#include "CodeGen/GenType.h"  // for warning/error messages
     38
     39bool ctordtorp = false; // print all debug
     40bool ctorp = false; // print ctor debug
     41bool cpctorp = false; // print copy ctor debug
     42bool dtorp = false; // print dtor debug
    4343#define PRINT( text ) if ( ctordtorp ) { text }
    4444#define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text }
     
    4747namespace InitTweak {
    4848        namespace {
    49                 const std::list<Label> noLabels;
    50                 const std::list<Expression*> noDesignators;
    51 
    5249                class InsertImplicitCalls : public GenPoly::PolyMutator {
    5350                public:
     
    6966
    7067                        /// create and resolve ctor/dtor expression: fname(var, [cpArg])
    71                         ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
     68                        Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
     69                        Expression * makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg = NULL );
    7270                        /// true if type does not need to be copy constructed to ensure correctness
    73                         bool skipCopyConstruct( Type * );
     71                        bool skipCopyConstruct( Type * type );
     72                        void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr );
     73                        void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr );
    7474                private:
    7575                        TypeSubstitution * env;
     
    357357                }
    358358
    359                 ApplicationExpr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
     359                Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
    360360                        assert( var );
     361                        return makeCtorDtor( fname, new AddressExpr( new VariableExpr( var ) ), cpArg );
     362                }
     363
     364                Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg ) {
     365                        assert( thisArg );
    361366                        UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) );
    362                         untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ) );
     367                        untyped->get_args().push_back( thisArg );
    363368                        if (cpArg) untyped->get_args().push_back( cpArg->clone() );
    364369
     
    367372                        // (VariableExpr and already resolved expression)
    368373                        CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
    369                         ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
     374                        Expression * resolved = ResolvExpr::findVoidExpression( untyped, *this );
     375                        assert( resolved );
    370376                        if ( resolved->get_env() ) {
    371377                                env->add( *resolved->get_env() );
    372378                        } // if
    373379
    374                         assert( resolved );
    375380                        delete untyped;
    376381                        return resolved;
    377382                }
    378383
     384                void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) {
     385                        static UniqueName tempNamer("_tmp_cp");
     386                        CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
     387                        assert( arg->has_result() );
     388                        Type * result = arg->get_result();
     389                        if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types
     390
     391                        // type may involve type variables, so apply type substitution to get temporary variable's actual type
     392                        result = result->clone();
     393                        impCpCtorExpr->get_env()->apply( result );
     394                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
     395                        tmp->get_type()->set_isConst( false );
     396
     397                        // create and resolve copy constructor
     398                        CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
     399                        Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg );
     400
     401                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) {
     402                                // if the chosen constructor is intrinsic, the copy is unnecessary, so
     403                                // don't create the temporary and don't call the copy constructor
     404                                VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
     405                                assert( function );
     406                                if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return;
     407                        }
     408
     409                        // replace argument to function call with temporary
     410                        arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
     411                        impCpCtorExpr->get_tempDecls().push_back( tmp );
     412                        impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
     413                }
     414
     415                void ResolveCopyCtors::destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ) {
     416                        impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( ret ) ) );
     417                }
     418
    379419                void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    380                         static UniqueName tempNamer("_tmp_cp");
    381                         static UniqueName retNamer("_tmp_cp_ret");
    382 
    383420                        CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
    384421                        Visitor::visit( impCpCtorExpr );
     
    389426                        // take each argument and attempt to copy construct it.
    390427                        for ( Expression * & arg : appExpr->get_args() ) {
    391                                 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
    392                                 // xxx - need to handle tuple arguments
    393                                 assert( ! arg->get_results().empty() );
    394                                 Type * result = arg->get_results().front();
    395                                 if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types
    396                                 // type may involve type variables, so apply type substitution to get temporary variable's actual type
    397                                 result = result->clone();
    398                                 impCpCtorExpr->get_env()->apply( result );
    399                                 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    400                                 tmp->get_type()->set_isConst( false );
    401 
    402                                 // create and resolve copy constructor
    403                                 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
    404                                 ApplicationExpr * cpCtor = makeCtorDtor( "?{}", tmp, arg );
    405 
    406                                 // if the chosen constructor is intrinsic, the copy is unnecessary, so
    407                                 // don't create the temporary and don't call the copy constructor
    408                                 VariableExpr * function = dynamic_cast< VariableExpr * >( cpCtor->get_function() );
    409                                 assert( function );
    410                                 if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) {
    411                                         // replace argument to function call with temporary
    412                                         arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
    413                                         impCpCtorExpr->get_tempDecls().push_back( tmp );
    414                                         impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
    415                                 } // if
     428                                copyConstructArg( arg, impCpCtorExpr );
    416429                        } // for
    417430
     
    423436                        // level. Trying to pass that environment along.
    424437                        callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    425                         for ( Type * result : appExpr->get_results() ) {
     438                        Type * result = appExpr->get_result();
     439                        if ( ! result->isVoid() ) {
     440                                static UniqueName retNamer("_tmp_cp_ret");
    426441                                result = result->clone();
    427442                                impCpCtorExpr->get_env()->apply( result );
     
    430445                                impCpCtorExpr->get_returnDecls().push_back( ret );
    431446                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    432                                 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
     447                                destructRet( new VariableExpr( ret ) , impCpCtorExpr );
    433448                        } // for
    434449                        CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
     
    479494                                // know the result type of the assignment is the type of the LHS (minus the pointer), so
    480495                                // add that onto the assignment expression so that later steps have the necessary information
    481                                 assign->add_result( returnDecl->get_type()->clone() );
     496                                assign->set_result( returnDecl->get_type()->clone() );
    482497
    483498                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    484                                 if ( callExpr->get_results().front()->get_isLvalue() ) {
     499                                if ( callExpr->get_result()->get_isLvalue() ) {
    485500                                        // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning
    486501                                        // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the
     
    500515                                        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    501516                                        deref->get_args().push_back( retExpr );
    502                                         deref->add_result( resultType );
     517                                        deref->set_result( resultType );
    503518                                        retExpr = deref;
    504519                                } // if
     
    939954                Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) {
    940955                        static UniqueName tempNamer( "_tmp_ctor_expr" );
    941                         assert( ctorExpr->get_results().size() == 1 );
    942                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr );
     956                        // xxx - is the size check necessary?
     957                        assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 );
     958                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );
    943959                        addDeclaration( tmp );
    944960
     
    952968                        assign->get_args().push_back( new VariableExpr( tmp ) );
    953969                        assign->get_args().push_back( firstArg );
    954                         cloneAll( ctorExpr->get_results(), assign->get_results() );
     970                        assign->set_result( ctorExpr->get_result()->clone() );
    955971                        firstArg = assign;
    956972
  • src/InitTweak/GenInit.cc

    rfe7b281 ra1e67dd  
    2929#include "GenPoly/DeclMutator.h"
    3030#include "GenPoly/ScopedSet.h"
     31#include "ResolvExpr/typeops.h"
    3132
    3233namespace InitTweak {
     
    5051
    5152          protected:
    52                 std::list<DeclarationWithType*> returnVals;
     53                FunctionType * ftype;
    5354                UniqueName tempNamer;
    5455                std::string funcName;
     
    8687
    8788                bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
     89                bool isManaged( Type * type ) const; // determine if type is managed
    8890                void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
    8991                GenPoly::ScopedSet< std::string > managedTypes;
     
    134136
    135137        Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
    136                 // update for multiple return values
     138                std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
    137139                assert( returnVals.size() == 0 || returnVals.size() == 1 );
    138140                // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
     
    156158
    157159        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    158                 ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals );
     160                // xxx - need to handle named return values - this pass may need to happen
     161                // after resolution? the ordering is tricky because return statements must be
     162                // constructed - the simplest way to do that (while also handling multiple
     163                // returns) is to structure the returnVals into a tuple, as done here.
     164                // however, if the tuple return value is structured before resolution,
     165                // it's difficult to resolve named return values, since the name is lost
     166                // in conversion to a tuple. this might be easiest to deal with
     167                // after reference types are added, as it may then be possible to
     168                // uniformly move named return values to the parameter list directly
     169                ValueGuard< FunctionType * > oldFtype( ftype );
    159170                ValueGuard< std::string > oldFuncName( funcName );
    160171
    161                 FunctionType * type = functionDecl->get_functionType();
    162                 returnVals = type->get_returnVals();
     172                ftype = functionDecl->get_functionType();
     173                std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();
     174                if ( retVals.size() > 1 ) {
     175                        TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) );
     176                        ObjectDecl * newRet = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
     177                        retVals.clear();
     178                        retVals.push_back( newRet );
     179                }
    163180                funcName = functionDecl->get_name();
    164181                DeclarationWithType * decl = Mutator::mutate( functionDecl );
     
    220237        }
    221238
     239        bool CtorDtor::isManaged( Type * type ) const {
     240                if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) {
     241                        // tuple is also managed if any of its components are managed
     242                        if ( std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); }) ) {
     243                                return true;
     244                        }
     245                }
     246                return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
     247        }
     248
    222249        bool CtorDtor::isManaged( ObjectDecl * objDecl ) const {
    223250                Type * type = objDecl->get_type();
     
    225252                        type = at->get_base();
    226253                }
    227                 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
     254                return isManaged( type );
    228255        }
    229256
     
    236263                        managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) );
    237264                }
     265        }
     266
     267        ConstructorInit * genCtorInit( ObjectDecl * objDecl ) {
     268                // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
     269                // for each constructable object
     270                std::list< Statement * > ctor;
     271                std::list< Statement * > dtor;
     272
     273                InitExpander srcParam( objDecl->get_init() );
     274                InitExpander nullParam( (Initializer *)NULL );
     275                SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl );
     276                SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false );
     277
     278                // Currently genImplicitCall produces a single Statement - a CompoundStmt
     279                // which  wraps everything that needs to happen. As such, it's technically
     280                // possible to use a Statement ** in the above calls, but this is inherently
     281                // unsafe, so instead we take the slightly less efficient route, but will be
     282                // immediately informed if somehow the above assumption is broken. In this case,
     283                // we could always wrap the list of statements at this point with a CompoundStmt,
     284                // but it seems reasonable at the moment for this to be done by genImplicitCall
     285                // itself. It is possible that genImplicitCall produces no statements (e.g. if
     286                // an array type does not have a dimension). In this case, it's fine to ignore
     287                // the object for the purposes of construction.
     288                assert( ctor.size() == dtor.size() && ctor.size() <= 1 );
     289                if ( ctor.size() == 1 ) {
     290                        // need to remember init expression, in case no ctors exist
     291                        // if ctor does exist, want to use ctor expression instead of init
     292                        // push this decision to the resolver
     293                        assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) );
     294                        return new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() );
     295                }
     296                return nullptr;
    238297        }
    239298
     
    248307                        if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl );
    249308
    250                         // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
    251                         // for each constructable object
    252                         std::list< Statement * > ctor;
    253                         std::list< Statement * > dtor;
    254 
    255                         InitExpander srcParam( objDecl->get_init() );
    256                         InitExpander nullParam( (Initializer *)NULL );
    257                         SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl );
    258                         SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false );
    259 
    260                         // Currently genImplicitCall produces a single Statement - a CompoundStmt
    261                         // which  wraps everything that needs to happen. As such, it's technically
    262                         // possible to use a Statement ** in the above calls, but this is inherently
    263                         // unsafe, so instead we take the slightly less efficient route, but will be
    264                         // immediately informed if somehow the above assumption is broken. In this case,
    265                         // we could always wrap the list of statements at this point with a CompoundStmt,
    266                         // but it seems reasonable at the moment for this to be done by genImplicitCall
    267                         // itself. It is possible that genImplicitCall produces no statements (e.g. if
    268                         // an array type does not have a dimension). In this case, it's fine to ignore
    269                         // the object for the purposes of construction.
    270                         assert( ctor.size() == dtor.size() && ctor.size() <= 1 );
    271                         if ( ctor.size() == 1 ) {
    272                                 // need to remember init expression, in case no ctors exist
    273                                 // if ctor does exist, want to use ctor expression instead of init
    274                                 // push this decision to the resolver
    275                                 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) );
    276                                 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) );
    277                         }
     309                        objDecl->set_init( genCtorInit( objDecl ) );
    278310                }
    279311                return Parent::mutate( objDecl );
     
    288320                managedTypes.beginScope();
    289321                // go through assertions and recursively add seen ctor/dtors
    290                 for ( TypeDecl * tyDecl : functionDecl->get_functionType()->get_forall() ) {
     322                for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) {
    291323                        for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
    292324                                assertion = assertion->acceptMutator( *this );
  • src/InitTweak/GenInit.h

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // RemoveInit.h --
     7// GenInit.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2727        /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
    2828        void genInit( std::list< Declaration * > & translationUnit );
     29
     30        /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer
     31        ConstructorInit * genCtorInit( ObjectDecl * objDecl );
    2932} // namespace
    3033
  • src/InitTweak/InitTweak.cc

    rfe7b281 ra1e67dd  
    340340                return allofCtorDtor( stmt, []( Expression * callExpr ){
    341341                        if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
    342                                 assert( ! appExpr->get_function()->get_results().empty() );
    343                                 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() );
     342                                FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() );
    344343                                assert( funcType );
    345344                                return funcType->get_parameters().size() == 1;
     
    388387                                return memberExpr->get_member()->get_name();
    389388                        } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) {
    390                                 return memberExpr->get_member();
     389                                return funcName( memberExpr->get_member() );
    391390                        } else {
    392391                                assertf( false, "Unexpected expression type being called as a function in call expression" );
     
    451450                // virtual void visit( LogicalExpr *logicalExpr );
    452451                // virtual void visit( ConditionalExpr *conditionalExpr );
    453                 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
    454                 virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; }
    455452                virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }
    456453                virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }
    457454                virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }
    458455                virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
     456                virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
     457                virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
    459458
    460459                bool isConstExpr;
  • src/Makefile.in

    rfe7b281 ra1e67dd  
    105105        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    106106        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
    107         ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \
    108107        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    109108        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    191190        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
    192191        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    193         Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
     192        Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
    194193am_driver_cfa_cpp_OBJECTS = $(am__objects_1)
    195194driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS)
     
    364363        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    365364        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    366         ControlStruct/ForExprMutator.cc \
    367         ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \
     365        ControlStruct/ForExprMutator.cc GenPoly/Box.cc \
    368366        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    369367        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
     
    405403        SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \
    406404        SynTree/Attribute.cc Tuples/TupleAssignment.cc \
    407         Tuples/NameMatcher.cc
     405        Tuples/TupleExpansion.cc
    408406MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    409407        ${cfa_cpplib_PROGRAMS}}
     
    540538        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    541539ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT):  \
    542         ControlStruct/$(am__dirstamp) \
    543         ControlStruct/$(DEPDIR)/$(am__dirstamp)
    544 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT):  \
    545540        ControlStruct/$(am__dirstamp) \
    546541        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     
    776771Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT):  \
    777772        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    778 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \
    779         Tuples/$(DEPDIR)/$(am__dirstamp)
     773Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT): \
     774        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    780775driver/$(am__dirstamp):
    781776        @$(MKDIR_P) driver
     
    799794        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
    800795        -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT)
    801         -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)
    802796        -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT)
    803797        -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT)
     
    886880        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
    887881        -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)
    888         -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    889882        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
     883        -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
    890884
    891885distclean-compile:
     
    906900@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
    907901@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@
    908 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@
    909902@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@
    910903@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
     
    993986@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    994987@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
    995 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@
    996988@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
     989@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@
    997990
    998991.cc.o:
     
    12361229@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi`
    12371230
    1238 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc
    1239 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
    1240 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
    1241 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@
    1242 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1243 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
    1244 
    1245 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc
    1246 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
    1247 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
    1248 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@
    1249 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1250 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
    1251 
    12521231GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    12531232@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc
     
    24402419@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleAssignment.obj `if test -f 'Tuples/TupleAssignment.cc'; then $(CYGPATH_W) 'Tuples/TupleAssignment.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleAssignment.cc'; fi`
    24412420
    2442 Tuples/driver_cfa_cpp-NameMatcher.o: Tuples/NameMatcher.cc
    2443 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc
    2444 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po
    2445 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.o' libtool=no @AMDEPBACKSLASH@
    2446 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2447 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc
    2448 
    2449 Tuples/driver_cfa_cpp-NameMatcher.obj: Tuples/NameMatcher.cc
    2450 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi`
    2451 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po
    2452 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.obj' libtool=no @AMDEPBACKSLASH@
    2453 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2454 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi`
     2421Tuples/driver_cfa_cpp-TupleExpansion.o: Tuples/TupleExpansion.cc
     2422@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc
     2423@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po
     2424@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.o' libtool=no @AMDEPBACKSLASH@
     2425@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2426@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc
     2427
     2428Tuples/driver_cfa_cpp-TupleExpansion.obj: Tuples/TupleExpansion.cc
     2429@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi`
     2430@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po
     2431@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.obj' libtool=no @AMDEPBACKSLASH@
     2432@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2433@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi`
    24552434
    24562435.ll.cc:
  • src/Parser/ExpressionNode.cc

    rfe7b281 ra1e67dd  
    198198}
    199199
    200 Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) {
    201         UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeMoveBuild< Expression >(expr_node) );
    202         delete member;
    203         return ret;
    204 }
    205 
    206 Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) {
     200Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
     201        UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     202        return ret;
     203}
     204
     205Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) {
    207206        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    208207        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    209         UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
    210         delete member;
     208        UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref );
    211209        return ret;
    212210}
  • src/Parser/ParseNode.h

    rfe7b281 ra1e67dd  
    160160
    161161Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    162 Expression * build_fieldSel( ExpressionNode * expr_node, NameExpr * member );
    163 Expression * build_pfieldSel( ExpressionNode * expr_node, NameExpr * member );
     162Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     163Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member );
    164164Expression * build_addressOf( ExpressionNode * expr_node );
    165165Expression * build_sizeOfexpr( ExpressionNode * expr_node );
     
    383383//##############################################################################
    384384
    385 template< typename SynTreeType, typename NodeType >
    386 void buildList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) {
     385template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
     386void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
    387387        SemanticError errors;
    388         std::back_insert_iterator< std::list< SynTreeType * > > out( outputList );
     388        std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
    389389        const NodeType * cur = firstNode;
    390390
  • src/Parser/TypeData.cc

    rfe7b281 ra1e67dd  
    385385} // TypeData::print
    386386
    387 void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) {
     387template< typename ForallList >
     388void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) {
    388389        buildList( firstNode, outputList );
    389         for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    390                 if ( (*i)->get_kind() == TypeDecl::Any ) {
     390        for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     391                TypeDecl * td = static_cast<TypeDecl*>(*i);
     392                if ( td->get_kind() == TypeDecl::Any ) {
    391393                        // add assertion parameters to `type' tyvars in reverse order
    392394                        // add dtor:  void ^?{}(T *)
    393395                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    394                         dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    395                         (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
     396                        dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     397                        td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
    396398
    397399                        // add copy ctor:  void ?{}(T *, T)
    398400                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );
    399                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    400                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    401                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
     401                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     402                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     403                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
    402404
    403405                        // add default ctor:  void ?{}(T *)
    404406                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    405                         ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    406                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
     407                        ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     408                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
    407409
    408410                        // add assignment operator:  T * ?=?(T *, T)
    409411                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );
    410                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    411                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    412                         assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    413                         (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
     412                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     413                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     414                        assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     415                        td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
    414416                } // if
    415417        } // for
     
    515517                // character types. The implementation shall define char to have the same range, representation, and behavior as
    516518                // either signed char or unsigned char.
    517                 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 
     519                static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char };
    518520
    519521                if ( td->length != DeclarationNode::NoLength ) {
  • src/Parser/parser.cc

    rfe7b281 ra1e67dd  
    10231023static const yytype_uint16 yyrline[] =
    10241024{
    1025        0,   302,   302,   306,   313,   314,   315,   319,   320,   321,
    1026      325,   326,   330,   331,   335,   336,   340,   344,   345,   356,
    1027      358,   360,   362,   367,   368,   374,   378,   380,   381,   382,
    1028      384,   385,   387,   389,   391,   400,   401,   407,   408,   412,
    1029      413,   417,   421,   423,   425,   427,   432,   434,   438,   441,
    1030      443,   445,   450,   463,   465,   467,   469,   471,   473,   475,
    1031      477,   479,   481,   483,   490,   491,   497,   498,   499,   500,
    1032      504,   505,   507,   512,   513,   515,   517,   522,   523,   525,
    1033      530,   531,   533,   538,   539,   541,   543,   545,   550,   551,
    1034      553,   558,   559,   564,   565,   570,   571,   576,   577,   582,
    1035      583,   588,   589,   592,   594,   599,   604,   605,   607,   613,
    1036      614,   618,   619,   620,   621,   622,   623,   624,   625,   626,
    1037      627,   628,   629,   635,   637,   639,   641,   646,   647,   652,
    1038      653,   659,   660,   666,   667,   668,   669,   670,   671,   672,
    1039      673,   674,   684,   691,   693,   703,   704,   709,   711,   717,
    1040      719,   723,   724,   729,   734,   737,   739,   741,   751,   753,
    1041      764,   765,   767,   771,   773,   777,   778,   783,   784,   788,
    1042      793,   794,   798,   800,   806,   807,   811,   813,   815,   817,
    1043      823,   824,   828,   830,   835,   837,   839,   844,   846,   851,
    1044      853,   857,   860,   864,   867,   871,   873,   875,   877,   882,
    1045      884,   886,   891,   893,   895,   897,   899,   904,   906,   908,
    1046      910,   915,   927,   928,   933,   935,   940,   944,   946,   948,
    1047      950,   952,   958,   959,   965,   966,   970,   971,   976,   978,
    1048      984,   985,   987,   992,   997,  1007,  1009,  1013,  1014,  1019,
    1049     1021,  1025,  1026,  1030,  1032,  1036,  1037,  1041,  1042,  1046,
    1050     1047,  1062,  1063,  1064,  1065,  1066,  1070,  1075,  1082,  1092,
    1051     1097,  1102,  1110,  1115,  1120,  1125,  1130,  1138,  1160,  1165,
    1052     1172,  1174,  1181,  1186,  1191,  1202,  1207,  1212,  1217,  1222,
    1053     1231,  1236,  1244,  1245,  1246,  1247,  1253,  1258,  1266,  1267,
    1054     1268,  1269,  1273,  1274,  1275,  1276,  1281,  1282,  1291,  1292,
    1055     1297,  1298,  1303,  1305,  1307,  1309,  1311,  1314,  1313,  1325,
    1056     1326,  1328,  1338,  1339,  1344,  1346,  1348,  1350,  1352,  1355,
    1057     1357,  1360,  1365,  1367,  1369,  1371,  1373,  1375,  1377,  1379,
    1058     1381,  1383,  1385,  1387,  1389,  1395,  1396,  1398,  1400,  1402,
    1059     1407,  1408,  1414,  1415,  1417,  1419,  1424,  1426,  1428,  1430,
    1060     1435,  1436,  1438,  1440,  1445,  1446,  1448,  1453,  1454,  1456,
    1061     1458,  1463,  1465,  1467,  1472,  1473,  1477,  1479,  1485,  1484,
    1062     1488,  1490,  1495,  1497,  1503,  1504,  1509,  1510,  1512,  1513,
    1063     1522,  1523,  1525,  1527,  1532,  1534,  1540,  1541,  1543,  1546,
    1064     1549,  1554,  1555,  1560,  1565,  1569,  1571,  1577,  1576,  1583,
    1065     1585,  1591,  1592,  1600,  1601,  1605,  1606,  1607,  1609,  1611,
    1066     1618,  1619,  1621,  1623,  1628,  1629,  1635,  1636,  1640,  1641,
    1067     1646,  1647,  1648,  1650,  1658,  1659,  1661,  1664,  1666,  1670,
    1068     1671,  1672,  1674,  1676,  1680,  1685,  1693,  1694,  1703,  1705,
    1069     1710,  1711,  1712,  1716,  1717,  1718,  1722,  1723,  1724,  1728,
    1070     1729,  1730,  1735,  1736,  1737,  1738,  1744,  1745,  1747,  1752,
    1071     1753,  1758,  1759,  1760,  1761,  1762,  1777,  1778,  1783,  1784,
    1072     1790,  1792,  1795,  1797,  1799,  1822,  1823,  1825,  1827,  1832,
    1073     1833,  1835,  1840,  1845,  1846,  1852,  1851,  1855,  1859,  1861,
    1074     1863,  1869,  1870,  1875,  1880,  1882,  1887,  1889,  1890,  1892,
    1075     1897,  1899,  1901,  1906,  1908,  1913,  1918,  1926,  1932,  1931,
    1076     1945,  1946,  1951,  1952,  1956,  1961,  1966,  1974,  1979,  1990,
    1077     1991,  1996,  1997,  2003,  2004,  2008,  2009,  2010,  2013,  2012,
    1078     2023,  2032,  2038,  2044,  2053,  2059,  2065,  2071,  2077,  2085,
    1079     2091,  2099,  2105,  2114,  2115,  2116,  2120,  2124,  2126,  2131,
    1080     2132,  2136,  2137,  2142,  2148,  2149,  2152,  2154,  2155,  2159,
    1081     2160,  2161,  2162,  2196,  2198,  2199,  2201,  2206,  2211,  2216,
    1082     2218,  2220,  2225,  2227,  2229,  2231,  2236,  2238,  2247,  2249,
    1083     2250,  2255,  2257,  2259,  2264,  2266,  2268,  2273,  2275,  2277,
    1084     2286,  2287,  2288,  2292,  2294,  2296,  2301,  2303,  2305,  2310,
    1085     2312,  2314,  2329,  2331,  2332,  2334,  2339,  2340,  2345,  2347,
    1086     2349,  2354,  2356,  2358,  2360,  2365,  2367,  2369,  2379,  2381,
    1087     2382,  2384,  2389,  2391,  2393,  2398,  2400,  2402,  2404,  2409,
    1088     2411,  2413,  2444,  2446,  2447,  2449,  2454,  2459,  2467,  2469,
    1089     2471,  2476,  2478,  2483,  2485,  2499,  2500,  2502,  2507,  2509,
    1090     2511,  2513,  2515,  2520,  2521,  2523,  2525,  2530,  2532,  2534,
    1091     2540,  2542,  2544,  2548,  2550,  2552,  2554,  2568,  2569,  2571,
    1092     2576,  2578,  2580,  2582,  2584,  2589,  2590,  2592,  2594,  2599,
    1093     2601,  2603,  2609,  2610,  2612,  2621,  2624,  2626,  2629,  2631,
    1094     2633,  2646,  2647,  2649,  2654,  2656,  2658,  2660,  2662,  2667,
    1095     2668,  2670,  2672,  2677,  2679,  2687,  2688,  2689,  2694,  2695,
    1096     2699,  2701,  2703,  2705,  2707,  2709,  2716,  2718,  2720,  2722,
    1097     2724,  2727,  2729,  2731,  2733,  2735,  2740,  2742,  2744,  2749,
    1098     2775,  2776,  2778,  2782,  2783,  2787,  2789,  2791,  2793,  2795,
    1099     2797,  2804,  2806,  2808,  2810,  2812,  2814,  2819,  2824,  2826,
    1100     2828,  2846,  2848,  2853,  2854
     1025       0,   301,   301,   305,   312,   313,   314,   318,   319,   320,
     1026     324,   325,   329,   330,   334,   335,   339,   343,   344,   355,
     1027     357,   359,   361,   366,   367,   373,   377,   379,   381,   383,
     1028     385,   387,   389,   391,   393,   402,   403,   409,   410,   414,
     1029     415,   419,   422,   424,   426,   428,   433,   436,   441,   444,
     1030     446,   448,   453,   466,   468,   470,   472,   474,   476,   478,
     1031     480,   482,   484,   486,   493,   494,   500,   501,   502,   503,
     1032     507,   508,   510,   515,   516,   518,   520,   525,   526,   528,
     1033     533,   534,   536,   541,   542,   544,   546,   548,   553,   554,
     1034     556,   561,   562,   567,   568,   573,   574,   579,   580,   585,
     1035     586,   591,   592,   595,   597,   602,   607,   608,   610,   616,
     1036     617,   621,   622,   623,   624,   625,   626,   627,   628,   629,
     1037     630,   631,   632,   638,   640,   642,   644,   649,   650,   655,
     1038     656,   662,   663,   669,   670,   671,   672,   673,   674,   675,
     1039     676,   677,   687,   694,   696,   706,   707,   712,   714,   720,
     1040     722,   726,   727,   732,   737,   740,   742,   744,   754,   756,
     1041     767,   768,   770,   774,   776,   780,   781,   786,   787,   791,
     1042     796,   797,   801,   803,   809,   810,   814,   816,   818,   820,
     1043     826,   827,   831,   833,   838,   840,   842,   847,   849,   854,
     1044     856,   860,   863,   867,   870,   874,   876,   878,   880,   885,
     1045     887,   889,   894,   896,   898,   900,   902,   907,   909,   911,
     1046     913,   918,   930,   931,   936,   938,   943,   947,   949,   951,
     1047     953,   955,   961,   962,   968,   969,   973,   974,   979,   981,
     1048     987,   988,   990,   995,  1000,  1010,  1012,  1016,  1017,  1022,
     1049    1024,  1028,  1029,  1033,  1035,  1039,  1040,  1044,  1045,  1049,
     1050    1050,  1065,  1066,  1067,  1068,  1069,  1073,  1078,  1085,  1095,
     1051    1100,  1105,  1113,  1118,  1123,  1128,  1133,  1141,  1163,  1168,
     1052    1175,  1177,  1184,  1189,  1194,  1205,  1210,  1215,  1220,  1225,
     1053    1234,  1239,  1247,  1248,  1249,  1250,  1256,  1261,  1269,  1270,
     1054    1271,  1272,  1276,  1277,  1278,  1279,  1284,  1285,  1294,  1295,
     1055    1300,  1301,  1306,  1308,  1310,  1312,  1314,  1317,  1316,  1328,
     1056    1329,  1331,  1341,  1342,  1347,  1349,  1351,  1353,  1355,  1358,
     1057    1360,  1363,  1368,  1370,  1372,  1374,  1376,  1378,  1380,  1382,
     1058    1384,  1386,  1388,  1390,  1392,  1398,  1399,  1401,  1403,  1405,
     1059    1410,  1411,  1417,  1418,  1420,  1422,  1427,  1429,  1431,  1433,
     1060    1438,  1439,  1441,  1443,  1448,  1449,  1451,  1456,  1457,  1459,
     1061    1461,  1466,  1468,  1470,  1475,  1476,  1480,  1482,  1488,  1487,
     1062    1491,  1493,  1498,  1500,  1506,  1507,  1512,  1513,  1515,  1516,
     1063    1525,  1526,  1528,  1530,  1535,  1537,  1543,  1544,  1546,  1549,
     1064    1552,  1557,  1558,  1563,  1568,  1572,  1574,  1580,  1579,  1586,
     1065    1588,  1594,  1595,  1603,  1604,  1608,  1609,  1610,  1612,  1614,
     1066    1621,  1622,  1624,  1626,  1631,  1632,  1638,  1639,  1643,  1644,
     1067    1649,  1650,  1651,  1653,  1661,  1662,  1664,  1667,  1669,  1673,
     1068    1674,  1675,  1677,  1679,  1683,  1688,  1696,  1697,  1706,  1708,
     1069    1713,  1714,  1715,  1719,  1720,  1721,  1725,  1726,  1727,  1731,
     1070    1732,  1733,  1738,  1739,  1740,  1741,  1747,  1748,  1750,  1755,
     1071    1756,  1761,  1762,  1763,  1764,  1765,  1780,  1781,  1786,  1787,
     1072    1793,  1795,  1798,  1800,  1802,  1825,  1826,  1828,  1830,  1835,
     1073    1836,  1838,  1843,  1848,  1849,  1855,  1854,  1858,  1862,  1864,
     1074    1866,  1872,  1873,  1878,  1883,  1885,  1890,  1892,  1893,  1895,
     1075    1900,  1902,  1904,  1909,  1911,  1916,  1921,  1929,  1935,  1934,
     1076    1948,  1949,  1954,  1955,  1959,  1964,  1969,  1977,  1982,  1993,
     1077    1994,  1999,  2000,  2006,  2007,  2011,  2012,  2013,  2016,  2015,
     1078    2026,  2035,  2041,  2047,  2056,  2062,  2068,  2074,  2080,  2088,
     1079    2094,  2102,  2108,  2117,  2118,  2119,  2123,  2127,  2129,  2134,
     1080    2135,  2139,  2140,  2145,  2151,  2152,  2155,  2157,  2158,  2162,
     1081    2163,  2164,  2165,  2199,  2201,  2202,  2204,  2209,  2214,  2219,
     1082    2221,  2223,  2228,  2230,  2232,  2234,  2239,  2241,  2250,  2252,
     1083    2253,  2258,  2260,  2262,  2267,  2269,  2271,  2276,  2278,  2280,
     1084    2289,  2290,  2291,  2295,  2297,  2299,  2304,  2306,  2308,  2313,
     1085    2315,  2317,  2332,  2334,  2335,  2337,  2342,  2343,  2348,  2350,
     1086    2352,  2357,  2359,  2361,  2363,  2368,  2370,  2372,  2382,  2384,
     1087    2385,  2387,  2392,  2394,  2396,  2401,  2403,  2405,  2407,  2412,
     1088    2414,  2416,  2447,  2449,  2450,  2452,  2457,  2462,  2470,  2472,
     1089    2474,  2479,  2481,  2486,  2488,  2502,  2503,  2505,  2510,  2512,
     1090    2514,  2516,  2518,  2523,  2524,  2526,  2528,  2533,  2535,  2537,
     1091    2543,  2545,  2547,  2551,  2553,  2555,  2557,  2571,  2572,  2574,
     1092    2579,  2581,  2583,  2585,  2587,  2592,  2593,  2595,  2597,  2602,
     1093    2604,  2606,  2612,  2613,  2615,  2624,  2627,  2629,  2632,  2634,
     1094    2636,  2649,  2650,  2652,  2657,  2659,  2661,  2663,  2665,  2670,
     1095    2671,  2673,  2675,  2680,  2682,  2690,  2691,  2692,  2697,  2698,
     1096    2702,  2704,  2706,  2708,  2710,  2712,  2719,  2721,  2723,  2725,
     1097    2727,  2730,  2732,  2734,  2736,  2738,  2743,  2745,  2747,  2752,
     1098    2778,  2779,  2781,  2785,  2786,  2790,  2792,  2794,  2796,  2798,
     1099    2800,  2807,  2809,  2811,  2813,  2815,  2817,  2822,  2827,  2829,
     1100    2831,  2849,  2851,  2856,  2857
    11011101};
    11021102#endif
     
    49774977
    49784978/* Line 1806 of yacc.c  */
    4979 #line 302 "parser.yy"
     4979#line 301 "parser.yy"
    49804980    { typedefTable.enterScope(); }
    49814981    break;
     
    49844984
    49854985/* Line 1806 of yacc.c  */
    4986 #line 306 "parser.yy"
     4986#line 305 "parser.yy"
    49874987    { typedefTable.leaveScope(); }
    49884988    break;
     
    49914991
    49924992/* Line 1806 of yacc.c  */
     4993#line 312 "parser.yy"
     4994    { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); }
     4995    break;
     4996
     4997  case 5:
     4998
     4999/* Line 1806 of yacc.c  */
    49935000#line 313 "parser.yy"
    4994     { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); }
    4995     break;
    4996 
    4997   case 5:
     5001    { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }
     5002    break;
     5003
     5004  case 6:
    49985005
    49995006/* Line 1806 of yacc.c  */
    50005007#line 314 "parser.yy"
    5001     { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }
    5002     break;
    5003 
    5004   case 6:
    5005 
    5006 /* Line 1806 of yacc.c  */
    5007 #line 315 "parser.yy"
    50085008    { (yyval.en) = new ExpressionNode( build_constantChar( *(yyvsp[(1) - (1)].tok) ) ); }
    50095009    break;
     
    50125012
    50135013/* Line 1806 of yacc.c  */
    5014 #line 340 "parser.yy"
     5014#line 339 "parser.yy"
    50155015    { (yyval.constant) = build_constantStr( *(yyvsp[(1) - (1)].str) ); }
    50165016    break;
     
    50195019
    50205020/* Line 1806 of yacc.c  */
    5021 #line 344 "parser.yy"
     5021#line 343 "parser.yy"
    50225022    { (yyval.str) = (yyvsp[(1) - (1)].tok); }
    50235023    break;
     
    50265026
    50275027/* Line 1806 of yacc.c  */
    5028 #line 346 "parser.yy"
     5028#line 345 "parser.yy"
    50295029    {
    50305030                        appendStr( (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].tok) );                                            // append 2nd juxtaposed string to 1st
     
    50375037
    50385038/* Line 1806 of yacc.c  */
    5039 #line 357 "parser.yy"
     5039#line 356 "parser.yy"
    50405040    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    50415041    break;
     
    50445044
    50455045/* Line 1806 of yacc.c  */
    5046 #line 359 "parser.yy"
     5046#line 358 "parser.yy"
    50475047    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    50485048    break;
     
    50515051
    50525052/* Line 1806 of yacc.c  */
    5053 #line 361 "parser.yy"
     5053#line 360 "parser.yy"
    50545054    { (yyval.en) = (yyvsp[(2) - (3)].en); }
    50555055    break;
     
    50585058
    50595059/* Line 1806 of yacc.c  */
    5060 #line 363 "parser.yy"
     5060#line 362 "parser.yy"
    50615061    { (yyval.en) = new ExpressionNode( build_valexpr( (yyvsp[(2) - (3)].sn) ) ); }
    50625062    break;
     
    50655065
    50665066/* Line 1806 of yacc.c  */
    5067 #line 373 "parser.yy"
     5067#line 372 "parser.yy"
    50685068    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Index, (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ) ); }
    50695069    break;
     
    50725072
    50735073/* Line 1806 of yacc.c  */
    5074 #line 375 "parser.yy"
     5074#line 374 "parser.yy"
    50755075    { (yyval.en) = new ExpressionNode( build_func( (yyvsp[(1) - (4)].en), (yyvsp[(3) - (4)].en) ) ); }
    50765076    break;
     
    50795079
    50805080/* Line 1806 of yacc.c  */
    5081 #line 379 "parser.yy"
     5081#line 378 "parser.yy"
    50825082    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); }
    50835083    break;
    50845084
     5085  case 27:
     5086
     5087/* Line 1806 of yacc.c  */
     5088#line 380 "parser.yy"
     5089    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5090    break;
     5091
     5092  case 28:
     5093
     5094/* Line 1806 of yacc.c  */
     5095#line 382 "parser.yy"
     5096    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_constantInteger( *(yyvsp[(3) - (3)].tok) ) ) ); }
     5097    break;
     5098
    50855099  case 29:
    50865100
    50875101/* Line 1806 of yacc.c  */
    5088 #line 383 "parser.yy"
     5102#line 384 "parser.yy"
    50895103    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); }
    50905104    break;
    50915105
     5106  case 30:
     5107
     5108/* Line 1806 of yacc.c  */
     5109#line 386 "parser.yy"
     5110    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5111    break;
     5112
    50925113  case 31:
    50935114
    50945115/* Line 1806 of yacc.c  */
    5095 #line 386 "parser.yy"
     5116#line 388 "parser.yy"
    50965117    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, (yyvsp[(1) - (2)].en) ) ); }
    50975118    break;
     
    51005121
    51015122/* Line 1806 of yacc.c  */
    5102 #line 388 "parser.yy"
     5123#line 390 "parser.yy"
    51035124    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, (yyvsp[(1) - (2)].en) ) ); }
    51045125    break;
     
    51075128
    51085129/* Line 1806 of yacc.c  */
    5109 #line 390 "parser.yy"
     5130#line 392 "parser.yy"
    51105131    { (yyval.en) = new ExpressionNode( build_compoundLiteral( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ) ); }
    51115132    break;
     
    51145135
    51155136/* Line 1806 of yacc.c  */
    5116 #line 392 "parser.yy"
     5137#line 394 "parser.yy"
    51175138    {
    51185139                        Token fn;
     
    51255146
    51265147/* Line 1806 of yacc.c  */
    5127 #line 402 "parser.yy"
     5148#line 404 "parser.yy"
    51285149    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    51295150    break;
     
    51325153
    51335154/* Line 1806 of yacc.c  */
    5134 #line 407 "parser.yy"
     5155#line 409 "parser.yy"
    51355156    { (yyval.en) = 0; }
    51365157    break;
     
    51395160
    51405161/* Line 1806 of yacc.c  */
    5141 #line 413 "parser.yy"
     5162#line 415 "parser.yy"
    51425163    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    51435164    break;
    51445165
    5145   case 41:
    5146 
    5147 /* Line 1806 of yacc.c  */
    5148 #line 420 "parser.yy"
     5166  case 42:
     5167
     5168/* Line 1806 of yacc.c  */
     5169#line 423 "parser.yy"
     5170    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); }
     5171    break;
     5172
     5173  case 43:
     5174
     5175/* Line 1806 of yacc.c  */
     5176#line 425 "parser.yy"
     5177    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5178    break;
     5179
     5180  case 44:
     5181
     5182/* Line 1806 of yacc.c  */
     5183#line 427 "parser.yy"
     5184    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); }
     5185    break;
     5186
     5187  case 45:
     5188
     5189/* Line 1806 of yacc.c  */
     5190#line 429 "parser.yy"
     5191    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5192    break;
     5193
     5194  case 46:
     5195
     5196/* Line 1806 of yacc.c  */
     5197#line 434 "parser.yy"
    51495198    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    51505199    break;
    51515200
    5152   case 42:
    5153 
    5154 /* Line 1806 of yacc.c  */
    5155 #line 422 "parser.yy"
    5156     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
    5157     break;
    5158 
    5159   case 43:
    5160 
    5161 /* Line 1806 of yacc.c  */
    5162 #line 424 "parser.yy"
    5163     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
    5164     break;
    5165 
    5166   case 44:
    5167 
    5168 /* Line 1806 of yacc.c  */
    5169 #line 426 "parser.yy"
    5170     { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
    5171     break;
    5172 
    5173   case 45:
    5174 
    5175 /* Line 1806 of yacc.c  */
    5176 #line 428 "parser.yy"
    5177     { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
     5201  case 47:
     5202
     5203/* Line 1806 of yacc.c  */
     5204#line 437 "parser.yy"
     5205    { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); }
    51785206    break;
    51795207
     
    51815209
    51825210/* Line 1806 of yacc.c  */
    5183 #line 442 "parser.yy"
     5211#line 445 "parser.yy"
    51845212    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    51855213    break;
     
    51885216
    51895217/* Line 1806 of yacc.c  */
    5190 #line 444 "parser.yy"
     5218#line 447 "parser.yy"
    51915219    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    51925220    break;
     
    51955223
    51965224/* Line 1806 of yacc.c  */
    5197 #line 446 "parser.yy"
     5225#line 449 "parser.yy"
    51985226    { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); }
    51995227    break;
     
    52025230
    52035231/* Line 1806 of yacc.c  */
    5204 #line 451 "parser.yy"
     5232#line 454 "parser.yy"
    52055233    {
    52065234                        switch ( (yyvsp[(1) - (2)].op) ) {
     
    52205248
    52215249/* Line 1806 of yacc.c  */
    5222 #line 464 "parser.yy"
     5250#line 467 "parser.yy"
    52235251    { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); }
    52245252    break;
     
    52275255
    52285256/* Line 1806 of yacc.c  */
    5229 #line 466 "parser.yy"
     5257#line 469 "parser.yy"
    52305258    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); }
    52315259    break;
     
    52345262
    52355263/* Line 1806 of yacc.c  */
    5236 #line 468 "parser.yy"
     5264#line 471 "parser.yy"
    52375265    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); }
    52385266    break;
     
    52415269
    52425270/* Line 1806 of yacc.c  */
    5243 #line 470 "parser.yy"
     5271#line 473 "parser.yy"
    52445272    { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52455273    break;
     
    52485276
    52495277/* Line 1806 of yacc.c  */
    5250 #line 472 "parser.yy"
     5278#line 475 "parser.yy"
    52515279    { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52525280    break;
     
    52555283
    52565284/* Line 1806 of yacc.c  */
    5257 #line 474 "parser.yy"
     5285#line 477 "parser.yy"
    52585286    { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52595287    break;
     
    52625290
    52635291/* Line 1806 of yacc.c  */
    5264 #line 476 "parser.yy"
     5292#line 479 "parser.yy"
    52655293    { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52665294    break;
     
    52695297
    52705298/* Line 1806 of yacc.c  */
    5271 #line 478 "parser.yy"
     5299#line 481 "parser.yy"
    52725300    { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); }
    52735301    break;
     
    52765304
    52775305/* Line 1806 of yacc.c  */
    5278 #line 480 "parser.yy"
     5306#line 483 "parser.yy"
    52795307    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); }
    52805308    break;
     
    52835311
    52845312/* Line 1806 of yacc.c  */
    5285 #line 482 "parser.yy"
     5313#line 485 "parser.yy"
    52865314    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); }
    52875315    break;
     
    52905318
    52915319/* Line 1806 of yacc.c  */
    5292 #line 484 "parser.yy"
     5320#line 487 "parser.yy"
    52935321    { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); }
    52945322    break;
     
    52975325
    52985326/* Line 1806 of yacc.c  */
    5299 #line 490 "parser.yy"
     5327#line 493 "parser.yy"
    53005328    { (yyval.op) = OperKinds::PointTo; }
    53015329    break;
     
    53045332
    53055333/* Line 1806 of yacc.c  */
    5306 #line 491 "parser.yy"
     5334#line 494 "parser.yy"
    53075335    { (yyval.op) = OperKinds::AddressOf; }
    53085336    break;
     
    53115339
    53125340/* Line 1806 of yacc.c  */
    5313 #line 497 "parser.yy"
     5341#line 500 "parser.yy"
    53145342    { (yyval.op) = OperKinds::UnPlus; }
    53155343    break;
     
    53185346
    53195347/* Line 1806 of yacc.c  */
    5320 #line 498 "parser.yy"
     5348#line 501 "parser.yy"
    53215349    { (yyval.op) = OperKinds::UnMinus; }
    53225350    break;
     
    53255353
    53265354/* Line 1806 of yacc.c  */
    5327 #line 499 "parser.yy"
     5355#line 502 "parser.yy"
    53285356    { (yyval.op) = OperKinds::Neg; }
    53295357    break;
     
    53325360
    53335361/* Line 1806 of yacc.c  */
    5334 #line 500 "parser.yy"
     5362#line 503 "parser.yy"
    53355363    { (yyval.op) = OperKinds::BitNeg; }
    53365364    break;
     
    53395367
    53405368/* Line 1806 of yacc.c  */
    5341 #line 506 "parser.yy"
     5369#line 509 "parser.yy"
    53425370    { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); }
    53435371    break;
     
    53465374
    53475375/* Line 1806 of yacc.c  */
    5348 #line 508 "parser.yy"
     5376#line 511 "parser.yy"
    53495377    { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); }
    53505378    break;
     
    53535381
    53545382/* Line 1806 of yacc.c  */
    5355 #line 514 "parser.yy"
     5383#line 517 "parser.yy"
    53565384    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53575385    break;
     
    53605388
    53615389/* Line 1806 of yacc.c  */
    5362 #line 516 "parser.yy"
     5390#line 519 "parser.yy"
    53635391    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53645392    break;
     
    53675395
    53685396/* Line 1806 of yacc.c  */
    5369 #line 518 "parser.yy"
     5397#line 521 "parser.yy"
    53705398    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53715399    break;
     
    53745402
    53755403/* Line 1806 of yacc.c  */
    5376 #line 524 "parser.yy"
     5404#line 527 "parser.yy"
    53775405    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53785406    break;
     
    53815409
    53825410/* Line 1806 of yacc.c  */
    5383 #line 526 "parser.yy"
     5411#line 529 "parser.yy"
    53845412    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53855413    break;
     
    53885416
    53895417/* Line 1806 of yacc.c  */
    5390 #line 532 "parser.yy"
     5418#line 535 "parser.yy"
    53915419    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53925420    break;
     
    53955423
    53965424/* Line 1806 of yacc.c  */
    5397 #line 534 "parser.yy"
     5425#line 537 "parser.yy"
    53985426    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53995427    break;
     
    54025430
    54035431/* Line 1806 of yacc.c  */
    5404 #line 540 "parser.yy"
     5432#line 543 "parser.yy"
    54055433    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54065434    break;
     
    54095437
    54105438/* Line 1806 of yacc.c  */
    5411 #line 542 "parser.yy"
     5439#line 545 "parser.yy"
    54125440    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54135441    break;
     
    54165444
    54175445/* Line 1806 of yacc.c  */
    5418 #line 544 "parser.yy"
     5446#line 547 "parser.yy"
    54195447    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54205448    break;
     
    54235451
    54245452/* Line 1806 of yacc.c  */
    5425 #line 546 "parser.yy"
     5453#line 549 "parser.yy"
    54265454    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54275455    break;
     
    54305458
    54315459/* Line 1806 of yacc.c  */
    5432 #line 552 "parser.yy"
     5460#line 555 "parser.yy"
    54335461    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54345462    break;
     
    54375465
    54385466/* Line 1806 of yacc.c  */
    5439 #line 554 "parser.yy"
     5467#line 557 "parser.yy"
    54405468    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54415469    break;
     
    54445472
    54455473/* Line 1806 of yacc.c  */
    5446 #line 560 "parser.yy"
     5474#line 563 "parser.yy"
    54475475    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54485476    break;
     
    54515479
    54525480/* Line 1806 of yacc.c  */
    5453 #line 566 "parser.yy"
     5481#line 569 "parser.yy"
    54545482    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54555483    break;
     
    54585486
    54595487/* Line 1806 of yacc.c  */
    5460 #line 572 "parser.yy"
     5488#line 575 "parser.yy"
    54615489    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54625490    break;
     
    54655493
    54665494/* Line 1806 of yacc.c  */
    5467 #line 578 "parser.yy"
     5495#line 581 "parser.yy"
    54685496    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); }
    54695497    break;
     
    54725500
    54735501/* Line 1806 of yacc.c  */
    5474 #line 584 "parser.yy"
     5502#line 587 "parser.yy"
    54755503    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); }
    54765504    break;
     
    54795507
    54805508/* Line 1806 of yacc.c  */
    5481 #line 590 "parser.yy"
     5509#line 593 "parser.yy"
    54825510    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
    54835511    break;
     
    54865514
    54875515/* Line 1806 of yacc.c  */
    5488 #line 593 "parser.yy"
     5516#line 596 "parser.yy"
    54895517    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); }
    54905518    break;
     
    54935521
    54945522/* Line 1806 of yacc.c  */
    5495 #line 595 "parser.yy"
     5523#line 598 "parser.yy"
    54965524    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
    54975525    break;
     
    55005528
    55015529/* Line 1806 of yacc.c  */
    5502 #line 606 "parser.yy"
     5530#line 609 "parser.yy"
    55035531    { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    55045532    break;
     
    55075535
    55085536/* Line 1806 of yacc.c  */
    5509 #line 608 "parser.yy"
     5537#line 611 "parser.yy"
    55105538    { (yyval.en) = ( (yyvsp[(2) - (2)].en) == 0 ) ? (yyvsp[(1) - (2)].en) : new ExpressionNode( build_binary_ptr( OperKinds::Assign, (yyvsp[(1) - (2)].en), (yyvsp[(2) - (2)].en) ) ); }
    55115539    break;
     
    55145542
    55155543/* Line 1806 of yacc.c  */
    5516 #line 613 "parser.yy"
     5544#line 616 "parser.yy"
    55175545    { (yyval.en) = nullptr; }
    55185546    break;
     
    55215549
    55225550/* Line 1806 of yacc.c  */
    5523 #line 618 "parser.yy"
     5551#line 621 "parser.yy"
    55245552    { (yyval.op) = OperKinds::Assign; }
    55255553    break;
     
    55285556
    55295557/* Line 1806 of yacc.c  */
    5530 #line 619 "parser.yy"
     5558#line 622 "parser.yy"
    55315559    { (yyval.op) = OperKinds::AtAssn; }
    55325560    break;
     
    55355563
    55365564/* Line 1806 of yacc.c  */
    5537 #line 620 "parser.yy"
     5565#line 623 "parser.yy"
    55385566    { (yyval.op) = OperKinds::MulAssn; }
    55395567    break;
     
    55425570
    55435571/* Line 1806 of yacc.c  */
    5544 #line 621 "parser.yy"
     5572#line 624 "parser.yy"
    55455573    { (yyval.op) = OperKinds::DivAssn; }
    55465574    break;
     
    55495577
    55505578/* Line 1806 of yacc.c  */
    5551 #line 622 "parser.yy"
     5579#line 625 "parser.yy"
    55525580    { (yyval.op) = OperKinds::ModAssn; }
    55535581    break;
     
    55565584
    55575585/* Line 1806 of yacc.c  */
    5558 #line 623 "parser.yy"
     5586#line 626 "parser.yy"
    55595587    { (yyval.op) = OperKinds::PlusAssn; }
    55605588    break;
     
    55635591
    55645592/* Line 1806 of yacc.c  */
    5565 #line 624 "parser.yy"
     5593#line 627 "parser.yy"
    55665594    { (yyval.op) = OperKinds::MinusAssn; }
    55675595    break;
     
    55705598
    55715599/* Line 1806 of yacc.c  */
    5572 #line 625 "parser.yy"
     5600#line 628 "parser.yy"
    55735601    { (yyval.op) = OperKinds::LSAssn; }
    55745602    break;
     
    55775605
    55785606/* Line 1806 of yacc.c  */
    5579 #line 626 "parser.yy"
     5607#line 629 "parser.yy"
    55805608    { (yyval.op) = OperKinds::RSAssn; }
    55815609    break;
     
    55845612
    55855613/* Line 1806 of yacc.c  */
    5586 #line 627 "parser.yy"
     5614#line 630 "parser.yy"
    55875615    { (yyval.op) = OperKinds::AndAssn; }
    55885616    break;
     
    55915619
    55925620/* Line 1806 of yacc.c  */
    5593 #line 628 "parser.yy"
     5621#line 631 "parser.yy"
    55945622    { (yyval.op) = OperKinds::ERAssn; }
    55955623    break;
     
    55985626
    55995627/* Line 1806 of yacc.c  */
    5600 #line 629 "parser.yy"
     5628#line 632 "parser.yy"
    56015629    { (yyval.op) = OperKinds::OrAssn; }
    56025630    break;
     
    56055633
    56065634/* Line 1806 of yacc.c  */
    5607 #line 636 "parser.yy"
     5635#line 639 "parser.yy"
    56085636    { (yyval.en) = new ExpressionNode( build_tuple() ); }
    56095637    break;
     
    56125640
    56135641/* Line 1806 of yacc.c  */
    5614 #line 638 "parser.yy"
     5642#line 641 "parser.yy"
    56155643    { (yyval.en) = new ExpressionNode( build_tuple( (yyvsp[(3) - (5)].en) ) ); }
    56165644    break;
     
    56195647
    56205648/* Line 1806 of yacc.c  */
    5621 #line 640 "parser.yy"
     5649#line 643 "parser.yy"
    56225650    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); }
    56235651    break;
     
    56265654
    56275655/* Line 1806 of yacc.c  */
    5628 #line 642 "parser.yy"
     5656#line 645 "parser.yy"
    56295657    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); }
    56305658    break;
     
    56335661
    56345662/* Line 1806 of yacc.c  */
    5635 #line 648 "parser.yy"
     5663#line 651 "parser.yy"
    56365664    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    56375665    break;
     
    56405668
    56415669/* Line 1806 of yacc.c  */
    5642 #line 654 "parser.yy"
     5670#line 657 "parser.yy"
    56435671    { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    56445672    break;
     
    56475675
    56485676/* Line 1806 of yacc.c  */
    5649 #line 659 "parser.yy"
     5677#line 662 "parser.yy"
    56505678    { (yyval.en) = 0; }
    56515679    break;
     
    56545682
    56555683/* Line 1806 of yacc.c  */
    5656 #line 668 "parser.yy"
     5684#line 671 "parser.yy"
    56575685    { (yyval.sn) = (yyvsp[(1) - (1)].sn); }
    56585686    break;
     
    56615689
    56625690/* Line 1806 of yacc.c  */
    5663 #line 675 "parser.yy"
     5691#line 678 "parser.yy"
    56645692    {
    56655693                        Token fn;
     
    56725700
    56735701/* Line 1806 of yacc.c  */
    5674 #line 685 "parser.yy"
     5702#line 688 "parser.yy"
    56755703    {
    56765704                        (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) );
     
    56815709
    56825710/* Line 1806 of yacc.c  */
    5683 #line 692 "parser.yy"
     5711#line 695 "parser.yy"
    56845712    { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    56855713    break;
     
    56885716
    56895717/* Line 1806 of yacc.c  */
    5690 #line 699 "parser.yy"
     5718#line 702 "parser.yy"
    56915719    { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); }
    56925720    break;
     
    56955723
    56965724/* Line 1806 of yacc.c  */
    5697 #line 705 "parser.yy"
     5725#line 708 "parser.yy"
    56985726    { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } }
    56995727    break;
     
    57025730
    57035731/* Line 1806 of yacc.c  */
    5704 #line 710 "parser.yy"
     5732#line 713 "parser.yy"
    57055733    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    57065734    break;
     
    57095737
    57105738/* Line 1806 of yacc.c  */
    5711 #line 712 "parser.yy"
     5739#line 715 "parser.yy"
    57125740    {   // mark all fields in list
    57135741                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    57205748
    57215749/* Line 1806 of yacc.c  */
    5722 #line 718 "parser.yy"
     5750#line 721 "parser.yy"
    57235751    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    57245752    break;
     
    57275755
    57285756/* Line 1806 of yacc.c  */
    5729 #line 725 "parser.yy"
     5757#line 728 "parser.yy"
    57305758    { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } }
    57315759    break;
     
    57345762
    57355763/* Line 1806 of yacc.c  */
    5736 #line 730 "parser.yy"
     5764#line 733 "parser.yy"
    57375765    { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); }
    57385766    break;
     
    57415769
    57425770/* Line 1806 of yacc.c  */
    5743 #line 736 "parser.yy"
     5771#line 739 "parser.yy"
    57445772    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }
    57455773    break;
     
    57485776
    57495777/* Line 1806 of yacc.c  */
    5750 #line 738 "parser.yy"
     5778#line 741 "parser.yy"
    57515779    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }
    57525780    break;
     
    57555783
    57565784/* Line 1806 of yacc.c  */
    5757 #line 740 "parser.yy"
     5785#line 743 "parser.yy"
    57585786    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57595787    break;
     
    57625790
    57635791/* Line 1806 of yacc.c  */
    5764 #line 742 "parser.yy"
     5792#line 745 "parser.yy"
    57655793    {
    57665794                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    57775805
    57785806/* Line 1806 of yacc.c  */
    5779 #line 752 "parser.yy"
     5807#line 755 "parser.yy"
    57805808    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57815809    break;
     
    57845812
    57855813/* Line 1806 of yacc.c  */
    5786 #line 754 "parser.yy"
     5814#line 757 "parser.yy"
    57875815    {
    57885816                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    57945822
    57955823/* Line 1806 of yacc.c  */
    5796 #line 764 "parser.yy"
     5824#line 767 "parser.yy"
    57975825    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    57985826    break;
     
    58015829
    58025830/* Line 1806 of yacc.c  */
    5803 #line 766 "parser.yy"
     5831#line 769 "parser.yy"
    58045832    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    58055833    break;
     
    58085836
    58095837/* Line 1806 of yacc.c  */
    5810 #line 771 "parser.yy"
     5838#line 774 "parser.yy"
    58115839    { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); }
    58125840    break;
     
    58155843
    58165844/* Line 1806 of yacc.c  */
    5817 #line 773 "parser.yy"
     5845#line 776 "parser.yy"
    58185846    { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }
    58195847    break;
     
    58225850
    58235851/* Line 1806 of yacc.c  */
    5824 #line 777 "parser.yy"
     5852#line 780 "parser.yy"
    58255853    { (yyval.sn) = (yyvsp[(2) - (3)].sn); }
    58265854    break;
     
    58295857
    58305858/* Line 1806 of yacc.c  */
    5831 #line 778 "parser.yy"
     5859#line 781 "parser.yy"
    58325860    { (yyval.sn) = new StatementNode( build_default() ); }
    58335861    break;
     
    58365864
    58375865/* Line 1806 of yacc.c  */
    5838 #line 784 "parser.yy"
     5866#line 787 "parser.yy"
    58395867    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); }
    58405868    break;
     
    58435871
    58445872/* Line 1806 of yacc.c  */
    5845 #line 788 "parser.yy"
     5873#line 791 "parser.yy"
    58465874    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58475875    break;
     
    58505878
    58515879/* Line 1806 of yacc.c  */
    5852 #line 793 "parser.yy"
     5880#line 796 "parser.yy"
    58535881    { (yyval.sn) = 0; }
    58545882    break;
     
    58575885
    58585886/* Line 1806 of yacc.c  */
    5859 #line 799 "parser.yy"
     5887#line 802 "parser.yy"
    58605888    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58615889    break;
     
    58645892
    58655893/* Line 1806 of yacc.c  */
    5866 #line 801 "parser.yy"
     5894#line 804 "parser.yy"
    58675895    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); }
    58685896    break;
     
    58715899
    58725900/* Line 1806 of yacc.c  */
    5873 #line 806 "parser.yy"
     5901#line 809 "parser.yy"
    58745902    { (yyval.sn) = 0; }
    58755903    break;
     
    58785906
    58795907/* Line 1806 of yacc.c  */
    5880 #line 812 "parser.yy"
     5908#line 815 "parser.yy"
    58815909    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); }
    58825910    break;
     
    58855913
    58865914/* Line 1806 of yacc.c  */
    5887 #line 814 "parser.yy"
     5915#line 817 "parser.yy"
    58885916    { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); }
    58895917    break;
     
    58925920
    58935921/* Line 1806 of yacc.c  */
    5894 #line 816 "parser.yy"
     5922#line 819 "parser.yy"
    58955923    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); }
    58965924    break;
     
    58995927
    59005928/* Line 1806 of yacc.c  */
    5901 #line 818 "parser.yy"
     5929#line 821 "parser.yy"
    59025930    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(3) - (4)].sn)->set_last( (yyvsp[(4) - (4)].sn) ) ) ) ) ) ); }
    59035931    break;
     
    59065934
    59075935/* Line 1806 of yacc.c  */
    5908 #line 823 "parser.yy"
     5936#line 826 "parser.yy"
    59095937    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    59105938    break;
     
    59135941
    59145942/* Line 1806 of yacc.c  */
    5915 #line 829 "parser.yy"
     5943#line 832 "parser.yy"
    59165944    { (yyval.sn) = 0; }
    59175945    break;
     
    59205948
    59215949/* Line 1806 of yacc.c  */
    5922 #line 831 "parser.yy"
     5950#line 834 "parser.yy"
    59235951    { (yyval.sn) = 0; }
    59245952    break;
     
    59275955
    59285956/* Line 1806 of yacc.c  */
    5929 #line 836 "parser.yy"
     5957#line 839 "parser.yy"
    59305958    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    59315959    break;
     
    59345962
    59355963/* Line 1806 of yacc.c  */
    5936 #line 838 "parser.yy"
     5964#line 841 "parser.yy"
    59375965    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); }
    59385966    break;
     
    59415969
    59425970/* Line 1806 of yacc.c  */
    5943 #line 840 "parser.yy"
     5971#line 843 "parser.yy"
    59445972    { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }
    59455973    break;
     
    59485976
    59495977/* Line 1806 of yacc.c  */
    5950 #line 845 "parser.yy"
     5978#line 848 "parser.yy"
    59515979    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); }
    59525980    break;
     
    59555983
    59565984/* Line 1806 of yacc.c  */
    5957 #line 847 "parser.yy"
     5985#line 850 "parser.yy"
    59585986    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); }
    59595987    break;
     
    59625990
    59635991/* Line 1806 of yacc.c  */
    5964 #line 852 "parser.yy"
     5992#line 855 "parser.yy"
    59655993    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }
    59665994    break;
     
    59695997
    59705998/* Line 1806 of yacc.c  */
    5971 #line 856 "parser.yy"
     5999#line 859 "parser.yy"
    59726000    { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
    59736001    break;
     
    59766004
    59776005/* Line 1806 of yacc.c  */
    5978 #line 859 "parser.yy"
     6006#line 862 "parser.yy"
    59796007    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); }
    59806008    break;
     
    59836011
    59846012/* Line 1806 of yacc.c  */
    5985 #line 863 "parser.yy"
     6013#line 866 "parser.yy"
    59866014    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); }
    59876015    break;
     
    59906018
    59916019/* Line 1806 of yacc.c  */
    5992 #line 866 "parser.yy"
     6020#line 869 "parser.yy"
    59936021    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    59946022    break;
     
    59976025
    59986026/* Line 1806 of yacc.c  */
    5999 #line 870 "parser.yy"
     6027#line 873 "parser.yy"
    60006028    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); }
    60016029    break;
     
    60046032
    60056033/* Line 1806 of yacc.c  */
    6006 #line 872 "parser.yy"
     6034#line 875 "parser.yy"
    60076035    { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); }
    60086036    break;
     
    60116039
    60126040/* Line 1806 of yacc.c  */
    6013 #line 874 "parser.yy"
     6041#line 877 "parser.yy"
    60146042    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    60156043    break;
     
    60186046
    60196047/* Line 1806 of yacc.c  */
    6020 #line 876 "parser.yy"
     6048#line 879 "parser.yy"
    60216049    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    60226050    break;
     
    60256053
    60266054/* Line 1806 of yacc.c  */
    6027 #line 878 "parser.yy"
     6055#line 881 "parser.yy"
    60286056    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); }
    60296057    break;
     
    60326060
    60336061/* Line 1806 of yacc.c  */
    6034 #line 883 "parser.yy"
     6062#line 886 "parser.yy"
    60356063    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }
    60366064    break;
     
    60396067
    60406068/* Line 1806 of yacc.c  */
    6041 #line 885 "parser.yy"
     6069#line 888 "parser.yy"
    60426070    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }
    60436071    break;
     
    60466074
    60476075/* Line 1806 of yacc.c  */
    6048 #line 887 "parser.yy"
     6076#line 890 "parser.yy"
    60496077    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }
    60506078    break;
     
    60536081
    60546082/* Line 1806 of yacc.c  */
    6055 #line 894 "parser.yy"
     6083#line 897 "parser.yy"
    60566084    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60576085    break;
     
    60606088
    60616089/* Line 1806 of yacc.c  */
    6062 #line 896 "parser.yy"
     6090#line 899 "parser.yy"
    60636091    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60646092    break;
     
    60676095
    60686096/* Line 1806 of yacc.c  */
    6069 #line 898 "parser.yy"
     6097#line 901 "parser.yy"
    60706098    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60716099    break;
     
    60746102
    60756103/* Line 1806 of yacc.c  */
    6076 #line 900 "parser.yy"
     6104#line 903 "parser.yy"
    60776105    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60786106    break;
     
    60816109
    60826110/* Line 1806 of yacc.c  */
    6083 #line 905 "parser.yy"
     6111#line 908 "parser.yy"
    60846112    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60856113    break;
     
    60886116
    60896117/* Line 1806 of yacc.c  */
    6090 #line 907 "parser.yy"
     6118#line 910 "parser.yy"
    60916119    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    60926120    break;
     
    60956123
    60966124/* Line 1806 of yacc.c  */
    6097 #line 909 "parser.yy"
     6125#line 912 "parser.yy"
    60986126    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60996127    break;
     
    61026130
    61036131/* Line 1806 of yacc.c  */
    6104 #line 911 "parser.yy"
     6132#line 914 "parser.yy"
    61056133    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    61066134    break;
     
    61096137
    61106138/* Line 1806 of yacc.c  */
    6111 #line 916 "parser.yy"
     6139#line 919 "parser.yy"
    61126140    {
    61136141                        (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) );
     
    61186146
    61196147/* Line 1806 of yacc.c  */
    6120 #line 929 "parser.yy"
     6148#line 932 "parser.yy"
    61216149    {
    61226150                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    61286156
    61296157/* Line 1806 of yacc.c  */
    6130 #line 934 "parser.yy"
     6158#line 937 "parser.yy"
    61316159    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    61326160    break;
     
    61356163
    61366164/* Line 1806 of yacc.c  */
    6137 #line 936 "parser.yy"
     6165#line 939 "parser.yy"
    61386166    {
    61396167                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    61456173
    61466174/* Line 1806 of yacc.c  */
    6147 #line 945 "parser.yy"
     6175#line 948 "parser.yy"
    61486176    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); }
    61496177    break;
     
    61526180
    61536181/* Line 1806 of yacc.c  */
    6154 #line 947 "parser.yy"
     6182#line 950 "parser.yy"
    61556183    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); }
    61566184    break;
     
    61596187
    61606188/* Line 1806 of yacc.c  */
    6161 #line 949 "parser.yy"
     6189#line 952 "parser.yy"
    61626190    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); }
    61636191    break;
     
    61666194
    61676195/* Line 1806 of yacc.c  */
    6168 #line 951 "parser.yy"
     6196#line 954 "parser.yy"
    61696197    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ) ); }
    61706198    break;
     
    61736201
    61746202/* Line 1806 of yacc.c  */
    6175 #line 953 "parser.yy"
     6203#line 956 "parser.yy"
    61766204    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ) ); }
    61776205    break;
     
    61806208
    61816209/* Line 1806 of yacc.c  */
    6182 #line 958 "parser.yy"
     6210#line 961 "parser.yy"
    61836211    { (yyval.flag) = false; }
    61846212    break;
     
    61876215
    61886216/* Line 1806 of yacc.c  */
    6189 #line 960 "parser.yy"
     6217#line 963 "parser.yy"
    61906218    { (yyval.flag) = true; }
    61916219    break;
     
    61946222
    61956223/* Line 1806 of yacc.c  */
    6196 #line 965 "parser.yy"
     6224#line 968 "parser.yy"
    61976225    { (yyval.en) = 0; }
    61986226    break;
     
    62016229
    62026230/* Line 1806 of yacc.c  */
    6203 #line 972 "parser.yy"
     6231#line 975 "parser.yy"
    62046232    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    62056233    break;
     
    62086236
    62096237/* Line 1806 of yacc.c  */
    6210 #line 977 "parser.yy"
     6238#line 980 "parser.yy"
    62116239    { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }
    62126240    break;
     
    62156243
    62166244/* Line 1806 of yacc.c  */
    6217 #line 979 "parser.yy"
     6245#line 982 "parser.yy"
    62186246    { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }
    62196247    break;
     
    62226250
    62236251/* Line 1806 of yacc.c  */
    6224 #line 984 "parser.yy"
     6252#line 987 "parser.yy"
    62256253    { (yyval.en) = 0; }
    62266254    break;
     
    62296257
    62306258/* Line 1806 of yacc.c  */
    6231 #line 986 "parser.yy"
     6259#line 989 "parser.yy"
    62326260    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    62336261    break;
     
    62366264
    62376265/* Line 1806 of yacc.c  */
    6238 #line 988 "parser.yy"
     6266#line 991 "parser.yy"
    62396267    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); }
    62406268    break;
     
    62436271
    62446272/* Line 1806 of yacc.c  */
    6245 #line 993 "parser.yy"
     6273#line 996 "parser.yy"
    62466274    {
    62476275                        (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) );
     
    62536281
    62546282/* Line 1806 of yacc.c  */
    6255 #line 998 "parser.yy"
     6283#line 1001 "parser.yy"
    62566284    {
    62576285                        (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) );
     
    62636291
    62646292/* Line 1806 of yacc.c  */
    6265 #line 1008 "parser.yy"
     6293#line 1011 "parser.yy"
    62666294    { (yyval.decl) = 0; }
    62676295    break;
     
    62706298
    62716299/* Line 1806 of yacc.c  */
    6272 #line 1015 "parser.yy"
     6300#line 1018 "parser.yy"
    62736301    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    62746302    break;
     
    62776305
    62786306/* Line 1806 of yacc.c  */
    6279 #line 1020 "parser.yy"
     6307#line 1023 "parser.yy"
    62806308    { (yyval.decl) = 0; }
    62816309    break;
     
    62846312
    62856313/* Line 1806 of yacc.c  */
    6286 #line 1027 "parser.yy"
     6314#line 1030 "parser.yy"
    62876315    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    62886316    break;
     
    62916319
    62926320/* Line 1806 of yacc.c  */
    6293 #line 1041 "parser.yy"
     6321#line 1044 "parser.yy"
    62946322    {}
    62956323    break;
     
    62986326
    62996327/* Line 1806 of yacc.c  */
    6300 #line 1042 "parser.yy"
     6328#line 1045 "parser.yy"
    63016329    {}
    63026330    break;
     
    63056333
    63066334/* Line 1806 of yacc.c  */
    6307 #line 1071 "parser.yy"
     6335#line 1074 "parser.yy"
    63086336    {
    63096337                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63156343
    63166344/* Line 1806 of yacc.c  */
    6317 #line 1078 "parser.yy"
     6345#line 1081 "parser.yy"
    63186346    {
    63196347                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63256353
    63266354/* Line 1806 of yacc.c  */
    6327 #line 1083 "parser.yy"
     6355#line 1086 "parser.yy"
    63286356    {
    63296357                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID );
     
    63356363
    63366364/* Line 1806 of yacc.c  */
    6337 #line 1093 "parser.yy"
     6365#line 1096 "parser.yy"
    63386366    {
    63396367                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63456373
    63466374/* Line 1806 of yacc.c  */
    6347 #line 1098 "parser.yy"
     6375#line 1101 "parser.yy"
    63486376    {
    63496377                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63556383
    63566384/* Line 1806 of yacc.c  */
    6357 #line 1103 "parser.yy"
     6385#line 1106 "parser.yy"
    63586386    {
    63596387                        typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) );
     
    63656393
    63666394/* Line 1806 of yacc.c  */
    6367 #line 1111 "parser.yy"
     6395#line 1114 "parser.yy"
    63686396    {
    63696397                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63756403
    63766404/* Line 1806 of yacc.c  */
    6377 #line 1116 "parser.yy"
     6405#line 1119 "parser.yy"
    63786406    {
    63796407                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63856413
    63866414/* Line 1806 of yacc.c  */
    6387 #line 1121 "parser.yy"
     6415#line 1124 "parser.yy"
    63886416    {
    63896417                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63956423
    63966424/* Line 1806 of yacc.c  */
    6397 #line 1126 "parser.yy"
     6425#line 1129 "parser.yy"
    63986426    {
    63996427                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    64056433
    64066434/* Line 1806 of yacc.c  */
    6407 #line 1131 "parser.yy"
     6435#line 1134 "parser.yy"
    64086436    {
    64096437                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    64156443
    64166444/* Line 1806 of yacc.c  */
    6417 #line 1139 "parser.yy"
     6445#line 1142 "parser.yy"
    64186446    {
    64196447                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(3) - (8)].tok), DeclarationNode::newTuple( 0 ), (yyvsp[(6) - (8)].decl), 0, true );
     
    64246452
    64256453/* Line 1806 of yacc.c  */
    6426 #line 1162 "parser.yy"
     6454#line 1165 "parser.yy"
    64276455    {
    64286456                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    64336461
    64346462/* Line 1806 of yacc.c  */
    6435 #line 1166 "parser.yy"
     6463#line 1169 "parser.yy"
    64366464    {
    64376465                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    64426470
    64436471/* Line 1806 of yacc.c  */
    6444 #line 1173 "parser.yy"
     6472#line 1176 "parser.yy"
    64456473    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    64466474    break;
     
    64496477
    64506478/* Line 1806 of yacc.c  */
    6451 #line 1177 "parser.yy"
     6479#line 1180 "parser.yy"
    64526480    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); }
    64536481    break;
     
    64566484
    64576485/* Line 1806 of yacc.c  */
    6458 #line 1182 "parser.yy"
     6486#line 1185 "parser.yy"
    64596487    {
    64606488                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64666494
    64676495/* Line 1806 of yacc.c  */
    6468 #line 1187 "parser.yy"
     6496#line 1190 "parser.yy"
    64696497    {
    64706498                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64766504
    64776505/* Line 1806 of yacc.c  */
    6478 #line 1192 "parser.yy"
     6506#line 1195 "parser.yy"
    64796507    {
    64806508                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD );
     
    64866514
    64876515/* Line 1806 of yacc.c  */
    6488 #line 1203 "parser.yy"
     6516#line 1206 "parser.yy"
    64896517    {
    64906518                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64966524
    64976525/* Line 1806 of yacc.c  */
    6498 #line 1208 "parser.yy"
     6526#line 1211 "parser.yy"
    64996527    {
    65006528                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65066534
    65076535/* Line 1806 of yacc.c  */
    6508 #line 1213 "parser.yy"
     6536#line 1216 "parser.yy"
    65096537    {
    65106538                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65166544
    65176545/* Line 1806 of yacc.c  */
    6518 #line 1218 "parser.yy"
     6546#line 1221 "parser.yy"
    65196547    {
    65206548                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65266554
    65276555/* Line 1806 of yacc.c  */
    6528 #line 1223 "parser.yy"
     6556#line 1226 "parser.yy"
    65296557    {
    65306558                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65366564
    65376565/* Line 1806 of yacc.c  */
    6538 #line 1232 "parser.yy"
     6566#line 1235 "parser.yy"
    65396567    {
    65406568                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD );
     
    65466574
    65476575/* Line 1806 of yacc.c  */
    6548 #line 1237 "parser.yy"
     6576#line 1240 "parser.yy"
    65496577    {
    65506578                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD );
     
    65566584
    65576585/* Line 1806 of yacc.c  */
    6558 #line 1254 "parser.yy"
     6586#line 1257 "parser.yy"
    65596587    {
    65606588                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65666594
    65676595/* Line 1806 of yacc.c  */
    6568 #line 1259 "parser.yy"
     6596#line 1262 "parser.yy"
    65696597    {
    65706598                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65766604
    65776605/* Line 1806 of yacc.c  */
    6578 #line 1281 "parser.yy"
     6606#line 1284 "parser.yy"
    65796607    { (yyval.decl) = 0; }
    65806608    break;
     
    65836611
    65846612/* Line 1806 of yacc.c  */
    6585 #line 1293 "parser.yy"
     6613#line 1296 "parser.yy"
    65866614    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    65876615    break;
     
    65906618
    65916619/* Line 1806 of yacc.c  */
    6592 #line 1304 "parser.yy"
     6620#line 1307 "parser.yy"
    65936621    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); }
    65946622    break;
     
    65976625
    65986626/* Line 1806 of yacc.c  */
    6599 #line 1306 "parser.yy"
     6627#line 1309 "parser.yy"
    66006628    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); }
    66016629    break;
     
    66046632
    66056633/* Line 1806 of yacc.c  */
    6606 #line 1308 "parser.yy"
     6634#line 1311 "parser.yy"
    66076635    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); }
    66086636    break;
     
    66116639
    66126640/* Line 1806 of yacc.c  */
    6613 #line 1310 "parser.yy"
     6641#line 1313 "parser.yy"
    66146642    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
    66156643    break;
     
    66186646
    66196647/* Line 1806 of yacc.c  */
    6620 #line 1312 "parser.yy"
     6648#line 1315 "parser.yy"
    66216649    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
    66226650    break;
     
    66256653
    66266654/* Line 1806 of yacc.c  */
    6627 #line 1314 "parser.yy"
     6655#line 1317 "parser.yy"
    66286656    {
    66296657                        typedefTable.enterScope();
     
    66346662
    66356663/* Line 1806 of yacc.c  */
    6636 #line 1318 "parser.yy"
     6664#line 1321 "parser.yy"
    66376665    {
    66386666                        typedefTable.leaveScope();
     
    66446672
    66456673/* Line 1806 of yacc.c  */
    6646 #line 1327 "parser.yy"
     6674#line 1330 "parser.yy"
    66476675    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66486676    break;
     
    66516679
    66526680/* Line 1806 of yacc.c  */
    6653 #line 1329 "parser.yy"
     6681#line 1332 "parser.yy"
    66546682    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    66556683    break;
     
    66586686
    66596687/* Line 1806 of yacc.c  */
    6660 #line 1340 "parser.yy"
     6688#line 1343 "parser.yy"
    66616689    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66626690    break;
     
    66656693
    66666694/* Line 1806 of yacc.c  */
    6667 #line 1345 "parser.yy"
     6695#line 1348 "parser.yy"
    66686696    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
    66696697    break;
     
    66726700
    66736701/* Line 1806 of yacc.c  */
    6674 #line 1347 "parser.yy"
     6702#line 1350 "parser.yy"
    66756703    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); }
    66766704    break;
     
    66796707
    66806708/* Line 1806 of yacc.c  */
    6681 #line 1349 "parser.yy"
     6709#line 1352 "parser.yy"
    66826710    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
    66836711    break;
     
    66866714
    66876715/* Line 1806 of yacc.c  */
    6688 #line 1351 "parser.yy"
     6716#line 1354 "parser.yy"
    66896717    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    66906718    break;
     
    66936721
    66946722/* Line 1806 of yacc.c  */
    6695 #line 1354 "parser.yy"
     6723#line 1357 "parser.yy"
    66966724    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; }
    66976725    break;
     
    67006728
    67016729/* Line 1806 of yacc.c  */
    6702 #line 1356 "parser.yy"
     6730#line 1359 "parser.yy"
    67036731    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
    67046732    break;
     
    67076735
    67086736/* Line 1806 of yacc.c  */
    6709 #line 1359 "parser.yy"
     6737#line 1362 "parser.yy"
    67106738    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; }
    67116739    break;
     
    67146742
    67156743/* Line 1806 of yacc.c  */
    6716 #line 1361 "parser.yy"
     6744#line 1364 "parser.yy"
    67176745    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }
    67186746    break;
     
    67216749
    67226750/* Line 1806 of yacc.c  */
    6723 #line 1366 "parser.yy"
     6751#line 1369 "parser.yy"
    67246752    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    67256753    break;
     
    67286756
    67296757/* Line 1806 of yacc.c  */
    6730 #line 1368 "parser.yy"
     6758#line 1371 "parser.yy"
    67316759    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); }
    67326760    break;
     
    67356763
    67366764/* Line 1806 of yacc.c  */
    6737 #line 1370 "parser.yy"
     6765#line 1373 "parser.yy"
    67386766    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    67396767    break;
     
    67426770
    67436771/* Line 1806 of yacc.c  */
    6744 #line 1372 "parser.yy"
     6772#line 1375 "parser.yy"
    67456773    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); }
    67466774    break;
     
    67496777
    67506778/* Line 1806 of yacc.c  */
    6751 #line 1374 "parser.yy"
     6779#line 1377 "parser.yy"
    67526780    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); }
    67536781    break;
     
    67566784
    67576785/* Line 1806 of yacc.c  */
    6758 #line 1376 "parser.yy"
     6786#line 1379 "parser.yy"
    67596787    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); }
    67606788    break;
     
    67636791
    67646792/* Line 1806 of yacc.c  */
    6765 #line 1378 "parser.yy"
     6793#line 1381 "parser.yy"
    67666794    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
    67676795    break;
     
    67706798
    67716799/* Line 1806 of yacc.c  */
    6772 #line 1380 "parser.yy"
     6800#line 1383 "parser.yy"
    67736801    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
    67746802    break;
     
    67776805
    67786806/* Line 1806 of yacc.c  */
    6779 #line 1382 "parser.yy"
     6807#line 1385 "parser.yy"
    67806808    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    67816809    break;
     
    67846812
    67856813/* Line 1806 of yacc.c  */
    6786 #line 1384 "parser.yy"
     6814#line 1387 "parser.yy"
    67876815    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    67886816    break;
     
    67916819
    67926820/* Line 1806 of yacc.c  */
    6793 #line 1386 "parser.yy"
     6821#line 1389 "parser.yy"
    67946822    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
    67956823    break;
     
    67986826
    67996827/* Line 1806 of yacc.c  */
    6800 #line 1388 "parser.yy"
     6828#line 1391 "parser.yy"
    68016829    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
    68026830    break;
     
    68056833
    68066834/* Line 1806 of yacc.c  */
    6807 #line 1390 "parser.yy"
     6835#line 1393 "parser.yy"
    68086836    { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    68096837    break;
     
    68126840
    68136841/* Line 1806 of yacc.c  */
    6814 #line 1397 "parser.yy"
     6842#line 1400 "parser.yy"
    68156843    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68166844    break;
     
    68196847
    68206848/* Line 1806 of yacc.c  */
    6821 #line 1399 "parser.yy"
     6849#line 1402 "parser.yy"
    68226850    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68236851    break;
     
    68266854
    68276855/* Line 1806 of yacc.c  */
    6828 #line 1401 "parser.yy"
     6856#line 1404 "parser.yy"
    68296857    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68306858    break;
     
    68336861
    68346862/* Line 1806 of yacc.c  */
    6835 #line 1403 "parser.yy"
     6863#line 1406 "parser.yy"
    68366864    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); }
    68376865    break;
     
    68406868
    68416869/* Line 1806 of yacc.c  */
    6842 #line 1409 "parser.yy"
     6870#line 1412 "parser.yy"
    68436871    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68446872    break;
     
    68476875
    68486876/* Line 1806 of yacc.c  */
    6849 #line 1416 "parser.yy"
     6877#line 1419 "parser.yy"
    68506878    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68516879    break;
     
    68546882
    68556883/* Line 1806 of yacc.c  */
    6856 #line 1418 "parser.yy"
     6884#line 1421 "parser.yy"
    68576885    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68586886    break;
     
    68616889
    68626890/* Line 1806 of yacc.c  */
    6863 #line 1420 "parser.yy"
     6891#line 1423 "parser.yy"
    68646892    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); }
    68656893    break;
     
    68686896
    68696897/* Line 1806 of yacc.c  */
    6870 #line 1425 "parser.yy"
     6898#line 1428 "parser.yy"
    68716899    { (yyval.decl) = (yyvsp[(3) - (4)].decl); }
    68726900    break;
     
    68756903
    68766904/* Line 1806 of yacc.c  */
    6877 #line 1427 "parser.yy"
     6905#line 1430 "parser.yy"
    68786906    { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); }
    68796907    break;
     
    68826910
    68836911/* Line 1806 of yacc.c  */
    6884 #line 1429 "parser.yy"
     6912#line 1432 "parser.yy"
    68856913    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); }
    68866914    break;
     
    68896917
    68906918/* Line 1806 of yacc.c  */
    6891 #line 1431 "parser.yy"
     6919#line 1434 "parser.yy"
    68926920    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    68936921    break;
     
    68966924
    68976925/* Line 1806 of yacc.c  */
    6898 #line 1437 "parser.yy"
     6926#line 1440 "parser.yy"
    68996927    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69006928    break;
     
    69036931
    69046932/* Line 1806 of yacc.c  */
    6905 #line 1439 "parser.yy"
     6933#line 1442 "parser.yy"
    69066934    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69076935    break;
     
    69106938
    69116939/* Line 1806 of yacc.c  */
    6912 #line 1441 "parser.yy"
     6940#line 1444 "parser.yy"
    69136941    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    69146942    break;
     
    69176945
    69186946/* Line 1806 of yacc.c  */
    6919 #line 1447 "parser.yy"
     6947#line 1450 "parser.yy"
    69206948    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69216949    break;
     
    69246952
    69256953/* Line 1806 of yacc.c  */
    6926 #line 1449 "parser.yy"
     6954#line 1452 "parser.yy"
    69276955    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69286956    break;
     
    69316959
    69326960/* Line 1806 of yacc.c  */
    6933 #line 1455 "parser.yy"
     6961#line 1458 "parser.yy"
    69346962    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69356963    break;
     
    69386966
    69396967/* Line 1806 of yacc.c  */
    6940 #line 1457 "parser.yy"
     6968#line 1460 "parser.yy"
    69416969    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69426970    break;
     
    69456973
    69466974/* Line 1806 of yacc.c  */
    6947 #line 1459 "parser.yy"
     6975#line 1462 "parser.yy"
    69486976    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    69496977    break;
     
    69526980
    69536981/* Line 1806 of yacc.c  */
    6954 #line 1464 "parser.yy"
     6982#line 1467 "parser.yy"
    69556983    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); }
    69566984    break;
     
    69596987
    69606988/* Line 1806 of yacc.c  */
    6961 #line 1466 "parser.yy"
     6989#line 1469 "parser.yy"
    69626990    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69636991    break;
     
    69666994
    69676995/* Line 1806 of yacc.c  */
    6968 #line 1468 "parser.yy"
     6996#line 1471 "parser.yy"
    69696997    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69706998    break;
     
    69737001
    69747002/* Line 1806 of yacc.c  */
    6975 #line 1478 "parser.yy"
     7003#line 1481 "parser.yy"
    69767004    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); }
    69777005    break;
     
    69807008
    69817009/* Line 1806 of yacc.c  */
    6982 #line 1480 "parser.yy"
     7010#line 1483 "parser.yy"
    69837011    {
    69847012                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    69907018
    69917019/* Line 1806 of yacc.c  */
    6992 #line 1485 "parser.yy"
     7020#line 1488 "parser.yy"
    69937021    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    69947022    break;
     
    69977025
    69987026/* Line 1806 of yacc.c  */
    6999 #line 1487 "parser.yy"
     7027#line 1490 "parser.yy"
    70007028    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); }
    70017029    break;
     
    70047032
    70057033/* Line 1806 of yacc.c  */
    7006 #line 1489 "parser.yy"
     7034#line 1492 "parser.yy"
    70077035    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); }
    70087036    break;
     
    70117039
    70127040/* Line 1806 of yacc.c  */
    7013 #line 1491 "parser.yy"
     7041#line 1494 "parser.yy"
    70147042    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    70157043    break;
     
    70187046
    70197047/* Line 1806 of yacc.c  */
    7020 #line 1496 "parser.yy"
     7048#line 1499 "parser.yy"
    70217049    { (yyval.aggKey) = DeclarationNode::Struct; }
    70227050    break;
     
    70257053
    70267054/* Line 1806 of yacc.c  */
    7027 #line 1498 "parser.yy"
     7055#line 1501 "parser.yy"
    70287056    { (yyval.aggKey) = DeclarationNode::Union; }
    70297057    break;
     
    70327060
    70337061/* Line 1806 of yacc.c  */
    7034 #line 1503 "parser.yy"
     7062#line 1506 "parser.yy"
    70357063    { (yyval.decl) = 0; }
    70367064    break;
     
    70397067
    70407068/* Line 1806 of yacc.c  */
    7041 #line 1505 "parser.yy"
     7069#line 1508 "parser.yy"
    70427070    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    70437071    break;
     
    70467074
    70477075/* Line 1806 of yacc.c  */
    7048 #line 1511 "parser.yy"
     7076#line 1514 "parser.yy"
    70497077    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
    70507078    break;
     
    70537081
    70547082/* Line 1806 of yacc.c  */
    7055 #line 1514 "parser.yy"
     7083#line 1517 "parser.yy"
    70567084    {   // mark all fields in list
    70577085                        for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    70647092
    70657093/* Line 1806 of yacc.c  */
    7066 #line 1524 "parser.yy"
     7094#line 1527 "parser.yy"
    70677095    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); }
    70687096    break;
     
    70717099
    70727100/* Line 1806 of yacc.c  */
    7073 #line 1526 "parser.yy"
     7101#line 1529 "parser.yy"
    70747102    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); }
    70757103    break;
     
    70787106
    70797107/* Line 1806 of yacc.c  */
    7080 #line 1528 "parser.yy"
     7108#line 1531 "parser.yy"
    70817109    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); }
    70827110    break;
     
    70857113
    70867114/* Line 1806 of yacc.c  */
    7087 #line 1533 "parser.yy"
     7115#line 1536 "parser.yy"
    70887116    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    70897117    break;
     
    70927120
    70937121/* Line 1806 of yacc.c  */
    7094 #line 1535 "parser.yy"
     7122#line 1538 "parser.yy"
    70957123    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); }
    70967124    break;
     
    70997127
    71007128/* Line 1806 of yacc.c  */
    7101 #line 1540 "parser.yy"
     7129#line 1543 "parser.yy"
    71027130    { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ }
    71037131    break;
     
    71067134
    71077135/* Line 1806 of yacc.c  */
    7108 #line 1542 "parser.yy"
     7136#line 1545 "parser.yy"
    71097137    { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); }
    71107138    break;
    71117139
    71127140  case 388:
    7113 
    7114 /* Line 1806 of yacc.c  */
    7115 #line 1545 "parser.yy"
    7116     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
    7117     break;
    7118 
    7119   case 389:
    71207141
    71217142/* Line 1806 of yacc.c  */
     
    71247145    break;
    71257146
     7147  case 389:
     7148
     7149/* Line 1806 of yacc.c  */
     7150#line 1551 "parser.yy"
     7151    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
     7152    break;
     7153
    71267154  case 391:
    71277155
    71287156/* Line 1806 of yacc.c  */
    7129 #line 1554 "parser.yy"
     7157#line 1557 "parser.yy"
    71307158    { (yyval.en) = 0; }
    71317159    break;
     
    71347162
    71357163/* Line 1806 of yacc.c  */
    7136 #line 1556 "parser.yy"
     7164#line 1559 "parser.yy"
    71377165    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    71387166    break;
     
    71417169
    71427170/* Line 1806 of yacc.c  */
    7143 #line 1561 "parser.yy"
     7171#line 1564 "parser.yy"
    71447172    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    71457173    break;
     
    71487176
    71497177/* Line 1806 of yacc.c  */
    7150 #line 1570 "parser.yy"
     7178#line 1573 "parser.yy"
    71517179    { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); }
    71527180    break;
     
    71557183
    71567184/* Line 1806 of yacc.c  */
    7157 #line 1572 "parser.yy"
     7185#line 1575 "parser.yy"
    71587186    {
    71597187                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    71657193
    71667194/* Line 1806 of yacc.c  */
    7167 #line 1577 "parser.yy"
     7195#line 1580 "parser.yy"
    71687196    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    71697197    break;
     
    71727200
    71737201/* Line 1806 of yacc.c  */
    7174 #line 1579 "parser.yy"
     7202#line 1582 "parser.yy"
    71757203    { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); }
    71767204    break;
     
    71797207
    71807208/* Line 1806 of yacc.c  */
    7181 #line 1584 "parser.yy"
     7209#line 1587 "parser.yy"
    71827210    { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); }
    71837211    break;
     
    71867214
    71877215/* Line 1806 of yacc.c  */
    7188 #line 1586 "parser.yy"
     7216#line 1589 "parser.yy"
    71897217    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); }
    71907218    break;
     
    71937221
    71947222/* Line 1806 of yacc.c  */
    7195 #line 1591 "parser.yy"
     7223#line 1594 "parser.yy"
    71967224    { (yyval.en) = 0; }
    71977225    break;
     
    72007228
    72017229/* Line 1806 of yacc.c  */
    7202 #line 1593 "parser.yy"
     7230#line 1596 "parser.yy"
    72037231    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    72047232    break;
     
    72077235
    72087236/* Line 1806 of yacc.c  */
    7209 #line 1600 "parser.yy"
     7237#line 1603 "parser.yy"
    72107238    { (yyval.decl) = 0; }
    72117239    break;
     
    72147242
    72157243/* Line 1806 of yacc.c  */
    7216 #line 1608 "parser.yy"
     7244#line 1611 "parser.yy"
    72177245    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72187246    break;
     
    72217249
    72227250/* Line 1806 of yacc.c  */
    7223 #line 1610 "parser.yy"
     7251#line 1613 "parser.yy"
    72247252    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72257253    break;
     
    72287256
    72297257/* Line 1806 of yacc.c  */
    7230 #line 1612 "parser.yy"
     7258#line 1615 "parser.yy"
    72317259    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72327260    break;
     
    72357263
    72367264/* Line 1806 of yacc.c  */
    7237 #line 1620 "parser.yy"
     7265#line 1623 "parser.yy"
    72387266    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72397267    break;
     
    72427270
    72437271/* Line 1806 of yacc.c  */
    7244 #line 1622 "parser.yy"
     7272#line 1625 "parser.yy"
    72457273    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72467274    break;
     
    72497277
    72507278/* Line 1806 of yacc.c  */
    7251 #line 1624 "parser.yy"
     7279#line 1627 "parser.yy"
    72527280    { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); }
    72537281    break;
     
    72567284
    72577285/* Line 1806 of yacc.c  */
    7258 #line 1630 "parser.yy"
     7286#line 1633 "parser.yy"
    72597287    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72607288    break;
     
    72637291
    72647292/* Line 1806 of yacc.c  */
    7265 #line 1635 "parser.yy"
     7293#line 1638 "parser.yy"
    72667294    { (yyval.decl) = 0; }
    72677295    break;
     
    72707298
    72717299/* Line 1806 of yacc.c  */
    7272 #line 1642 "parser.yy"
     7300#line 1645 "parser.yy"
    72737301    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72747302    break;
     
    72777305
    72787306/* Line 1806 of yacc.c  */
    7279 #line 1649 "parser.yy"
     7307#line 1652 "parser.yy"
    72807308    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72817309    break;
     
    72847312
    72857313/* Line 1806 of yacc.c  */
    7286 #line 1651 "parser.yy"
     7314#line 1654 "parser.yy"
    72877315    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72887316    break;
    72897317
    72907318  case 425:
    7291 
    7292 /* Line 1806 of yacc.c  */
    7293 #line 1660 "parser.yy"
    7294     { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
    7295     break;
    7296 
    7297   case 426:
    72987319
    72997320/* Line 1806 of yacc.c  */
     
    73027323    break;
    73037324
     7325  case 426:
     7326
     7327/* Line 1806 of yacc.c  */
     7328#line 1666 "parser.yy"
     7329    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
     7330    break;
     7331
    73047332  case 427:
    73057333
    73067334/* Line 1806 of yacc.c  */
    7307 #line 1665 "parser.yy"
     7335#line 1668 "parser.yy"
    73087336    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); }
    73097337    break;
     
    73127340
    73137341/* Line 1806 of yacc.c  */
    7314 #line 1675 "parser.yy"
     7342#line 1678 "parser.yy"
    73157343    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    73167344    break;
     
    73197347
    73207348/* Line 1806 of yacc.c  */
    7321 #line 1681 "parser.yy"
     7349#line 1684 "parser.yy"
    73227350    {
    73237351                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    73297357
    73307358/* Line 1806 of yacc.c  */
    7331 #line 1686 "parser.yy"
     7359#line 1689 "parser.yy"
    73327360    {
    73337361                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    73397367
    73407368/* Line 1806 of yacc.c  */
    7341 #line 1695 "parser.yy"
     7369#line 1698 "parser.yy"
    73427370    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73437371    break;
     
    73467374
    73477375/* Line 1806 of yacc.c  */
    7348 #line 1704 "parser.yy"
     7376#line 1707 "parser.yy"
    73497377    { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); }
    73507378    break;
     
    73537381
    73547382/* Line 1806 of yacc.c  */
    7355 #line 1706 "parser.yy"
     7383#line 1709 "parser.yy"
    73567384    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); }
    73577385    break;
     
    73607388
    73617389/* Line 1806 of yacc.c  */
    7362 #line 1731 "parser.yy"
     7390#line 1734 "parser.yy"
    73637391    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73647392    break;
     
    73677395
    73687396/* Line 1806 of yacc.c  */
    7369 #line 1739 "parser.yy"
     7397#line 1742 "parser.yy"
    73707398    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73717399    break;
     
    73747402
    73757403/* Line 1806 of yacc.c  */
    7376 #line 1744 "parser.yy"
     7404#line 1747 "parser.yy"
    73777405    { (yyval.in) = 0; }
    73787406    break;
     
    73817409
    73827410/* Line 1806 of yacc.c  */
    7383 #line 1746 "parser.yy"
     7411#line 1749 "parser.yy"
    73847412    { (yyval.in) = (yyvsp[(2) - (2)].in); }
    73857413    break;
     
    73887416
    73897417/* Line 1806 of yacc.c  */
    7390 #line 1748 "parser.yy"
     7418#line 1751 "parser.yy"
    73917419    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); }
    73927420    break;
     
    73957423
    73967424/* Line 1806 of yacc.c  */
    7397 #line 1752 "parser.yy"
     7425#line 1755 "parser.yy"
    73987426    { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); }
    73997427    break;
     
    74027430
    74037431/* Line 1806 of yacc.c  */
    7404 #line 1753 "parser.yy"
     7432#line 1756 "parser.yy"
    74057433    { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); }
    74067434    break;
     
    74097437
    74107438/* Line 1806 of yacc.c  */
    7411 #line 1758 "parser.yy"
     7439#line 1761 "parser.yy"
    74127440    { (yyval.in) = 0; }
    74137441    break;
     
    74167444
    74177445/* Line 1806 of yacc.c  */
    7418 #line 1760 "parser.yy"
     7446#line 1763 "parser.yy"
    74197447    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); }
    74207448    break;
     
    74237451
    74247452/* Line 1806 of yacc.c  */
    7425 #line 1761 "parser.yy"
     7453#line 1764 "parser.yy"
    74267454    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); }
    74277455    break;
     
    74307458
    74317459/* Line 1806 of yacc.c  */
    7432 #line 1763 "parser.yy"
     7460#line 1766 "parser.yy"
    74337461    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); }
    74347462    break;
     
    74377465
    74387466/* Line 1806 of yacc.c  */
    7439 #line 1779 "parser.yy"
     7467#line 1782 "parser.yy"
    74407468    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); }
    74417469    break;
     
    74447472
    74457473/* Line 1806 of yacc.c  */
    7446 #line 1785 "parser.yy"
     7474#line 1788 "parser.yy"
    74477475    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); }
    74487476    break;
     
    74517479
    74527480/* Line 1806 of yacc.c  */
    7453 #line 1791 "parser.yy"
     7481#line 1794 "parser.yy"
    74547482    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); }
    74557483    break;
     
    74587486
    74597487/* Line 1806 of yacc.c  */
    7460 #line 1794 "parser.yy"
     7488#line 1797 "parser.yy"
    74617489    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74627490    break;
     
    74657493
    74667494/* Line 1806 of yacc.c  */
    7467 #line 1796 "parser.yy"
     7495#line 1799 "parser.yy"
    74687496    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74697497    break;
     
    74727500
    74737501/* Line 1806 of yacc.c  */
    7474 #line 1798 "parser.yy"
     7502#line 1801 "parser.yy"
    74757503    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); }
    74767504    break;
     
    74797507
    74807508/* Line 1806 of yacc.c  */
    7481 #line 1800 "parser.yy"
     7509#line 1803 "parser.yy"
    74827510    { (yyval.en) = (yyvsp[(4) - (6)].en); }
    74837511    break;
     
    74867514
    74877515/* Line 1806 of yacc.c  */
    7488 #line 1824 "parser.yy"
     7516#line 1827 "parser.yy"
    74897517    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    74907518    break;
     
    74937521
    74947522/* Line 1806 of yacc.c  */
    7495 #line 1826 "parser.yy"
     7523#line 1829 "parser.yy"
    74967524    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    74977525    break;
     
    75007528
    75017529/* Line 1806 of yacc.c  */
    7502 #line 1828 "parser.yy"
     7530#line 1831 "parser.yy"
    75037531    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    75047532    break;
     
    75077535
    75087536/* Line 1806 of yacc.c  */
    7509 #line 1834 "parser.yy"
     7537#line 1837 "parser.yy"
    75107538    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    75117539    break;
     
    75147542
    75157543/* Line 1806 of yacc.c  */
    7516 #line 1836 "parser.yy"
     7544#line 1839 "parser.yy"
    75177545    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    75187546    break;
     
    75217549
    75227550/* Line 1806 of yacc.c  */
    7523 #line 1841 "parser.yy"
     7551#line 1844 "parser.yy"
    75247552    { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    75257553    break;
     
    75287556
    75297557/* Line 1806 of yacc.c  */
    7530 #line 1847 "parser.yy"
     7558#line 1850 "parser.yy"
    75317559    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); }
    75327560    break;
     
    75357563
    75367564/* Line 1806 of yacc.c  */
    7537 #line 1852 "parser.yy"
     7565#line 1855 "parser.yy"
    75387566    { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); }
    75397567    break;
     
    75427570
    75437571/* Line 1806 of yacc.c  */
    7544 #line 1854 "parser.yy"
     7572#line 1857 "parser.yy"
    75457573    { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); }
    75467574    break;
     
    75497577
    75507578/* Line 1806 of yacc.c  */
    7551 #line 1860 "parser.yy"
     7579#line 1863 "parser.yy"
    75527580    { (yyval.tclass) = DeclarationNode::Otype; }
    75537581    break;
     
    75567584
    75577585/* Line 1806 of yacc.c  */
    7558 #line 1862 "parser.yy"
     7586#line 1865 "parser.yy"
    75597587    { (yyval.tclass) = DeclarationNode::Ftype; }
    75607588    break;
     
    75637591
    75647592/* Line 1806 of yacc.c  */
    7565 #line 1864 "parser.yy"
     7593#line 1867 "parser.yy"
    75667594    { (yyval.tclass) = DeclarationNode::Dtype; }
    75677595    break;
     
    75707598
    75717599/* Line 1806 of yacc.c  */
    7572 #line 1869 "parser.yy"
     7600#line 1872 "parser.yy"
    75737601    { (yyval.decl) = 0; }
    75747602    break;
     
    75777605
    75787606/* Line 1806 of yacc.c  */
    7579 #line 1871 "parser.yy"
     7607#line 1874 "parser.yy"
    75807608    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    75817609    break;
     
    75847612
    75857613/* Line 1806 of yacc.c  */
    7586 #line 1876 "parser.yy"
     7614#line 1879 "parser.yy"
    75877615    {
    75887616                        typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) );
     
    75947622
    75957623/* Line 1806 of yacc.c  */
    7596 #line 1881 "parser.yy"
     7624#line 1884 "parser.yy"
    75977625    { (yyval.decl) = (yyvsp[(4) - (5)].decl); }
    75987626    break;
     
    76017629
    76027630/* Line 1806 of yacc.c  */
    7603 #line 1883 "parser.yy"
     7631#line 1886 "parser.yy"
    76047632    { (yyval.decl) = 0; }
    76057633    break;
     
    76087636
    76097637/* Line 1806 of yacc.c  */
    7610 #line 1888 "parser.yy"
     7638#line 1891 "parser.yy"
    76117639    { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); }
    76127640    break;
     
    76157643
    76167644/* Line 1806 of yacc.c  */
    7617 #line 1891 "parser.yy"
     7645#line 1894 "parser.yy"
    76187646    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); }
    76197647    break;
     
    76227650
    76237651/* Line 1806 of yacc.c  */
    7624 #line 1893 "parser.yy"
     7652#line 1896 "parser.yy"
    76257653    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    76267654    break;
     
    76297657
    76307658/* Line 1806 of yacc.c  */
    7631 #line 1898 "parser.yy"
     7659#line 1901 "parser.yy"
    76327660    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    76337661    break;
     
    76367664
    76377665/* Line 1806 of yacc.c  */
    7638 #line 1900 "parser.yy"
     7666#line 1903 "parser.yy"
    76397667    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); }
    76407668    break;
     
    76437671
    76447672/* Line 1806 of yacc.c  */
    7645 #line 1902 "parser.yy"
     7673#line 1905 "parser.yy"
    76467674    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); }
    76477675    break;
     
    76507678
    76517679/* Line 1806 of yacc.c  */
    7652 #line 1907 "parser.yy"
     7680#line 1910 "parser.yy"
    76537681    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); }
    76547682    break;
     
    76577685
    76587686/* Line 1806 of yacc.c  */
    7659 #line 1909 "parser.yy"
     7687#line 1912 "parser.yy"
    76607688    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); }
    76617689    break;
     
    76647692
    76657693/* Line 1806 of yacc.c  */
    7666 #line 1914 "parser.yy"
     7694#line 1917 "parser.yy"
    76677695    {
    76687696                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD );
     
    76747702
    76757703/* Line 1806 of yacc.c  */
    7676 #line 1919 "parser.yy"
     7704#line 1922 "parser.yy"
    76777705    {
    76787706                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG );
     
    76847712
    76857713/* Line 1806 of yacc.c  */
    7686 #line 1927 "parser.yy"
     7714#line 1930 "parser.yy"
    76877715    {
    76887716                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID );
     
    76947722
    76957723/* Line 1806 of yacc.c  */
    7696 #line 1932 "parser.yy"
     7724#line 1935 "parser.yy"
    76977725    {
    76987726                        typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) );
     
    77047732
    77057733/* Line 1806 of yacc.c  */
    7706 #line 1937 "parser.yy"
     7734#line 1940 "parser.yy"
    77077735    {
    77087736                        typedefTable.leaveTrait();
     
    77157743
    77167744/* Line 1806 of yacc.c  */
    7717 #line 1947 "parser.yy"
     7745#line 1950 "parser.yy"
    77187746    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    77197747    break;
     
    77227750
    77237751/* Line 1806 of yacc.c  */
    7724 #line 1957 "parser.yy"
     7752#line 1960 "parser.yy"
    77257753    {
    77267754                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77327760
    77337761/* Line 1806 of yacc.c  */
    7734 #line 1962 "parser.yy"
     7762#line 1965 "parser.yy"
    77357763    {
    77367764                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77427770
    77437771/* Line 1806 of yacc.c  */
    7744 #line 1967 "parser.yy"
     7772#line 1970 "parser.yy"
    77457773    {
    77467774                        typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    77527780
    77537781/* Line 1806 of yacc.c  */
    7754 #line 1975 "parser.yy"
     7782#line 1978 "parser.yy"
    77557783    {
    77567784                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77627790
    77637791/* Line 1806 of yacc.c  */
    7764 #line 1980 "parser.yy"
     7792#line 1983 "parser.yy"
    77657793    {
    77667794                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77727800
    77737801/* Line 1806 of yacc.c  */
    7774 #line 1990 "parser.yy"
     7802#line 1993 "parser.yy"
    77757803    {}
    77767804    break;
     
    77797807
    77807808/* Line 1806 of yacc.c  */
    7781 #line 1992 "parser.yy"
     7809#line 1995 "parser.yy"
    77827810    { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl);    }
    77837811    break;
     
    77867814
    77877815/* Line 1806 of yacc.c  */
    7788 #line 1998 "parser.yy"
     7816#line 2001 "parser.yy"
    77897817    { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); }
    77907818    break;
     
    77937821
    77947822/* Line 1806 of yacc.c  */
    7795 #line 2003 "parser.yy"
     7823#line 2006 "parser.yy"
    77967824    { (yyval.decl) = 0; }
    77977825    break;
     
    78007828
    78017829/* Line 1806 of yacc.c  */
    7802 #line 2011 "parser.yy"
     7830#line 2014 "parser.yy"
    78037831    {}
    78047832    break;
     
    78077835
    78087836/* Line 1806 of yacc.c  */
    7809 #line 2013 "parser.yy"
     7837#line 2016 "parser.yy"
    78107838    {
    78117839                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     
    78177845
    78187846/* Line 1806 of yacc.c  */
    7819 #line 2018 "parser.yy"
     7847#line 2021 "parser.yy"
    78207848    {
    78217849                        linkage = linkageStack.top();
     
    78287856
    78297857/* Line 1806 of yacc.c  */
    7830 #line 2024 "parser.yy"
     7858#line 2027 "parser.yy"
    78317859    {   // mark all fields in list
    78327860                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    78397867
    78407868/* Line 1806 of yacc.c  */
    7841 #line 2039 "parser.yy"
     7869#line 2042 "parser.yy"
    78427870    {
    78437871                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78507878
    78517879/* Line 1806 of yacc.c  */
    7852 #line 2045 "parser.yy"
     7880#line 2048 "parser.yy"
    78537881    {
    78547882                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78617889
    78627890/* Line 1806 of yacc.c  */
    7863 #line 2054 "parser.yy"
     7891#line 2057 "parser.yy"
    78647892    {
    78657893                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78727900
    78737901/* Line 1806 of yacc.c  */
    7874 #line 2060 "parser.yy"
     7902#line 2063 "parser.yy"
    78757903    {
    78767904                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78837911
    78847912/* Line 1806 of yacc.c  */
    7885 #line 2066 "parser.yy"
     7913#line 2069 "parser.yy"
    78867914    {
    78877915                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78947922
    78957923/* Line 1806 of yacc.c  */
    7896 #line 2072 "parser.yy"
     7924#line 2075 "parser.yy"
    78977925    {
    78987926                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79057933
    79067934/* Line 1806 of yacc.c  */
    7907 #line 2078 "parser.yy"
     7935#line 2081 "parser.yy"
    79087936    {
    79097937                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79167944
    79177945/* Line 1806 of yacc.c  */
    7918 #line 2086 "parser.yy"
     7946#line 2089 "parser.yy"
    79197947    {
    79207948                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79277955
    79287956/* Line 1806 of yacc.c  */
    7929 #line 2092 "parser.yy"
     7957#line 2095 "parser.yy"
    79307958    {
    79317959                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79387966
    79397967/* Line 1806 of yacc.c  */
    7940 #line 2100 "parser.yy"
     7968#line 2103 "parser.yy"
    79417969    {
    79427970                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79497977
    79507978/* Line 1806 of yacc.c  */
    7951 #line 2106 "parser.yy"
     7979#line 2109 "parser.yy"
    79527980    {
    79537981                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79607988
    79617989/* Line 1806 of yacc.c  */
    7962 #line 2121 "parser.yy"
     7990#line 2124 "parser.yy"
    79637991    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    79647992    break;
     
    79677995
    79687996/* Line 1806 of yacc.c  */
    7969 #line 2126 "parser.yy"
     7997#line 2129 "parser.yy"
    79707998    { delete (yyvsp[(3) - (5)].str); }
    79717999    break;
     
    79748002
    79758003/* Line 1806 of yacc.c  */
    7976 #line 2131 "parser.yy"
     8004#line 2134 "parser.yy"
    79778005    { (yyval.decl) = 0; }
    79788006    break;
     
    79818009
    79828010/* Line 1806 of yacc.c  */
    7983 #line 2138 "parser.yy"
     8011#line 2141 "parser.yy"
    79848012    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    79858013    break;
     
    79888016
    79898017/* Line 1806 of yacc.c  */
    7990 #line 2144 "parser.yy"
     8018#line 2147 "parser.yy"
    79918019    { (yyval.decl) = 0; }
    79928020    break;
     
    79958023
    79968024/* Line 1806 of yacc.c  */
    7997 #line 2155 "parser.yy"
     8025#line 2158 "parser.yy"
    79988026    { delete (yyvsp[(3) - (4)].en); }
    79998027    break;
     
    80028030
    80038031/* Line 1806 of yacc.c  */
    8004 #line 2159 "parser.yy"
     8032#line 2162 "parser.yy"
    80058033    { delete (yyvsp[(1) - (1)].tok); }
    80068034    break;
     
    80098037
    80108038/* Line 1806 of yacc.c  */
    8011 #line 2160 "parser.yy"
     8039#line 2163 "parser.yy"
    80128040    { delete (yyvsp[(1) - (1)].decl); }
    80138041    break;
     
    80168044
    80178045/* Line 1806 of yacc.c  */
    8018 #line 2161 "parser.yy"
     8046#line 2164 "parser.yy"
    80198047    { delete (yyvsp[(1) - (1)].decl); }
    80208048    break;
     
    80238051
    80248052/* Line 1806 of yacc.c  */
    8025 #line 2162 "parser.yy"
     8053#line 2165 "parser.yy"
    80268054    { delete (yyvsp[(1) - (1)].decl); }
    80278055    break;
    80288056
    80298057  case 563:
    8030 
    8031 /* Line 1806 of yacc.c  */
    8032 #line 2197 "parser.yy"
    8033     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8034     break;
    8035 
    8036   case 565:
    80378058
    80388059/* Line 1806 of yacc.c  */
     
    80418062    break;
    80428063
     8064  case 565:
     8065
     8066/* Line 1806 of yacc.c  */
     8067#line 2203 "parser.yy"
     8068    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8069    break;
     8070
    80438071  case 566:
    80448072
    80458073/* Line 1806 of yacc.c  */
    8046 #line 2202 "parser.yy"
     8074#line 2205 "parser.yy"
    80478075    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    80488076    break;
     
    80518079
    80528080/* Line 1806 of yacc.c  */
    8053 #line 2207 "parser.yy"
     8081#line 2210 "parser.yy"
    80548082    {
    80558083                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    80618089
    80628090/* Line 1806 of yacc.c  */
    8063 #line 2212 "parser.yy"
     8091#line 2215 "parser.yy"
    80648092    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80658093    break;
     
    80688096
    80698097/* Line 1806 of yacc.c  */
    8070 #line 2217 "parser.yy"
     8098#line 2220 "parser.yy"
    80718099    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    80728100    break;
     
    80758103
    80768104/* Line 1806 of yacc.c  */
    8077 #line 2219 "parser.yy"
     8105#line 2222 "parser.yy"
    80788106    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    80798107    break;
     
    80828110
    80838111/* Line 1806 of yacc.c  */
    8084 #line 2221 "parser.yy"
     8112#line 2224 "parser.yy"
    80858113    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80868114    break;
     
    80898117
    80908118/* Line 1806 of yacc.c  */
    8091 #line 2226 "parser.yy"
     8119#line 2229 "parser.yy"
    80928120    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    80938121    break;
     
    80968124
    80978125/* Line 1806 of yacc.c  */
    8098 #line 2228 "parser.yy"
     8126#line 2231 "parser.yy"
    80998127    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81008128    break;
     
    81038131
    81048132/* Line 1806 of yacc.c  */
    8105 #line 2230 "parser.yy"
     8133#line 2233 "parser.yy"
    81068134    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81078135    break;
     
    81108138
    81118139/* Line 1806 of yacc.c  */
    8112 #line 2232 "parser.yy"
     8140#line 2235 "parser.yy"
    81138141    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81148142    break;
     
    81178145
    81188146/* Line 1806 of yacc.c  */
    8119 #line 2237 "parser.yy"
     8147#line 2240 "parser.yy"
    81208148    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    81218149    break;
     
    81248152
    81258153/* Line 1806 of yacc.c  */
    8126 #line 2239 "parser.yy"
     8154#line 2242 "parser.yy"
    81278155    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81288156    break;
    81298157
    81308158  case 578:
    8131 
    8132 /* Line 1806 of yacc.c  */
    8133 #line 2248 "parser.yy"
    8134     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8135     break;
    8136 
    8137   case 580:
    81388159
    81398160/* Line 1806 of yacc.c  */
     
    81428163    break;
    81438164
     8165  case 580:
     8166
     8167/* Line 1806 of yacc.c  */
     8168#line 2254 "parser.yy"
     8169    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8170    break;
     8171
    81448172  case 581:
    81458173
    81468174/* Line 1806 of yacc.c  */
    8147 #line 2256 "parser.yy"
     8175#line 2259 "parser.yy"
    81488176    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    81498177    break;
     
    81528180
    81538181/* Line 1806 of yacc.c  */
    8154 #line 2258 "parser.yy"
     8182#line 2261 "parser.yy"
    81558183    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    81568184    break;
     
    81598187
    81608188/* Line 1806 of yacc.c  */
    8161 #line 2260 "parser.yy"
     8189#line 2263 "parser.yy"
    81628190    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81638191    break;
     
    81668194
    81678195/* Line 1806 of yacc.c  */
    8168 #line 2265 "parser.yy"
     8196#line 2268 "parser.yy"
    81698197    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    81708198    break;
     
    81738201
    81748202/* Line 1806 of yacc.c  */
    8175 #line 2267 "parser.yy"
     8203#line 2270 "parser.yy"
    81768204    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    81778205    break;
     
    81808208
    81818209/* Line 1806 of yacc.c  */
    8182 #line 2269 "parser.yy"
     8210#line 2272 "parser.yy"
    81838211    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81848212    break;
     
    81878215
    81888216/* Line 1806 of yacc.c  */
    8189 #line 2274 "parser.yy"
     8217#line 2277 "parser.yy"
    81908218    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81918219    break;
     
    81948222
    81958223/* Line 1806 of yacc.c  */
    8196 #line 2276 "parser.yy"
     8224#line 2279 "parser.yy"
    81978225    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81988226    break;
     
    82018229
    82028230/* Line 1806 of yacc.c  */
    8203 #line 2278 "parser.yy"
     8231#line 2281 "parser.yy"
    82048232    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82058233    break;
     
    82088236
    82098237/* Line 1806 of yacc.c  */
    8210 #line 2293 "parser.yy"
     8238#line 2296 "parser.yy"
    82118239    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); }
    82128240    break;
     
    82158243
    82168244/* Line 1806 of yacc.c  */
    8217 #line 2295 "parser.yy"
     8245#line 2298 "parser.yy"
    82188246    { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); }
    82198247    break;
     
    82228250
    82238251/* Line 1806 of yacc.c  */
    8224 #line 2297 "parser.yy"
     8252#line 2300 "parser.yy"
    82258253    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82268254    break;
     
    82298257
    82308258/* Line 1806 of yacc.c  */
    8231 #line 2302 "parser.yy"
     8259#line 2305 "parser.yy"
    82328260    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    82338261    break;
     
    82368264
    82378265/* Line 1806 of yacc.c  */
    8238 #line 2304 "parser.yy"
     8266#line 2307 "parser.yy"
    82398267    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    82408268    break;
     
    82438271
    82448272/* Line 1806 of yacc.c  */
    8245 #line 2306 "parser.yy"
     8273#line 2309 "parser.yy"
    82468274    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82478275    break;
     
    82508278
    82518279/* Line 1806 of yacc.c  */
    8252 #line 2311 "parser.yy"
     8280#line 2314 "parser.yy"
    82538281    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    82548282    break;
     
    82578285
    82588286/* Line 1806 of yacc.c  */
    8259 #line 2313 "parser.yy"
     8287#line 2316 "parser.yy"
    82608288    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    82618289    break;
     
    82648292
    82658293/* Line 1806 of yacc.c  */
    8266 #line 2315 "parser.yy"
     8294#line 2318 "parser.yy"
    82678295    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82688296    break;
    82698297
    82708298  case 602:
    8271 
    8272 /* Line 1806 of yacc.c  */
    8273 #line 2330 "parser.yy"
    8274     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8275     break;
    8276 
    8277   case 604:
    82788299
    82798300/* Line 1806 of yacc.c  */
     
    82828303    break;
    82838304
     8305  case 604:
     8306
     8307/* Line 1806 of yacc.c  */
     8308#line 2336 "parser.yy"
     8309    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8310    break;
     8311
    82848312  case 605:
    82858313
    82868314/* Line 1806 of yacc.c  */
    8287 #line 2335 "parser.yy"
     8315#line 2338 "parser.yy"
    82888316    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    82898317    break;
     
    82928320
    82938321/* Line 1806 of yacc.c  */
    8294 #line 2341 "parser.yy"
     8322#line 2344 "parser.yy"
    82958323    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82968324    break;
     
    82998327
    83008328/* Line 1806 of yacc.c  */
    8301 #line 2346 "parser.yy"
     8329#line 2349 "parser.yy"
    83028330    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    83038331    break;
     
    83068334
    83078335/* Line 1806 of yacc.c  */
    8308 #line 2348 "parser.yy"
     8336#line 2351 "parser.yy"
    83098337    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    83108338    break;
     
    83138341
    83148342/* Line 1806 of yacc.c  */
    8315 #line 2350 "parser.yy"
     8343#line 2353 "parser.yy"
    83168344    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83178345    break;
     
    83208348
    83218349/* Line 1806 of yacc.c  */
    8322 #line 2355 "parser.yy"
     8350#line 2358 "parser.yy"
    83238351    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    83248352    break;
     
    83278355
    83288356/* Line 1806 of yacc.c  */
    8329 #line 2357 "parser.yy"
     8357#line 2360 "parser.yy"
    83308358    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83318359    break;
     
    83348362
    83358363/* Line 1806 of yacc.c  */
    8336 #line 2359 "parser.yy"
     8364#line 2362 "parser.yy"
    83378365    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83388366    break;
     
    83418369
    83428370/* Line 1806 of yacc.c  */
    8343 #line 2361 "parser.yy"
     8371#line 2364 "parser.yy"
    83448372    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83458373    break;
     
    83488376
    83498377/* Line 1806 of yacc.c  */
    8350 #line 2366 "parser.yy"
     8378#line 2369 "parser.yy"
    83518379    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    83528380    break;
     
    83558383
    83568384/* Line 1806 of yacc.c  */
    8357 #line 2368 "parser.yy"
     8385#line 2371 "parser.yy"
    83588386    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    83598387    break;
     
    83628390
    83638391/* Line 1806 of yacc.c  */
    8364 #line 2370 "parser.yy"
     8392#line 2373 "parser.yy"
    83658393    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83668394    break;
    83678395
    83688396  case 618:
    8369 
    8370 /* Line 1806 of yacc.c  */
    8371 #line 2380 "parser.yy"
    8372     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8373     break;
    8374 
    8375   case 620:
    83768397
    83778398/* Line 1806 of yacc.c  */
     
    83808401    break;
    83818402
     8403  case 620:
     8404
     8405/* Line 1806 of yacc.c  */
     8406#line 2386 "parser.yy"
     8407    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8408    break;
     8409
    83828410  case 621:
    83838411
    83848412/* Line 1806 of yacc.c  */
    8385 #line 2385 "parser.yy"
     8413#line 2388 "parser.yy"
    83868414    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83878415    break;
     
    83908418
    83918419/* Line 1806 of yacc.c  */
    8392 #line 2390 "parser.yy"
     8420#line 2393 "parser.yy"
    83938421    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    83948422    break;
     
    83978425
    83988426/* Line 1806 of yacc.c  */
    8399 #line 2392 "parser.yy"
     8427#line 2395 "parser.yy"
    84008428    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    84018429    break;
     
    84048432
    84058433/* Line 1806 of yacc.c  */
    8406 #line 2394 "parser.yy"
     8434#line 2397 "parser.yy"
    84078435    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84088436    break;
     
    84118439
    84128440/* Line 1806 of yacc.c  */
    8413 #line 2399 "parser.yy"
     8441#line 2402 "parser.yy"
    84148442    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    84158443    break;
     
    84188446
    84198447/* Line 1806 of yacc.c  */
    8420 #line 2401 "parser.yy"
     8448#line 2404 "parser.yy"
    84218449    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    84228450    break;
     
    84258453
    84268454/* Line 1806 of yacc.c  */
    8427 #line 2403 "parser.yy"
     8455#line 2406 "parser.yy"
    84288456    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    84298457    break;
     
    84328460
    84338461/* Line 1806 of yacc.c  */
    8434 #line 2405 "parser.yy"
     8462#line 2408 "parser.yy"
    84358463    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84368464    break;
     
    84398467
    84408468/* Line 1806 of yacc.c  */
    8441 #line 2410 "parser.yy"
     8469#line 2413 "parser.yy"
    84428470    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    84438471    break;
     
    84468474
    84478475/* Line 1806 of yacc.c  */
    8448 #line 2412 "parser.yy"
     8476#line 2415 "parser.yy"
    84498477    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    84508478    break;
     
    84538481
    84548482/* Line 1806 of yacc.c  */
    8455 #line 2414 "parser.yy"
     8483#line 2417 "parser.yy"
    84568484    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84578485    break;
    84588486
    84598487  case 632:
    8460 
    8461 /* Line 1806 of yacc.c  */
    8462 #line 2445 "parser.yy"
    8463     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8464     break;
    8465 
    8466   case 634:
    84678488
    84688489/* Line 1806 of yacc.c  */
     
    84718492    break;
    84728493
     8494  case 634:
     8495
     8496/* Line 1806 of yacc.c  */
     8497#line 2451 "parser.yy"
     8498    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8499    break;
     8500
    84738501  case 635:
    84748502
    84758503/* Line 1806 of yacc.c  */
    8476 #line 2450 "parser.yy"
     8504#line 2453 "parser.yy"
    84778505    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84788506    break;
     
    84818509
    84828510/* Line 1806 of yacc.c  */
    8483 #line 2455 "parser.yy"
     8511#line 2458 "parser.yy"
    84848512    {
    84858513                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    84918519
    84928520/* Line 1806 of yacc.c  */
    8493 #line 2460 "parser.yy"
     8521#line 2463 "parser.yy"
    84948522    {
    84958523                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    85018529
    85028530/* Line 1806 of yacc.c  */
    8503 #line 2468 "parser.yy"
     8531#line 2471 "parser.yy"
    85048532    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    85058533    break;
     
    85088536
    85098537/* Line 1806 of yacc.c  */
    8510 #line 2470 "parser.yy"
     8538#line 2473 "parser.yy"
    85118539    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    85128540    break;
     
    85158543
    85168544/* Line 1806 of yacc.c  */
    8517 #line 2472 "parser.yy"
     8545#line 2475 "parser.yy"
    85188546    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    85198547    break;
     
    85228550
    85238551/* Line 1806 of yacc.c  */
    8524 #line 2477 "parser.yy"
     8552#line 2480 "parser.yy"
    85258553    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    85268554    break;
     
    85298557
    85308558/* Line 1806 of yacc.c  */
    8531 #line 2479 "parser.yy"
     8559#line 2482 "parser.yy"
    85328560    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    85338561    break;
     
    85368564
    85378565/* Line 1806 of yacc.c  */
    8538 #line 2484 "parser.yy"
     8566#line 2487 "parser.yy"
    85398567    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    85408568    break;
     
    85438571
    85448572/* Line 1806 of yacc.c  */
    8545 #line 2486 "parser.yy"
     8573#line 2489 "parser.yy"
    85468574    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    85478575    break;
     
    85508578
    85518579/* Line 1806 of yacc.c  */
    8552 #line 2501 "parser.yy"
     8580#line 2504 "parser.yy"
    85538581    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85548582    break;
     
    85578585
    85588586/* Line 1806 of yacc.c  */
    8559 #line 2503 "parser.yy"
     8587#line 2506 "parser.yy"
    85608588    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85618589    break;
     
    85648592
    85658593/* Line 1806 of yacc.c  */
    8566 #line 2508 "parser.yy"
     8594#line 2511 "parser.yy"
    85678595    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    85688596    break;
     
    85718599
    85728600/* Line 1806 of yacc.c  */
    8573 #line 2510 "parser.yy"
     8601#line 2513 "parser.yy"
    85748602    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    85758603    break;
     
    85788606
    85798607/* Line 1806 of yacc.c  */
    8580 #line 2512 "parser.yy"
     8608#line 2515 "parser.yy"
    85818609    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    85828610    break;
     
    85858613
    85868614/* Line 1806 of yacc.c  */
    8587 #line 2514 "parser.yy"
     8615#line 2517 "parser.yy"
    85888616    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    85898617    break;
     
    85928620
    85938621/* Line 1806 of yacc.c  */
    8594 #line 2516 "parser.yy"
     8622#line 2519 "parser.yy"
    85958623    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    85968624    break;
     
    85998627
    86008628/* Line 1806 of yacc.c  */
    8601 #line 2522 "parser.yy"
     8629#line 2525 "parser.yy"
    86028630    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    86038631    break;
     
    86068634
    86078635/* Line 1806 of yacc.c  */
    8608 #line 2524 "parser.yy"
     8636#line 2527 "parser.yy"
    86098637    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    86108638    break;
     
    86138641
    86148642/* Line 1806 of yacc.c  */
    8615 #line 2526 "parser.yy"
     8643#line 2529 "parser.yy"
    86168644    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86178645    break;
     
    86208648
    86218649/* Line 1806 of yacc.c  */
    8622 #line 2531 "parser.yy"
     8650#line 2534 "parser.yy"
    86238651    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    86248652    break;
     
    86278655
    86288656/* Line 1806 of yacc.c  */
    8629 #line 2533 "parser.yy"
     8657#line 2536 "parser.yy"
    86308658    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    86318659    break;
     
    86348662
    86358663/* Line 1806 of yacc.c  */
    8636 #line 2535 "parser.yy"
     8664#line 2538 "parser.yy"
    86378665    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86388666    break;
     
    86418669
    86428670/* Line 1806 of yacc.c  */
    8643 #line 2541 "parser.yy"
     8671#line 2544 "parser.yy"
    86448672    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    86458673    break;
     
    86488676
    86498677/* Line 1806 of yacc.c  */
    8650 #line 2543 "parser.yy"
     8678#line 2546 "parser.yy"
    86518679    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); }
    86528680    break;
     
    86558683
    86568684/* Line 1806 of yacc.c  */
    8657 #line 2549 "parser.yy"
     8685#line 2552 "parser.yy"
    86588686    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); }
    86598687    break;
     
    86628690
    86638691/* Line 1806 of yacc.c  */
    8664 #line 2551 "parser.yy"
     8692#line 2554 "parser.yy"
    86658693    { (yyval.decl) = DeclarationNode::newVarArray( 0 ); }
    86668694    break;
     
    86698697
    86708698/* Line 1806 of yacc.c  */
    8671 #line 2553 "parser.yy"
     8699#line 2556 "parser.yy"
    86728700    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); }
    86738701    break;
     
    86768704
    86778705/* Line 1806 of yacc.c  */
    8678 #line 2555 "parser.yy"
     8706#line 2558 "parser.yy"
    86798707    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); }
    86808708    break;
     
    86838711
    86848712/* Line 1806 of yacc.c  */
    8685 #line 2570 "parser.yy"
     8713#line 2573 "parser.yy"
    86868714    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    86878715    break;
     
    86908718
    86918719/* Line 1806 of yacc.c  */
    8692 #line 2572 "parser.yy"
     8720#line 2575 "parser.yy"
    86938721    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    86948722    break;
     
    86978725
    86988726/* Line 1806 of yacc.c  */
    8699 #line 2577 "parser.yy"
     8727#line 2580 "parser.yy"
    87008728    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    87018729    break;
     
    87048732
    87058733/* Line 1806 of yacc.c  */
    8706 #line 2579 "parser.yy"
     8734#line 2582 "parser.yy"
    87078735    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    87088736    break;
     
    87118739
    87128740/* Line 1806 of yacc.c  */
    8713 #line 2581 "parser.yy"
     8741#line 2584 "parser.yy"
    87148742    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    87158743    break;
     
    87188746
    87198747/* Line 1806 of yacc.c  */
    8720 #line 2583 "parser.yy"
     8748#line 2586 "parser.yy"
    87218749    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    87228750    break;
     
    87258753
    87268754/* Line 1806 of yacc.c  */
    8727 #line 2585 "parser.yy"
     8755#line 2588 "parser.yy"
    87288756    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87298757    break;
     
    87328760
    87338761/* Line 1806 of yacc.c  */
    8734 #line 2591 "parser.yy"
     8762#line 2594 "parser.yy"
    87358763    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87368764    break;
     
    87398767
    87408768/* Line 1806 of yacc.c  */
    8741 #line 2593 "parser.yy"
     8769#line 2596 "parser.yy"
    87428770    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87438771    break;
     
    87468774
    87478775/* Line 1806 of yacc.c  */
    8748 #line 2595 "parser.yy"
     8776#line 2598 "parser.yy"
    87498777    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87508778    break;
     
    87538781
    87548782/* Line 1806 of yacc.c  */
    8755 #line 2600 "parser.yy"
     8783#line 2603 "parser.yy"
    87568784    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    87578785    break;
     
    87608788
    87618789/* Line 1806 of yacc.c  */
    8762 #line 2602 "parser.yy"
     8790#line 2605 "parser.yy"
    87638791    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    87648792    break;
     
    87678795
    87688796/* Line 1806 of yacc.c  */
    8769 #line 2604 "parser.yy"
     8797#line 2607 "parser.yy"
    87708798    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87718799    break;
     
    87748802
    87758803/* Line 1806 of yacc.c  */
    8776 #line 2611 "parser.yy"
     8804#line 2614 "parser.yy"
    87778805    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    87788806    break;
     
    87818809
    87828810/* Line 1806 of yacc.c  */
    8783 #line 2622 "parser.yy"
     8811#line 2625 "parser.yy"
    87848812    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    87858813    break;
     
    87888816
    87898817/* Line 1806 of yacc.c  */
    8790 #line 2625 "parser.yy"
     8818#line 2628 "parser.yy"
    87918819    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    87928820    break;
     
    87958823
    87968824/* Line 1806 of yacc.c  */
    8797 #line 2627 "parser.yy"
     8825#line 2630 "parser.yy"
    87988826    { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); }
    87998827    break;
     
    88028830
    88038831/* Line 1806 of yacc.c  */
    8804 #line 2630 "parser.yy"
     8832#line 2633 "parser.yy"
    88058833    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    88068834    break;
     
    88098837
    88108838/* Line 1806 of yacc.c  */
    8811 #line 2632 "parser.yy"
     8839#line 2635 "parser.yy"
    88128840    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); }
    88138841    break;
     
    88168844
    88178845/* Line 1806 of yacc.c  */
    8818 #line 2634 "parser.yy"
     8846#line 2637 "parser.yy"
    88198847    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); }
    88208848    break;
     
    88238851
    88248852/* Line 1806 of yacc.c  */
    8825 #line 2648 "parser.yy"
     8853#line 2651 "parser.yy"
    88268854    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    88278855    break;
     
    88308858
    88318859/* Line 1806 of yacc.c  */
    8832 #line 2650 "parser.yy"
     8860#line 2653 "parser.yy"
    88338861    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    88348862    break;
     
    88378865
    88388866/* Line 1806 of yacc.c  */
    8839 #line 2655 "parser.yy"
     8867#line 2658 "parser.yy"
    88408868    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    88418869    break;
     
    88448872
    88458873/* Line 1806 of yacc.c  */
    8846 #line 2657 "parser.yy"
     8874#line 2660 "parser.yy"
    88478875    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    88488876    break;
     
    88518879
    88528880/* Line 1806 of yacc.c  */
    8853 #line 2659 "parser.yy"
     8881#line 2662 "parser.yy"
    88548882    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    88558883    break;
     
    88588886
    88598887/* Line 1806 of yacc.c  */
    8860 #line 2661 "parser.yy"
     8888#line 2664 "parser.yy"
    88618889    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    88628890    break;
     
    88658893
    88668894/* Line 1806 of yacc.c  */
    8867 #line 2663 "parser.yy"
     8895#line 2666 "parser.yy"
    88688896    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88698897    break;
     
    88728900
    88738901/* Line 1806 of yacc.c  */
    8874 #line 2669 "parser.yy"
     8902#line 2672 "parser.yy"
    88758903    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    88768904    break;
     
    88798907
    88808908/* Line 1806 of yacc.c  */
    8881 #line 2671 "parser.yy"
     8909#line 2674 "parser.yy"
    88828910    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    88838911    break;
     
    88868914
    88878915/* Line 1806 of yacc.c  */
    8888 #line 2673 "parser.yy"
     8916#line 2676 "parser.yy"
    88898917    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88908918    break;
     
    88938921
    88948922/* Line 1806 of yacc.c  */
    8895 #line 2678 "parser.yy"
     8923#line 2681 "parser.yy"
    88968924    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    88978925    break;
     
    89008928
    89018929/* Line 1806 of yacc.c  */
    8902 #line 2680 "parser.yy"
     8930#line 2683 "parser.yy"
    89038931    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    89048932    break;
     
    89078935
    89088936/* Line 1806 of yacc.c  */
    8909 #line 2690 "parser.yy"
     8937#line 2693 "parser.yy"
    89108938    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    89118939    break;
     
    89148942
    89158943/* Line 1806 of yacc.c  */
    8916 #line 2700 "parser.yy"
     8944#line 2703 "parser.yy"
    89178945    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89188946    break;
     
    89218949
    89228950/* Line 1806 of yacc.c  */
    8923 #line 2702 "parser.yy"
     8951#line 2705 "parser.yy"
    89248952    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89258953    break;
     
    89288956
    89298957/* Line 1806 of yacc.c  */
    8930 #line 2704 "parser.yy"
     8958#line 2707 "parser.yy"
    89318959    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89328960    break;
     
    89358963
    89368964/* Line 1806 of yacc.c  */
    8937 #line 2706 "parser.yy"
     8965#line 2709 "parser.yy"
    89388966    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89398967    break;
     
    89428970
    89438971/* Line 1806 of yacc.c  */
    8944 #line 2708 "parser.yy"
     8972#line 2711 "parser.yy"
    89458973    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89468974    break;
     
    89498977
    89508978/* Line 1806 of yacc.c  */
    8951 #line 2710 "parser.yy"
     8979#line 2713 "parser.yy"
    89528980    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89538981    break;
     
    89568984
    89578985/* Line 1806 of yacc.c  */
    8958 #line 2717 "parser.yy"
     8986#line 2720 "parser.yy"
    89598987    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89608988    break;
     
    89638991
    89648992/* Line 1806 of yacc.c  */
    8965 #line 2719 "parser.yy"
     8993#line 2722 "parser.yy"
    89668994    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    89678995    break;
     
    89708998
    89718999/* Line 1806 of yacc.c  */
    8972 #line 2721 "parser.yy"
     9000#line 2724 "parser.yy"
    89739001    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89749002    break;
     
    89779005
    89789006/* Line 1806 of yacc.c  */
    8979 #line 2723 "parser.yy"
     9007#line 2726 "parser.yy"
    89809008    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    89819009    break;
     
    89849012
    89859013/* Line 1806 of yacc.c  */
    8986 #line 2725 "parser.yy"
     9014#line 2728 "parser.yy"
    89879015    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    89889016    break;
     
    89919019
    89929020/* Line 1806 of yacc.c  */
    8993 #line 2728 "parser.yy"
     9021#line 2731 "parser.yy"
    89949022    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89959023    break;
     
    89989026
    89999027/* Line 1806 of yacc.c  */
    9000 #line 2730 "parser.yy"
     9028#line 2733 "parser.yy"
    90019029    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    90029030    break;
     
    90059033
    90069034/* Line 1806 of yacc.c  */
    9007 #line 2732 "parser.yy"
     9035#line 2735 "parser.yy"
    90089036    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    90099037    break;
     
    90129040
    90139041/* Line 1806 of yacc.c  */
    9014 #line 2734 "parser.yy"
     9042#line 2737 "parser.yy"
    90159043    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    90169044    break;
     
    90199047
    90209048/* Line 1806 of yacc.c  */
    9021 #line 2736 "parser.yy"
     9049#line 2739 "parser.yy"
    90229050    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    90239051    break;
     
    90269054
    90279055/* Line 1806 of yacc.c  */
    9028 #line 2741 "parser.yy"
     9056#line 2744 "parser.yy"
    90299057    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    90309058    break;
     
    90339061
    90349062/* Line 1806 of yacc.c  */
    9035 #line 2743 "parser.yy"
     9063#line 2746 "parser.yy"
    90369064    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    90379065    break;
     
    90409068
    90419069/* Line 1806 of yacc.c  */
    9042 #line 2748 "parser.yy"
     9070#line 2751 "parser.yy"
    90439071    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); }
    90449072    break;
     
    90479075
    90489076/* Line 1806 of yacc.c  */
    9049 #line 2750 "parser.yy"
     9077#line 2753 "parser.yy"
    90509078    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); }
    90519079    break;
     
    90549082
    90559083/* Line 1806 of yacc.c  */
    9056 #line 2777 "parser.yy"
     9084#line 2780 "parser.yy"
    90579085    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    90589086    break;
     
    90619089
    90629090/* Line 1806 of yacc.c  */
    9063 #line 2788 "parser.yy"
     9091#line 2791 "parser.yy"
    90649092    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90659093    break;
     
    90689096
    90699097/* Line 1806 of yacc.c  */
    9070 #line 2790 "parser.yy"
     9098#line 2793 "parser.yy"
    90719099    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90729100    break;
     
    90759103
    90769104/* Line 1806 of yacc.c  */
    9077 #line 2792 "parser.yy"
     9105#line 2795 "parser.yy"
    90789106    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90799107    break;
     
    90829110
    90839111/* Line 1806 of yacc.c  */
    9084 #line 2794 "parser.yy"
     9112#line 2797 "parser.yy"
    90859113    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90869114    break;
     
    90899117
    90909118/* Line 1806 of yacc.c  */
    9091 #line 2796 "parser.yy"
     9119#line 2799 "parser.yy"
    90929120    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90939121    break;
     
    90969124
    90979125/* Line 1806 of yacc.c  */
    9098 #line 2798 "parser.yy"
     9126#line 2801 "parser.yy"
    90999127    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    91009128    break;
     
    91039131
    91049132/* Line 1806 of yacc.c  */
    9105 #line 2805 "parser.yy"
     9133#line 2808 "parser.yy"
    91069134    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91079135    break;
     
    91109138
    91119139/* Line 1806 of yacc.c  */
    9112 #line 2807 "parser.yy"
     9140#line 2810 "parser.yy"
    91139141    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91149142    break;
     
    91179145
    91189146/* Line 1806 of yacc.c  */
    9119 #line 2809 "parser.yy"
     9147#line 2812 "parser.yy"
    91209148    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    91219149    break;
     
    91249152
    91259153/* Line 1806 of yacc.c  */
    9126 #line 2811 "parser.yy"
     9154#line 2814 "parser.yy"
    91279155    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91289156    break;
     
    91319159
    91329160/* Line 1806 of yacc.c  */
    9133 #line 2813 "parser.yy"
     9161#line 2816 "parser.yy"
    91349162    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91359163    break;
     
    91389166
    91399167/* Line 1806 of yacc.c  */
    9140 #line 2815 "parser.yy"
     9168#line 2818 "parser.yy"
    91419169    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    91429170    break;
     
    91459173
    91469174/* Line 1806 of yacc.c  */
    9147 #line 2820 "parser.yy"
     9175#line 2823 "parser.yy"
    91489176    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    91499177    break;
     
    91529180
    91539181/* Line 1806 of yacc.c  */
    9154 #line 2825 "parser.yy"
     9182#line 2828 "parser.yy"
    91559183    { (yyval.decl) = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), (yyvsp[(4) - (5)].decl), nullptr ); }
    91569184    break;
     
    91599187
    91609188/* Line 1806 of yacc.c  */
    9161 #line 2827 "parser.yy"
     9189#line 2830 "parser.yy"
    91629190    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91639191    break;
     
    91669194
    91679195/* Line 1806 of yacc.c  */
    9168 #line 2829 "parser.yy"
     9196#line 2832 "parser.yy"
    91699197    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91709198    break;
     
    91739201
    91749202/* Line 1806 of yacc.c  */
    9175 #line 2853 "parser.yy"
     9203#line 2856 "parser.yy"
    91769204    { (yyval.en) = 0; }
    91779205    break;
     
    91809208
    91819209/* Line 1806 of yacc.c  */
    9182 #line 2855 "parser.yy"
     9210#line 2858 "parser.yy"
    91839211    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    91849212    break;
     
    91879215
    91889216/* Line 1806 of yacc.c  */
    9189 #line 9190 "Parser/parser.cc"
     9217#line 9218 "Parser/parser.cc"
    91909218      default: break;
    91919219    }
     
    94189446
    94199447/* Line 2067 of yacc.c  */
    9420 #line 2858 "parser.yy"
     9448#line 2861 "parser.yy"
    94219449
    94229450// ----end of grammar----
  • src/Parser/parser.yy

    rfe7b281 ra1e67dd  
    195195
    196196%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    197 %type<en> field field_list
    198 %type<tok> field_name
     197%type<en> field field_list field_name
    199198
    200199%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    379378                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    380379        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     380                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    381381        | postfix_expression '.' INTEGERconstant
     382                { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
    382383        | postfix_expression ARROW no_attr_identifier
    383384                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    384385        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     386                        { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    385387        | postfix_expression ICR
    386388                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     
    418420                // ambiguity with .0 so space required after field-selection, e.g.
    419421                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    420                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
    421422        | field_name '.' field
    422                 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     423                { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    423424        | field_name '.' '[' push field_list pop ']'
    424                 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
     425                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    425426        | field_name ARROW field
    426                 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
     427                { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    427428        | field_name ARROW '[' push field_list pop ']'
    428                 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     429                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    429430        ;
    430431
    431432field_name:
    432433        no_attr_identifier
     434                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    433435                // x.1, x.[0, 0.0]
    434436        | INTEGERconstant
     437                { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }
    435438        ;
    436439
  • src/ResolvExpr/Alternative.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Alternative.cc -- 
     7// Alternative.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1212// Last Modified On : Sat May 16 23:54:23 2015
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#include "Alternative.h"
     
    2020
    2121namespace ResolvExpr {
    22         Alternative::Alternative() : expr( 0 ) {}
     22        Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {}
    2323
    2424        Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
     
    3535                if ( &other == this ) return *this;
    3636                initialize( other, *this );
     37                return *this;
     38        }
     39
     40        Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) {
     41                other.expr = nullptr;
     42        }
     43
     44        Alternative & Alternative::operator=( Alternative && other ) {
     45                if ( &other == this )  return *this;
     46                delete expr;
     47                cost = other.cost;
     48                cvtCost = other.cvtCost;
     49                expr = other.expr;
     50                env = other.env;
     51                other.expr = nullptr;
    3752                return *this;
    3853        }
     
    5469                        expr->print( os, indent );
    5570                        os << "(types:" << std::endl;
    56                         printAll( expr->get_results(), os, indent + 4 );
    57                         os << ")" << std::endl;
     71                        os << std::string( indent+4, ' ' );
     72                        expr->get_result()->print( os, indent + 4 );
     73                        os << std::endl << ")" << std::endl;
    5874                } else {
    5975                        os << "Null expression!" << std::endl;
  • src/ResolvExpr/Alternative.h

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Alternative.h -- 
     7// Alternative.h --
    88//
    99// Author           : Richard C. Bilson
     
    1212// Last Modified On : Sat May 16 23:54:39 2015
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#ifndef ALTERNATIVE_H
     
    3232                Alternative( const Alternative &other );
    3333                Alternative &operator=( const Alternative &other );
     34                Alternative( Alternative && other );
     35                Alternative &operator=( Alternative && other );
    3436                ~Alternative();
    35  
     37
    3638                void initialize( const Alternative &src, Alternative &dest );
    37  
     39
    3840                void print( std::ostream &os, int indent = 0 ) const;
    39  
     41
    4042                Cost cost;
    4143                Cost cvtCost;
  • src/ResolvExpr/AlternativeFinder.cc

    rfe7b281 ra1e67dd  
    3838#include "SynTree/TypeSubstitution.h"
    3939#include "SymTab/Validate.h"
    40 #include "Tuples/TupleAssignment.h"
    41 #include "Tuples/NameMatcher.h"
     40#include "Tuples/Tuples.h"
    4241#include "Common/utility.h"
    4342#include "InitTweak/InitTweak.h"
     
    6463        }
    6564
     65        Cost sumCost( const AltList &in ) {
     66                Cost total;
     67                for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) {
     68                        total += i->cost;
     69                }
     70                return total;
     71        }
     72
    6673        namespace {
    6774                void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) {
     
    7683                                out.push_back( i->expr->clone() );
    7784                        }
    78                 }
    79 
    80                 Cost sumCost( const AltList &in ) {
    81                         Cost total;
    82                         for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) {
    83                                 total += i->cost;
    84                         }
    85                         return total;
    8685                }
    8786
     
    101100                                PruneStruct current( candidate );
    102101                                std::string mangleName;
    103                                 for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ) {
    104                                         Type *newType = (*retType)->clone();
     102                                {
     103                                        Type * newType = candidate->expr->get_result()->clone();
    105104                                        candidate->env.apply( newType );
    106                                         mangleName += SymTab::Mangler::mangle( newType );
     105                                        mangleName = SymTab::Mangler::mangle( newType );
    107106                                        delete newType;
    108107                                }
     
    133132                                if ( ! target->second.isAmbiguous ) {
    134133                                        Alternative &alt = *target->second.candidate;
    135                                         for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) {
    136                                                 alt.env.applyFree( *result );
    137                                         }
     134                                        alt.env.applyFree( alt.expr->get_result() );
    138135                                        *out++ = alt;
    139136                                }
    140137                        }
    141 
    142                 }
    143 
    144                 template< typename InputIterator, typename OutputIterator >
    145                 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    146                         AltList alternatives;
    147 
    148                         // select the alternatives that have the minimum parameter cost
    149                         Cost minCost = Cost::infinity;
    150                         for ( AltList::iterator i = begin; i != end; ++i ) {
    151                                 if ( i->cost < minCost ) {
    152                                         minCost = i->cost;
    153                                         i->cost = i->cvtCost;
    154                                         alternatives.clear();
    155                                         alternatives.push_back( *i );
    156                                 } else if ( i->cost == minCost ) {
    157                                         i->cost = i->cvtCost;
    158                                         alternatives.push_back( *i );
    159                                 }
    160                         }
    161                         std::copy( alternatives.begin(), alternatives.end(), out );
    162                 }
    163 
    164                 template< typename InputIterator >
    165                 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
    166                         while ( begin != end ) {
    167                                 result.simpleCombine( (*begin++).env );
    168                         }
    169138                }
    170139
    171140                void renameTypes( Expression *expr ) {
    172                         for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
    173                                 (*i)->accept( global_renamer );
    174                         }
     141                        expr->get_result()->accept( global_renamer );
    175142                }
    176143        }
     
    204171                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    205172                        if ( adjust ) {
    206                                 adjustExprTypeList( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );
     173                                adjustExprType( i->expr->get_result(), i->env, indexer );
    207174                        }
    208175                }
     
    241208
    242209        template< typename StructOrUnionType >
    243         void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) {
     210        void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
     211
     212                // by this point, member must be a name expr
     213                NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member );
     214                const std::string & name = nameExpr->get_name();
    244215                std::list< Declaration* > members;
    245216                aggInst->lookup( name, members );
     
    254225        }
    255226
     227        void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
     228                if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) {
     229                        // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning
     230                        // xxx - this should be improved by memoizing the value of constant exprs
     231                        // during parsing and reusing that information here.
     232                        std::stringstream ss( constantExpr->get_constant()->get_value() );
     233                        int val;
     234                        std::string tmp;
     235                        if ( ss >> val && ! (ss >> tmp) ) {
     236                                if ( val >= 0 && (unsigned int)val < tupleType->size() ) {
     237                                        alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
     238                                } // if
     239                        } // if
     240                } // if
     241        }
     242
    256243        void AlternativeFinder::visit( ApplicationExpr *applicationExpr ) {
    257244                alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) );
     
    259246
    260247        Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) {
    261                 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( alt.expr );
    262                 assert( appExpr );
    263                 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    264                 assert( pointer );
    265                 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    266                 assert( function );
     248                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr );
     249                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     250                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    267251
    268252                Cost convCost( 0, 0, 0 );
     
    270254                std::list< DeclarationWithType* >::iterator formal = formals.begin();
    271255                std::list< Expression* >& actuals = appExpr->get_args();
     256
     257                std::list< Type * > formalTypes;
     258                std::list< Type * >::iterator formalType = formalTypes.end();
     259
    272260                for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
     261
    273262                        PRINT(
    274263                                std::cerr << "actual expression:" << std::endl;
    275264                                (*actualExpr)->print( std::cerr, 8 );
    276265                                std::cerr << "--- results are" << std::endl;
    277                                 printAll( (*actualExpr)->get_results(), std::cerr, 8 );
     266                                (*actualExpr)->get_result()->print( std::cerr, 8 );
    278267                        )
    279268                        std::list< DeclarationWithType* >::iterator startFormal = formal;
    280269                        Cost actualCost;
    281                         for ( std::list< Type* >::iterator actual = (*actualExpr)->get_results().begin(); actual != (*actualExpr)->get_results().end(); ++actual ) {
    282                                 if ( formal == formals.end() ) {
    283                                         if ( function->get_isVarArgs() ) {
    284                                                 convCost += Cost( 1, 0, 0 );
    285                                                 break;
    286                                         } else {
    287                                                 return Cost::infinity;
     270                        std::list< Type * > flatActualTypes;
     271                        flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) );
     272                        for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) {
     273
     274
     275                                // tuple handling code
     276                                if ( formalType == formalTypes.end() ) {
     277                                        // the type of the formal parameter may be a tuple type. To make this easier to work with,
     278                                        // flatten the tuple type and traverse the resulting list of types, incrementing the formal
     279                                        // iterator once its types have been extracted. Once a particular formal parameter's type has
     280                                        // been exhausted load the next formal parameter's type.
     281                                        if ( formal == formals.end() ) {
     282                                                if ( function->get_isVarArgs() ) {
     283                                                        convCost += Cost( 1, 0, 0 );
     284                                                        break;
     285                                                } else {
     286                                                        return Cost::infinity;
     287                                                }
    288288                                        }
     289                                        formalTypes.clear();
     290                                        flatten( (*formal)->get_type(), back_inserter( formalTypes ) );
     291                                        formalType = formalTypes.begin();
     292                                        ++formal;
    289293                                }
     294
    290295                                PRINT(
    291296                                        std::cerr << std::endl << "converting ";
    292                                         (*actual)->print( std::cerr, 8 );
     297                                        (*actualType)->print( std::cerr, 8 );
    293298                                        std::cerr << std::endl << " to ";
    294299                                        (*formal)->get_type()->print( std::cerr, 8 );
    295300                                )
    296                                 Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env );
     301                                Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env );
    297302                                PRINT(
    298303                                        std::cerr << std::endl << "cost is" << newCost << std::endl;
     
    305310                                actualCost += newCost;
    306311
    307                                 convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );
    308 
    309                                 formal++;
     312                                convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 );
     313
     314                                formalType++;
    310315                        }
    311316                        if ( actualCost != Cost( 0, 0, 0 ) ) {
     
    356361        /// Adds type variables to the open variable set and marks their assertions
    357362        void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) {
    358                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     363                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    359364                        unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();
    360365                        for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {
     
    365370        }
    366371
    367         bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) {
     372        /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType,
     373        /// producing expression(s) in out and their total cost in cost.
     374        template< typename AltIterator, typename OutputIterator >
     375        bool instantiateArgument( Type * formalType, Initializer * defaultValue, AltIterator & actualIt, AltIterator actualEnd, OpenVarSet & openVars, TypeEnvironment & resultEnv, AssertionSet & resultNeed, AssertionSet & resultHave, const SymTab::Indexer & indexer, Cost & cost, OutputIterator out ) {
     376                if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) {
     377                        // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType
     378                        TupleExpr * tupleExpr = new TupleExpr();
     379                        for ( Type * type : *tupleType ) {
     380                                if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) {
     381                                        delete tupleExpr;
     382                                        return false;
     383                                }
     384                        }
     385                        tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) );
     386                        *out++ = tupleExpr;
     387                } else if ( actualIt != actualEnd ) {
     388                        // both actualType and formalType are atomic (non-tuple) types - if they unify
     389                        // then accept actual as an argument, otherwise return false (fail to instantiate argument)
     390                        Expression * actual = actualIt->expr;
     391                        Type * actualType = actual->get_result();
     392                        PRINT(
     393                                std::cerr << "formal type is ";
     394                                formalType->print( std::cerr );
     395                                std::cerr << std::endl << "actual type is ";
     396                                actualType->print( std::cerr );
     397                                std::cerr << std::endl;
     398                        )
     399                        if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
     400                                return false;
     401                        }
     402                        // move the expression from the alternative to the output iterator
     403                        *out++ = actual;
     404                        actualIt->expr = nullptr;
     405                        cost += actualIt->cost;
     406                        ++actualIt;
     407                } else {
     408                        // End of actuals - Handle default values
     409                        if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) {
     410                                // so far, only constant expressions are accepted as default values
     411                                if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) {
     412                                        if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) {
     413                                                if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
     414                                                        // xxx - Don't know if this is right
     415                                                        *out++ = cnstexpr->clone();
     416                                                        return true;
     417                                                } // if
     418                                        } // if
     419                                } // if
     420                        } // if
     421                        return false;
     422                } // if
     423                return true;
     424        }
     425
     426        bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) {
    368427                simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv );
    369428                // make sure we don't widen any existing bindings
     
    373432                resultEnv.extractOpenVars( openVars );
    374433
    375                 /*
    376                   Tuples::NameMatcher matcher( formals );
    377                   try {
    378                   matcher.match( actuals );
    379                   } catch ( Tuples::NoMatch &e ) {
    380                   std::cerr << "Alternative doesn't match: " << e.message << std::endl;
    381                   }
    382                 */
    383                 std::list< DeclarationWithType* >::iterator formal = formals.begin();
    384                 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
    385                         for ( std::list< Type* >::iterator actual = actualExpr->expr->get_results().begin(); actual != actualExpr->expr->get_results().end(); ++actual ) {
    386                                 if ( formal == formals.end() ) {
    387                                         return isVarArgs;
    388                                 }
    389                                 PRINT(
    390                                         std::cerr << "formal type is ";
    391                                         (*formal)->get_type()->print( std::cerr );
    392                                         std::cerr << std::endl << "actual type is ";
    393                                         (*actual)->print( std::cerr );
    394                                         std::cerr << std::endl;
    395                                 )
    396                                 if ( ! unify( (*formal)->get_type(), *actual, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    397                                         return false;
    398                                 }
    399                                 formal++;
    400                         }
    401                 }
    402                 // Handling of default values
    403                 while ( formal != formals.end() ) {
    404                         if ( ObjectDecl *od = dynamic_cast<ObjectDecl *>( *formal ) )
    405                                 if ( SingleInit *si = dynamic_cast<SingleInit *>( od->get_init() ))
    406                                         // so far, only constant expressions are accepted as default values
    407                                         if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) )
    408                                                 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) )
    409                                                         if ( unify( (*formal)->get_type(), cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    410                                                                 // XXX Don't know if this is right
    411                                                                 actuals.push_back( Alternative( cnstexpr->clone(), env, Cost::zero ) );
    412                                                                 formal++;
    413                                                                 if ( formal == formals.end()) break;
    414                                                         }
    415                         return false;
     434                // flatten actuals so that each actual has an atomic (non-tuple) type
     435                AltList exploded;
     436                Tuples::explode( actuals, back_inserter( exploded ) );
     437
     438                AltList::iterator actualExpr = exploded.begin();
     439                AltList::iterator actualEnd = exploded.end();
     440                for ( DeclarationWithType * formal : formals ) {
     441                        // match flattened actuals with formal parameters - actuals will be grouped to match
     442                        // with formals as appropriate
     443                        Cost cost;
     444                        std::list< Expression * > newExprs;
     445                        ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal );
     446                        if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) {
     447                                deleteAll( newExprs );
     448                                return false;
     449                        }
     450                        // success - produce argument as a new alternative
     451                        assert( newExprs.size() == 1 );
     452                        out.push_back( Alternative( newExprs.front(), resultEnv, cost ) );
     453                }
     454                if ( actualExpr != actualEnd ) {
     455                        // there are still actuals remaining, but we've run out of formal parameters to match against
     456                        // this is okay only if the function is variadic
     457                        if ( ! isVarArgs ) {
     458                                return false;
     459                        }
     460                        out.splice( out.end(), exploded, actualExpr, actualEnd );
    416461                }
    417462                return true;
     
    500545                                //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    501546                                Expression *varExpr = new VariableExpr( candDecl );
    502                                 deleteAll( varExpr->get_results() );
    503                                 varExpr->get_results().clear();
    504                                 varExpr->get_results().push_front( adjType->clone() );
     547                                delete varExpr->get_result();
     548                                varExpr->set_result( adjType->clone() );
    505549                                PRINT(
    506550                                        std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
     
    545589
    546590        template< typename OutputIterator >
    547         void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {
     591        void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) {
    548592                OpenVarSet openVars;
    549593                AssertionSet resultNeed, resultHave;
    550594                TypeEnvironment resultEnv;
    551595                makeUnifiableVars( funcType, openVars, resultNeed );
    552                 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) {
     596                AltList instantiatedActuals; // filled by instantiate function
     597                if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) {
    553598                        ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() );
    554                         Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt ) );
    555                         makeExprList( actualAlt, appExpr->get_args() );
     599                        Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) );
     600                        makeExprList( instantiatedActuals, appExpr->get_args() );
    556601                        PRINT(
    557602                                std::cerr << "need assertions:" << std::endl;
     
    574619                                PointerType pt( Type::Qualifiers(), v.clone() );
    575620                                UntypedExpr *vexpr = untypedExpr->clone();
    576                                 vexpr->get_results().push_front( pt.clone() );
     621                                vexpr->set_result( pt.clone() );
    577622                                alternatives.push_back( Alternative( vexpr, env, Cost()) );
    578623                                return;
     
    587632                combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) );
    588633
    589                 Tuples::TupleAssignSpotter tassign( this );
    590                 if ( tassign.isTupleAssignment( untypedExpr, possibilities ) ) {
    591                         // take care of possible tuple assignments, or discard expression
    592                         return;
    593                 } // else ...
     634                // take care of possible tuple assignments
     635                // if not tuple assignment, assignment is taken care of as a normal function call
     636                Tuples::handleTupleAssignment( *this, untypedExpr, possibilities );
    594637
    595638                AltList candidates;
     
    604647                                // check if the type is pointer to function
    605648                                PointerType *pointer;
    606                                 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {
     649                                if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) {
    607650                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    608651                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    640683                                                // check if the type is pointer to function
    641684                                                PointerType *pointer;
    642                                                 if ( funcOp->expr->get_results().size() == 1
    643                                                         && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) {
     685                                                if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) {
    644686                                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    645687                                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    665707
    666708                        PRINT(
    667                                 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( withFunc->expr );
    668                                 assert( appExpr );
    669                                 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    670                                 assert( pointer );
    671                                 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    672                                 assert( function );
     709                                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr );
     710                                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     711                                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    673712                                std::cerr << "Case +++++++++++++" << std::endl;
    674713                                std::cerr << "formals are:" << std::endl;
     
    692731
    693732        bool isLvalue( Expression *expr ) {
    694                 for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
    695                         if ( !(*i)->get_isLvalue() ) return false;
    696                 } // for
    697                 return true;
     733                // xxx - recurse into tuples?
     734                return expr->has_result() && expr->get_result()->get_isLvalue();
    698735        }
    699736
     
    709746
    710747        void AlternativeFinder::visit( CastExpr *castExpr ) {
    711                 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) {
    712                         *i = resolveTypeof( *i, indexer );
    713                         SymTab::validateType( *i, &indexer );
    714                         adjustExprType( *i, env, indexer );
    715                 } // for
     748                Type *& toType = castExpr->get_result();
     749                toType = resolveTypeof( toType, indexer );
     750                SymTab::validateType( toType, &indexer );
     751                adjustExprType( toType, env, indexer );
    716752
    717753                AlternativeFinder finder( indexer, env );
     
    727763                        // that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
    728764                        // to.
    729                         int discardedValues = (*i).expr->get_results().size() - castExpr->get_results().size();
     765                        int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size();
    730766                        if ( discardedValues < 0 ) continue;
    731                         std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin();
    732                         std::advance( candidate_end, castExpr->get_results().size() );
     767                        // xxx - may need to go into tuple types and extract relavent types and use unifyList
    733768                        // unification run for side-effects
    734                         unifyList( castExpr->get_results().begin(), castExpr->get_results().end(),
    735                                            (*i).expr->get_results().begin(), candidate_end,
    736                                    i->env, needAssertions, haveAssertions, openVars, indexer );
    737                         Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end,
    738                                                                                   castExpr->get_results().begin(), castExpr->get_results().end(),
    739                                                                                   indexer, i->env );
     769                        unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer );
     770                        Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env );
    740771                        if ( thisCost != Cost::infinity ) {
    741772                                // count one safe conversion for each value that is thrown away
     
    760791
    761792                for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) {
    762                         if ( agg->expr->get_results().size() == 1 ) {
    763                                 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) {
    764                                         addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    765                                 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) {
    766                                         addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    767                                 } // if
     793                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) {
     794                                addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     795                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) {
     796                                addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     797                        } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) {
     798                                addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    768799                        } // if
    769800                } // for
     
    791822                        renameTypes( alternatives.back().expr );
    792823                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) {
    793                                 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
     824                                NameExpr nameExpr( "" );
     825                                addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
    794826                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) {
    795                                 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
     827                                NameExpr nameExpr( "" );
     828                                addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
    796829                        } // if
    797830                } // for
     
    894927                        alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) );
    895928                        for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    896                                 alternatives.back().expr->get_results().push_back( (*i)->get_type()->clone() );
     929                                alternatives.back().expr->set_result( (*i)->get_type()->clone() );
    897930                        } // for
    898931                } // if
     
    917950                                                        finder.find( attrExpr->get_expr() );
    918951                                                        for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    919                                                                 if ( choice->expr->get_results().size() == 1 ) {
    920                                                                         resolveAttr(*i, function, choice->expr->get_results().front(), choice->env );
     952                                                                if ( choice->expr->get_result()->size() == 1 ) {
     953                                                                        resolveAttr(*i, function, choice->expr->get_result(), choice->env );
    921954                                                                } // fi
    922955                                                        } // for
     
    960993                                        AssertionSet needAssertions, haveAssertions;
    961994                                        Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost );
    962                                         std::list< Type* > commonTypes;
    963                                         if ( unifyList( second->expr->get_results().begin(), second->expr->get_results().end(), third->expr->get_results().begin(), third->expr->get_results().end(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
     995                                        Type* commonType;
     996                                        if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    964997                                                ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() );
    965                                                 std::list< Type* >::const_iterator original = second->expr->get_results().begin();
    966                                                 std::list< Type* >::const_iterator commonType = commonTypes.begin();
    967                                                 for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) {
    968                                                         if ( *commonType ) {
    969                                                                 newExpr->get_results().push_back( *commonType );
    970                                                         } else {
    971                                                                 newExpr->get_results().push_back( (*original)->clone() );
    972                                                         } // if
    973                                                 } // for
     998                                                newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() );
    974999                                                newAlt.expr = newExpr;
    9751000                                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
     
    9991024                        TupleExpr *newExpr = new TupleExpr;
    10001025                        makeExprList( *i, newExpr->get_exprs() );
    1001                         for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) {
    1002                                 for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) {
    1003                                         newExpr->get_results().push_back( (*resultType)->clone() );
    1004                                 } // for
    1005                         } // for
     1026                        newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) );
    10061027
    10071028                        TypeEnvironment compositeEnv;
     
    10241045                }
    10251046        }
     1047
     1048        void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) {
     1049                alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
     1050        }
     1051
     1052        void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) {
     1053                alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );
     1054        }
     1055
     1056        void AlternativeFinder::visit( UniqueExpr *unqExpr ) {
     1057                AlternativeFinder finder( indexer, env );
     1058                finder.findWithAdjustment( unqExpr->get_expr() );
     1059                for ( Alternative & alt : finder.alternatives ) {
     1060                        // xxx - it's possible that this won't always do the right thing, i.e. two UniqueExprs
     1061                        // with the same ID may resolve to different expressions. If this ever happens, it might be necessary
     1062                        // to try to select an alternative here (i.e. error is there is not a unique min-cost expression).
     1063                        // One other thought is to to resolve each ID once and map the IDs to resolved expressions,
     1064                        // but this isn't as simple as it sounds since the alternative is not selected here, meaning it might
     1065                        // require complicated tracking throughout the system.
     1066
     1067                        // brand the new UniqueExprs with the same id so that they are recognized as the same expression by the expansion pass
     1068                        alternatives.push_back( Alternative( new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ), env, Cost::zero ) );
     1069                }
     1070        }
     1071
    10261072} // namespace ResolvExpr
    10271073
  • src/ResolvExpr/AlternativeFinder.h

    rfe7b281 ra1e67dd  
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    69           public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
     69                virtual void visit( TupleIndexExpr *tupleExpr );
     70                virtual void visit( TupleAssignExpr *tupleExpr );
     71                virtual void visit( UniqueExpr *unqExpr );
     72                /// Runs a new alternative finder on each element in [begin, end)
     73                /// and writes each alternative finder to out.
    7074                template< typename InputIterator, typename OutputIterator >
    7175                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    7276
    73           private:
    7477                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    75                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name );
     78                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     79                /// Adds alternatives for member expressions where the left side has tuple type
     80                void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
    7681                /// Adds alternatives for offsetof expressions, given the base type and name of the member
    7782                template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
    78                 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave );
     83                bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out );
    7984                template< typename OutputIterator >
    80                 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );
     85                void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out );
    8186                template< typename OutputIterator >
    8287                void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out );
     
    8994
    9095        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
     96
     97        template< typename InputIterator, typename OutputIterator >
     98        void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
     99                AltList alternatives;
     100
     101                // select the alternatives that have the minimum parameter cost
     102                Cost minCost = Cost::infinity;
     103                for ( InputIterator i = begin; i != end; ++i ) {
     104                        if ( i->cost < minCost ) {
     105                                minCost = i->cost;
     106                                i->cost = i->cvtCost;
     107                                alternatives.clear();
     108                                alternatives.push_back( *i );
     109                        } else if ( i->cost == minCost ) {
     110                                i->cost = i->cvtCost;
     111                                alternatives.push_back( *i );
     112                        }
     113                }
     114                std::copy( alternatives.begin(), alternatives.end(), out );
     115        }
     116
     117        Cost sumCost( const AltList &in );
     118
     119        template< typename InputIterator >
     120        void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
     121                while ( begin != end ) {
     122                        result.simpleCombine( (*begin++).env );
     123                }
     124        }
    91125} // namespace ResolvExpr
    92126
  • src/ResolvExpr/AlternativePrinter.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AlternativePrinter.cc -- 
     7// AlternativePrinter.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3333                for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    3434                        os << "Alternative " << count++ << " ==============" << std::endl;
    35                         printAll( i->expr->get_results(), os );
     35                        i->expr->get_result()->print( os );
    3636                        //    i->print( os );
    3737                        os << std::endl;
  • src/ResolvExpr/ConversionCost.cc

    rfe7b281 ra1e67dd  
    240240                        std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
    241241                        std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin();
    242                         while ( srcIt != tupleType->get_types().end() ) {
     242                        while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    243243                                Cost newCost = conversionCost( *srcIt++, *destIt++, indexer, env );
    244244                                if ( newCost == Cost::infinity ) {
  • src/ResolvExpr/FindOpenVars.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FindOpenVars.cc -- 
     7// FindOpenVars.cc --
    88//
    99// Author           : Richard C. Bilson
     
    4747        void FindOpenVars::common_action( Type *type ) {
    4848                if ( nextIsOpen ) {
    49                         for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     49                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    5050                                openVars[ (*i)->get_name() ] = (*i)->get_kind();
    5151                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
     
    5656                        }
    5757                } else {
    58                         for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     58                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    5959                                closedVars[ (*i)->get_name() ] = (*i)->get_kind();
    6060                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
  • src/ResolvExpr/RenameVars.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // RenameVars.cc -- 
     7// RenameVars.cc --
    88//
    99// Author           : Richard C. Bilson
     
    125125                        mapStack.push_front( mapStack.front() );
    126126                        // renames all "forall" type names to `_${level}_${name}'
    127                         for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     127                        for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    128128                                std::ostringstream output;
    129129                                output << "_" << level << "_" << (*i)->get_name();
  • src/ResolvExpr/ResolveTypeof.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ResolveTypeof.cc -- 
     7// ResolveTypeof.cc --
    88//
    99// Author           : Richard C. Bilson
     
    5858                if ( typeofType->get_expr() ) {
    5959                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
    60                         assert( newExpr->get_results().size() > 0 );
    61                         Type *newType;
    62                         if ( newExpr->get_results().size() > 1 ) {
    63                                 TupleType *tupleType = new TupleType( Type::Qualifiers() );
    64                                 cloneAll( newExpr->get_results(), tupleType->get_types() );
    65                                 newType = tupleType;
    66                         } else {
    67                                 newType = newExpr->get_results().front()->clone();
    68                         } // if
     60                        assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
     61                        Type *newType = newExpr->get_result();
    6962                        delete typeofType;
    7063                        return newType;
  • src/ResolvExpr/Resolver.cc

    rfe7b281 ra1e67dd  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
     21#include "typeops.h"
    2122#include "SynTree/Statement.h"
    2223#include "SynTree/Type.h"
     
    3738
    3839                virtual void visit( FunctionDecl *functionDecl );
    39                 virtual void visit( ObjectDecl *functionDecl );
     40                virtual void visit( ObjectDecl *objectDecl );
    4041                virtual void visit( TypeDecl *typeDecl );
    4142                virtual void visit( EnumDecl * enumDecl );
     
    6768          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6869          void fallbackInit( ConstructorInit * ctorInit );
    69                 std::list< Type * > functionReturn;
     70                Type * functionReturn;
    7071                Type *initContext;
    7172                Type *switchType;
     
    157158                        const TypeEnvironment *newEnv = 0;
    158159                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    159                                 if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
     160                                if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
    160161                                        if ( newExpr ) {
    161162                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    234235                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    235236                functionDecl->set_type( new_type );
    236                 std::list< Type * > oldFunctionReturn = functionReturn;
    237                 functionReturn.clear();
    238                 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
    239                         functionReturn.push_back( (*i)->get_type() );
    240                 } // for
     237                ValueGuard< Type * > oldFunctionReturn( functionReturn );
     238                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    241239                SymTab::Indexer::visit( functionDecl );
    242                 functionReturn = oldFunctionReturn;
    243240        }
    244241
     
    338335        void Resolver::visit( ReturnStmt *returnStmt ) {
    339336                if ( returnStmt->get_expr() ) {
    340                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
    341                         cloneAll( functionReturn, castExpr->get_results() );
     337                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
    342338                        Expression *newExpr = findSingleExpression( castExpr, *this );
    343339                        delete castExpr;
     
    384380                                if ( isCharType( at->get_base() ) ) {
    385381                                        // check if the resolved type is char *
    386                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
     382                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    387383                                                if ( isCharType( pt->get_base() ) ) {
    388384                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    446442                                (*iter)->accept( *this );
    447443                        } // for
     444                } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
     445                        for ( Type * t : *tt ) {
     446                                if ( iter == end ) break;
     447                                initContext = t;
     448                                (*iter++)->accept( *this );
     449                        }
    448450                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    449451                        resolveAggrInit( st->get_baseStruct(), iter, end );
  • src/ResolvExpr/TypeEnvironment.cc

    rfe7b281 ra1e67dd  
    158158        }
    159159
    160         void TypeEnvironment::add( const std::list< TypeDecl* > &tyDecls ) {
    161                 for ( std::list< TypeDecl* >::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) {
     160        void TypeEnvironment::add( const Type::ForallList &tyDecls ) {
     161                for ( Type::ForallList::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) {
    162162                        EqvClass newClass;
    163163                        newClass.vars.insert( (*i)->get_name() );
  • src/ResolvExpr/TypeEnvironment.h

    rfe7b281 ra1e67dd  
    5555                bool lookup( const std::string &var, EqvClass &eqvClass ) const;
    5656                void add( const EqvClass &eqvClass );
    57                 void add( const std::list< TypeDecl* > &tyDecls );
     57                void add( const Type::ForallList &tyDecls );
    5858                template< typename SynTreeClass > int apply( SynTreeClass *&type ) const;
    5959                template< typename SynTreeClass > int applyFree( SynTreeClass *&type ) const;
  • src/ResolvExpr/Unify.cc

    rfe7b281 ra1e67dd  
    598598        }
    599599
     600        // xxx - compute once and store in the FunctionType?
     601        Type * extractResultType( FunctionType * function ) {
     602                if ( function->get_returnVals().size() == 0 ) {
     603                        return new VoidType( Type::Qualifiers() );
     604                } else if ( function->get_returnVals().size() == 1 ) {
     605                        return function->get_returnVals().front()->get_type()->clone();
     606                } else {
     607                        TupleType * tupleType = new TupleType( Type::Qualifiers() );
     608                        for ( DeclarationWithType * decl : function->get_returnVals() ) {
     609                                tupleType->get_types().push_back( decl->get_type()->clone() );
     610                        } // for
     611                        return tupleType;
     612                }
     613        }
    600614} // namespace ResolvExpr
    601615
  • src/ResolvExpr/typeops.h

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // typeops.h -- 
     7// typeops.h --
    88//
    99// Author           : Richard C. Bilson
     
    3030                typedef typename InputIterator::value_type SetType;
    3131                typedef typename std::list< typename SetType::value_type > ListType;
    32  
     32
    3333                if ( begin == end )     {
    3434                        *out++ = ListType();
    3535                        return;
    3636                } // if
    37  
     37
    3838                InputIterator current = begin;
    3939                begin++;
     
    4141                std::list< ListType > recursiveResult;
    4242                combos( begin, end, back_inserter( recursiveResult ) );
    43  
     43
    4444                for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) {
    4545                        for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) {
     
    5252                } // for
    5353        }
    54  
     54
    5555        // in AdjustExprType.cc
    5656        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
     
    144144        }
    145145
     146        /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.
     147        Type * extractResultType( FunctionType * functionType );
     148
    146149        // in CommonType.cc
    147150        Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
     
    152155        // in Occurs.cc
    153156        bool occurs( Type *type, std::string varName, const TypeEnvironment &env );
     157
     158        // flatten tuple type into list of types
     159        template< typename OutputIterator >
     160        void flatten( Type * type, OutputIterator out ) {
     161                if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {
     162                        for ( Type * t : tupleType->get_types() ) {
     163                                flatten( t, out );
     164                        }
     165                } else {
     166                        *out++ = type;
     167                }
     168        }
    154169} // namespace ResolvExpr
    155170
  • src/SymTab/Autogen.cc

    rfe7b281 ra1e67dd  
    116116                // This happens before function pointer type conversion, so need to do it manually here
    117117                VariableExpr * assignVarExpr = new VariableExpr( assignDecl );
    118                 Type *& assignVarExprType = assignVarExpr->get_results().front();
     118                Type * assignVarExprType = assignVarExpr->get_result();
    119119                assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType );
     120                assignVarExpr->set_result( assignVarExprType );
    120121                ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr );
    121122                assignExpr->get_args().push_back( new VariableExpr( dstParam ) );
  • src/SymTab/Indexer.cc

    rfe7b281 ra1e67dd  
    4040
    4141namespace SymTab {
    42         template< typename Container, typename VisitorType >
    43         inline void acceptAllNewScope( Container &container, VisitorType &visitor ) {
     42        template< typename TreeType, typename VisitorType >
     43        inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
    4444                visitor.enterScope();
    45                 acceptAll( container, visitor );
     45                maybeAccept( tree, visitor );
    4646                visitor.leaveScope();
    4747        }
     
    143143                for ( DeclarationWithType * decl : copy ) {
    144144                        if ( FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl ) ) {
    145                                 std::list< DeclarationWithType * > params = function->get_functionType()->get_parameters();
     145                                std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters();
    146146                                assert( ! params.empty() );
    147147                                // use base type of pointer, so that qualifiers on the pointer type aren't considered.
     
    337337
    338338        void Indexer::visit( ApplicationExpr *applicationExpr ) {
    339                 acceptAllNewScope( applicationExpr->get_results(), *this );
     339                acceptNewScope( applicationExpr->get_result(), *this );
    340340                maybeAccept( applicationExpr->get_function(), *this );
    341341                acceptAll( applicationExpr->get_args(), *this );
     
    343343
    344344        void Indexer::visit( UntypedExpr *untypedExpr ) {
    345                 acceptAllNewScope( untypedExpr->get_results(), *this );
     345                acceptNewScope( untypedExpr->get_result(), *this );
    346346                acceptAll( untypedExpr->get_args(), *this );
    347347        }
    348348
    349349        void Indexer::visit( NameExpr *nameExpr ) {
    350                 acceptAllNewScope( nameExpr->get_results(), *this );
     350                acceptNewScope( nameExpr->get_result(), *this );
    351351        }
    352352
    353353        void Indexer::visit( AddressExpr *addressExpr ) {
    354                 acceptAllNewScope( addressExpr->get_results(), *this );
     354                acceptNewScope( addressExpr->get_result(), *this );
    355355                maybeAccept( addressExpr->get_arg(), *this );
    356356        }
    357357
    358358        void Indexer::visit( LabelAddressExpr *labAddressExpr ) {
    359                 acceptAllNewScope( labAddressExpr->get_results(), *this );
     359                acceptNewScope( labAddressExpr->get_result(), *this );
    360360                maybeAccept( labAddressExpr->get_arg(), *this );
    361361        }
    362362
    363363        void Indexer::visit( CastExpr *castExpr ) {
    364                 acceptAllNewScope( castExpr->get_results(), *this );
     364                acceptNewScope( castExpr->get_result(), *this );
    365365                maybeAccept( castExpr->get_arg(), *this );
    366366        }
    367367
    368368        void Indexer::visit( UntypedMemberExpr *memberExpr ) {
    369                 acceptAllNewScope( memberExpr->get_results(), *this );
     369                acceptNewScope( memberExpr->get_result(), *this );
    370370                maybeAccept( memberExpr->get_aggregate(), *this );
    371371        }
    372372
    373373        void Indexer::visit( MemberExpr *memberExpr ) {
    374                 acceptAllNewScope( memberExpr->get_results(), *this );
     374                acceptNewScope( memberExpr->get_result(), *this );
    375375                maybeAccept( memberExpr->get_aggregate(), *this );
    376376        }
    377377
    378378        void Indexer::visit( VariableExpr *variableExpr ) {
    379                 acceptAllNewScope( variableExpr->get_results(), *this );
     379                acceptNewScope( variableExpr->get_result(), *this );
    380380        }
    381381
    382382        void Indexer::visit( ConstantExpr *constantExpr ) {
    383                 acceptAllNewScope( constantExpr->get_results(), *this );
     383                acceptNewScope( constantExpr->get_result(), *this );
    384384                maybeAccept( constantExpr->get_constant(), *this );
    385385        }
    386386
    387387        void Indexer::visit( SizeofExpr *sizeofExpr ) {
    388                 acceptAllNewScope( sizeofExpr->get_results(), *this );
     388                acceptNewScope( sizeofExpr->get_result(), *this );
    389389                if ( sizeofExpr->get_isType() ) {
    390390                        maybeAccept( sizeofExpr->get_type(), *this );
     
    395395
    396396        void Indexer::visit( AlignofExpr *alignofExpr ) {
    397                 acceptAllNewScope( alignofExpr->get_results(), *this );
     397                acceptNewScope( alignofExpr->get_result(), *this );
    398398                if ( alignofExpr->get_isType() ) {
    399399                        maybeAccept( alignofExpr->get_type(), *this );
     
    404404
    405405        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
    406                 acceptAllNewScope( offsetofExpr->get_results(), *this );
     406                acceptNewScope( offsetofExpr->get_result(), *this );
    407407                maybeAccept( offsetofExpr->get_type(), *this );
    408408        }
    409409
    410410        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
    411                 acceptAllNewScope( offsetofExpr->get_results(), *this );
     411                acceptNewScope( offsetofExpr->get_result(), *this );
    412412                maybeAccept( offsetofExpr->get_type(), *this );
    413413                maybeAccept( offsetofExpr->get_member(), *this );
     
    415415
    416416        void Indexer::visit( OffsetPackExpr *offsetPackExpr ) {
    417                 acceptAllNewScope( offsetPackExpr->get_results(), *this );
     417                acceptNewScope( offsetPackExpr->get_result(), *this );
    418418                maybeAccept( offsetPackExpr->get_type(), *this );
    419419        }
    420420
    421421        void Indexer::visit( AttrExpr *attrExpr ) {
    422                 acceptAllNewScope( attrExpr->get_results(), *this );
     422                acceptNewScope( attrExpr->get_result(), *this );
    423423                if ( attrExpr->get_isType() ) {
    424424                        maybeAccept( attrExpr->get_type(), *this );
     
    429429
    430430        void Indexer::visit( LogicalExpr *logicalExpr ) {
    431                 acceptAllNewScope( logicalExpr->get_results(), *this );
     431                acceptNewScope( logicalExpr->get_result(), *this );
    432432                maybeAccept( logicalExpr->get_arg1(), *this );
    433433                maybeAccept( logicalExpr->get_arg2(), *this );
     
    435435
    436436        void Indexer::visit( ConditionalExpr *conditionalExpr ) {
    437                 acceptAllNewScope( conditionalExpr->get_results(), *this );
     437                acceptNewScope( conditionalExpr->get_result(), *this );
    438438                maybeAccept( conditionalExpr->get_arg1(), *this );
    439439                maybeAccept( conditionalExpr->get_arg2(), *this );
     
    442442
    443443        void Indexer::visit( CommaExpr *commaExpr ) {
    444                 acceptAllNewScope( commaExpr->get_results(), *this );
     444                acceptNewScope( commaExpr->get_result(), *this );
    445445                maybeAccept( commaExpr->get_arg1(), *this );
    446446                maybeAccept( commaExpr->get_arg2(), *this );
     
    448448
    449449        void Indexer::visit( TupleExpr *tupleExpr ) {
    450                 acceptAllNewScope( tupleExpr->get_results(), *this );
     450                acceptNewScope( tupleExpr->get_result(), *this );
    451451                acceptAll( tupleExpr->get_exprs(), *this );
    452452        }
    453453
    454         void Indexer::visit( SolvedTupleExpr *tupleExpr ) {
    455                 acceptAllNewScope( tupleExpr->get_results(), *this );
    456                 acceptAll( tupleExpr->get_exprs(), *this );
     454        void Indexer::visit( TupleAssignExpr *tupleExpr ) {
     455                acceptNewScope( tupleExpr->get_result(), *this );
     456                enterScope();
     457                acceptAll( tupleExpr->get_tempDecls(), *this );
     458                acceptAll( tupleExpr->get_assigns(), *this );
     459                leaveScope();
    457460        }
    458461
    459462        void Indexer::visit( TypeExpr *typeExpr ) {
    460                 acceptAllNewScope( typeExpr->get_results(), *this );
     463                acceptNewScope( typeExpr->get_result(), *this );
    461464                maybeAccept( typeExpr->get_type(), *this );
    462465        }
     
    469472
    470473        void Indexer::visit( UntypedValofExpr *valofExpr ) {
    471                 acceptAllNewScope( valofExpr->get_results(), *this );
     474                acceptNewScope( valofExpr->get_result(), *this );
    472475                maybeAccept( valofExpr->get_body(), *this );
    473476        }
  • src/SymTab/Indexer.h

    rfe7b281 ra1e67dd  
    6464                virtual void visit( ConditionalExpr *conditionalExpr );
    6565                virtual void visit( CommaExpr *commaExpr );
    66                 virtual void visit( TupleExpr *tupleExpr );
    67                 virtual void visit( SolvedTupleExpr *tupleExpr );
    6866                virtual void visit( TypeExpr *typeExpr );
    6967                virtual void visit( AsmExpr *asmExpr );
    7068                virtual void visit( UntypedValofExpr *valofExpr );
     69                virtual void visit( TupleExpr *tupleExpr );
     70                virtual void visit( TupleAssignExpr *tupleExpr );
    7171
    7272                virtual void visit( TraitInstType *contextInst );
  • src/SymTab/Mangler.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Mangler.cc -- 
     7// Mangler.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3535                return mangler.get_mangleName();
    3636        }
    37        
     37
    3838        Mangler::Mangler( bool mangleOverridable, bool typeMode )
    3939                : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ), typeMode( typeMode ) {}
    40                
     40
    4141        Mangler::Mangler( const Mangler &rhs ) : mangleName() {
    4242                varNums = rhs.varNums;
     
    115115                        "Ir",   // LongDoubleImaginary
    116116                };
    117  
     117
    118118                printQualifiers( basicType );
    119119                mangleName << btLetter[ basicType->get_kind() ];
     
    253253                // skip if not including qualifiers
    254254                if ( typeMode ) return;
    255                
     255
    256256                if ( ! type->get_forall().empty() ) {
    257257                        std::list< std::string > assertionNames;
    258258                        int tcount = 0, dcount = 0, fcount = 0;
    259259                        mangleName << "A";
    260                         for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     260                        for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    261261                                switch ( (*i)->get_kind() ) {
    262262                                  case TypeDecl::Any:
  • src/SymTab/Validate.cc

    rfe7b281 ra1e67dd  
    2323// - All enumeration constants have type EnumInstType.
    2424//
    25 // - The type "void" never occurs in lists of function parameter or return types; neither do tuple types.  A function
    26 //   taking no arguments has no argument types, and tuples are flattened.
     25// - The type "void" never occurs in lists of function parameter or return types.  A function
     26//   taking no arguments has no argument types.
    2727//
    2828// - No context instances exist; they are all replaced by the set of declarations signified by the context, instantiated
     
    429429        /// Fix up assertions
    430430        void forallFixer( Type *func ) {
    431                 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
     431                for ( Type::ForallList::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
    432432                        std::list< DeclarationWithType * > toBeDone, nextRound;
    433433                        toBeDone.splice( toBeDone.end(), (*type )->get_assertions() );
  • src/SynTree/AddressExpr.cc

    rfe7b281 ra1e67dd  
    1919
    2020AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
    21         for ( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) {
    22                 get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );
    23         } // for
     21        if ( arg->has_result() ) {
     22                set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) );
     23        }
    2424}
    2525
     
    3535        if ( arg ) {
    3636                os << std::string( indent+2, ' ' );
    37     arg->print( os, indent+2 );
     37                arg->print( os, indent+2 );
    3838        } // if
    3939}
  • src/SynTree/ApplicationExpr.cc

    rfe7b281 ra1e67dd  
    2121#include "TypeSubstitution.h"
    2222#include "Common/utility.h"
    23 
     23#include "ResolvExpr/typeops.h"
    2424
    2525ParamEntry::ParamEntry( const ParamEntry &other ) :
     
    4343
    4444ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
    45         PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() );
    46         assert( pointer );
    47         FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    48         assert( function );
     45        PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
     46        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    4947
    50         for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    51                 get_results().push_back( (*i)->get_type()->clone() );
    52         } // for
     48        set_result( ResolvExpr::extractResultType( function ) );
     49
     50        assert( has_result() );
    5351}
    5452
  • src/SynTree/CommaExpr.cc

    rfe7b281 ra1e67dd  
    2323        // to false on all result types. Actually doing this causes some strange things
    2424        // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    25         cloneAll( arg2->get_results(), get_results() );
    26         // for ( Type *& type : get_results() ) {
    27         //      type->set_isLvalue( false );
    28         // }
     25        set_result( maybeClone( arg2->get_result() ) );
     26        // get_type->set_isLvalue( false );
    2927}
    3028
  • src/SynTree/Expression.cc

    rfe7b281 ra1e67dd  
    3131
    3232
    33 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
    34 
    35 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    36         cloneAll( other.results, results );
     33Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
     34
     35Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    3736}
    3837
     
    4039        delete env;
    4140        delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    42         deleteAll( results );
    43 }
    44 
    45 void Expression::add_result( Type *t ) {
    46         if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) {
    47                 std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) );
    48         } else {
    49                 results.push_back(t);
    50         } // if
     41        delete result;
    5142}
    5243
     
    6859
    6960ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
    70         add_result( constant.get_type()->clone() );
     61        set_result( constant.get_type()->clone() );
    7162}
    7263
     
    8576        assert( var );
    8677        assert( var->get_type() );
    87         add_result( var->get_type()->clone() );
    88         for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
    89                 (*i)->set_isLvalue( true );
    90         } // for
     78        Type * type = var->get_type()->clone();
     79        type->set_isLvalue( true );
     80        set_result( type );
    9181}
    9282
     
    110100SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    111101                Expression( _aname ), expr(expr_), type(0), isType(false) {
    112         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     102        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    113103}
    114104
    115105SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    116106                Expression( _aname ), expr(0), type(type_), isType(true) {
    117         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     107        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    118108}
    119109
     
    141131AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    142132                Expression( _aname ), expr(expr_), type(0), isType(false) {
    143         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     133        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    144134}
    145135
    146136AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    147137                Expression( _aname ), expr(0), type(type_), isType(true) {
    148         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     138        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    149139}
    150140
     
    172162UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
    173163                Expression( _aname ), type(type_), member(member_) {
    174         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     164        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    175165}
    176166
     
    197187OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
    198188                Expression( _aname ), type(type_), member(member_) {
    199         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     189        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    200190}
    201191
     
    229219
    230220OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    231         add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     221        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    232222}
    233223
     
    284274
    285275CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    286         add_result(toType);
     276        set_result(toType);
    287277}
    288278
    289279CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     280        set_result( new VoidType( Type::Qualifiers() ) );
    290281}
    291282
     
    303294        arg->print(os, indent+2);
    304295        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
    305         if ( results.empty() ) {
    306                 os << std::string( indent+2, ' ' ) << "nothing" << std::endl;
     296        os << std::string( indent+2, ' ' );
     297        if ( result->isVoid() ) {
     298                os << "nothing";
    307299        } else {
    308                 printAll(results, os, indent+2);
     300                result->print( os, indent+2 );
    309301        } // if
    310         Expression::print( os, indent );
    311 }
    312 
    313 UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) :
     302        os << std::endl;
     303        Expression::print( os, indent );
     304}
     305
     306UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) :
    314307                Expression( _aname ), member(_member), aggregate(_aggregate) {}
    315308
    316309UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
    317                 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     310                Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
    318311}
    319312
    320313UntypedMemberExpr::~UntypedMemberExpr() {
    321314        delete aggregate;
     315        delete member;
    322316}
    323317
    324318void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    325         os << "Untyped Member Expression, with field: " << get_member();
     319        os << "Untyped Member Expression, with field: " << std::endl;
     320        os << std::string( indent+2, ' ' );
     321        get_member()->print(os, indent+4);
     322        os << std::string( indent+2, ' ' );
    326323
    327324        Expression *agg = get_aggregate();
    328         os << ", from aggregate: ";
     325        os << "from aggregate: " << std::endl;
    329326        if (agg != 0) {
    330                 os << std::string( indent + 2, ' ' );
    331                 agg->print(os, indent + 2);
     327                os << std::string( indent + 4, ' ' );
     328                agg->print(os, indent + 4);
    332329        }
    333330        os << std::string( indent+2, ' ' );
     
    338335MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    339336                Expression( _aname ), member(_member), aggregate(_aggregate) {
    340         add_result( member->get_type()->clone() );
    341         for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
    342                 (*i)->set_isLvalue( true );
    343         } // for
     337        set_result( member->get_type()->clone() );
     338        get_result()->set_isLvalue( true );
    344339}
    345340
     
    372367}
    373368
    374 
    375 UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {}
     369UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
     370                Expression( _aname ), function(_function), args(_args) {}
    376371
    377372UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    379374        cloneAll( other.args, args );
    380375}
    381 
    382 UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :
    383                 Expression( _aname ), function(_function), args(_args) {}
    384376
    385377UntypedExpr::~UntypedExpr() {
     
    419411LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    420412                Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    421         add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
     413        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    422414}
    423415
     
    477469ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    478470        assert( callExpr );
    479         cloneAll( callExpr->get_results(), results );
     471        assert( callExpr->has_result() );
     472        set_result( callExpr->get_result()->clone() );
    480473}
    481474
     
    510503        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    511504        assert( arg );
    512         cloneAll( arg->get_results(), results );
     505        set_result( maybeClone( arg->get_result() ) );
    513506}
    514507
     
    530523
    531524CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    532         add_result( type->clone() );
    533 }
    534 
    535 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     525        assert( type && initializer );
     526        set_result( type->clone() );
     527}
     528
     529CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {}
    536530
    537531CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    542536void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
    543537        os << "Compound Literal Expression: " << std::endl;
    544         if ( type ) type->print( os, indent + 2 );
    545         if ( initializer ) initializer->print( os, indent + 2 );
     538        os << std::string( indent+2, ' ' );
     539        type->print( os, indent + 2 );
     540        os << std::string( indent+2, ' ' );
     541        initializer->print( os, indent + 2 );
    546542}
    547543
     
    557553
    558554RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    559 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
     555RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    560556void RangeExpr::print( std::ostream &os, int indent ) const {
    561         os << std::string( indent, ' ' ) << "Range Expression: ";
     557        os << "Range Expression: ";
    562558        low->print( os, indent );
    563559        os << " ... ";
    564560        high->print( os, indent );
     561}
     562
     563StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
     564        assert( statements );
     565        std::list< Statement * > & body = statements->get_kids();
     566        if ( ! body.empty() ) {
     567                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
     568                        set_result( maybeClone( exprStmt->get_expr()->get_result() ) );
     569                }
     570        }
     571}
     572StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {}
     573StmtExpr::~StmtExpr() {
     574        delete statements;
     575}
     576void StmtExpr::print( std::ostream &os, int indent ) const {
     577        os << "Statement Expression: " << std::endl << std::string( indent, ' ' );
     578        statements->print( os, indent+2 );
     579}
     580
     581
     582long long UniqueExpr::count = 0;
     583UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), id( idVal ) {
     584        assert( count != -1 );
     585        if ( id == -1 ) id = count++;
     586        set_expr( expr );
     587        assert( expr );
     588        if ( expr->get_result() ) {
     589                set_result( expr->get_result()->clone() );
     590        }
     591}
     592UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), id( other.id ) {
     593}
     594UniqueExpr::~UniqueExpr() {
     595        if ( expr.unique() ) {
     596                delete *expr;
     597        }
     598}
     599void UniqueExpr::print( std::ostream &os, int indent ) const {
     600        os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' );
     601        get_expr()->print( os, indent+2 );
    565602}
    566603
  • src/SynTree/Expression.h

    rfe7b281 ra1e67dd  
    3232        virtual ~Expression();
    3333
    34         std::list<Type *>& get_results() { return results; }
    35         void add_result( Type *t );
     34        Type *& get_result() { return result; }
     35        void set_result( Type *newValue ) { result = newValue; }
     36        bool has_result() const { return result != nullptr; }
    3637
    3738        TypeSubstitution *get_env() const { return env; }
     
    4748        virtual void print( std::ostream &os, int indent = 0 ) const;
    4849  protected:
    49         std::list<Type *> results;
     50        Type * result;
    5051        TypeSubstitution *env;
    5152        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     
    9899class UntypedExpr : public Expression {
    99100  public:
    100         UntypedExpr( Expression *function, Expression *_aname = nullptr );
     101        UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr );
    101102        UntypedExpr( const UntypedExpr &other );
    102         UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );
    103103        virtual ~UntypedExpr();
    104104
     
    200200class UntypedMemberExpr : public Expression {
    201201  public:
    202         UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr );
     202        UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr );
    203203        UntypedMemberExpr( const UntypedMemberExpr &other );
    204204        virtual ~UntypedMemberExpr();
    205205
    206         std::string get_member() const { return member; }
    207         void set_member( const std::string &newValue ) { member = newValue; }
     206        Expression * get_member() const { return member; }
     207        void set_member( Expression * newValue ) { member = newValue; }
    208208        Expression *get_aggregate() const { return aggregate; }
    209209        void set_aggregate( Expression *newValue ) { aggregate = newValue; }
     
    214214        virtual void print( std::ostream &os, int indent = 0 ) const;
    215215  private:
    216         std::string member;
     216        Expression *member;
    217217        Expression *aggregate;
    218218};
     
    483483};
    484484
    485 /// TupleExpr represents a tuple expression ( [a, b, c] )
    486 class TupleExpr : public Expression {
    487   public:
    488         TupleExpr( Expression *_aname = nullptr );
    489         TupleExpr( const TupleExpr &other );
    490         virtual ~TupleExpr();
    491 
    492         void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
    493         std::list<Expression*>& get_exprs() { return exprs; }
    494 
    495         virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
    496         virtual void accept( Visitor &v ) { v.visit( this ); }
    497         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    498         virtual void print( std::ostream &os, int indent = 0 ) const;
    499   private:
    500         std::list<Expression*> exprs;
    501 };
    502 
    503 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
    504 class SolvedTupleExpr : public Expression {
    505   public:
    506         SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}
    507         SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );
    508         SolvedTupleExpr( const SolvedTupleExpr &other );
    509         virtual ~SolvedTupleExpr() {}
    510 
    511         std::list<Expression*> &get_exprs() { return exprs; }
    512 
    513         virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
    514         virtual void accept( Visitor &v ) { v.visit( this ); }
    515         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    516         virtual void print( std::ostream &os, int indent = 0 ) const;
    517   private:
    518         std::list<Expression*> exprs;
    519 };
    520 
    521485/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    522486class TypeExpr : public Expression {
     
    618582        CompoundLiteralExpr( Type * type, Initializer * initializer );
    619583        CompoundLiteralExpr( const CompoundLiteralExpr &other );
    620         ~CompoundLiteralExpr();
     584        virtual ~CompoundLiteralExpr();
    621585
    622586        Type * get_type() const { return type; }
     
    670634  private:
    671635        Expression *low, *high;
     636};
     637
     638/// TupleExpr represents a tuple expression ( [a, b, c] )
     639class TupleExpr : public Expression {
     640  public:
     641        TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr );
     642        TupleExpr( const TupleExpr &other );
     643        virtual ~TupleExpr();
     644
     645        void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
     646        std::list<Expression*>& get_exprs() { return exprs; }
     647
     648        virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
     649        virtual void accept( Visitor &v ) { v.visit( this ); }
     650        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     651        virtual void print( std::ostream &os, int indent = 0 ) const;
     652  private:
     653        std::list<Expression*> exprs;
     654};
     655
     656/// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer
     657class TupleIndexExpr : public Expression {
     658  public:
     659        TupleIndexExpr( Expression * tuple, unsigned int index );
     660        TupleIndexExpr( const TupleIndexExpr &other );
     661        virtual ~TupleIndexExpr();
     662
     663        Expression * get_tuple() const { return tuple; }
     664        int get_index() const { return index; }
     665        TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; }
     666        TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; }
     667
     668        virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); }
     669        virtual void accept( Visitor &v ) { v.visit( this ); }
     670        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     671        virtual void print( std::ostream &os, int indent = 0 ) const;
     672  private:
     673        Expression * tuple;
     674        unsigned int index;
     675};
     676
     677/// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer
     678class MemberTupleExpr : public Expression {
     679  public:
     680        MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );
     681        MemberTupleExpr( const MemberTupleExpr &other );
     682        virtual ~MemberTupleExpr();
     683
     684        Expression * get_member() const { return member; }
     685        Expression * get_aggregate() const { return aggregate; }
     686        MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; }
     687        MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; }
     688
     689        virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); }
     690        virtual void accept( Visitor &v ) { v.visit( this ); }
     691        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     692        virtual void print( std::ostream &os, int indent = 0 ) const;
     693  private:
     694        Expression * member;
     695        Expression * aggregate;
     696};
     697
     698/// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression
     699class TupleAssignExpr : public Expression {
     700  public:
     701        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
     702        TupleAssignExpr( const TupleAssignExpr &other );
     703        virtual ~TupleAssignExpr();
     704
     705        std::list< Expression * > & get_assigns() { return assigns; }
     706        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     707
     708        virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); }
     709        virtual void accept( Visitor &v ) { v.visit( this ); }
     710        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     711        virtual void print( std::ostream &os, int indent = 0 ) const;
     712  private:
     713        std::list< Expression * > assigns; // assignment expressions that use tempDecls
     714        std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs
     715};
     716
     717/// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; })
     718class StmtExpr : public Expression {
     719public:
     720        StmtExpr( CompoundStmt *statements );
     721        StmtExpr( const StmtExpr & other );
     722        virtual ~StmtExpr();
     723
     724        CompoundStmt * get_statements() const { return statements; }
     725        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
     726
     727        virtual StmtExpr *clone() const { return new StmtExpr( *this ); }
     728        virtual void accept( Visitor &v ) { v.visit( this ); }
     729        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     730        virtual void print( std::ostream &os, int indent = 0 ) const;
     731private:
     732        CompoundStmt * statements;
     733};
     734
     735class UniqueExpr : public Expression {
     736public:
     737        UniqueExpr( Expression * expr, long long idVal = -1 );
     738        UniqueExpr( const UniqueExpr & other );
     739        ~UniqueExpr();
     740
     741        Expression * get_expr() const { return *expr; }
     742        UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; }
     743
     744        int get_id() const { return id; }
     745
     746        virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); }
     747        virtual void accept( Visitor &v ) { v.visit( this ); }
     748        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     749        virtual void print( std::ostream &os, int indent = 0 ) const;
     750private:
     751        std::shared_ptr< Expression * > expr;
     752        int id;
     753        static long long count;
    672754};
    673755
  • src/SynTree/Initializer.h

    rfe7b281 ra1e67dd  
    2323
    2424#include <cassert>
     25
     26const std::list<Expression*> noDesignators;
    2527
    2628// Initializer: base class for object initializers (provide default values)
  • src/SynTree/Mutator.cc

    rfe7b281 ra1e67dd  
    178178
    179179Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    180         mutateAll( applicationExpr->get_results(), *this );
     180        applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
    181181        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    182182        mutateAll( applicationExpr->get_args(), *this );
     
    185185
    186186Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
    187         mutateAll( untypedExpr->get_results(), *this );
     187        untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
    188188        mutateAll( untypedExpr->get_args(), *this );
    189189        return untypedExpr;
     
    191191
    192192Expression *Mutator::mutate( NameExpr *nameExpr ) {
    193         mutateAll( nameExpr->get_results(), *this );
     193        nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
    194194        return nameExpr;
    195195}
    196196
    197197Expression *Mutator::mutate( AddressExpr *addressExpr ) {
    198         mutateAll( addressExpr->get_results(), *this );
     198        addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
    199199        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    200200        return addressExpr;
     
    202202
    203203Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    204         mutateAll( labelAddressExpr->get_results(), *this );
     204        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    205205        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    206206        return labelAddressExpr;
     
    208208
    209209Expression *Mutator::mutate( CastExpr *castExpr ) {
    210         mutateAll( castExpr->get_results(), *this );
     210        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    211211        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    212212        return castExpr;
     
    214214
    215215Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    216         mutateAll( memberExpr->get_results(), *this );
     216        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     217        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
     218        memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
     219        return memberExpr;
     220}
     221
     222Expression *Mutator::mutate( MemberExpr *memberExpr ) {
     223        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    217224        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    218225        return memberExpr;
    219226}
    220227
    221 Expression *Mutator::mutate( MemberExpr *memberExpr ) {
    222         mutateAll( memberExpr->get_results(), *this );
    223         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    224         return memberExpr;
    225 }
    226 
    227228Expression *Mutator::mutate( VariableExpr *variableExpr ) {
    228         mutateAll( variableExpr->get_results(), *this );
     229        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
    229230        return variableExpr;
    230231}
    231232
    232233Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
    233         mutateAll( constantExpr->get_results(), *this );
     234        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
    234235//  maybeMutate( constantExpr->get_constant(), *this )
    235236        return constantExpr;
     
    237238
    238239Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
    239         mutateAll( sizeofExpr->get_results(), *this );
     240        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
    240241        if ( sizeofExpr->get_isType() ) {
    241242                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
     
    247248
    248249Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
    249         mutateAll( alignofExpr->get_results(), *this );
     250        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
    250251        if ( alignofExpr->get_isType() ) {
    251252                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
     
    257258
    258259Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    259         mutateAll( offsetofExpr->get_results(), *this );
     260        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    260261        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    261262        return offsetofExpr;
     
    263264
    264265Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    265         mutateAll( offsetofExpr->get_results(), *this );
     266        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    266267        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    267268        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     
    270271
    271272Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    272         mutateAll( offsetPackExpr->get_results(), *this );
     273        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
    273274        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
    274275        return offsetPackExpr;
     
    276277
    277278Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    278         mutateAll( attrExpr->get_results(), *this );
     279        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
    279280        if ( attrExpr->get_isType() ) {
    280281                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
     
    286287
    287288Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
    288         mutateAll( logicalExpr->get_results(), *this );
     289        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
    289290        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
    290291        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
     
    293294
    294295Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    295         mutateAll( conditionalExpr->get_results(), *this );
     296        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
    296297        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
    297298        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
     
    301302
    302303Expression *Mutator::mutate( CommaExpr *commaExpr ) {
    303         mutateAll( commaExpr->get_results(), *this );
     304        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
    304305        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
    305306        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
     
    307308}
    308309
    309 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
    310         mutateAll( tupleExpr->get_results(), *this );
    311         mutateAll( tupleExpr->get_exprs(), *this );
    312         return tupleExpr;
    313 }
    314 
    315 Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {
    316         mutateAll( tupleExpr->get_results(), *this );
    317         mutateAll( tupleExpr->get_exprs(), *this );
    318         return tupleExpr;
    319 }
    320 
    321310Expression *Mutator::mutate( TypeExpr *typeExpr ) {
    322         mutateAll( typeExpr->get_results(), *this );
     311        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
    323312        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
    324313        return typeExpr;
     
    340329
    341330Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
    342         mutateAll( ctorExpr->get_results(), *this );
     331        ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
    343332        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
    344333        return ctorExpr;
     
    346335
    347336Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    348         mutateAll( compLitExpr->get_results(), *this );
     337        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    349338        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    350339        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
     
    353342
    354343Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    355         mutateAll( valofExpr->get_results(), *this );
     344        valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    356345        return valofExpr;
    357346}
     
    361350        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
    362351        return rangeExpr;
     352}
     353
     354Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
     355        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     356        mutateAll( tupleExpr->get_exprs(), *this );
     357        return tupleExpr;
     358}
     359
     360Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
     361        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     362        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
     363        return tupleExpr;
     364}
     365
     366Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
     367        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     368        tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
     369        tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );
     370        return tupleExpr;
     371}
     372
     373Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
     374        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
     375        mutateAll( assignExpr->get_tempDecls(), *this );
     376        mutateAll( assignExpr->get_assigns(), *this );
     377        return assignExpr;
     378}
     379
     380Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
     381        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
     382        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
     383        return stmtExpr;
     384}
     385
     386Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
     387        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
     388        uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
     389        return uniqueExpr;
    363390}
    364391
  • src/SynTree/Mutator.h

    rfe7b281 ra1e67dd  
    7171        virtual Expression* mutate( ConditionalExpr *conditionalExpr );
    7272        virtual Expression* mutate( CommaExpr *commaExpr );
    73         virtual Expression* mutate( TupleExpr *tupleExpr );
    74         virtual Expression* mutate( SolvedTupleExpr *tupleExpr );
    7573        virtual Expression* mutate( TypeExpr *typeExpr );
    7674        virtual Expression* mutate( AsmExpr *asmExpr );
     
    8078        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8179        virtual Expression* mutate( RangeExpr *rangeExpr );
     80        virtual Expression* mutate( TupleExpr *tupleExpr );
     81        virtual Expression* mutate( TupleIndexExpr *tupleExpr );
     82        virtual Expression* mutate( MemberTupleExpr *tupleExpr );
     83        virtual Expression* mutate( TupleAssignExpr *assignExpr );
     84        virtual Expression* mutate( StmtExpr * stmtExpr );
     85        virtual Expression* mutate( UniqueExpr * uniqueExpr );
    8286
    8387        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/ReferenceToType.cc

    rfe7b281 ra1e67dd  
    5656        }
    5757} // namespace
     58
     59StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct ) : Parent( tq, baseStruct->get_name() ), baseStruct( baseStruct ) {}
    5860
    5961std::string StructInstType::typeString() const { return "struct"; }
  • src/SynTree/SynTree.h

    rfe7b281 ra1e67dd  
    7676class ConditionalExpr;
    7777class CommaExpr;
    78 class TupleExpr;
    79 class SolvedTupleExpr;
    8078class TypeExpr;
    8179class AsmExpr;
     
    8583class UntypedValofExpr;
    8684class RangeExpr;
     85class TupleExpr;
     86class TupleIndexExpr;
     87class MemberTupleExpr;
     88class TupleAssignExpr;
     89class StmtExpr;
     90class UniqueExpr;
    8791
    8892class Type;
  • src/SynTree/TupleExpr.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleExpr.cc -- 
     7// TupleExpr.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1616#include "Expression.h"
    1717#include "Common/utility.h"
     18#include "Type.h"
     19#include "Declaration.h"
     20#include "Tuples/Tuples.h"
    1821
    19 TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
     22TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) {
     23        if ( ! exprs.empty() ) {
     24                if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) {
     25                        set_result( Tuples::makeTupleType( exprs ) );
     26                }
     27        }
    2028}
    2129
     
    2937
    3038void TupleExpr::print( std::ostream &os, int indent ) const {
    31         os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
     39        os << "Tuple:" << std::endl;
    3240        printAll( exprs, os, indent+2 );
    3341        Expression::print( os, indent );
    3442}
    3543
    36 SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
    37         std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
     44TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index )  {
     45        TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() );
     46        assert( type->size() > index );
     47        set_result( (*std::next( type->get_types().begin(), index ))->clone() );
     48        get_result()->set_isLvalue( type->get_isLvalue() );
    3849}
    3950
    40 SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
    41         cloneAll( other.exprs, exprs );
     51TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
    4252}
    4353
    44 void SolvedTupleExpr::print( std::ostream &os, int indent ) const {
    45         os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl;
    46         printAll( exprs, os, indent+2 );
     54TupleIndexExpr::~TupleIndexExpr() {
     55        delete tuple;
     56}
     57
     58void TupleIndexExpr::print( std::ostream &os, int indent ) const {
     59        os << "Tuple Index Expression, with tuple:" << std::endl;
     60        os << std::string( indent+2, ' ' );
     61        tuple->print( os, indent+2 );
     62        os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl;
    4763        Expression::print( os, indent );
    4864}
     65
     66MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
     67        set_result( maybeClone( member->get_result() ) ); // xxx - ???
     68}
     69
     70MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
     71}
     72
     73MemberTupleExpr::~MemberTupleExpr() {
     74        delete member;
     75        delete aggregate;
     76}
     77
     78void MemberTupleExpr::print( std::ostream &os, int indent ) const {
     79        os << "Member Tuple Expression, with aggregate:" << std::endl;
     80        os << std::string( indent+2, ' ' );
     81        aggregate->print( os, indent+2 );
     82        os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
     83        os << std::string( indent+2, ' ' );
     84        member->print( os, indent+2 );
     85        Expression::print( os, indent );
     86}
     87
     88
     89TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) {
     90        set_result( Tuples::makeTupleType( assigns ) );
     91}
     92
     93TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ), tempDecls( other.tempDecls ) /* temporary */ {
     94        cloneAll( other.assigns, assigns );
     95        // xxx - clone needs to go into assigns and replace tempDecls
     96}
     97
     98TupleAssignExpr::~TupleAssignExpr() {
     99        deleteAll( assigns );
     100        // deleteAll( tempDecls );
     101}
     102
     103void TupleAssignExpr::print( std::ostream &os, int indent ) const {
     104        os << "Tuple Assignment Expression, with temporaries:" << std::endl;
     105        printAll( tempDecls, os, indent+4 );
     106        os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl;
     107        printAll( assigns, os, indent+4 );
     108        Expression::print( os, indent );
     109}
     110
     111
    49112
    50113// Local Variables: //
  • src/SynTree/TupleType.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleType.cc -- 
     7// TupleType.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1717#include "Common/utility.h"
    1818
    19 TupleType::TupleType( const Type::Qualifiers &tq ) : Type( tq ) {
     19TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types ) : Type( tq ), types( types ) {
    2020}
    2121
  • src/SynTree/Type.h

    rfe7b281 ra1e67dd  
    2020#include "Visitor.h"
    2121#include "Mutator.h"
     22#include "Common/utility.h"
    2223
    2324class Type {
     
    2728                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
    2829
     30                Qualifiers &operator&=( const Qualifiers &other );
    2931                Qualifiers &operator+=( const Qualifiers &other );
    3032                Qualifiers &operator-=( const Qualifiers &other );
     
    6365        void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    6466        void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    65         std::list<TypeDecl*>& get_forall() { return forall; }
     67
     68        typedef std::list<TypeDecl *> ForallList;
     69        ForallList& get_forall() { return forall; }
     70
     71        /// How many elemental types are represented by this type
     72        virtual unsigned size() const { return 1; };
     73        virtual bool isVoid() const { return size() == 0; }
    6674
    6775        virtual Type *clone() const = 0;
     
    7179  private:
    7280        Qualifiers tq;
    73         std::list<TypeDecl*> forall;
     81        ForallList forall;
    7482};
    7583
     
    7785  public:
    7886        VoidType( const Type::Qualifiers &tq );
     87
     88        virtual unsigned size() const { return 0; };
    7989
    8090        virtual VoidType *clone() const { return new VoidType( *this ); }
     
    234244  public:
    235245        StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
     246        StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );
    236247        StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    237248
     
    348359class TupleType : public Type {
    349360  public:
    350         TupleType( const Type::Qualifiers &tq );
     361        TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );
    351362        TupleType( const TupleType& );
    352363        virtual ~TupleType();
    353364
     365        typedef std::list<Type*> value_type;
     366        typedef value_type::iterator iterator;
     367
    354368        std::list<Type*>& get_types() { return types; }
     369        virtual unsigned size() const { return types.size(); };
     370
     371        iterator begin() { return types.begin(); }
     372        iterator end() { return types.end(); }
    355373
    356374        virtual TupleType *clone() const { return new TupleType( *this ); }
     
    442460};
    443461
     462inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {
     463        isConst &= other.isConst;
     464        isVolatile &= other.isVolatile;
     465        isRestrict &= other.isRestrict;
     466        isLvalue &= other.isLvalue;
     467        isAtomic &= other.isAtomic;
     468        return *this;
     469}
     470
    444471inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    445472        isConst |= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    rfe7b281 ra1e67dd  
    7272Type *TypeSubstitution::lookup( std::string formalType ) const {
    7373        TypeEnvType::const_iterator i = typeEnv.find( formalType );
    74        
     74
    7575        // break on not in substitution set
    7676        if ( i == typeEnv.end() ) return 0;
    77        
     77
    7878        // attempt to transitively follow TypeInstType links.
    7979        while ( TypeInstType *actualType = dynamic_cast< TypeInstType* >( i->second ) ) {
    8080                const std::string& typeName = actualType->get_name();
    81                
     81
    8282                // break cycles in the transitive follow
    8383                if ( formalType == typeName ) break;
    84                
     84
    8585                // Look for the type this maps to, returning previous mapping if none-such
    8686                i = typeEnv.find( typeName );
    8787                if ( i == typeEnv.end() ) return actualType;
    8888        }
    89        
     89
    9090        // return type from substitution set
    9191        return i->second;
    92        
     92
    9393#if 0
    9494        if ( i == typeEnv.end() ) {
     
    149149        // bind type variables from forall-qualifiers
    150150        if ( freeOnly ) {
    151                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     151                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    152152                        boundVars.insert( (*tyvar )->get_name() );
    153153                } // for
     
    163163        // bind type variables from forall-qualifiers
    164164        if ( freeOnly ) {
    165                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     165                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    166166                        boundVars.insert( (*tyvar )->get_name() );
    167167                } // for
  • src/SynTree/Visitor.cc

    rfe7b281 ra1e67dd  
    150150
    151151void Visitor::visit( ApplicationExpr *applicationExpr ) {
    152         acceptAll( applicationExpr->get_results(), *this );
     152        maybeAccept( applicationExpr->get_result(), *this );
    153153        maybeAccept( applicationExpr->get_function(), *this );
    154154        acceptAll( applicationExpr->get_args(), *this );
     
    156156
    157157void Visitor::visit( UntypedExpr *untypedExpr ) {
    158         acceptAll( untypedExpr->get_results(), *this );
     158        maybeAccept( untypedExpr->get_result(), *this );
    159159        acceptAll( untypedExpr->get_args(), *this );
    160160}
    161161
    162162void Visitor::visit( NameExpr *nameExpr ) {
    163         acceptAll( nameExpr->get_results(), *this );
     163        maybeAccept( nameExpr->get_result(), *this );
    164164}
    165165
    166166void Visitor::visit( AddressExpr *addressExpr ) {
    167         acceptAll( addressExpr->get_results(), *this );
     167        maybeAccept( addressExpr->get_result(), *this );
    168168        maybeAccept( addressExpr->get_arg(), *this );
    169169}
    170170
    171171void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    172         acceptAll( labAddressExpr->get_results(), *this );
     172        maybeAccept( labAddressExpr->get_result(), *this );
    173173        maybeAccept( labAddressExpr->get_arg(), *this );
    174174}
    175175
    176176void Visitor::visit( CastExpr *castExpr ) {
    177         acceptAll( castExpr->get_results(), *this );
     177        maybeAccept( castExpr->get_result(), *this );
    178178        maybeAccept( castExpr->get_arg(), *this );
    179179}
    180180
    181181void Visitor::visit( UntypedMemberExpr *memberExpr ) {
    182         acceptAll( memberExpr->get_results(), *this );
     182        maybeAccept( memberExpr->get_result(), *this );
    183183        maybeAccept( memberExpr->get_aggregate(), *this );
     184        maybeAccept( memberExpr->get_member(), *this );
    184185}
    185186
    186187void Visitor::visit( MemberExpr *memberExpr ) {
    187         acceptAll( memberExpr->get_results(), *this );
     188        maybeAccept( memberExpr->get_result(), *this );
    188189        maybeAccept( memberExpr->get_aggregate(), *this );
    189190}
    190191
    191192void Visitor::visit( VariableExpr *variableExpr ) {
    192         acceptAll( variableExpr->get_results(), *this );
     193        maybeAccept( variableExpr->get_result(), *this );
    193194}
    194195
    195196void Visitor::visit( ConstantExpr *constantExpr ) {
    196         acceptAll( constantExpr->get_results(), *this );
     197        maybeAccept( constantExpr->get_result(), *this );
    197198        maybeAccept( constantExpr->get_constant(), *this );
    198199}
    199200
    200201void Visitor::visit( SizeofExpr *sizeofExpr ) {
    201         acceptAll( sizeofExpr->get_results(), *this );
     202        maybeAccept( sizeofExpr->get_result(), *this );
    202203        if ( sizeofExpr->get_isType() ) {
    203204                maybeAccept( sizeofExpr->get_type(), *this );
     
    208209
    209210void Visitor::visit( AlignofExpr *alignofExpr ) {
    210         acceptAll( alignofExpr->get_results(), *this );
     211        maybeAccept( alignofExpr->get_result(), *this );
    211212        if ( alignofExpr->get_isType() ) {
    212213                maybeAccept( alignofExpr->get_type(), *this );
     
    217218
    218219void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
    219         acceptAll( offsetofExpr->get_results(), *this );
     220        maybeAccept( offsetofExpr->get_result(), *this );
    220221        maybeAccept( offsetofExpr->get_type(), *this );
    221222}
    222223
    223224void Visitor::visit( OffsetofExpr *offsetofExpr ) {
    224         acceptAll( offsetofExpr->get_results(), *this );
     225        maybeAccept( offsetofExpr->get_result(), *this );
    225226        maybeAccept( offsetofExpr->get_type(), *this );
    226227        maybeAccept( offsetofExpr->get_member(), *this );
     
    228229
    229230void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
    230         acceptAll( offsetPackExpr->get_results(), *this );
     231        maybeAccept( offsetPackExpr->get_result(), *this );
    231232        maybeAccept( offsetPackExpr->get_type(), *this );
    232233}
    233234
    234235void Visitor::visit( AttrExpr *attrExpr ) {
    235         acceptAll( attrExpr->get_results(), *this );
     236        maybeAccept( attrExpr->get_result(), *this );
    236237        if ( attrExpr->get_isType() ) {
    237238                maybeAccept( attrExpr->get_type(), *this );
     
    242243
    243244void Visitor::visit( LogicalExpr *logicalExpr ) {
    244         acceptAll( logicalExpr->get_results(), *this );
     245        maybeAccept( logicalExpr->get_result(), *this );
    245246        maybeAccept( logicalExpr->get_arg1(), *this );
    246247        maybeAccept( logicalExpr->get_arg2(), *this );
     
    248249
    249250void Visitor::visit( ConditionalExpr *conditionalExpr ) {
    250         acceptAll( conditionalExpr->get_results(), *this );
     251        maybeAccept( conditionalExpr->get_result(), *this );
    251252        maybeAccept( conditionalExpr->get_arg1(), *this );
    252253        maybeAccept( conditionalExpr->get_arg2(), *this );
     
    255256
    256257void Visitor::visit( CommaExpr *commaExpr ) {
    257         acceptAll( commaExpr->get_results(), *this );
     258        maybeAccept( commaExpr->get_result(), *this );
    258259        maybeAccept( commaExpr->get_arg1(), *this );
    259260        maybeAccept( commaExpr->get_arg2(), *this );
    260261}
    261262
    262 void Visitor::visit( TupleExpr *tupleExpr ) {
    263         acceptAll( tupleExpr->get_results(), *this );
    264         acceptAll( tupleExpr->get_exprs(), *this );
    265 }
    266 
    267 void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
    268         acceptAll( tupleExpr->get_results(), *this );
    269         acceptAll( tupleExpr->get_exprs(), *this );
    270 }
    271 
    272263void Visitor::visit( TypeExpr *typeExpr ) {
    273         acceptAll( typeExpr->get_results(), *this );
     264        maybeAccept( typeExpr->get_result(), *this );
    274265        maybeAccept( typeExpr->get_type(), *this );
    275266}
     
    288279
    289280void Visitor::visit( ConstructorExpr * ctorExpr ) {
    290         acceptAll( ctorExpr->get_results(), *this );
     281        maybeAccept( ctorExpr->get_result(), *this );
    291282        maybeAccept( ctorExpr->get_callExpr(), *this );
    292283}
    293284
    294285void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    295         acceptAll( compLitExpr->get_results(), *this );
     286        maybeAccept( compLitExpr->get_result(), *this );
    296287        maybeAccept( compLitExpr->get_type(), *this );
    297288        maybeAccept( compLitExpr->get_initializer(), *this );
     
    299290
    300291void Visitor::visit( UntypedValofExpr *valofExpr ) {
    301         acceptAll( valofExpr->get_results(), *this );
     292        maybeAccept( valofExpr->get_result(), *this );
    302293        maybeAccept( valofExpr->get_body(), *this );
    303294}
     
    306297        maybeAccept( rangeExpr->get_low(), *this );
    307298        maybeAccept( rangeExpr->get_high(), *this );
     299}
     300
     301void Visitor::visit( TupleExpr *tupleExpr ) {
     302        maybeAccept( tupleExpr->get_result(), *this );
     303        acceptAll( tupleExpr->get_exprs(), *this );
     304}
     305
     306void Visitor::visit( TupleIndexExpr *tupleExpr ) {
     307        maybeAccept( tupleExpr->get_result(), *this );
     308        maybeAccept( tupleExpr->get_tuple(), *this );
     309}
     310
     311void Visitor::visit( MemberTupleExpr *tupleExpr ) {
     312        maybeAccept( tupleExpr->get_result(), *this );
     313        maybeAccept( tupleExpr->get_member(), *this );
     314        maybeAccept( tupleExpr->get_aggregate(), *this );
     315}
     316
     317void Visitor::visit( TupleAssignExpr *assignExpr ) {
     318        maybeAccept( assignExpr->get_result(), *this );
     319        acceptAll( assignExpr->get_tempDecls(), *this );
     320        acceptAll( assignExpr->get_assigns(), *this );
     321}
     322
     323void Visitor::visit( StmtExpr *stmtExpr ) {
     324        maybeAccept( stmtExpr->get_result(), *this );
     325        maybeAccept( stmtExpr->get_statements(), *this );
     326}
     327
     328void Visitor::visit( UniqueExpr *uniqueExpr ) {
     329        maybeAccept( uniqueExpr->get_result(), *this );
     330        maybeAccept( uniqueExpr->get_expr(), *this );
    308331}
    309332
  • src/SynTree/Visitor.h

    rfe7b281 ra1e67dd  
    7171        virtual void visit( ConditionalExpr *conditionalExpr );
    7272        virtual void visit( CommaExpr *commaExpr );
    73         virtual void visit( TupleExpr *tupleExpr );
    74         virtual void visit( SolvedTupleExpr *tupleExpr );
    7573        virtual void visit( TypeExpr *typeExpr );
    7674        virtual void visit( AsmExpr *asmExpr );
     
    8078        virtual void visit( UntypedValofExpr *valofExpr );
    8179        virtual void visit( RangeExpr *rangeExpr );
     80        virtual void visit( TupleExpr *tupleExpr );
     81        virtual void visit( TupleIndexExpr *tupleExpr );
     82        virtual void visit( MemberTupleExpr *tupleExpr );
     83        virtual void visit( TupleAssignExpr *assignExpr );
     84        virtual void visit( StmtExpr * stmtExpr );
     85        virtual void visit( UniqueExpr * uniqueExpr );
    8286
    8387        virtual void visit( VoidType *basicType );
  • src/Tuples/TupleAssignment.cc

    rfe7b281 ra1e67dd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleAssignment.cc -- 
     7// TupleAssignment.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    1818#include "ResolvExpr/typeops.h"
    1919#include "SynTree/Expression.h"
    20 #include "TupleAssignment.h"
     20#include "SynTree/Initializer.h"
     21#include "Tuples.h"
    2122#include "Common/SemanticError.h"
     23#include "InitTweak/InitTweak.h"
    2224
    2325#include <functional>
     
    2729#include <cassert>
    2830#include <set>
     31#include <unordered_set>
    2932
    3033namespace Tuples {
    31         TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f = 0 )
    32                 : currentFinder(f), matcher(0), hasMatched( false ) {}
    33 
    34         bool TupleAssignSpotter::pointsToTuple( Expression *expr ) {
     34        class TupleAssignSpotter {
     35          public:
     36                // dispatcher for Tuple (multiple and mass) assignment operations
     37                TupleAssignSpotter( ResolvExpr::AlternativeFinder & );
     38                void spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities );
     39
     40          private:
     41                void match();
     42
     43                struct Matcher {
     44                  public:
     45                        Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts );
     46                        virtual ~Matcher() {}
     47                        virtual void match( std::list< Expression * > &out ) = 0;
     48                        ResolvExpr::AltList lhs, rhs;
     49                        TupleAssignSpotter &spotter;
     50                        std::list< ObjectDecl * > tmpDecls;
     51                };
     52
     53                struct MassAssignMatcher : public Matcher {
     54                  public:
     55                        MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts );
     56                        virtual void match( std::list< Expression * > &out );
     57                };
     58
     59                struct MultipleAssignMatcher : public Matcher {
     60                  public:
     61                        MultipleAssignMatcher( TupleAssignSpotter &spot, const ResolvExpr::AltList & alts );
     62                        virtual void match( std::list< Expression * > &out );
     63                };
     64
     65                ResolvExpr::AlternativeFinder &currentFinder;
     66                std::string fname;
     67                std::unique_ptr< Matcher > matcher;
     68        };
     69
     70        /// true if expr is an expression of tuple type, i.e. a tuple expression, tuple variable, or MRV (multiple-return-value) function
     71        bool isTuple( Expression *expr ) {
     72                if ( ! expr ) return false;
     73                assert( expr->has_result() );
     74                return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1;
     75        }
     76
     77        template< typename AltIter >
     78        bool isMultAssign( AltIter begin, AltIter end ) {
     79                // multiple assignment if more than one alternative in the range or if
     80                // the alternative is a tuple
     81                if ( begin == end ) return false;
     82                if ( isTuple( begin->expr ) ) return true;
     83                return ++begin != end;
     84        }
     85
     86        bool pointsToTuple( Expression *expr ) {
    3587                // also check for function returning tuple of reference types
    36                 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(expr) )
    37                         if ( isTuple(addr->get_arg() ) )
    38                                 return true;
     88                if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
     89                        return pointsToTuple( castExpr->get_arg() );
     90                } else if ( AddressExpr *addr = dynamic_cast< AddressExpr * >( expr) ) {
     91                        return isTuple( addr->get_arg() );
     92                }
    3993                return false;
    4094        }
    4195
    42         bool TupleAssignSpotter::isTupleVar( DeclarationWithType *decl ) {
    43                 if ( dynamic_cast<TupleType *>(decl->get_type()) )
    44                         return true;
    45                 return false;
    46         }
    47 
    48         bool TupleAssignSpotter::isTuple( Expression *expr, bool isRight ) {
    49                 // true if `expr' is an expression returning a tuple: tuple, tuple variable or MRV function
    50                 if ( ! expr ) return false;
    51 
    52                 if ( dynamic_cast<TupleExpr *>(expr) )
    53                         return true;
    54                 else if ( VariableExpr *var = dynamic_cast<VariableExpr *>(expr) ) {
    55                         if ( isTupleVar(var->get_var()) )
    56                                 return true;
    57                 }
    58 
    59                 return false;
    60         }
    61 
    62         bool TupleAssignSpotter::match() {
    63                 assert ( matcher != 0 );
    64 
    65                 std::list< Expression * > new_assigns;
    66                 if ( ! matcher->match(new_assigns) )
    67                         return false;
    68 
    69                 if ( new_assigns.empty() ) return false;
    70                 /*return */matcher->solve( new_assigns );
    71                 if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
    72                         // now resolve new assignments
    73                         std::list< Expression * > solved_assigns;
    74                         ResolvExpr::AltList solved_alts;
    75                         assert( currentFinder != 0 );
    76 
    77                         ResolvExpr::AltList current;
    78                         for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
    79                                 //try {
    80                                 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    81                                 finder.findWithAdjustment(*i);
    82                                 // prune expressions that don't coincide with
    83                                 ResolvExpr::AltList alts = finder.get_alternatives();
    84                                 assert( alts.size() == 1 );
    85                                 assert(alts.front().expr != 0 );
    86                                 current.push_back( finder.get_alternatives().front() );
    87                                 solved_assigns.push_back( alts.front().expr->clone() );
    88                                 //solved_assigns.back()->print(std::cerr);
    89                                 /*} catch( ... ) {
    90                                   continue; // no reasonable alternative found
    91                                   }*/
    92                         }
    93                         options.add_option( current );
    94 
    95                         return true;
    96                 } else { // mass assignment
    97                         //if ( new_assigns.empty() ) return false;
    98                         std::list< Expression * > solved_assigns;
    99                         ResolvExpr::AltList solved_alts;
    100                         assert( currentFinder != 0 );
    101 
    102                         ResolvExpr::AltList current;
    103                         if ( optMass.empty() ) {
    104                                 for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
    105                                         optMass.push_back( ResolvExpr::AltList() );
    106                         }
    107                         int cnt = 0;
    108                         for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
    109 
    110                                 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    111                                 finder.findWithAdjustment(*i);
    112                                 ResolvExpr::AltList alts = finder.get_alternatives();
    113                                 assert( alts.size() == 1 );
    114                                 assert(alts.front().expr != 0 );
    115                                 current.push_back( finder.get_alternatives().front() );
    116                                 optMass[cnt].push_back( finder.get_alternatives().front() );
    117                                 solved_assigns.push_back( alts.front().expr->clone() );
    118                         }
    119 
    120                         return true;
    121                 }
    122 
    123                 return false;
    124         }
    125 
    126         bool TupleAssignSpotter::isMVR( Expression *expr ) {
    127                 if ( expr->get_results().size() > 1 ) {
    128                         // MVR processing
    129                         return true;
    130                 }
    131                 return false;
    132         }
    133 
    134         bool TupleAssignSpotter::isTupleAssignment( UntypedExpr * expr, std::list<ResolvExpr::AltList> &possibilities ) {
    135                 if (  NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) {
    136 
    137                         if ( assgnop->get_name() == std::string("?=?") ) {
    138 
    139                                 for ( std::list<ResolvExpr::AltList>::iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
    140                                         assert( ali->size() == 2 );
    141                                         ResolvExpr::AltList::iterator opit = ali->begin();
    142                                         ResolvExpr::Alternative op1 = *opit, op2 = *(++opit);
    143 
    144                                         if ( pointsToTuple(op1.expr) ) { // also handles tuple vars
    145                                                 if ( isTuple( op2.expr, true ) )
    146                                                         matcher = new MultipleAssignMatcher(op1.expr, op2.expr);
    147                                                 else if ( isMVR( op2.expr ) ) {
    148                                                         // handle MVR differently
    149                                                 } else
     96        void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) {
     97                TupleAssignSpotter spotter( currentFinder );
     98                spotter.spot( expr, possibilities );
     99        }
     100
     101        TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder &f )
     102                : currentFinder(f) {}
     103
     104        void TupleAssignSpotter::spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) {
     105                if (  NameExpr *op = dynamic_cast< NameExpr * >(expr->get_function()) ) {
     106                        if ( InitTweak::isCtorDtorAssign( op->get_name() ) ) {
     107                                fname = op->get_name();
     108                                for ( std::list<ResolvExpr::AltList>::const_iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
     109                                        if ( ali->size() == 0 ) continue; // AlternativeFinder will natrually handle this case, if it's legal
     110                                        if ( ali->size() <= 1 && InitTweak::isAssignment( op->get_name() ) ) {
     111                                                // what does it mean if an assignment takes 1 argument? maybe someone defined such a function, in which case AlternativeFinder will naturally handle it
     112                                                continue;
     113                                        }
     114
     115                                        assert( ! ali->empty() );
     116                                        // grab args 2-N and group into a TupleExpr
     117                                        const ResolvExpr::Alternative & alt1 = ali->front();
     118                                        auto begin = std::next(ali->begin(), 1), end = ali->end();
     119                                        if ( pointsToTuple(alt1.expr) ) {
     120                                                if ( isMultAssign( begin, end ) ) {
     121                                                        matcher.reset( new MultipleAssignMatcher( *this, *ali ) );
     122                                                } else {
    150123                                                        // mass assignment
    151                                                         matcher = new MassAssignMatcher(op1.expr, op2.expr);
    152 
    153                                                 std::list< ResolvExpr::AltList > options;
    154                                                 if ( match() )
    155                                                         /*
    156                                                           if ( hasMatched ) {
    157                                                           // throw SemanticError("Ambiguous tuple assignment");
    158                                                           } else {*/
    159                                                         // Matched for the first time
    160                                                         hasMatched = true;
    161                                                 /*} */
    162                                         } /* else if ( isTuple( op2 ) )
    163                                                  throw SemanticError("Inapplicable tuple assignment.");
    164                                           */
    165                                 }
    166 
    167                                 if ( hasMatched ) {
    168                                         if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
    169                                                 //options.print( std::cerr );
    170                                                 std::list< ResolvExpr::AltList >best = options.get_best();
    171                                                 if ( best.size() == 1 ) {
    172                                                         std::list<Expression *> solved_assigns;
    173                                                         for ( ResolvExpr::AltList::iterator i = best.front().begin(); i != best.front().end(); ++i ) {
    174                                                                 solved_assigns.push_back( i->expr );
    175                                                         }
    176                                                         /* assigning cost zero? */
    177                                                         currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MULTIPLE*/), currentFinder->get_environ(), ResolvExpr::Cost() ) );
     124                                                        matcher.reset( new MassAssignMatcher( *this,  *ali ) );
    178125                                                }
    179                                         } else {
    180                                                 assert( ! optMass.empty() );
    181                                                 ResolvExpr::AltList winners;
    182                                                 for ( std::vector< ResolvExpr::AltList >::iterator i = optMass.begin(); i != optMass.end(); ++i )
    183                                                         findMinCostAlt( i->begin(), i->end(), back_inserter(winners) );
    184 
    185                                                 std::list< Expression *> solved_assigns;
    186                                                 for ( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i )
    187                                                         solved_assigns.push_back( i->expr );
    188                                                 currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MASS*/), currentFinder->get_environ(), ResolvExpr::Cost() ) );
     126                                                match();
    189127                                        }
    190128                                }
    191129                        }
    192130                }
    193                 return hasMatched;
    194         }
    195 
    196         void TupleAssignSpotter::Matcher::init( Expression *_lhs, Expression *_rhs ) {
    197                 lhs.clear();
    198                 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(_lhs) )
    199                         if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(addr->get_arg()) )
    200                                 std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(lhs) );
    201 
    202                 rhs.clear();
    203         }
    204 
    205         TupleAssignSpotter::Matcher::Matcher( /*TupleAssignSpotter &spot,*/ Expression *_lhs, Expression *_rhs ) /*: own_spotter(spot) */{
    206                 init(_lhs,_rhs);
    207         }
    208 
    209         TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( Expression *_lhs, Expression *_rhs )/* : own_spotter(spot) */{
    210                 init(_lhs,_rhs);
    211 
    212                 if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(_rhs) )
    213                         std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(rhs) );
    214         }
    215 
    216         UntypedExpr *TupleAssignSpotter::Matcher::createAssgn( Expression *left, Expression *right ) {
    217                 if ( left && right ) {
    218                         std::list< Expression * > args;
    219                         args.push_back(new AddressExpr(left->clone()));  args.push_back(right->clone());
    220                         return new UntypedExpr(new NameExpr("?=?"), args);
    221                 } else
    222                         throw 0; // xxx - diagnose the problem
    223         }
    224 
    225         bool TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) {
    226                 if ( lhs.empty() || (rhs.size() != 1) ) return false;
    227 
    228                 for ( std::list< Expression * >::iterator l = lhs.begin(); l != lhs.end(); l++ ) {
    229                         std::list< Expression * > args;
    230                         args.push_back( new AddressExpr(*l) );
    231                         args.push_back( rhs.front() );
    232                         out.push_back( new UntypedExpr(new NameExpr("?=?"), args) );
    233                 }
    234 
    235                 return true;
    236         }
    237 
    238         bool TupleAssignSpotter::MassAssignMatcher::solve( std::list< Expression * > &assigns ) {
    239                 /*
    240                   std::list< Expression * > solved_assigns;
    241                   ResolvExpr::AltList solved_alts;
    242                   assert( currentFinder != 0 );
    243 
    244                   ResolvExpr::AltList current;
    245                   if ( optMass.empty() ) {
    246                   for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
    247                   optMass.push_back( ResolvExpr::AltList() );
    248                   }
    249                   int cnt = 0;
    250                   for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
    251 
    252                   ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    253                   finder.findWithAdjustment(*i);
    254                   ResolvExpr::AltList alts = finder.get_alternatives();
    255                   assert( alts.size() == 1 );
    256                   assert(alts.front().expr != 0 );
    257                   current.push_back( finder.get_alternatives().front() );
    258                   optMass[cnt].push_back( finder.get_alternatives().front() );
    259                   solved_assigns.push_back( alts.front().expr->clone() );
    260                   }
    261                 */
    262                 return true;
    263         }
    264 
    265         bool TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) {
    266                 // need more complicated matching
     131        }
     132
     133        void TupleAssignSpotter::match() {
     134                assert ( matcher != 0 );
     135
     136                std::list< Expression * > new_assigns;
     137                matcher->match( new_assigns );
     138
     139                if ( new_assigns.empty() ) return;
     140                ResolvExpr::AltList current;
     141                // now resolve new assignments
     142                for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
     143                        ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() );
     144                        try {
     145                                finder.findWithAdjustment(*i);
     146                        } catch (...) {
     147                                return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid
     148                        }
     149                        // prune expressions that don't coincide with
     150                        ResolvExpr::AltList alts = finder.get_alternatives();
     151                        assert( alts.size() == 1 );
     152                        assert( alts.front().expr != 0 );
     153                        current.push_back( alts.front() );
     154                }
     155
     156                // extract expressions from the assignment alternatives to produce a list of assignments that
     157                // together form a single alternative
     158                std::list< Expression *> solved_assigns;
     159                for ( ResolvExpr::Alternative & alt : current ) {
     160                        solved_assigns.push_back( alt.expr->clone() );
     161                }
     162                // xxx - need to do this??
     163                ResolvExpr::TypeEnvironment compositeEnv;
     164                simpleCombineEnvironments( current.begin(), current.end(), compositeEnv );
     165                currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) );
     166        }
     167
     168        TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter) {
     169                assert( ! alts.empty() );
     170                ResolvExpr::Alternative lhsAlt = alts.front();
     171                // peel off the cast that exists on ctor/dtor expressions
     172                bool isCast = false;
     173                if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( lhsAlt.expr ) ) {
     174                        lhsAlt.expr = castExpr->get_arg();
     175                        castExpr->set_arg( nullptr );
     176                        delete castExpr;
     177                        isCast = true;
     178                }
     179
     180                // explode the lhs so that each field of the tuple-valued-expr is assigned.
     181                explode( lhsAlt, back_inserter(lhs) );
     182                // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed
     183                if ( isCast ) {
     184                        for ( ResolvExpr::Alternative & alt : lhs ) {
     185                                Expression *& expr = alt.expr;
     186                                Type * castType = expr->get_result()->clone();
     187                                Type * type = InitTweak::getPointerBase( castType );
     188                                assert( type );
     189                                type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
     190                                type->set_isLvalue( true ); // xxx - might not need this
     191                                expr = new CastExpr( expr, castType );
     192                        }
     193                }
     194                // }
     195        }
     196
     197        TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter,const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) {
     198                assert( alts.size() == 1 || alts.size() == 2 );
     199                if ( alts.size() == 2 ) {
     200                        rhs.push_back( alts.back() );
     201                }
     202        }
     203
     204        TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) {
     205                // explode the rhs so that each field of the tuple-valued-expr is assigned.
     206                explode( std::next(alts.begin(), 1), alts.end(), back_inserter(rhs) );
     207        }
     208
     209        UntypedExpr * createFunc( const std::string &fname, ObjectDecl *left, ObjectDecl *right ) {
     210                assert( left );
     211                std::list< Expression * > args;
     212                args.push_back( new AddressExpr( new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ new VariableExpr( left ) } ) ) );
     213                // args.push_back( new AddressExpr( new VariableExpr( left ) ) );
     214                if ( right ) args.push_back( new VariableExpr( right ) );
     215                return new UntypedExpr( new NameExpr( fname ), args );
     216        }
     217
     218        ObjectDecl * newObject( UniqueName & namer, Expression * expr ) {
     219                assert( expr->has_result() && ! expr->get_result()->isVoid() );
     220                return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );
     221        }
     222
     223        void TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) {
     224                static UniqueName lhsNamer( "__massassign_L" );
     225                static UniqueName rhsNamer( "__massassign_R" );
     226                assert ( ! lhs.empty() && rhs.size() <= 1);
     227
     228                ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr;
     229                for ( ResolvExpr::Alternative & lhsAlt : lhs ) {
     230                        ObjectDecl * ltmp = newObject( lhsNamer, lhsAlt.expr );
     231                        out.push_back( createFunc( spotter.fname, ltmp, rtmp ) );
     232                        tmpDecls.push_back( ltmp );
     233                }
     234                if ( rtmp ) tmpDecls.push_back( rtmp );
     235        }
     236
     237        void TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) {
     238                static UniqueName lhsNamer( "__multassign_L" );
     239                static UniqueName rhsNamer( "__multassign_R" );
     240                // xxx - need more complicated matching?
    267241                if ( lhs.size() == rhs.size() ) {
    268                         zipWith( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), back_inserter(out), TupleAssignSpotter::Matcher::createAssgn );
    269                         return true;
    270                 } //else
    271                 //std::cerr << "The length of (left, right) is: (" << lhs.size() << "," << rhs.size() << ")" << std::endl;*/
    272                 return false;
    273         }
    274 
    275         bool TupleAssignSpotter::MultipleAssignMatcher::solve( std::list< Expression * > &assigns ) {
    276                 /*
    277                   std::list< Expression * > solved_assigns;
    278                   ResolvExpr::AltList solved_alts;
    279                   assert( currentFinder != 0 );
    280 
    281                   ResolvExpr::AltList current;
    282                   for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
    283                   //try {
    284                   ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    285                   finder.findWithAdjustment(*i);
    286                   // prune expressions that don't coincide with
    287                   ResolvExpr::AltList alts = finder.get_alternatives();
    288                   assert( alts.size() == 1 );
    289                   assert(alts.front().expr != 0 );
    290                   current.push_back( finder.get_alternatives().front() );
    291                   solved_assigns.push_back( alts.front().expr->clone() );
    292                   //solved_assigns.back()->print(std::cerr);
    293                   //} catch( ... ) {
    294                   //continue; // no reasonable alternative found
    295                   //}
    296                   }
    297                   options.add_option( current );
    298                 */
    299 
    300                 return true;
    301         }
    302 
    303         void TupleAssignSpotter::Options::add_option( ResolvExpr::AltList &opt ) {
    304                 using namespace std;
    305 
    306                 options.push_back( opt );
    307                 /*
    308                   vector< Cost > costs;
    309                   costs.reserve( opt.size() );
    310                   transform( opt.begin(), opt.end(), back_inserter(costs), ptr_fun(extract_cost) );
    311                 */
    312                 // transpose matrix
    313                 if ( costMatrix.empty() )
    314                         for ( unsigned int i = 0; i< opt.size(); ++i)
    315                                 costMatrix.push_back( vector<ResolvExpr::Cost>() );
    316 
    317                 int cnt = 0;
    318                 for ( ResolvExpr::AltList::iterator i = opt.begin(); i != opt.end(); ++i, cnt++ )
    319                         costMatrix[cnt].push_back( i->cost );
    320 
    321                 return;
    322         }
    323 
    324         std::list< ResolvExpr::AltList > TupleAssignSpotter::Options::get_best() {
    325                 using namespace std;
    326                 using namespace ResolvExpr;
    327                 list< ResolvExpr::AltList > ret;
    328                 list< multiset<int> > solns;
    329                 for ( vector< vector<Cost> >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
    330                         list<int> current;
    331                         findMinCost( i->begin(), i->end(), back_inserter(current) );
    332                         solns.push_back( multiset<int>(current.begin(), current.end()) );
    333                 }
    334                 // need to combine
    335                 multiset<int> result;
    336                 lift_intersection( solns.begin(), solns.end(), inserter( result, result.begin() ) );
    337                 if ( result.size() != 1 )
    338                         throw SemanticError("Ambiguous tuple expression");
    339                 ret.push_back(get_option( *(result.begin() )));
    340                 return ret;
    341         }
    342 
    343         void TupleAssignSpotter::Options::print( std::ostream &ostr ) {
    344                 using namespace std;
    345 
    346                 for ( vector< vector < ResolvExpr::Cost > >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
    347                         for ( vector < ResolvExpr::Cost >::iterator j = i->begin(); j != i->end(); ++j )
    348                                 ostr << *j << " " ;
    349                         ostr << std::endl;
    350                 } // for
    351                 return;
    352         }
    353 
    354         ResolvExpr::Cost extract_cost( ResolvExpr::Alternative &alt ) {
    355                 return alt.cost;
    356         }
    357 
    358         template< typename InputIterator, typename OutputIterator >
    359         void TupleAssignSpotter::Options::findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    360                 using namespace ResolvExpr;
    361                 std::list<int> alternatives;
    362 
    363                 // select the alternatives that have the minimum parameter cost
    364                 Cost minCost = Cost::infinity;
    365                 unsigned int index = 0;
    366                 for ( InputIterator i = begin; i != end; ++i, index++ ) {
    367                         if ( *i < minCost ) {
    368                                 minCost = *i;
    369                                 alternatives.clear();
    370                                 alternatives.push_back( index );
    371                         } else if ( *i == minCost ) {
    372                                 alternatives.push_back( index );
    373                         }
    374                 }
    375                 std::copy( alternatives.begin(), alternatives.end(), out );
    376         }
    377 
    378         template< class InputIterator, class OutputIterator >
    379         void TupleAssignSpotter::Options::lift_intersection( InputIterator begin, InputIterator end, OutputIterator out ) {
    380                 if ( begin == end ) return;
    381                 InputIterator test = begin;
    382 
    383                 if (++test == end)
    384                         { copy(begin->begin(), begin->end(), out); return; }
    385 
    386 
    387                 std::multiset<int> cur; // InputIterator::value_type::value_type
    388                 copy( begin->begin(), begin->end(), inserter( cur, cur.begin() ) );
    389 
    390                 while ( test != end ) {
    391                         std::multiset<int> temp;
    392                         set_intersection( cur.begin(), cur.end(), test->begin(), test->end(), inserter(temp,temp.begin()) );
    393                         cur.clear();
    394                         copy( temp.begin(), temp.end(), inserter(cur,cur.begin()));
    395                         ++test;
    396                 }
    397 
    398                 copy( cur.begin(), cur.end(), out );
    399                 return;
    400         }
    401 
    402         ResolvExpr::AltList TupleAssignSpotter::Options::get_option( std::list< ResolvExpr::AltList >::size_type index ) {
    403                 if ( index >= options.size() )
    404                         throw 0; // XXX
    405                 std::list< ResolvExpr::AltList >::iterator it = options.begin();
    406                 for ( std::list< ResolvExpr::AltList >::size_type i = 0; i < index; ++i, ++it );
    407                 return *it;
     242                        std::list< ObjectDecl * > ltmp;
     243                        std::list< ObjectDecl * > rtmp;
     244                        std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), []( ResolvExpr::Alternative & alt ){
     245                                return newObject( lhsNamer, alt.expr );
     246                        });
     247                        std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), []( ResolvExpr::Alternative & alt ){
     248                                return newObject( rhsNamer, alt.expr );
     249                        });
     250                        zipWith( ltmp.begin(), ltmp.end(), rtmp.begin(), rtmp.end(), back_inserter(out), [&](ObjectDecl * obj1, ObjectDecl * obj2 ) { return createFunc(spotter.fname, obj1, obj2); } );
     251                        tmpDecls.splice( tmpDecls.end(), ltmp );
     252                        tmpDecls.splice( tmpDecls.end(), rtmp );
     253                }
    408254        }
    409255} // namespace Tuples
  • src/Tuples/module.mk

    rfe7b281 ra1e67dd  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    1616
    1717SRC +=  Tuples/TupleAssignment.cc \
    18         Tuples/NameMatcher.cc
     18        Tuples/TupleExpansion.cc
  • src/main.cc

    rfe7b281 ra1e67dd  
    4242#include "Common/UnimplementedError.h"
    4343#include "../config.h"
     44#include "Tuples/Tuples.h"
    4445
    4546using namespace std;
     
    231232                OPTPRINT( "tweakInit" )
    232233                InitTweak::genInit( translationUnit );
    233 
     234                OPTPRINT( "expandMemberTuples" );
     235                Tuples::expandMemberTuples( translationUnit );
    234236                if ( libcfap ) {
    235237                        // generate the bodies of cfa library functions
     
    248250                        return 0;
    249251                } // if
     252
     253                OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr
     254                Tuples::expandUniqueExpr( translationUnit );
    250255
    251256                // fix ObjectDecl - replaces ConstructorInit nodes
     
    272277                OPTPRINT( "box" )
    273278                GenPoly::box( translationUnit );
     279                OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
     280                Tuples::expandTuples( translationUnit );
    274281
    275282                // print tree right before code generation
Note: See TracChangeset for help on using the changeset viewer.