Changes in / [7756647:d58a39a0]


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

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r7756647 rd58a39a0  
    309309                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    310310                                                        newExpr->get_args().push_back( *arg );
    311                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_result() );
     311                                                        assert( (*arg)->get_results().size() == 1 );
     312                                                        Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
    312313                                                        assert( type );
    313                                                         newExpr->set_result( type->clone() );
     314                                                        newExpr->get_results().push_back( type->clone() );
    314315                                                        *arg = newExpr;
    315316                                                } // if
     
    526527                extension( castExpr );
    527528                output << "(";
    528                 if ( castExpr->get_result()->isVoid() ) {
     529                if ( castExpr->get_results().empty() ) {
    529530                        output << "(void)" ;
    530                 } else if ( ! castExpr->get_result()->get_isLvalue() ) {
     531                } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
    531532                        // at least one result type of cast, but not an lvalue
    532533                        output << "(";
    533                         output << genType( castExpr->get_result(), "" );
     534                        output << genType( castExpr->get_results().front(), "" );
    534535                        output << ")";
    535536                } else {
     
    639640        }
    640641
    641         void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
     642        void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
    642643
    643644        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    653654                asmExpr->get_operand()->accept( *this );
    654655                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 << "})";
    690656        }
    691657
  • src/CodeGen/CodeGenerator.h

    r7756647 rd58a39a0  
    7070                virtual void visit( ConditionalExpr *conditionalExpr );
    7171                virtual void visit( CommaExpr *commaExpr );
    72                 virtual void visit( CompoundLiteralExpr *compLitExpr );
    7372                virtual void visit( TupleExpr *tupleExpr );
    7473                virtual void visit( TypeExpr *typeExpr );
    7574                virtual void visit( AsmExpr * );
    76                 virtual void visit( StmtExpr * );
    7775
    7876                //*** Statements
  • src/CodeGen/GenType.cc

    r7756647 rd58a39a0  
    227227                        typeString = "_Atomic " + typeString;
    228228                } // if
     229                if ( type->get_isAttribute() ) {
     230                        typeString = "__attribute(( )) " + typeString;
     231                } // if
    229232        }
    230233} // namespace CodeGen
  • src/Common/utility.h

    r7756647 rd58a39a0  
    148148}
    149149
    150 // replace element of list with all elements of another list
    151150template< typename T >
    152151void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
     
    159158
    160159        return;
    161 }
    162 
    163 // replace range of a list with a single element
    164 template< typename T >
    165 void 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 );
    168160}
    169161
  • src/ControlStruct/Mutate.cc

    r7756647 rd58a39a0  
    2323#include "MLEMutator.h"
    2424#include "ForExprMutator.h"
     25#include "LabelTypeChecker.h"
    2526//#include "ExceptMutator.h"
    2627
     
    4041
    4142                //ExceptMutator exc;
     43                // LabelTypeChecker lbl;
    4244
    4345                mutateAll( translationUnit, formut );
    4446                acceptAll( translationUnit, lfix );
    4547                //mutateAll( translationUnit, exc );
     48                //acceptAll( translationUnit, lbl );
    4649        }
    4750} // namespace CodeGen
  • src/ControlStruct/module.mk

    r7756647 rd58a39a0  
    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
     21        ControlStruct/ForExprMutator.cc \
     22        ControlStruct/LabelTypeChecker.cc
    2223
  • src/GenPoly/Box.cc

    r7756647 rd58a39a0  
    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 Type::ForallList &forall );
     112                        void findTypeOps( const std::list< TypeDecl *> &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 Type::ForallList &forall ) {
     614                void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) {
    615615                        // what if a nested function uses an assignment operator?
    616616                        // assignOps.clear();
    617                         for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     617                        for ( std::list< TypeDecl *>::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 ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     682                                for ( std::list< TypeDecl *>::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()->has_result() ) return;
    785                         FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() );
     784                        if ( appExpr->get_function()->get_results().empty() ) return;
     785                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
    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 ) continue; // xxx - previously had check for non-empty fnArgBase results
    802                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );
     801                                if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
     802                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), 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 ) ); // xxx - result is never set on NameExpr
     892                        appExpr->set_function( new NameExpr( adapterName ) );
    893893
    894894                        return ret;
     
    896896
    897897                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    898                         assert( arg->has_result() );
     898                        assert( ! arg->get_results().empty() );
    899899                        if ( isPolyType( param, exprTyVars ) ) {
    900                                 if ( isPolyType( arg->get_result() ) ) {
     900                                if ( isPolyType( arg->get_results().front() ) ) {
    901901                                        // if the argument's type is polymorphic, we don't need to box again!
    902902                                        return;
    903                                 } else if ( arg->get_result()->get_isLvalue() ) {
     903                                } else if ( arg->get_results().front()->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 ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     948                        for ( std::list< TypeDecl *>::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->set_result( arg->get_type()->clone() );
     989                                        deref->get_results().push_back( arg->get_type()->clone() );
    990990                                        return deref;
    991991                                } // if
     
    10131013                        Statement *bodyStmt;
    10141014
    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();
     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();
    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 ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     1066                        for ( std::list< TypeDecl *>::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->set_result( appExpr->get_result()->clone() );
     1126                        addAssign->get_results().front() = appExpr->get_results().front()->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->has_result() );
     1140                                                assert( ! appExpr->get_results().empty() );
    11411141                                                assert( appExpr->get_args().size() == 2 );
    1142                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
    1143                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
     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 );
    11441144                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11451145                                                UntypedExpr *ret = 0;
     
    11611161                                                } // if
    11621162                                                if ( baseType1 || baseType2 ) {
    1163                                                         ret->set_result( appExpr->get_result()->clone() );
     1163                                                        ret->get_results().push_front( appExpr->get_results().front()->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->has_result() );
     1173                                                assert( ! appExpr->get_results().empty() );
    11741174                                                assert( ! appExpr->get_args().empty() );
    1175                                                 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
     1175                                                if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
    11761176                                                        Expression *ret = appExpr->get_args().front();
    1177                                                         delete ret->get_result();
    1178                                                         ret->set_result( appExpr->get_result()->clone() );
     1177                                                        delete ret->get_results().front();
     1178                                                        ret->get_results().front() = appExpr->get_results().front()->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->has_result() );
     1188                                                assert( ! appExpr->get_results().empty() );
    11891189                                                assert( appExpr->get_args().size() == 1 );
    1190                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    1191                                                         Type *tempType = appExpr->get_result()->clone();
     1190                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1191                                                        Type *tempType = appExpr->get_results().front()->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->has_result() );
     1208                                                assert( ! appExpr->get_results().empty() );
    12091209                                                assert( appExpr->get_args().size() == 1 );
    1210                                                 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1210                                                if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), 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->has_result() );
     1214                                                assert( ! appExpr->get_results().empty() );
    12151215                                                assert( appExpr->get_args().size() == 2 );
    1216                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
    1217                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
     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 );
    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->set_result( appExpr->get_result()->clone() );
     1222                                                        divide->get_results().push_front( appExpr->get_results().front()->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->has_result() );
     1240                                                assert( ! appExpr->get_results().empty() );
    12411241                                                assert( appExpr->get_args().size() == 2 );
    1242                                                 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
     1242                                                Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
    12431243                                                if ( baseType ) {
    12441244                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12661266                        useRetval = oldUseRetval;
    12671267
    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() );
     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 );
    12711273
    12721274                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13061308
    13071309                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1308                         if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1310                        if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13091311                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13101312                                        if ( name->get_name() == "*?" ) {
     
    13201322
    13211323                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1322                         assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
     1324                        assert( ! addrExpr->get_arg()->get_results().empty() );
    13231325
    13241326                        bool needs = false;
    13251327                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1326                                 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
     1328                                if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
    13271329                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13281330                                                if ( name->get_name() == "*?" ) {
    13291331                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    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() );
     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 );
    13331337                                                                needs = needsAdapter( function, scopeTyVars );
    13341338                                                        } // if
     
    13391343                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13401344                        // out of the if condition.
    1341                         bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
     1345                        bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
    13421346                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13431347                        if ( polytype || needs ) {
    13441348                                Expression *ret = addrExpr->get_arg();
    1345                                 delete ret->get_result();
    1346                                 ret->set_result( addrExpr->get_result()->clone() );
     1349                                delete ret->get_results().front();
     1350                                ret->get_results().front() = addrExpr->get_results().front()->clone();
    13471351                                addrExpr->set_arg( 0 );
    13481352                                delete addrExpr;
     
    13821386                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13831387                        if ( retval && returnStmt->get_expr() ) {
    1384                                 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
     1388                                assert( ! returnStmt->get_expr()->get_results().empty() );
    13851389                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13861390                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14161420                                        // find each of its needed secondary assignment operators
    14171421                                        std::list< Expression* > &tyParams = refType->get_parameters();
    1418                                         Type::ForallList &forallParams = functionDecl->get_type()->get_forall();
     1422                                        std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall();
    14191423                                        std::list< Expression* >::const_iterator tyIt = tyParams.begin();
    1420                                         Type::ForallList::const_iterator forallIt = forallParams.begin();
     1424                                        std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();
    14211425                                        for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) {
    14221426                                                // Add appropriate mapping to assignment expression environment
     
    14621466                                // replace return statement with appropriate assignment to out parameter
    14631467                                Expression *retParm = new NameExpr( retval->get_name() );
    1464                                 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1468                                retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14651469                                assignExpr->get_args().push_back( retParm );
    14661470                                assignExpr->get_args().push_back( returnStmt->get_expr() );
     
    15921596                        ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0,
    15931597                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1594                         for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1598                        for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    15951599                                ObjectDecl *sizeParm, *alignParm;
    15961600                                // add all size and alignment parameters to parameter list
  • src/GenPoly/CopyParams.cc

    r7756647 rd58a39a0  
    5454                                std::map< std::string, DeclarationWithType* > assignOps;
    5555                                // assume the assignment operator is the first assert param after any "type" parameter
    56                                 for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
     56                                for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    2929                virtual Type *mutate( PointerType *pointerType );
    3030          private:
    31                 void handleForall( const Type::ForallList &forall );
     31                void handleForall( const std::list< TypeDecl* > &forall );
    3232
    3333                std::list< FunctionType* > &functions;
     
    5151        }
    5252
    53         void FindFunction::handleForall( const Type::ForallList &forall ) {
    54                 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     53        void FindFunction::handleForall( const std::list< TypeDecl* > &forall ) {
     54                for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    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 ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
     230                for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    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() );
    101103
    102                         PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    103                         FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     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 );
    104108
    105109                        Type *funType = isLvalueRet( function );
    106110                        if ( funType && ! isIntrinsicApp( appExpr ) ) {
    107111                                Expression *expr = appExpr;
    108                                 Type *appType = appExpr->get_result();
     112                                Type *appType = appExpr->get_results().front();
    109113                                if ( isPolyType( funType ) && ! isPolyType( appType ) ) {
    110114                                        // make sure cast for polymorphic type is inside dereference
     
    112116                                }
    113117                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    114                                 deref->set_result( appType->clone() );
    115                                 appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) );
     118                                deref->get_results().push_back( appType->clone() );
     119                                appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
    116120                                deref->get_args().push_back( expr );
    117121                                return deref;
     
    123127                Statement * Pass1::mutate(ReturnStmt *retStmt) {
    124128                        if ( retval && retStmt->get_expr() ) {
    125                                 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) {
     129                                assert( ! retStmt->get_expr()->get_results().empty() );
     130                                if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) {
    126131                                        // ***** Code Removal ***** because casts may be stripped already
    127132
     
    150155                                retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) );
    151156                        } // if
    152 
     157 
    153158                        Visitor::visit( funType );
    154159                }
  • src/GenPoly/Specialize.cc

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

    r7756647 rd58a39a0  
    6969
    7070                        /// create and resolve ctor/dtor expression: fname(var, [cpArg])
    71                         Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
    72                         Expression * makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg = NULL );
     71                        ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
    7372                        /// true if type does not need to be copy constructed to ensure correctness
    74                         bool skipCopyConstruct( Type * type );
    75                         void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr );
    76                         void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr );
     73                        bool skipCopyConstruct( Type * );
    7774                private:
    7875                        TypeSubstitution * env;
     
    360357                }
    361358
    362                 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
     359                ApplicationExpr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
    363360                        assert( var );
    364                         return makeCtorDtor( fname, new AddressExpr( new VariableExpr( var ) ), cpArg );
    365                 }
    366 
    367                 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg ) {
    368                         assert( thisArg );
    369361                        UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) );
    370                         untyped->get_args().push_back( thisArg );
     362                        untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ) );
    371363                        if (cpArg) untyped->get_args().push_back( cpArg->clone() );
    372364
     
    375367                        // (VariableExpr and already resolved expression)
    376368                        CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
    377                         Expression * resolved = ResolvExpr::findVoidExpression( untyped, *this );
    378                         assert( resolved );
     369                        ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
    379370                        if ( resolved->get_env() ) {
    380371                                env->add( *resolved->get_env() );
    381372                        } // if
    382373
     374                        assert( resolved );
    383375                        delete untyped;
    384376                        return resolved;
    385377                }
    386378
    387                 void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) {
     379                void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    388380                        static UniqueName tempNamer("_tmp_cp");
    389                         CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
    390                         assert( arg->has_result() );
    391                         Type * result = arg->get_result();
    392                         if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types
    393 
    394                         // type may involve type variables, so apply type substitution to get temporary variable's actual type
    395                         result = result->clone();
    396                         impCpCtorExpr->get_env()->apply( result );
    397                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    398                         tmp->get_type()->set_isConst( false );
    399 
    400                         // create and resolve copy constructor
    401                         CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
    402                         Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg );
    403 
    404                         if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) {
    405                                 // if the chosen constructor is intrinsic, the copy is unnecessary, so
    406                                 // don't create the temporary and don't call the copy constructor
    407                                 VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
    408                                 assert( function );
    409                                 if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return;
    410                         }
    411 
    412                         // replace argument to function call with temporary
    413                         arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
    414                         impCpCtorExpr->get_tempDecls().push_back( tmp );
    415                         impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
    416                 }
    417 
    418                 void ResolveCopyCtors::destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ) {
    419                         impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( ret ) ) );
    420                 }
    421 
    422                 void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
     381                        static UniqueName retNamer("_tmp_cp_ret");
     382
    423383                        CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
    424384                        Visitor::visit( impCpCtorExpr );
     
    429389                        // take each argument and attempt to copy construct it.
    430390                        for ( Expression * & arg : appExpr->get_args() ) {
    431                                 copyConstructArg( arg, impCpCtorExpr );
     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
    432416                        } // for
    433417
     
    439423                        // level. Trying to pass that environment along.
    440424                        callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    441                         Type * result = appExpr->get_result();
    442                         if ( ! result->isVoid() ) {
    443                                 static UniqueName retNamer("_tmp_cp_ret");
     425                        for ( Type * result : appExpr->get_results() ) {
    444426                                result = result->clone();
    445427                                impCpCtorExpr->get_env()->apply( result );
     
    448430                                impCpCtorExpr->get_returnDecls().push_back( ret );
    449431                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    450                                 destructRet( new VariableExpr( ret ) , impCpCtorExpr );
     432                                impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
    451433                        } // for
    452434                        CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
     
    497479                                // know the result type of the assignment is the type of the LHS (minus the pointer), so
    498480                                // add that onto the assignment expression so that later steps have the necessary information
    499                                 assign->set_result( returnDecl->get_type()->clone() );
     481                                assign->add_result( returnDecl->get_type()->clone() );
    500482
    501483                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    502                                 if ( callExpr->get_result()->get_isLvalue() ) {
     484                                if ( callExpr->get_results().front()->get_isLvalue() ) {
    503485                                        // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning
    504486                                        // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the
     
    518500                                        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    519501                                        deref->get_args().push_back( retExpr );
    520                                         deref->set_result( resultType );
     502                                        deref->add_result( resultType );
    521503                                        retExpr = deref;
    522504                                } // if
     
    957939                Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) {
    958940                        static UniqueName tempNamer( "_tmp_ctor_expr" );
    959                         assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 );
    960                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );
     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 );
    961943                        addDeclaration( tmp );
    962944
     
    970952                        assign->get_args().push_back( new VariableExpr( tmp ) );
    971953                        assign->get_args().push_back( firstArg );
    972                         assign->set_result( ctorExpr->get_result()->clone() );
     954                        cloneAll( ctorExpr->get_results(), assign->get_results() );
    973955                        firstArg = assign;
    974956
  • src/InitTweak/GenInit.cc

    r7756647 rd58a39a0  
    2929#include "GenPoly/DeclMutator.h"
    3030#include "GenPoly/ScopedSet.h"
    31 #include "ResolvExpr/typeops.h"
    3231
    3332namespace InitTweak {
     
    5150
    5251          protected:
    53                 FunctionType * ftype;
     52                std::list<DeclarationWithType*> returnVals;
    5453                UniqueName tempNamer;
    5554                std::string funcName;
     
    8786
    8887                bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
    89                 bool isManaged( Type * type ) const; // determine if type is managed
    9088                void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
    9189                GenPoly::ScopedSet< std::string > managedTypes;
     
    136134
    137135        Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
    138                 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
     136                // update for multiple return values
    139137                assert( returnVals.size() == 0 || returnVals.size() == 1 );
    140138                // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
     
    158156
    159157        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    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 );
     158                ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals );
    170159                ValueGuard< std::string > oldFuncName( funcName );
    171160
    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                 }
     161                FunctionType * type = functionDecl->get_functionType();
     162                returnVals = type->get_returnVals();
    180163                funcName = functionDecl->get_name();
    181164                DeclarationWithType * decl = Mutator::mutate( functionDecl );
     
    237220        }
    238221
    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 
    249222        bool CtorDtor::isManaged( ObjectDecl * objDecl ) const {
    250223                Type * type = objDecl->get_type();
     
    252225                        type = at->get_base();
    253226                }
    254                 return isManaged( type );
     227                return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
    255228        }
    256229
     
    315288                managedTypes.beginScope();
    316289                // go through assertions and recursively add seen ctor/dtors
    317                 for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) {
     290                for ( TypeDecl * tyDecl : functionDecl->get_functionType()->get_forall() ) {
    318291                        for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
    319292                                assertion = assertion->acceptMutator( *this );
  • src/InitTweak/InitTweak.cc

    r7756647 rd58a39a0  
    340340                return allofCtorDtor( stmt, []( Expression * callExpr ){
    341341                        if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
    342                                 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() );
     342                                assert( ! appExpr->get_function()->get_results().empty() );
     343                                FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() );
    343344                                assert( funcType );
    344345                                return funcType->get_parameters().size() == 1;
     
    387388                                return memberExpr->get_member()->get_name();
    388389                        } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) {
    389                                 return funcName( memberExpr->get_member() );
     390                                return memberExpr->get_member();
    390391                        } else {
    391392                                assertf( false, "Unexpected expression type being called as a function in call expression" );
     
    450451                // virtual void visit( LogicalExpr *logicalExpr );
    451452                // virtual void visit( ConditionalExpr *conditionalExpr );
     453                virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
     454                virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; }
    452455                virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }
    453456                virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }
    454457                virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }
    455458                virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
    456                 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
    457                 virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
    458459
    459460                bool isConstExpr;
  • src/Makefile.in

    r7756647 rd58a39a0  
    105105        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    106106        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
     107        ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \
    107108        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    108109        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    190191        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
    191192        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    192         Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
     193        Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    193194am_driver_cfa_cpp_OBJECTS = $(am__objects_1)
    194195driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS)
     
    363364        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    364365        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    365         ControlStruct/ForExprMutator.cc GenPoly/Box.cc \
     366        ControlStruct/ForExprMutator.cc \
     367        ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \
    366368        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    367369        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
     
    403405        SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \
    404406        SynTree/Attribute.cc Tuples/TupleAssignment.cc \
    405         Tuples/TupleExpansion.cc
     407        Tuples/NameMatcher.cc
    406408MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    407409        ${cfa_cpplib_PROGRAMS}}
     
    538540        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    539541ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT):  \
     542        ControlStruct/$(am__dirstamp) \
     543        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     544ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT):  \
    540545        ControlStruct/$(am__dirstamp) \
    541546        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     
    771776Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT):  \
    772777        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    773 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT): \
    774         Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
     778Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \
     779        Tuples/$(DEPDIR)/$(am__dirstamp)
    775780driver/$(am__dirstamp):
    776781        @$(MKDIR_P) driver
     
    794799        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
    795800        -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT)
     801        -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)
    796802        -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT)
    797803        -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT)
     
    880886        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
    881887        -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)
     888        -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    882889        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
    883         -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
    884890
    885891distclean-compile:
     
    900906@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
    901907@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@
    902909@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@
    903910@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
     
    986993@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    987994@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@
    988996@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@
    990997
    991998.cc.o:
     
    12291236@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`
    12301237
     1238ControlStruct/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
     1245ControlStruct/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
    12311252GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    12321253@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
     
    24192440@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`
    24202441
    2421 Tuples/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 
    2428 Tuples/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`
     2442Tuples/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
     2449Tuples/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`
    24342455
    24352456.ll.cc:
  • src/Parser/ExpressionNode.cc

    r7756647 rd58a39a0  
    198198}
    199199
    200 Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
    201         UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
    202         return ret;
    203 }
    204 
    205 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) {
     200Expression *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
     206Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) {
    206207        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    207208        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    208         UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref );
     209        UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
     210        delete member;
    209211        return ret;
    210212}
  • src/Parser/ParseNode.h

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

    r7756647 rd58a39a0  
    385385} // TypeData::print
    386386
    387 template< typename ForallList >
    388 void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) {
     387void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) {
    389388        buildList( firstNode, outputList );
    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 ) {
     389        for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     390                if ( (*i)->get_kind() == TypeDecl::Any ) {
    393391                        // add assertion parameters to `type' tyvars in reverse order
    394392                        // add dtor:  void ^?{}(T *)
    395393                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    398396
    399397                        // add copy ctor:  void ?{}(T *, T)
    400398                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    404402
    405403                        // add default ctor:  void ?{}(T *)
    406404                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    409407
    410408                        // add assignment operator:  T * ?=?(T *, T)
    411409                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    416414                } // if
    417415        } // for
     
    517515                // character types. The implementation shall define char to have the same range, representation, and behavior as
    518516                // either signed char or unsigned char.
    519                 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char };
     517                static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 
    520518
    521519                if ( td->length != DeclarationNode::NoLength ) {
  • src/Parser/parser.cc

    r7756647 rd58a39a0  
    10251025       0,   302,   302,   306,   313,   314,   315,   319,   320,   321,
    10261026     325,   326,   330,   331,   335,   336,   340,   344,   345,   356,
    1027      358,   360,   362,   367,   368,   374,   378,   380,   382,   384,
    1028      386,   388,   390,   392,   394,   403,   404,   410,   411,   415,
    1029      416,   420,   424,   426,   428,   430,   435,   436,   440,   443,
    1030      445,   447,   452,   465,   467,   469,   471,   473,   475,   477,
    1031      479,   481,   483,   485,   492,   493,   499,   500,   501,   502,
    1032      506,   507,   509,   514,   515,   517,   519,   524,   525,   527,
    1033      532,   533,   535,   540,   541,   543,   545,   547,   552,   553,
    1034      555,   560,   561,   566,   567,   572,   573,   578,   579,   584,
    1035      585,   590,   591,   594,   596,   601,   606,   607,   609,   615,
    1036      616,   620,   621,   622,   623,   624,   625,   626,   627,   628,
    1037      629,   630,   631,   637,   639,   641,   643,   648,   649,   654,
    1038      655,   661,   662,   668,   669,   670,   671,   672,   673,   674,
    1039      675,   676,   686,   693,   695,   705,   706,   711,   713,   719,
    1040      721,   725,   726,   731,   736,   739,   741,   743,   753,   755,
    1041      766,   767,   769,   773,   775,   779,   780,   785,   786,   790,
    1042      795,   796,   800,   802,   808,   809,   813,   815,   817,   819,
    1043      825,   826,   830,   832,   837,   839,   841,   846,   848,   853,
    1044      855,   859,   862,   866,   869,   873,   875,   877,   879,   884,
    1045      886,   888,   893,   895,   897,   899,   901,   906,   908,   910,
    1046      912,   917,   929,   930,   935,   937,   942,   946,   948,   950,
    1047      952,   954,   960,   961,   967,   968,   972,   973,   978,   980,
    1048      986,   987,   989,   994,   999,  1009,  1011,  1015,  1016,  1021,
    1049     1023,  1027,  1028,  1032,  1034,  1038,  1039,  1043,  1044,  1048,
    1050     1049,  1064,  1065,  1066,  1067,  1068,  1072,  1077,  1084,  1094,
    1051     1099,  1104,  1112,  1117,  1122,  1127,  1132,  1140,  1162,  1167,
    1052     1174,  1176,  1183,  1188,  1193,  1204,  1209,  1214,  1219,  1224,
    1053     1233,  1238,  1246,  1247,  1248,  1249,  1255,  1260,  1268,  1269,
    1054     1270,  1271,  1275,  1276,  1277,  1278,  1283,  1284,  1293,  1294,
    1055     1299,  1300,  1305,  1307,  1309,  1311,  1313,  1316,  1315,  1327,
    1056     1328,  1330,  1340,  1341,  1346,  1348,  1350,  1352,  1354,  1357,
    1057     1359,  1362,  1367,  1369,  1371,  1373,  1375,  1377,  1379,  1381,
    1058     1383,  1385,  1387,  1389,  1391,  1397,  1398,  1400,  1402,  1404,
    1059     1409,  1410,  1416,  1417,  1419,  1421,  1426,  1428,  1430,  1432,
    1060     1437,  1438,  1440,  1442,  1447,  1448,  1450,  1455,  1456,  1458,
    1061     1460,  1465,  1467,  1469,  1474,  1475,  1479,  1481,  1487,  1486,
    1062     1490,  1492,  1497,  1499,  1505,  1506,  1511,  1512,  1514,  1515,
    1063     1524,  1525,  1527,  1529,  1534,  1536,  1542,  1543,  1545,  1548,
    1064     1551,  1556,  1557,  1562,  1567,  1571,  1573,  1579,  1578,  1585,
    1065     1587,  1593,  1594,  1602,  1603,  1607,  1608,  1609,  1611,  1613,
    1066     1620,  1621,  1623,  1625,  1630,  1631,  1637,  1638,  1642,  1643,
    1067     1648,  1649,  1650,  1652,  1660,  1661,  1663,  1666,  1668,  1672,
    1068     1673,  1674,  1676,  1678,  1682,  1687,  1695,  1696,  1705,  1707,
    1069     1712,  1713,  1714,  1718,  1719,  1720,  1724,  1725,  1726,  1730,
    1070     1731,  1732,  1737,  1738,  1739,  1740,  1746,  1747,  1749,  1754,
    1071     1755,  1760,  1761,  1762,  1763,  1764,  1779,  1780,  1785,  1786,
    1072     1792,  1794,  1797,  1799,  1801,  1824,  1825,  1827,  1829,  1834,
    1073     1835,  1837,  1842,  1847,  1848,  1854,  1853,  1857,  1861,  1863,
    1074     1865,  1871,  1872,  1877,  1882,  1884,  1889,  1891,  1892,  1894,
    1075     1899,  1901,  1903,  1908,  1910,  1915,  1920,  1928,  1934,  1933,
    1076     1947,  1948,  1953,  1954,  1958,  1963,  1968,  1976,  1981,  1992,
    1077     1993,  1998,  1999,  2005,  2006,  2010,  2011,  2012,  2015,  2014,
    1078     2025,  2034,  2040,  2046,  2055,  2061,  2067,  2073,  2079,  2087,
    1079     2093,  2101,  2107,  2116,  2117,  2118,  2122,  2126,  2128,  2133,
    1080     2134,  2138,  2139,  2144,  2150,  2151,  2154,  2156,  2157,  2161,
    1081     2162,  2163,  2164,  2198,  2200,  2201,  2203,  2208,  2213,  2218,
    1082     2220,  2222,  2227,  2229,  2231,  2233,  2238,  2240,  2249,  2251,
    1083     2252,  2257,  2259,  2261,  2266,  2268,  2270,  2275,  2277,  2279,
    1084     2288,  2289,  2290,  2294,  2296,  2298,  2303,  2305,  2307,  2312,
    1085     2314,  2316,  2331,  2333,  2334,  2336,  2341,  2342,  2347,  2349,
    1086     2351,  2356,  2358,  2360,  2362,  2367,  2369,  2371,  2381,  2383,
    1087     2384,  2386,  2391,  2393,  2395,  2400,  2402,  2404,  2406,  2411,
    1088     2413,  2415,  2446,  2448,  2449,  2451,  2456,  2461,  2469,  2471,
    1089     2473,  2478,  2480,  2485,  2487,  2501,  2502,  2504,  2509,  2511,
    1090     2513,  2515,  2517,  2522,  2523,  2525,  2527,  2532,  2534,  2536,
    1091     2542,  2544,  2546,  2550,  2552,  2554,  2556,  2570,  2571,  2573,
    1092     2578,  2580,  2582,  2584,  2586,  2591,  2592,  2594,  2596,  2601,
    1093     2603,  2605,  2611,  2612,  2614,  2623,  2626,  2628,  2631,  2633,
    1094     2635,  2648,  2649,  2651,  2656,  2658,  2660,  2662,  2664,  2669,
    1095     2670,  2672,  2674,  2679,  2681,  2689,  2690,  2691,  2696,  2697,
    1096     2701,  2703,  2705,  2707,  2709,  2711,  2718,  2720,  2722,  2724,
    1097     2726,  2728,  2730,  2732,  2734,  2736,  2741,  2743,  2745,  2750,
    1098     2776,  2777,  2779,  2783,  2784,  2788,  2790,  2792,  2794,  2796,
    1099     2798,  2805,  2807,  2809,  2811,  2813,  2815,  2820,  2825,  2827,
    1100     2829,  2847,  2849,  2854,  2855
     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,   433,   437,   440,
     1030     442,   444,   449,   462,   464,   466,   468,   470,   472,   474,
     1031     476,   478,   480,   482,   489,   490,   496,   497,   498,   499,
     1032     503,   504,   506,   511,   512,   514,   516,   521,   522,   524,
     1033     529,   530,   532,   537,   538,   540,   542,   544,   549,   550,
     1034     552,   557,   558,   563,   564,   569,   570,   575,   576,   581,
     1035     582,   587,   588,   591,   593,   598,   603,   604,   606,   612,
     1036     613,   617,   618,   619,   620,   621,   622,   623,   624,   625,
     1037     626,   627,   628,   634,   636,   638,   640,   645,   646,   651,
     1038     652,   658,   659,   665,   666,   667,   668,   669,   670,   671,
     1039     672,   673,   683,   690,   692,   702,   703,   708,   710,   716,
     1040     718,   722,   723,   728,   733,   736,   738,   740,   750,   752,
     1041     763,   764,   766,   770,   772,   776,   777,   782,   783,   787,
     1042     792,   793,   797,   799,   805,   806,   810,   812,   814,   816,
     1043     822,   823,   827,   829,   834,   836,   838,   843,   845,   850,
     1044     852,   856,   859,   863,   866,   870,   872,   874,   876,   881,
     1045     883,   885,   890,   892,   894,   896,   898,   903,   905,   907,
     1046     909,   914,   926,   927,   932,   934,   939,   943,   945,   947,
     1047     949,   951,   957,   958,   964,   965,   969,   970,   975,   977,
     1048     983,   984,   986,   991,   996,  1006,  1008,  1012,  1013,  1018,
     1049    1020,  1024,  1025,  1029,  1031,  1035,  1036,  1040,  1041,  1045,
     1050    1046,  1061,  1062,  1063,  1064,  1065,  1069,  1074,  1081,  1091,
     1051    1096,  1101,  1109,  1114,  1119,  1124,  1129,  1137,  1159,  1164,
     1052    1171,  1173,  1180,  1185,  1190,  1201,  1206,  1211,  1216,  1221,
     1053    1230,  1235,  1243,  1244,  1245,  1246,  1252,  1257,  1265,  1266,
     1054    1267,  1268,  1272,  1273,  1274,  1275,  1280,  1281,  1290,  1291,
     1055    1296,  1297,  1302,  1304,  1306,  1308,  1310,  1313,  1312,  1324,
     1056    1325,  1327,  1337,  1338,  1343,  1345,  1347,  1349,  1351,  1354,
     1057    1356,  1359,  1364,  1366,  1368,  1370,  1372,  1374,  1376,  1378,
     1058    1380,  1382,  1384,  1386,  1388,  1394,  1395,  1397,  1399,  1401,
     1059    1406,  1407,  1413,  1414,  1416,  1418,  1423,  1425,  1427,  1429,
     1060    1434,  1435,  1437,  1439,  1444,  1445,  1447,  1452,  1453,  1455,
     1061    1457,  1462,  1464,  1466,  1471,  1472,  1476,  1478,  1484,  1483,
     1062    1487,  1489,  1494,  1496,  1502,  1503,  1508,  1509,  1511,  1512,
     1063    1521,  1522,  1524,  1526,  1531,  1533,  1539,  1540,  1542,  1545,
     1064    1548,  1553,  1554,  1559,  1564,  1568,  1570,  1576,  1575,  1582,
     1065    1584,  1590,  1591,  1599,  1600,  1604,  1605,  1606,  1608,  1610,
     1066    1617,  1618,  1620,  1622,  1627,  1628,  1634,  1635,  1639,  1640,
     1067    1645,  1646,  1647,  1649,  1657,  1658,  1660,  1663,  1665,  1669,
     1068    1670,  1671,  1673,  1675,  1679,  1684,  1692,  1693,  1702,  1704,
     1069    1709,  1710,  1711,  1715,  1716,  1717,  1721,  1722,  1723,  1727,
     1070    1728,  1729,  1734,  1735,  1736,  1737,  1743,  1744,  1746,  1751,
     1071    1752,  1757,  1758,  1759,  1760,  1761,  1776,  1777,  1782,  1783,
     1072    1789,  1791,  1794,  1796,  1798,  1821,  1822,  1824,  1826,  1831,
     1073    1832,  1834,  1839,  1844,  1845,  1851,  1850,  1854,  1858,  1860,
     1074    1862,  1868,  1869,  1874,  1879,  1881,  1886,  1888,  1889,  1891,
     1075    1896,  1898,  1900,  1905,  1907,  1912,  1917,  1925,  1931,  1930,
     1076    1944,  1945,  1950,  1951,  1955,  1960,  1965,  1973,  1978,  1989,
     1077    1990,  1995,  1996,  2002,  2003,  2007,  2008,  2009,  2012,  2011,
     1078    2022,  2031,  2037,  2043,  2052,  2058,  2064,  2070,  2076,  2084,
     1079    2090,  2098,  2104,  2113,  2114,  2115,  2119,  2123,  2125,  2130,
     1080    2131,  2135,  2136,  2141,  2147,  2148,  2151,  2153,  2154,  2158,
     1081    2159,  2160,  2161,  2195,  2197,  2198,  2200,  2205,  2210,  2215,
     1082    2217,  2219,  2224,  2226,  2228,  2230,  2235,  2237,  2246,  2248,
     1083    2249,  2254,  2256,  2258,  2263,  2265,  2267,  2272,  2274,  2276,
     1084    2285,  2286,  2287,  2291,  2293,  2295,  2300,  2302,  2304,  2309,
     1085    2311,  2313,  2328,  2330,  2331,  2333,  2338,  2339,  2344,  2346,
     1086    2348,  2353,  2355,  2357,  2359,  2364,  2366,  2368,  2378,  2380,
     1087    2381,  2383,  2388,  2390,  2392,  2397,  2399,  2401,  2403,  2408,
     1088    2410,  2412,  2443,  2445,  2446,  2448,  2453,  2458,  2466,  2468,
     1089    2470,  2475,  2477,  2482,  2484,  2498,  2499,  2501,  2506,  2508,
     1090    2510,  2512,  2514,  2519,  2520,  2522,  2524,  2529,  2531,  2533,
     1091    2539,  2541,  2543,  2547,  2549,  2551,  2553,  2567,  2568,  2570,
     1092    2575,  2577,  2579,  2581,  2583,  2588,  2589,  2591,  2593,  2598,
     1093    2600,  2602,  2608,  2609,  2611,  2620,  2623,  2625,  2628,  2630,
     1094    2632,  2645,  2646,  2648,  2653,  2655,  2657,  2659,  2661,  2666,
     1095    2667,  2669,  2671,  2676,  2678,  2686,  2687,  2688,  2693,  2694,
     1096    2698,  2700,  2702,  2704,  2706,  2708,  2715,  2717,  2719,  2721,
     1097    2723,  2725,  2727,  2729,  2731,  2733,  2738,  2740,  2742,  2747,
     1098    2773,  2774,  2776,  2780,  2781,  2785,  2787,  2789,  2791,  2793,
     1099    2795,  2802,  2804,  2806,  2808,  2810,  2812,  2817,  2822,  2824,
     1100    2826,  2844,  2846,  2851,  2852
    11011101};
    11021102#endif
     
    50835083    break;
    50845084
    5085   case 27:
    5086 
    5087 /* Line 1806 of yacc.c  */
    5088 #line 381 "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:
     5085  case 29:
    50935086
    50945087/* Line 1806 of yacc.c  */
    50955088#line 383 "parser.yy"
    5096     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_constantInteger( *(yyvsp[(3) - (3)].tok) ) ) ); }
    5097     break;
    5098 
    5099   case 29:
    5100 
    5101 /* Line 1806 of yacc.c  */
    5102 #line 385 "parser.yy"
    51035089    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); }
    51045090    break;
    51055091
    5106   case 30:
    5107 
    5108 /* Line 1806 of yacc.c  */
    5109 #line 387 "parser.yy"
    5110     { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
    5111     break;
    5112 
    51135092  case 31:
    51145093
    51155094/* Line 1806 of yacc.c  */
    5116 #line 389 "parser.yy"
     5095#line 386 "parser.yy"
    51175096    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, (yyvsp[(1) - (2)].en) ) ); }
    51185097    break;
     
    51215100
    51225101/* Line 1806 of yacc.c  */
    5123 #line 391 "parser.yy"
     5102#line 388 "parser.yy"
    51245103    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, (yyvsp[(1) - (2)].en) ) ); }
    51255104    break;
     
    51285107
    51295108/* Line 1806 of yacc.c  */
    5130 #line 393 "parser.yy"
     5109#line 390 "parser.yy"
    51315110    { (yyval.en) = new ExpressionNode( build_compoundLiteral( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ) ); }
    51325111    break;
     
    51355114
    51365115/* Line 1806 of yacc.c  */
    5137 #line 395 "parser.yy"
     5116#line 392 "parser.yy"
    51385117    {
    51395118                        Token fn;
     
    51465125
    51475126/* Line 1806 of yacc.c  */
    5148 #line 405 "parser.yy"
     5127#line 402 "parser.yy"
    51495128    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    51505129    break;
     
    51535132
    51545133/* Line 1806 of yacc.c  */
    5155 #line 410 "parser.yy"
     5134#line 407 "parser.yy"
    51565135    { (yyval.en) = 0; }
    51575136    break;
     
    51605139
    51615140/* Line 1806 of yacc.c  */
    5162 #line 416 "parser.yy"
     5141#line 413 "parser.yy"
    51635142    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    51645143    break;
     
    51675146
    51685147/* Line 1806 of yacc.c  */
    5169 #line 423 "parser.yy"
     5148#line 420 "parser.yy"
    51705149    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    51715150    break;
     
    51745153
    51755154/* Line 1806 of yacc.c  */
    5176 #line 425 "parser.yy"
     5155#line 422 "parser.yy"
    51775156    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
    51785157    break;
     
    51815160
    51825161/* Line 1806 of yacc.c  */
    5183 #line 427 "parser.yy"
     5162#line 424 "parser.yy"
    51845163    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
    51855164    break;
     
    51885167
    51895168/* Line 1806 of yacc.c  */
    5190 #line 429 "parser.yy"
     5169#line 426 "parser.yy"
    51915170    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
    51925171    break;
     
    51955174
    51965175/* Line 1806 of yacc.c  */
    5197 #line 431 "parser.yy"
     5176#line 428 "parser.yy"
    51985177    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
    51995178    break;
     
    52025181
    52035182/* Line 1806 of yacc.c  */
    5204 #line 444 "parser.yy"
     5183#line 441 "parser.yy"
    52055184    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    52065185    break;
     
    52095188
    52105189/* Line 1806 of yacc.c  */
    5211 #line 446 "parser.yy"
     5190#line 443 "parser.yy"
    52125191    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    52135192    break;
     
    52165195
    52175196/* Line 1806 of yacc.c  */
    5218 #line 448 "parser.yy"
     5197#line 445 "parser.yy"
    52195198    { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); }
    52205199    break;
     
    52235202
    52245203/* Line 1806 of yacc.c  */
    5225 #line 453 "parser.yy"
     5204#line 450 "parser.yy"
    52265205    {
    52275206                        switch ( (yyvsp[(1) - (2)].op) ) {
     
    52415220
    52425221/* Line 1806 of yacc.c  */
    5243 #line 466 "parser.yy"
     5222#line 463 "parser.yy"
    52445223    { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); }
    52455224    break;
     
    52485227
    52495228/* Line 1806 of yacc.c  */
    5250 #line 468 "parser.yy"
     5229#line 465 "parser.yy"
    52515230    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); }
    52525231    break;
     
    52555234
    52565235/* Line 1806 of yacc.c  */
    5257 #line 470 "parser.yy"
     5236#line 467 "parser.yy"
    52585237    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); }
    52595238    break;
     
    52625241
    52635242/* Line 1806 of yacc.c  */
    5264 #line 472 "parser.yy"
     5243#line 469 "parser.yy"
    52655244    { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52665245    break;
     
    52695248
    52705249/* Line 1806 of yacc.c  */
    5271 #line 474 "parser.yy"
     5250#line 471 "parser.yy"
    52725251    { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52735252    break;
     
    52765255
    52775256/* Line 1806 of yacc.c  */
    5278 #line 476 "parser.yy"
     5257#line 473 "parser.yy"
    52795258    { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52805259    break;
     
    52835262
    52845263/* Line 1806 of yacc.c  */
    5285 #line 478 "parser.yy"
     5264#line 475 "parser.yy"
    52865265    { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52875266    break;
     
    52905269
    52915270/* Line 1806 of yacc.c  */
    5292 #line 480 "parser.yy"
     5271#line 477 "parser.yy"
    52935272    { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); }
    52945273    break;
     
    52975276
    52985277/* Line 1806 of yacc.c  */
    5299 #line 482 "parser.yy"
     5278#line 479 "parser.yy"
    53005279    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); }
    53015280    break;
     
    53045283
    53055284/* Line 1806 of yacc.c  */
    5306 #line 484 "parser.yy"
     5285#line 481 "parser.yy"
    53075286    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); }
    53085287    break;
     
    53115290
    53125291/* Line 1806 of yacc.c  */
    5313 #line 486 "parser.yy"
     5292#line 483 "parser.yy"
    53145293    { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); }
    53155294    break;
     
    53185297
    53195298/* Line 1806 of yacc.c  */
    5320 #line 492 "parser.yy"
     5299#line 489 "parser.yy"
    53215300    { (yyval.op) = OperKinds::PointTo; }
    53225301    break;
     
    53255304
    53265305/* Line 1806 of yacc.c  */
    5327 #line 493 "parser.yy"
     5306#line 490 "parser.yy"
    53285307    { (yyval.op) = OperKinds::AddressOf; }
    53295308    break;
     
    53325311
    53335312/* Line 1806 of yacc.c  */
     5313#line 496 "parser.yy"
     5314    { (yyval.op) = OperKinds::UnPlus; }
     5315    break;
     5316
     5317  case 67:
     5318
     5319/* Line 1806 of yacc.c  */
     5320#line 497 "parser.yy"
     5321    { (yyval.op) = OperKinds::UnMinus; }
     5322    break;
     5323
     5324  case 68:
     5325
     5326/* Line 1806 of yacc.c  */
     5327#line 498 "parser.yy"
     5328    { (yyval.op) = OperKinds::Neg; }
     5329    break;
     5330
     5331  case 69:
     5332
     5333/* Line 1806 of yacc.c  */
    53345334#line 499 "parser.yy"
    5335     { (yyval.op) = OperKinds::UnPlus; }
    5336     break;
    5337 
    5338   case 67:
    5339 
    5340 /* Line 1806 of yacc.c  */
    5341 #line 500 "parser.yy"
    5342     { (yyval.op) = OperKinds::UnMinus; }
    5343     break;
    5344 
    5345   case 68:
    5346 
    5347 /* Line 1806 of yacc.c  */
    5348 #line 501 "parser.yy"
    5349     { (yyval.op) = OperKinds::Neg; }
    5350     break;
    5351 
    5352   case 69:
    5353 
    5354 /* Line 1806 of yacc.c  */
    5355 #line 502 "parser.yy"
    53565335    { (yyval.op) = OperKinds::BitNeg; }
    53575336    break;
     
    53605339
    53615340/* Line 1806 of yacc.c  */
    5362 #line 508 "parser.yy"
     5341#line 505 "parser.yy"
    53635342    { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); }
    53645343    break;
     
    53675346
    53685347/* Line 1806 of yacc.c  */
    5369 #line 510 "parser.yy"
     5348#line 507 "parser.yy"
    53705349    { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); }
    53715350    break;
     
    53745353
    53755354/* Line 1806 of yacc.c  */
    5376 #line 516 "parser.yy"
     5355#line 513 "parser.yy"
    53775356    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53785357    break;
     
    53815360
    53825361/* Line 1806 of yacc.c  */
    5383 #line 518 "parser.yy"
     5362#line 515 "parser.yy"
    53845363    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53855364    break;
     
    53885367
    53895368/* Line 1806 of yacc.c  */
    5390 #line 520 "parser.yy"
     5369#line 517 "parser.yy"
    53915370    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53925371    break;
     
    53955374
    53965375/* Line 1806 of yacc.c  */
    5397 #line 526 "parser.yy"
     5376#line 523 "parser.yy"
    53985377    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53995378    break;
     
    54025381
    54035382/* Line 1806 of yacc.c  */
    5404 #line 528 "parser.yy"
     5383#line 525 "parser.yy"
    54055384    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54065385    break;
     
    54095388
    54105389/* Line 1806 of yacc.c  */
    5411 #line 534 "parser.yy"
     5390#line 531 "parser.yy"
    54125391    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54135392    break;
     
    54165395
    54175396/* Line 1806 of yacc.c  */
    5418 #line 536 "parser.yy"
     5397#line 533 "parser.yy"
    54195398    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54205399    break;
     
    54235402
    54245403/* Line 1806 of yacc.c  */
    5425 #line 542 "parser.yy"
     5404#line 539 "parser.yy"
    54265405    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54275406    break;
     
    54305409
    54315410/* Line 1806 of yacc.c  */
    5432 #line 544 "parser.yy"
     5411#line 541 "parser.yy"
    54335412    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54345413    break;
     
    54375416
    54385417/* Line 1806 of yacc.c  */
    5439 #line 546 "parser.yy"
     5418#line 543 "parser.yy"
    54405419    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54415420    break;
     
    54445423
    54455424/* Line 1806 of yacc.c  */
    5446 #line 548 "parser.yy"
     5425#line 545 "parser.yy"
    54475426    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54485427    break;
     
    54515430
    54525431/* Line 1806 of yacc.c  */
    5453 #line 554 "parser.yy"
     5432#line 551 "parser.yy"
    54545433    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54555434    break;
     
    54585437
    54595438/* Line 1806 of yacc.c  */
    5460 #line 556 "parser.yy"
     5439#line 553 "parser.yy"
    54615440    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54625441    break;
     
    54655444
    54665445/* Line 1806 of yacc.c  */
    5467 #line 562 "parser.yy"
     5446#line 559 "parser.yy"
    54685447    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54695448    break;
     
    54725451
    54735452/* Line 1806 of yacc.c  */
    5474 #line 568 "parser.yy"
     5453#line 565 "parser.yy"
    54755454    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54765455    break;
     
    54795458
    54805459/* Line 1806 of yacc.c  */
    5481 #line 574 "parser.yy"
     5460#line 571 "parser.yy"
    54825461    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54835462    break;
     
    54865465
    54875466/* Line 1806 of yacc.c  */
    5488 #line 580 "parser.yy"
     5467#line 577 "parser.yy"
    54895468    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); }
    54905469    break;
     
    54935472
    54945473/* Line 1806 of yacc.c  */
    5495 #line 586 "parser.yy"
     5474#line 583 "parser.yy"
    54965475    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); }
    54975476    break;
     
    55005479
    55015480/* Line 1806 of yacc.c  */
     5481#line 589 "parser.yy"
     5482    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
     5483    break;
     5484
     5485  case 103:
     5486
     5487/* Line 1806 of yacc.c  */
    55025488#line 592 "parser.yy"
     5489    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); }
     5490    break;
     5491
     5492  case 104:
     5493
     5494/* Line 1806 of yacc.c  */
     5495#line 594 "parser.yy"
    55035496    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
    55045497    break;
    55055498
    5506   case 103:
    5507 
    5508 /* Line 1806 of yacc.c  */
    5509 #line 595 "parser.yy"
    5510     { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); }
    5511     break;
    5512 
    5513   case 104:
    5514 
    5515 /* Line 1806 of yacc.c  */
    5516 #line 597 "parser.yy"
    5517     { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
    5518     break;
    5519 
    55205499  case 107:
    55215500
    55225501/* Line 1806 of yacc.c  */
    5523 #line 608 "parser.yy"
     5502#line 605 "parser.yy"
    55245503    { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    55255504    break;
     
    55285507
    55295508/* Line 1806 of yacc.c  */
    5530 #line 610 "parser.yy"
     5509#line 607 "parser.yy"
    55315510    { (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) ) ); }
    55325511    break;
     
    55355514
    55365515/* Line 1806 of yacc.c  */
    5537 #line 615 "parser.yy"
     5516#line 612 "parser.yy"
    55385517    { (yyval.en) = nullptr; }
    55395518    break;
     
    55425521
    55435522/* Line 1806 of yacc.c  */
     5523#line 617 "parser.yy"
     5524    { (yyval.op) = OperKinds::Assign; }
     5525    break;
     5526
     5527  case 112:
     5528
     5529/* Line 1806 of yacc.c  */
     5530#line 618 "parser.yy"
     5531    { (yyval.op) = OperKinds::AtAssn; }
     5532    break;
     5533
     5534  case 113:
     5535
     5536/* Line 1806 of yacc.c  */
     5537#line 619 "parser.yy"
     5538    { (yyval.op) = OperKinds::MulAssn; }
     5539    break;
     5540
     5541  case 114:
     5542
     5543/* Line 1806 of yacc.c  */
    55445544#line 620 "parser.yy"
    5545     { (yyval.op) = OperKinds::Assign; }
    5546     break;
    5547 
    5548   case 112:
     5545    { (yyval.op) = OperKinds::DivAssn; }
     5546    break;
     5547
     5548  case 115:
    55495549
    55505550/* Line 1806 of yacc.c  */
    55515551#line 621 "parser.yy"
    5552     { (yyval.op) = OperKinds::AtAssn; }
    5553     break;
    5554 
    5555   case 113:
     5552    { (yyval.op) = OperKinds::ModAssn; }
     5553    break;
     5554
     5555  case 116:
    55565556
    55575557/* Line 1806 of yacc.c  */
    55585558#line 622 "parser.yy"
    5559     { (yyval.op) = OperKinds::MulAssn; }
    5560     break;
    5561 
    5562   case 114:
     5559    { (yyval.op) = OperKinds::PlusAssn; }
     5560    break;
     5561
     5562  case 117:
    55635563
    55645564/* Line 1806 of yacc.c  */
    55655565#line 623 "parser.yy"
    5566     { (yyval.op) = OperKinds::DivAssn; }
    5567     break;
    5568 
    5569   case 115:
     5566    { (yyval.op) = OperKinds::MinusAssn; }
     5567    break;
     5568
     5569  case 118:
    55705570
    55715571/* Line 1806 of yacc.c  */
    55725572#line 624 "parser.yy"
    5573     { (yyval.op) = OperKinds::ModAssn; }
    5574     break;
    5575 
    5576   case 116:
     5573    { (yyval.op) = OperKinds::LSAssn; }
     5574    break;
     5575
     5576  case 119:
    55775577
    55785578/* Line 1806 of yacc.c  */
    55795579#line 625 "parser.yy"
    5580     { (yyval.op) = OperKinds::PlusAssn; }
    5581     break;
    5582 
    5583   case 117:
     5580    { (yyval.op) = OperKinds::RSAssn; }
     5581    break;
     5582
     5583  case 120:
    55845584
    55855585/* Line 1806 of yacc.c  */
    55865586#line 626 "parser.yy"
    5587     { (yyval.op) = OperKinds::MinusAssn; }
    5588     break;
    5589 
    5590   case 118:
     5587    { (yyval.op) = OperKinds::AndAssn; }
     5588    break;
     5589
     5590  case 121:
    55915591
    55925592/* Line 1806 of yacc.c  */
    55935593#line 627 "parser.yy"
    5594     { (yyval.op) = OperKinds::LSAssn; }
    5595     break;
    5596 
    5597   case 119:
     5594    { (yyval.op) = OperKinds::ERAssn; }
     5595    break;
     5596
     5597  case 122:
    55985598
    55995599/* Line 1806 of yacc.c  */
    56005600#line 628 "parser.yy"
    5601     { (yyval.op) = OperKinds::RSAssn; }
    5602     break;
    5603 
    5604   case 120:
    5605 
    5606 /* Line 1806 of yacc.c  */
    5607 #line 629 "parser.yy"
    5608     { (yyval.op) = OperKinds::AndAssn; }
    5609     break;
    5610 
    5611   case 121:
    5612 
    5613 /* Line 1806 of yacc.c  */
    5614 #line 630 "parser.yy"
    5615     { (yyval.op) = OperKinds::ERAssn; }
    5616     break;
    5617 
    5618   case 122:
    5619 
    5620 /* Line 1806 of yacc.c  */
    5621 #line 631 "parser.yy"
    56225601    { (yyval.op) = OperKinds::OrAssn; }
    56235602    break;
     
    56265605
    56275606/* Line 1806 of yacc.c  */
    5628 #line 638 "parser.yy"
     5607#line 635 "parser.yy"
    56295608    { (yyval.en) = new ExpressionNode( build_tuple() ); }
    56305609    break;
     
    56335612
    56345613/* Line 1806 of yacc.c  */
    5635 #line 640 "parser.yy"
     5614#line 637 "parser.yy"
    56365615    { (yyval.en) = new ExpressionNode( build_tuple( (yyvsp[(3) - (5)].en) ) ); }
    56375616    break;
     
    56405619
    56415620/* Line 1806 of yacc.c  */
    5642 #line 642 "parser.yy"
     5621#line 639 "parser.yy"
    56435622    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); }
    56445623    break;
     
    56475626
    56485627/* Line 1806 of yacc.c  */
    5649 #line 644 "parser.yy"
     5628#line 641 "parser.yy"
    56505629    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); }
    56515630    break;
     
    56545633
    56555634/* Line 1806 of yacc.c  */
    5656 #line 650 "parser.yy"
     5635#line 647 "parser.yy"
    56575636    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    56585637    break;
     
    56615640
    56625641/* Line 1806 of yacc.c  */
    5663 #line 656 "parser.yy"
     5642#line 653 "parser.yy"
    56645643    { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    56655644    break;
     
    56685647
    56695648/* Line 1806 of yacc.c  */
    5670 #line 661 "parser.yy"
     5649#line 658 "parser.yy"
    56715650    { (yyval.en) = 0; }
    56725651    break;
     
    56755654
    56765655/* Line 1806 of yacc.c  */
    5677 #line 670 "parser.yy"
     5656#line 667 "parser.yy"
    56785657    { (yyval.sn) = (yyvsp[(1) - (1)].sn); }
    56795658    break;
     
    56825661
    56835662/* Line 1806 of yacc.c  */
    5684 #line 677 "parser.yy"
     5663#line 674 "parser.yy"
    56855664    {
    56865665                        Token fn;
     
    56935672
    56945673/* Line 1806 of yacc.c  */
    5695 #line 687 "parser.yy"
     5674#line 684 "parser.yy"
    56965675    {
    56975676                        (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) );
     
    57025681
    57035682/* Line 1806 of yacc.c  */
    5704 #line 694 "parser.yy"
     5683#line 691 "parser.yy"
    57055684    { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    57065685    break;
     
    57095688
    57105689/* Line 1806 of yacc.c  */
    5711 #line 701 "parser.yy"
     5690#line 698 "parser.yy"
    57125691    { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); }
    57135692    break;
     
    57165695
    57175696/* Line 1806 of yacc.c  */
    5718 #line 707 "parser.yy"
     5697#line 704 "parser.yy"
    57195698    { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } }
    57205699    break;
     
    57235702
    57245703/* Line 1806 of yacc.c  */
    5725 #line 712 "parser.yy"
     5704#line 709 "parser.yy"
    57265705    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    57275706    break;
     
    57305709
    57315710/* Line 1806 of yacc.c  */
    5732 #line 714 "parser.yy"
     5711#line 711 "parser.yy"
    57335712    {   // mark all fields in list
    57345713                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    57415720
    57425721/* Line 1806 of yacc.c  */
    5743 #line 720 "parser.yy"
     5722#line 717 "parser.yy"
    57445723    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    57455724    break;
     
    57485727
    57495728/* Line 1806 of yacc.c  */
    5750 #line 727 "parser.yy"
     5729#line 724 "parser.yy"
    57515730    { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } }
    57525731    break;
     
    57555734
    57565735/* Line 1806 of yacc.c  */
    5757 #line 732 "parser.yy"
     5736#line 729 "parser.yy"
    57585737    { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); }
    57595738    break;
     
    57625741
    57635742/* Line 1806 of yacc.c  */
    5764 #line 738 "parser.yy"
     5743#line 735 "parser.yy"
    57655744    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }
    57665745    break;
     
    57695748
    57705749/* Line 1806 of yacc.c  */
    5771 #line 740 "parser.yy"
     5750#line 737 "parser.yy"
    57725751    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }
    57735752    break;
     
    57765755
    57775756/* Line 1806 of yacc.c  */
    5778 #line 742 "parser.yy"
     5757#line 739 "parser.yy"
    57795758    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57805759    break;
     
    57835762
    57845763/* Line 1806 of yacc.c  */
    5785 #line 744 "parser.yy"
     5764#line 741 "parser.yy"
    57865765    {
    57875766                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    57985777
    57995778/* Line 1806 of yacc.c  */
    5800 #line 754 "parser.yy"
     5779#line 751 "parser.yy"
    58015780    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    58025781    break;
     
    58055784
    58065785/* Line 1806 of yacc.c  */
    5807 #line 756 "parser.yy"
     5786#line 753 "parser.yy"
    58085787    {
    58095788                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    58155794
    58165795/* Line 1806 of yacc.c  */
    5817 #line 766 "parser.yy"
     5796#line 763 "parser.yy"
    58185797    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    58195798    break;
     
    58225801
    58235802/* Line 1806 of yacc.c  */
    5824 #line 768 "parser.yy"
     5803#line 765 "parser.yy"
    58255804    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    58265805    break;
     
    58295808
    58305809/* Line 1806 of yacc.c  */
    5831 #line 773 "parser.yy"
     5810#line 770 "parser.yy"
    58325811    { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); }
    58335812    break;
     
    58365815
    58375816/* Line 1806 of yacc.c  */
    5838 #line 775 "parser.yy"
     5817#line 772 "parser.yy"
    58395818    { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }
    58405819    break;
     
    58435822
    58445823/* Line 1806 of yacc.c  */
    5845 #line 779 "parser.yy"
     5824#line 776 "parser.yy"
    58465825    { (yyval.sn) = (yyvsp[(2) - (3)].sn); }
    58475826    break;
     
    58505829
    58515830/* Line 1806 of yacc.c  */
    5852 #line 780 "parser.yy"
     5831#line 777 "parser.yy"
    58535832    { (yyval.sn) = new StatementNode( build_default() ); }
    58545833    break;
     
    58575836
    58585837/* Line 1806 of yacc.c  */
    5859 #line 786 "parser.yy"
     5838#line 783 "parser.yy"
    58605839    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); }
    58615840    break;
     
    58645843
    58655844/* Line 1806 of yacc.c  */
    5866 #line 790 "parser.yy"
     5845#line 787 "parser.yy"
    58675846    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58685847    break;
     
    58715850
    58725851/* Line 1806 of yacc.c  */
    5873 #line 795 "parser.yy"
     5852#line 792 "parser.yy"
    58745853    { (yyval.sn) = 0; }
    58755854    break;
     
    58785857
    58795858/* Line 1806 of yacc.c  */
    5880 #line 801 "parser.yy"
     5859#line 798 "parser.yy"
    58815860    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58825861    break;
     
    58855864
    58865865/* Line 1806 of yacc.c  */
    5887 #line 803 "parser.yy"
     5866#line 800 "parser.yy"
    58885867    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); }
    58895868    break;
     
    58925871
    58935872/* Line 1806 of yacc.c  */
    5894 #line 808 "parser.yy"
     5873#line 805 "parser.yy"
    58955874    { (yyval.sn) = 0; }
    58965875    break;
     
    58995878
    59005879/* Line 1806 of yacc.c  */
    5901 #line 814 "parser.yy"
     5880#line 811 "parser.yy"
    59025881    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); }
    59035882    break;
     
    59065885
    59075886/* Line 1806 of yacc.c  */
    5908 #line 816 "parser.yy"
     5887#line 813 "parser.yy"
    59095888    { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); }
    59105889    break;
     
    59135892
    59145893/* Line 1806 of yacc.c  */
    5915 #line 818 "parser.yy"
     5894#line 815 "parser.yy"
    59165895    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); }
    59175896    break;
     
    59205899
    59215900/* Line 1806 of yacc.c  */
    5922 #line 820 "parser.yy"
     5901#line 817 "parser.yy"
    59235902    { (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) ) ) ) ) ) ); }
    59245903    break;
     
    59275906
    59285907/* Line 1806 of yacc.c  */
    5929 #line 825 "parser.yy"
     5908#line 822 "parser.yy"
    59305909    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    59315910    break;
     
    59345913
    59355914/* Line 1806 of yacc.c  */
    5936 #line 831 "parser.yy"
     5915#line 828 "parser.yy"
    59375916    { (yyval.sn) = 0; }
    59385917    break;
     
    59415920
    59425921/* Line 1806 of yacc.c  */
    5943 #line 833 "parser.yy"
     5922#line 830 "parser.yy"
    59445923    { (yyval.sn) = 0; }
    59455924    break;
     
    59485927
    59495928/* Line 1806 of yacc.c  */
    5950 #line 838 "parser.yy"
     5929#line 835 "parser.yy"
    59515930    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    59525931    break;
     
    59555934
    59565935/* Line 1806 of yacc.c  */
    5957 #line 840 "parser.yy"
     5936#line 837 "parser.yy"
    59585937    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); }
    59595938    break;
     
    59625941
    59635942/* Line 1806 of yacc.c  */
    5964 #line 842 "parser.yy"
     5943#line 839 "parser.yy"
    59655944    { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }
    59665945    break;
     
    59695948
    59705949/* Line 1806 of yacc.c  */
    5971 #line 847 "parser.yy"
     5950#line 844 "parser.yy"
    59725951    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); }
    59735952    break;
     
    59765955
    59775956/* Line 1806 of yacc.c  */
    5978 #line 849 "parser.yy"
     5957#line 846 "parser.yy"
    59795958    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); }
    59805959    break;
     
    59835962
    59845963/* Line 1806 of yacc.c  */
    5985 #line 854 "parser.yy"
     5964#line 851 "parser.yy"
    59865965    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }
    59875966    break;
     
    59905969
    59915970/* Line 1806 of yacc.c  */
     5971#line 855 "parser.yy"
     5972    { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
     5973    break;
     5974
     5975  case 191:
     5976
     5977/* Line 1806 of yacc.c  */
    59925978#line 858 "parser.yy"
    5993     { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
    5994     break;
    5995 
    5996   case 191:
    5997 
    5998 /* Line 1806 of yacc.c  */
    5999 #line 861 "parser.yy"
    60005979    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); }
    60015980    break;
     
    60045983
    60055984/* Line 1806 of yacc.c  */
     5985#line 862 "parser.yy"
     5986    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); }
     5987    break;
     5988
     5989  case 193:
     5990
     5991/* Line 1806 of yacc.c  */
    60065992#line 865 "parser.yy"
    6007     { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); }
    6008     break;
    6009 
    6010   case 193:
    6011 
    6012 /* Line 1806 of yacc.c  */
    6013 #line 868 "parser.yy"
    60145993    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    60155994    break;
     
    60185997
    60195998/* Line 1806 of yacc.c  */
    6020 #line 872 "parser.yy"
     5999#line 869 "parser.yy"
    60216000    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); }
    60226001    break;
     
    60256004
    60266005/* Line 1806 of yacc.c  */
    6027 #line 874 "parser.yy"
     6006#line 871 "parser.yy"
    60286007    { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); }
    60296008    break;
     
    60326011
    60336012/* Line 1806 of yacc.c  */
    6034 #line 876 "parser.yy"
     6013#line 873 "parser.yy"
    60356014    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    60366015    break;
     
    60396018
    60406019/* Line 1806 of yacc.c  */
    6041 #line 878 "parser.yy"
     6020#line 875 "parser.yy"
    60426021    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    60436022    break;
     
    60466025
    60476026/* Line 1806 of yacc.c  */
    6048 #line 880 "parser.yy"
     6027#line 877 "parser.yy"
    60496028    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); }
    60506029    break;
     
    60536032
    60546033/* Line 1806 of yacc.c  */
    6055 #line 885 "parser.yy"
     6034#line 882 "parser.yy"
    60566035    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }
    60576036    break;
     
    60606039
    60616040/* Line 1806 of yacc.c  */
    6062 #line 887 "parser.yy"
     6041#line 884 "parser.yy"
    60636042    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }
    60646043    break;
     
    60676046
    60686047/* Line 1806 of yacc.c  */
    6069 #line 889 "parser.yy"
     6048#line 886 "parser.yy"
    60706049    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }
    60716050    break;
     
    60746053
    60756054/* Line 1806 of yacc.c  */
    6076 #line 896 "parser.yy"
     6055#line 893 "parser.yy"
    60776056    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60786057    break;
     
    60816060
    60826061/* Line 1806 of yacc.c  */
    6083 #line 898 "parser.yy"
     6062#line 895 "parser.yy"
    60846063    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60856064    break;
     
    60886067
    60896068/* Line 1806 of yacc.c  */
    6090 #line 900 "parser.yy"
     6069#line 897 "parser.yy"
    60916070    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60926071    break;
     
    60956074
    60966075/* Line 1806 of yacc.c  */
    6097 #line 902 "parser.yy"
     6076#line 899 "parser.yy"
    60986077    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60996078    break;
     
    61026081
    61036082/* Line 1806 of yacc.c  */
    6104 #line 907 "parser.yy"
     6083#line 904 "parser.yy"
    61056084    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    61066085    break;
     
    61096088
    61106089/* Line 1806 of yacc.c  */
    6111 #line 909 "parser.yy"
     6090#line 906 "parser.yy"
    61126091    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    61136092    break;
     
    61166095
    61176096/* Line 1806 of yacc.c  */
    6118 #line 911 "parser.yy"
     6097#line 908 "parser.yy"
    61196098    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    61206099    break;
     
    61236102
    61246103/* Line 1806 of yacc.c  */
    6125 #line 913 "parser.yy"
     6104#line 910 "parser.yy"
    61266105    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    61276106    break;
     
    61306109
    61316110/* Line 1806 of yacc.c  */
    6132 #line 918 "parser.yy"
     6111#line 915 "parser.yy"
    61336112    {
    61346113                        (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) );
     
    61396118
    61406119/* Line 1806 of yacc.c  */
    6141 #line 931 "parser.yy"
     6120#line 928 "parser.yy"
    61426121    {
    61436122                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    61496128
    61506129/* Line 1806 of yacc.c  */
    6151 #line 936 "parser.yy"
     6130#line 933 "parser.yy"
    61526131    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    61536132    break;
     
    61566135
    61576136/* Line 1806 of yacc.c  */
    6158 #line 938 "parser.yy"
     6137#line 935 "parser.yy"
    61596138    {
    61606139                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    61666145
    61676146/* Line 1806 of yacc.c  */
    6168 #line 947 "parser.yy"
     6147#line 944 "parser.yy"
    61696148    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); }
    61706149    break;
     
    61736152
    61746153/* Line 1806 of yacc.c  */
    6175 #line 949 "parser.yy"
     6154#line 946 "parser.yy"
    61766155    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); }
    61776156    break;
     
    61806159
    61816160/* Line 1806 of yacc.c  */
    6182 #line 951 "parser.yy"
     6161#line 948 "parser.yy"
    61836162    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); }
    61846163    break;
     
    61876166
    61886167/* Line 1806 of yacc.c  */
    6189 #line 953 "parser.yy"
     6168#line 950 "parser.yy"
    61906169    { (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) ) ); }
    61916170    break;
     
    61946173
    61956174/* Line 1806 of yacc.c  */
    6196 #line 955 "parser.yy"
     6175#line 952 "parser.yy"
    61976176    { (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) ) ); }
    61986177    break;
     
    62016180
    62026181/* Line 1806 of yacc.c  */
    6203 #line 960 "parser.yy"
     6182#line 957 "parser.yy"
    62046183    { (yyval.flag) = false; }
    62056184    break;
     
    62086187
    62096188/* Line 1806 of yacc.c  */
    6210 #line 962 "parser.yy"
     6189#line 959 "parser.yy"
    62116190    { (yyval.flag) = true; }
    62126191    break;
     
    62156194
    62166195/* Line 1806 of yacc.c  */
    6217 #line 967 "parser.yy"
     6196#line 964 "parser.yy"
    62186197    { (yyval.en) = 0; }
    62196198    break;
     
    62226201
    62236202/* Line 1806 of yacc.c  */
    6224 #line 974 "parser.yy"
     6203#line 971 "parser.yy"
    62256204    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    62266205    break;
     
    62296208
    62306209/* Line 1806 of yacc.c  */
    6231 #line 979 "parser.yy"
     6210#line 976 "parser.yy"
    62326211    { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }
    62336212    break;
     
    62366215
    62376216/* Line 1806 of yacc.c  */
    6238 #line 981 "parser.yy"
     6217#line 978 "parser.yy"
    62396218    { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }
    62406219    break;
     
    62436222
    62446223/* Line 1806 of yacc.c  */
    6245 #line 986 "parser.yy"
     6224#line 983 "parser.yy"
    62466225    { (yyval.en) = 0; }
    62476226    break;
     
    62506229
    62516230/* Line 1806 of yacc.c  */
    6252 #line 988 "parser.yy"
     6231#line 985 "parser.yy"
    62536232    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    62546233    break;
     
    62576236
    62586237/* Line 1806 of yacc.c  */
    6259 #line 990 "parser.yy"
     6238#line 987 "parser.yy"
    62606239    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); }
    62616240    break;
     
    62646243
    62656244/* Line 1806 of yacc.c  */
    6266 #line 995 "parser.yy"
     6245#line 992 "parser.yy"
    62676246    {
    62686247                        (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) );
     
    62746253
    62756254/* Line 1806 of yacc.c  */
    6276 #line 1000 "parser.yy"
     6255#line 997 "parser.yy"
    62776256    {
    62786257                        (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) );
     
    62846263
    62856264/* Line 1806 of yacc.c  */
    6286 #line 1010 "parser.yy"
     6265#line 1007 "parser.yy"
    62876266    { (yyval.decl) = 0; }
    62886267    break;
     
    62916270
    62926271/* Line 1806 of yacc.c  */
    6293 #line 1017 "parser.yy"
     6272#line 1014 "parser.yy"
    62946273    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    62956274    break;
     
    62986277
    62996278/* Line 1806 of yacc.c  */
    6300 #line 1022 "parser.yy"
     6279#line 1019 "parser.yy"
    63016280    { (yyval.decl) = 0; }
    63026281    break;
     
    63056284
    63066285/* Line 1806 of yacc.c  */
    6307 #line 1029 "parser.yy"
     6286#line 1026 "parser.yy"
    63086287    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    63096288    break;
     
    63126291
    63136292/* Line 1806 of yacc.c  */
    6314 #line 1043 "parser.yy"
     6293#line 1040 "parser.yy"
    63156294    {}
    63166295    break;
     
    63196298
    63206299/* Line 1806 of yacc.c  */
    6321 #line 1044 "parser.yy"
     6300#line 1041 "parser.yy"
    63226301    {}
    63236302    break;
     
    63266305
    63276306/* Line 1806 of yacc.c  */
    6328 #line 1073 "parser.yy"
     6307#line 1070 "parser.yy"
    63296308    {
    63306309                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63366315
    63376316/* Line 1806 of yacc.c  */
    6338 #line 1080 "parser.yy"
     6317#line 1077 "parser.yy"
    63396318    {
    63406319                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63466325
    63476326/* Line 1806 of yacc.c  */
    6348 #line 1085 "parser.yy"
     6327#line 1082 "parser.yy"
    63496328    {
    63506329                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID );
     
    63566335
    63576336/* Line 1806 of yacc.c  */
    6358 #line 1095 "parser.yy"
     6337#line 1092 "parser.yy"
    63596338    {
    63606339                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63666345
    63676346/* Line 1806 of yacc.c  */
    6368 #line 1100 "parser.yy"
     6347#line 1097 "parser.yy"
    63696348    {
    63706349                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63766355
    63776356/* Line 1806 of yacc.c  */
    6378 #line 1105 "parser.yy"
     6357#line 1102 "parser.yy"
    63796358    {
    63806359                        typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) );
     
    63866365
    63876366/* Line 1806 of yacc.c  */
    6388 #line 1113 "parser.yy"
     6367#line 1110 "parser.yy"
    63896368    {
    63906369                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63966375
    63976376/* Line 1806 of yacc.c  */
    6398 #line 1118 "parser.yy"
     6377#line 1115 "parser.yy"
    63996378    {
    64006379                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    64066385
    64076386/* Line 1806 of yacc.c  */
    6408 #line 1123 "parser.yy"
     6387#line 1120 "parser.yy"
    64096388    {
    64106389                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    64166395
    64176396/* Line 1806 of yacc.c  */
    6418 #line 1128 "parser.yy"
     6397#line 1125 "parser.yy"
    64196398    {
    64206399                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    64266405
    64276406/* Line 1806 of yacc.c  */
    6428 #line 1133 "parser.yy"
     6407#line 1130 "parser.yy"
    64296408    {
    64306409                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    64366415
    64376416/* Line 1806 of yacc.c  */
    6438 #line 1141 "parser.yy"
     6417#line 1138 "parser.yy"
    64396418    {
    64406419                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(3) - (8)].tok), DeclarationNode::newTuple( 0 ), (yyvsp[(6) - (8)].decl), 0, true );
     
    64456424
    64466425/* Line 1806 of yacc.c  */
    6447 #line 1164 "parser.yy"
     6426#line 1161 "parser.yy"
    64486427    {
    64496428                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    64546433
    64556434/* Line 1806 of yacc.c  */
    6456 #line 1168 "parser.yy"
     6435#line 1165 "parser.yy"
    64576436    {
    64586437                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    64636442
    64646443/* Line 1806 of yacc.c  */
    6465 #line 1175 "parser.yy"
     6444#line 1172 "parser.yy"
    64666445    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    64676446    break;
     
    64706449
    64716450/* Line 1806 of yacc.c  */
    6472 #line 1179 "parser.yy"
     6451#line 1176 "parser.yy"
    64736452    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); }
    64746453    break;
     
    64776456
    64786457/* Line 1806 of yacc.c  */
    6479 #line 1184 "parser.yy"
     6458#line 1181 "parser.yy"
    64806459    {
    64816460                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64876466
    64886467/* Line 1806 of yacc.c  */
    6489 #line 1189 "parser.yy"
     6468#line 1186 "parser.yy"
    64906469    {
    64916470                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64976476
    64986477/* Line 1806 of yacc.c  */
    6499 #line 1194 "parser.yy"
     6478#line 1191 "parser.yy"
    65006479    {
    65016480                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD );
     
    65076486
    65086487/* Line 1806 of yacc.c  */
    6509 #line 1205 "parser.yy"
     6488#line 1202 "parser.yy"
    65106489    {
    65116490                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65176496
    65186497/* Line 1806 of yacc.c  */
    6519 #line 1210 "parser.yy"
     6498#line 1207 "parser.yy"
    65206499    {
    65216500                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65276506
    65286507/* Line 1806 of yacc.c  */
    6529 #line 1215 "parser.yy"
     6508#line 1212 "parser.yy"
    65306509    {
    65316510                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65376516
    65386517/* Line 1806 of yacc.c  */
    6539 #line 1220 "parser.yy"
     6518#line 1217 "parser.yy"
    65406519    {
    65416520                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65476526
    65486527/* Line 1806 of yacc.c  */
    6549 #line 1225 "parser.yy"
     6528#line 1222 "parser.yy"
    65506529    {
    65516530                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    65576536
    65586537/* Line 1806 of yacc.c  */
    6559 #line 1234 "parser.yy"
     6538#line 1231 "parser.yy"
    65606539    {
    65616540                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD );
     
    65676546
    65686547/* Line 1806 of yacc.c  */
    6569 #line 1239 "parser.yy"
     6548#line 1236 "parser.yy"
    65706549    {
    65716550                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD );
     
    65776556
    65786557/* Line 1806 of yacc.c  */
    6579 #line 1256 "parser.yy"
     6558#line 1253 "parser.yy"
    65806559    {
    65816560                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65876566
    65886567/* Line 1806 of yacc.c  */
    6589 #line 1261 "parser.yy"
     6568#line 1258 "parser.yy"
    65906569    {
    65916570                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65976576
    65986577/* Line 1806 of yacc.c  */
    6599 #line 1283 "parser.yy"
     6578#line 1280 "parser.yy"
    66006579    { (yyval.decl) = 0; }
    66016580    break;
     
    66046583
    66056584/* Line 1806 of yacc.c  */
    6606 #line 1295 "parser.yy"
     6585#line 1292 "parser.yy"
    66076586    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66086587    break;
     
    66116590
    66126591/* Line 1806 of yacc.c  */
    6613 #line 1306 "parser.yy"
     6592#line 1303 "parser.yy"
    66146593    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); }
    66156594    break;
     
    66186597
    66196598/* Line 1806 of yacc.c  */
    6620 #line 1308 "parser.yy"
     6599#line 1305 "parser.yy"
    66216600    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); }
    66226601    break;
     
    66256604
    66266605/* Line 1806 of yacc.c  */
    6627 #line 1310 "parser.yy"
     6606#line 1307 "parser.yy"
    66286607    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); }
    66296608    break;
     
    66326611
    66336612/* Line 1806 of yacc.c  */
    6634 #line 1312 "parser.yy"
     6613#line 1309 "parser.yy"
    66356614    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
    66366615    break;
     
    66396618
    66406619/* Line 1806 of yacc.c  */
    6641 #line 1314 "parser.yy"
     6620#line 1311 "parser.yy"
    66426621    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
    66436622    break;
     
    66466625
    66476626/* Line 1806 of yacc.c  */
    6648 #line 1316 "parser.yy"
     6627#line 1313 "parser.yy"
    66496628    {
    66506629                        typedefTable.enterScope();
     
    66556634
    66566635/* Line 1806 of yacc.c  */
    6657 #line 1320 "parser.yy"
     6636#line 1317 "parser.yy"
    66586637    {
    66596638                        typedefTable.leaveScope();
     
    66656644
    66666645/* Line 1806 of yacc.c  */
    6667 #line 1329 "parser.yy"
     6646#line 1326 "parser.yy"
    66686647    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66696648    break;
     
    66726651
    66736652/* Line 1806 of yacc.c  */
    6674 #line 1331 "parser.yy"
     6653#line 1328 "parser.yy"
    66756654    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    66766655    break;
     
    66796658
    66806659/* Line 1806 of yacc.c  */
    6681 #line 1342 "parser.yy"
     6660#line 1339 "parser.yy"
    66826661    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66836662    break;
     
    66866665
    66876666/* Line 1806 of yacc.c  */
    6688 #line 1347 "parser.yy"
     6667#line 1344 "parser.yy"
    66896668    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
    66906669    break;
     
    66936672
    66946673/* Line 1806 of yacc.c  */
    6695 #line 1349 "parser.yy"
     6674#line 1346 "parser.yy"
    66966675    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); }
    66976676    break;
     
    67006679
    67016680/* Line 1806 of yacc.c  */
    6702 #line 1351 "parser.yy"
     6681#line 1348 "parser.yy"
    67036682    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
    67046683    break;
     
    67076686
    67086687/* Line 1806 of yacc.c  */
     6688#line 1350 "parser.yy"
     6689    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
     6690    break;
     6691
     6692  case 318:
     6693
     6694/* Line 1806 of yacc.c  */
    67096695#line 1353 "parser.yy"
    6710     { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    6711     break;
    6712 
    6713   case 318:
    6714 
    6715 /* Line 1806 of yacc.c  */
    6716 #line 1356 "parser.yy"
    67176696    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; }
    67186697    break;
     
    67216700
    67226701/* Line 1806 of yacc.c  */
     6702#line 1355 "parser.yy"
     6703    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
     6704    break;
     6705
     6706  case 320:
     6707
     6708/* Line 1806 of yacc.c  */
    67236709#line 1358 "parser.yy"
    6724     { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
    6725     break;
    6726 
    6727   case 320:
    6728 
    6729 /* Line 1806 of yacc.c  */
    6730 #line 1361 "parser.yy"
    67316710    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; }
    67326711    break;
     
    67356714
    67366715/* Line 1806 of yacc.c  */
    6737 #line 1363 "parser.yy"
     6716#line 1360 "parser.yy"
    67386717    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }
    67396718    break;
     
    67426721
    67436722/* Line 1806 of yacc.c  */
    6744 #line 1368 "parser.yy"
     6723#line 1365 "parser.yy"
    67456724    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    67466725    break;
     
    67496728
    67506729/* Line 1806 of yacc.c  */
    6751 #line 1370 "parser.yy"
     6730#line 1367 "parser.yy"
    67526731    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); }
    67536732    break;
     
    67566735
    67576736/* Line 1806 of yacc.c  */
    6758 #line 1372 "parser.yy"
     6737#line 1369 "parser.yy"
    67596738    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    67606739    break;
     
    67636742
    67646743/* Line 1806 of yacc.c  */
    6765 #line 1374 "parser.yy"
     6744#line 1371 "parser.yy"
    67666745    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); }
    67676746    break;
     
    67706749
    67716750/* Line 1806 of yacc.c  */
    6772 #line 1376 "parser.yy"
     6751#line 1373 "parser.yy"
    67736752    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); }
    67746753    break;
     
    67776756
    67786757/* Line 1806 of yacc.c  */
    6779 #line 1378 "parser.yy"
     6758#line 1375 "parser.yy"
    67806759    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); }
    67816760    break;
     
    67846763
    67856764/* Line 1806 of yacc.c  */
    6786 #line 1380 "parser.yy"
     6765#line 1377 "parser.yy"
    67876766    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
    67886767    break;
     
    67916770
    67926771/* Line 1806 of yacc.c  */
    6793 #line 1382 "parser.yy"
     6772#line 1379 "parser.yy"
    67946773    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
    67956774    break;
     
    67986777
    67996778/* Line 1806 of yacc.c  */
    6800 #line 1384 "parser.yy"
     6779#line 1381 "parser.yy"
    68016780    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    68026781    break;
     
    68056784
    68066785/* Line 1806 of yacc.c  */
    6807 #line 1386 "parser.yy"
     6786#line 1383 "parser.yy"
    68086787    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    68096788    break;
     
    68126791
    68136792/* Line 1806 of yacc.c  */
    6814 #line 1388 "parser.yy"
     6793#line 1385 "parser.yy"
    68156794    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
    68166795    break;
     
    68196798
    68206799/* Line 1806 of yacc.c  */
    6821 #line 1390 "parser.yy"
     6800#line 1387 "parser.yy"
    68226801    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
    68236802    break;
     
    68266805
    68276806/* Line 1806 of yacc.c  */
    6828 #line 1392 "parser.yy"
     6807#line 1389 "parser.yy"
    68296808    { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    68306809    break;
     
    68336812
    68346813/* Line 1806 of yacc.c  */
    6835 #line 1399 "parser.yy"
     6814#line 1396 "parser.yy"
    68366815    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68376816    break;
     
    68406819
    68416820/* Line 1806 of yacc.c  */
    6842 #line 1401 "parser.yy"
     6821#line 1398 "parser.yy"
    68436822    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68446823    break;
     
    68476826
    68486827/* Line 1806 of yacc.c  */
    6849 #line 1403 "parser.yy"
     6828#line 1400 "parser.yy"
    68506829    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68516830    break;
     
    68546833
    68556834/* Line 1806 of yacc.c  */
    6856 #line 1405 "parser.yy"
     6835#line 1402 "parser.yy"
    68576836    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); }
    68586837    break;
     
    68616840
    68626841/* Line 1806 of yacc.c  */
    6863 #line 1411 "parser.yy"
     6842#line 1408 "parser.yy"
    68646843    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68656844    break;
     
    68686847
    68696848/* Line 1806 of yacc.c  */
    6870 #line 1418 "parser.yy"
     6849#line 1415 "parser.yy"
    68716850    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68726851    break;
     
    68756854
    68766855/* Line 1806 of yacc.c  */
    6877 #line 1420 "parser.yy"
     6856#line 1417 "parser.yy"
    68786857    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68796858    break;
     
    68826861
    68836862/* Line 1806 of yacc.c  */
    6884 #line 1422 "parser.yy"
     6863#line 1419 "parser.yy"
    68856864    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); }
    68866865    break;
     
    68896868
    68906869/* Line 1806 of yacc.c  */
    6891 #line 1427 "parser.yy"
     6870#line 1424 "parser.yy"
    68926871    { (yyval.decl) = (yyvsp[(3) - (4)].decl); }
    68936872    break;
     
    68966875
    68976876/* Line 1806 of yacc.c  */
    6898 #line 1429 "parser.yy"
     6877#line 1426 "parser.yy"
    68996878    { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); }
    69006879    break;
     
    69036882
    69046883/* Line 1806 of yacc.c  */
    6905 #line 1431 "parser.yy"
     6884#line 1428 "parser.yy"
    69066885    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); }
    69076886    break;
     
    69106889
    69116890/* Line 1806 of yacc.c  */
    6912 #line 1433 "parser.yy"
     6891#line 1430 "parser.yy"
    69136892    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    69146893    break;
     
    69176896
    69186897/* Line 1806 of yacc.c  */
    6919 #line 1439 "parser.yy"
     6898#line 1436 "parser.yy"
    69206899    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69216900    break;
     
    69246903
    69256904/* Line 1806 of yacc.c  */
    6926 #line 1441 "parser.yy"
     6905#line 1438 "parser.yy"
    69276906    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69286907    break;
     
    69316910
    69326911/* Line 1806 of yacc.c  */
    6933 #line 1443 "parser.yy"
     6912#line 1440 "parser.yy"
    69346913    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    69356914    break;
     
    69386917
    69396918/* Line 1806 of yacc.c  */
    6940 #line 1449 "parser.yy"
     6919#line 1446 "parser.yy"
    69416920    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69426921    break;
     
    69456924
    69466925/* Line 1806 of yacc.c  */
    6947 #line 1451 "parser.yy"
     6926#line 1448 "parser.yy"
    69486927    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69496928    break;
     
    69526931
    69536932/* Line 1806 of yacc.c  */
    6954 #line 1457 "parser.yy"
     6933#line 1454 "parser.yy"
    69556934    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69566935    break;
     
    69596938
    69606939/* Line 1806 of yacc.c  */
    6961 #line 1459 "parser.yy"
     6940#line 1456 "parser.yy"
    69626941    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69636942    break;
     
    69666945
    69676946/* Line 1806 of yacc.c  */
    6968 #line 1461 "parser.yy"
     6947#line 1458 "parser.yy"
    69696948    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    69706949    break;
     
    69736952
    69746953/* Line 1806 of yacc.c  */
    6975 #line 1466 "parser.yy"
     6954#line 1463 "parser.yy"
    69766955    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); }
    69776956    break;
     
    69806959
    69816960/* Line 1806 of yacc.c  */
    6982 #line 1468 "parser.yy"
     6961#line 1465 "parser.yy"
    69836962    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69846963    break;
     
    69876966
    69886967/* Line 1806 of yacc.c  */
    6989 #line 1470 "parser.yy"
     6968#line 1467 "parser.yy"
    69906969    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69916970    break;
     
    69946973
    69956974/* Line 1806 of yacc.c  */
    6996 #line 1480 "parser.yy"
     6975#line 1477 "parser.yy"
    69976976    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); }
    69986977    break;
     
    70016980
    70026981/* Line 1806 of yacc.c  */
    7003 #line 1482 "parser.yy"
     6982#line 1479 "parser.yy"
    70046983    {
    70056984                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    70116990
    70126991/* Line 1806 of yacc.c  */
    7013 #line 1487 "parser.yy"
     6992#line 1484 "parser.yy"
    70146993    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    70156994    break;
     
    70186997
    70196998/* Line 1806 of yacc.c  */
    7020 #line 1489 "parser.yy"
     6999#line 1486 "parser.yy"
    70217000    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); }
    70227001    break;
     
    70257004
    70267005/* Line 1806 of yacc.c  */
    7027 #line 1491 "parser.yy"
     7006#line 1488 "parser.yy"
    70287007    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); }
    70297008    break;
     
    70327011
    70337012/* Line 1806 of yacc.c  */
    7034 #line 1493 "parser.yy"
     7013#line 1490 "parser.yy"
    70357014    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    70367015    break;
     
    70397018
    70407019/* Line 1806 of yacc.c  */
    7041 #line 1498 "parser.yy"
     7020#line 1495 "parser.yy"
    70427021    { (yyval.aggKey) = DeclarationNode::Struct; }
    70437022    break;
     
    70467025
    70477026/* Line 1806 of yacc.c  */
    7048 #line 1500 "parser.yy"
     7027#line 1497 "parser.yy"
    70497028    { (yyval.aggKey) = DeclarationNode::Union; }
    70507029    break;
     
    70537032
    70547033/* Line 1806 of yacc.c  */
    7055 #line 1505 "parser.yy"
     7034#line 1502 "parser.yy"
    70567035    { (yyval.decl) = 0; }
    70577036    break;
     
    70607039
    70617040/* Line 1806 of yacc.c  */
    7062 #line 1507 "parser.yy"
     7041#line 1504 "parser.yy"
    70637042    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    70647043    break;
     
    70677046
    70687047/* Line 1806 of yacc.c  */
     7048#line 1510 "parser.yy"
     7049    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
     7050    break;
     7051
     7052  case 379:
     7053
     7054/* Line 1806 of yacc.c  */
    70697055#line 1513 "parser.yy"
    7070     { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
    7071     break;
    7072 
    7073   case 379:
    7074 
    7075 /* Line 1806 of yacc.c  */
    7076 #line 1516 "parser.yy"
    70777056    {   // mark all fields in list
    70787057                        for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    70857064
    70867065/* Line 1806 of yacc.c  */
    7087 #line 1526 "parser.yy"
     7066#line 1523 "parser.yy"
    70887067    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); }
    70897068    break;
     
    70927071
    70937072/* Line 1806 of yacc.c  */
    7094 #line 1528 "parser.yy"
     7073#line 1525 "parser.yy"
    70957074    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); }
    70967075    break;
     
    70997078
    71007079/* Line 1806 of yacc.c  */
    7101 #line 1530 "parser.yy"
     7080#line 1527 "parser.yy"
    71027081    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); }
    71037082    break;
     
    71067085
    71077086/* Line 1806 of yacc.c  */
    7108 #line 1535 "parser.yy"
     7087#line 1532 "parser.yy"
    71097088    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    71107089    break;
     
    71137092
    71147093/* Line 1806 of yacc.c  */
    7115 #line 1537 "parser.yy"
     7094#line 1534 "parser.yy"
    71167095    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); }
    71177096    break;
     
    71207099
    71217100/* Line 1806 of yacc.c  */
    7122 #line 1542 "parser.yy"
     7101#line 1539 "parser.yy"
    71237102    { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ }
    71247103    break;
     
    71277106
    71287107/* Line 1806 of yacc.c  */
     7108#line 1541 "parser.yy"
     7109    { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); }
     7110    break;
     7111
     7112  case 388:
     7113
     7114/* Line 1806 of yacc.c  */
    71297115#line 1544 "parser.yy"
    7130     { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); }
    7131     break;
    7132 
    7133   case 388:
     7116    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
     7117    break;
     7118
     7119  case 389:
    71347120
    71357121/* Line 1806 of yacc.c  */
     
    71387124    break;
    71397125
    7140   case 389:
    7141 
    7142 /* Line 1806 of yacc.c  */
    7143 #line 1550 "parser.yy"
    7144     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
    7145     break;
    7146 
    71477126  case 391:
    71487127
    71497128/* Line 1806 of yacc.c  */
    7150 #line 1556 "parser.yy"
     7129#line 1553 "parser.yy"
    71517130    { (yyval.en) = 0; }
    71527131    break;
     
    71557134
    71567135/* Line 1806 of yacc.c  */
    7157 #line 1558 "parser.yy"
     7136#line 1555 "parser.yy"
    71587137    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    71597138    break;
     
    71627141
    71637142/* Line 1806 of yacc.c  */
    7164 #line 1563 "parser.yy"
     7143#line 1560 "parser.yy"
    71657144    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    71667145    break;
     
    71697148
    71707149/* Line 1806 of yacc.c  */
    7171 #line 1572 "parser.yy"
     7150#line 1569 "parser.yy"
    71727151    { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); }
    71737152    break;
     
    71767155
    71777156/* Line 1806 of yacc.c  */
    7178 #line 1574 "parser.yy"
     7157#line 1571 "parser.yy"
    71797158    {
    71807159                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    71867165
    71877166/* Line 1806 of yacc.c  */
    7188 #line 1579 "parser.yy"
     7167#line 1576 "parser.yy"
    71897168    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    71907169    break;
     
    71937172
    71947173/* Line 1806 of yacc.c  */
    7195 #line 1581 "parser.yy"
     7174#line 1578 "parser.yy"
    71967175    { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); }
    71977176    break;
     
    72007179
    72017180/* Line 1806 of yacc.c  */
    7202 #line 1586 "parser.yy"
     7181#line 1583 "parser.yy"
    72037182    { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); }
    72047183    break;
     
    72077186
    72087187/* Line 1806 of yacc.c  */
    7209 #line 1588 "parser.yy"
     7188#line 1585 "parser.yy"
    72107189    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); }
    72117190    break;
     
    72147193
    72157194/* Line 1806 of yacc.c  */
    7216 #line 1593 "parser.yy"
     7195#line 1590 "parser.yy"
    72177196    { (yyval.en) = 0; }
    72187197    break;
     
    72217200
    72227201/* Line 1806 of yacc.c  */
    7223 #line 1595 "parser.yy"
     7202#line 1592 "parser.yy"
    72247203    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    72257204    break;
     
    72287207
    72297208/* Line 1806 of yacc.c  */
    7230 #line 1602 "parser.yy"
     7209#line 1599 "parser.yy"
    72317210    { (yyval.decl) = 0; }
    72327211    break;
     
    72357214
    72367215/* Line 1806 of yacc.c  */
    7237 #line 1610 "parser.yy"
     7216#line 1607 "parser.yy"
    72387217    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72397218    break;
     
    72427221
    72437222/* Line 1806 of yacc.c  */
    7244 #line 1612 "parser.yy"
     7223#line 1609 "parser.yy"
    72457224    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72467225    break;
     
    72497228
    72507229/* Line 1806 of yacc.c  */
    7251 #line 1614 "parser.yy"
     7230#line 1611 "parser.yy"
    72527231    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72537232    break;
     
    72567235
    72577236/* Line 1806 of yacc.c  */
    7258 #line 1622 "parser.yy"
     7237#line 1619 "parser.yy"
    72597238    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72607239    break;
     
    72637242
    72647243/* Line 1806 of yacc.c  */
    7265 #line 1624 "parser.yy"
     7244#line 1621 "parser.yy"
    72667245    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72677246    break;
     
    72707249
    72717250/* Line 1806 of yacc.c  */
    7272 #line 1626 "parser.yy"
     7251#line 1623 "parser.yy"
    72737252    { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); }
    72747253    break;
     
    72777256
    72787257/* Line 1806 of yacc.c  */
    7279 #line 1632 "parser.yy"
     7258#line 1629 "parser.yy"
    72807259    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72817260    break;
     
    72847263
    72857264/* Line 1806 of yacc.c  */
    7286 #line 1637 "parser.yy"
     7265#line 1634 "parser.yy"
    72877266    { (yyval.decl) = 0; }
    72887267    break;
     
    72917270
    72927271/* Line 1806 of yacc.c  */
    7293 #line 1644 "parser.yy"
     7272#line 1641 "parser.yy"
    72947273    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72957274    break;
     
    72987277
    72997278/* Line 1806 of yacc.c  */
    7300 #line 1651 "parser.yy"
     7279#line 1648 "parser.yy"
    73017280    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    73027281    break;
     
    73057284
    73067285/* Line 1806 of yacc.c  */
    7307 #line 1653 "parser.yy"
     7286#line 1650 "parser.yy"
    73087287    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    73097288    break;
    73107289
    73117290  case 425:
     7291
     7292/* Line 1806 of yacc.c  */
     7293#line 1659 "parser.yy"
     7294    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
     7295    break;
     7296
     7297  case 426:
    73127298
    73137299/* Line 1806 of yacc.c  */
     
    73167302    break;
    73177303
    7318   case 426:
    7319 
    7320 /* Line 1806 of yacc.c  */
    7321 #line 1665 "parser.yy"
    7322     { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
    7323     break;
    7324 
    73257304  case 427:
    73267305
    73277306/* Line 1806 of yacc.c  */
    7328 #line 1667 "parser.yy"
     7307#line 1664 "parser.yy"
    73297308    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); }
    73307309    break;
     
    73337312
    73347313/* Line 1806 of yacc.c  */
    7335 #line 1677 "parser.yy"
     7314#line 1674 "parser.yy"
    73367315    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    73377316    break;
     
    73407319
    73417320/* Line 1806 of yacc.c  */
    7342 #line 1683 "parser.yy"
     7321#line 1680 "parser.yy"
    73437322    {
    73447323                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    73507329
    73517330/* Line 1806 of yacc.c  */
    7352 #line 1688 "parser.yy"
     7331#line 1685 "parser.yy"
    73537332    {
    73547333                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    73607339
    73617340/* Line 1806 of yacc.c  */
    7362 #line 1697 "parser.yy"
     7341#line 1694 "parser.yy"
    73637342    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73647343    break;
     
    73677346
    73687347/* Line 1806 of yacc.c  */
    7369 #line 1706 "parser.yy"
     7348#line 1703 "parser.yy"
    73707349    { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); }
    73717350    break;
     
    73747353
    73757354/* Line 1806 of yacc.c  */
    7376 #line 1708 "parser.yy"
     7355#line 1705 "parser.yy"
    73777356    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); }
    73787357    break;
     
    73817360
    73827361/* Line 1806 of yacc.c  */
    7383 #line 1733 "parser.yy"
     7362#line 1730 "parser.yy"
    73847363    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73857364    break;
     
    73887367
    73897368/* Line 1806 of yacc.c  */
    7390 #line 1741 "parser.yy"
     7369#line 1738 "parser.yy"
    73917370    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73927371    break;
     
    73957374
    73967375/* Line 1806 of yacc.c  */
    7397 #line 1746 "parser.yy"
     7376#line 1743 "parser.yy"
    73987377    { (yyval.in) = 0; }
    73997378    break;
     
    74027381
    74037382/* Line 1806 of yacc.c  */
    7404 #line 1748 "parser.yy"
     7383#line 1745 "parser.yy"
    74057384    { (yyval.in) = (yyvsp[(2) - (2)].in); }
    74067385    break;
     
    74097388
    74107389/* Line 1806 of yacc.c  */
    7411 #line 1750 "parser.yy"
     7390#line 1747 "parser.yy"
    74127391    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); }
    74137392    break;
     
    74167395
    74177396/* Line 1806 of yacc.c  */
    7418 #line 1754 "parser.yy"
     7397#line 1751 "parser.yy"
    74197398    { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); }
    74207399    break;
     
    74237402
    74247403/* Line 1806 of yacc.c  */
    7425 #line 1755 "parser.yy"
     7404#line 1752 "parser.yy"
    74267405    { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); }
    74277406    break;
     
    74307409
    74317410/* Line 1806 of yacc.c  */
     7411#line 1757 "parser.yy"
     7412    { (yyval.in) = 0; }
     7413    break;
     7414
     7415  case 463:
     7416
     7417/* Line 1806 of yacc.c  */
     7418#line 1759 "parser.yy"
     7419    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); }
     7420    break;
     7421
     7422  case 464:
     7423
     7424/* Line 1806 of yacc.c  */
    74327425#line 1760 "parser.yy"
    7433     { (yyval.in) = 0; }
    7434     break;
    7435 
    7436   case 463:
     7426    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); }
     7427    break;
     7428
     7429  case 465:
    74377430
    74387431/* Line 1806 of yacc.c  */
    74397432#line 1762 "parser.yy"
    7440     { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); }
    7441     break;
    7442 
    7443   case 464:
    7444 
    7445 /* Line 1806 of yacc.c  */
    7446 #line 1763 "parser.yy"
    7447     { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); }
    7448     break;
    7449 
    7450   case 465:
    7451 
    7452 /* Line 1806 of yacc.c  */
    7453 #line 1765 "parser.yy"
    74547433    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); }
    74557434    break;
     
    74587437
    74597438/* Line 1806 of yacc.c  */
    7460 #line 1781 "parser.yy"
     7439#line 1778 "parser.yy"
    74617440    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); }
    74627441    break;
     
    74657444
    74667445/* Line 1806 of yacc.c  */
    7467 #line 1787 "parser.yy"
     7446#line 1784 "parser.yy"
    74687447    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); }
    74697448    break;
     
    74727451
    74737452/* Line 1806 of yacc.c  */
     7453#line 1790 "parser.yy"
     7454    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); }
     7455    break;
     7456
     7457  case 471:
     7458
     7459/* Line 1806 of yacc.c  */
    74747460#line 1793 "parser.yy"
    7475     { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); }
    7476     break;
    7477 
    7478   case 471:
    7479 
    7480 /* Line 1806 of yacc.c  */
    7481 #line 1796 "parser.yy"
    74827461    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74837462    break;
     
    74867465
    74877466/* Line 1806 of yacc.c  */
    7488 #line 1798 "parser.yy"
     7467#line 1795 "parser.yy"
    74897468    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74907469    break;
     
    74937472
    74947473/* Line 1806 of yacc.c  */
    7495 #line 1800 "parser.yy"
     7474#line 1797 "parser.yy"
    74967475    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); }
    74977476    break;
     
    75007479
    75017480/* Line 1806 of yacc.c  */
    7502 #line 1802 "parser.yy"
     7481#line 1799 "parser.yy"
    75037482    { (yyval.en) = (yyvsp[(4) - (6)].en); }
    75047483    break;
     
    75077486
    75087487/* Line 1806 of yacc.c  */
    7509 #line 1826 "parser.yy"
     7488#line 1823 "parser.yy"
    75107489    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    75117490    break;
     
    75147493
    75157494/* Line 1806 of yacc.c  */
    7516 #line 1828 "parser.yy"
     7495#line 1825 "parser.yy"
    75177496    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    75187497    break;
     
    75217500
    75227501/* Line 1806 of yacc.c  */
    7523 #line 1830 "parser.yy"
     7502#line 1827 "parser.yy"
    75247503    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    75257504    break;
     
    75287507
    75297508/* Line 1806 of yacc.c  */
    7530 #line 1836 "parser.yy"
     7509#line 1833 "parser.yy"
    75317510    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    75327511    break;
     
    75357514
    75367515/* Line 1806 of yacc.c  */
    7537 #line 1838 "parser.yy"
     7516#line 1835 "parser.yy"
    75387517    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    75397518    break;
     
    75427521
    75437522/* Line 1806 of yacc.c  */
    7544 #line 1843 "parser.yy"
     7523#line 1840 "parser.yy"
    75457524    { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    75467525    break;
     
    75497528
    75507529/* Line 1806 of yacc.c  */
    7551 #line 1849 "parser.yy"
     7530#line 1846 "parser.yy"
    75527531    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); }
    75537532    break;
     
    75567535
    75577536/* Line 1806 of yacc.c  */
    7558 #line 1854 "parser.yy"
     7537#line 1851 "parser.yy"
    75597538    { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); }
    75607539    break;
     
    75637542
    75647543/* Line 1806 of yacc.c  */
    7565 #line 1856 "parser.yy"
     7544#line 1853 "parser.yy"
    75667545    { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); }
    75677546    break;
     
    75707549
    75717550/* Line 1806 of yacc.c  */
    7572 #line 1862 "parser.yy"
     7551#line 1859 "parser.yy"
    75737552    { (yyval.tclass) = DeclarationNode::Otype; }
    75747553    break;
     
    75777556
    75787557/* Line 1806 of yacc.c  */
    7579 #line 1864 "parser.yy"
     7558#line 1861 "parser.yy"
    75807559    { (yyval.tclass) = DeclarationNode::Ftype; }
    75817560    break;
     
    75847563
    75857564/* Line 1806 of yacc.c  */
    7586 #line 1866 "parser.yy"
     7565#line 1863 "parser.yy"
    75877566    { (yyval.tclass) = DeclarationNode::Dtype; }
    75887567    break;
     
    75917570
    75927571/* Line 1806 of yacc.c  */
    7593 #line 1871 "parser.yy"
     7572#line 1868 "parser.yy"
    75947573    { (yyval.decl) = 0; }
    75957574    break;
     
    75987577
    75997578/* Line 1806 of yacc.c  */
    7600 #line 1873 "parser.yy"
     7579#line 1870 "parser.yy"
    76017580    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    76027581    break;
     
    76057584
    76067585/* Line 1806 of yacc.c  */
    7607 #line 1878 "parser.yy"
     7586#line 1875 "parser.yy"
    76087587    {
    76097588                        typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) );
     
    76157594
    76167595/* Line 1806 of yacc.c  */
    7617 #line 1883 "parser.yy"
     7596#line 1880 "parser.yy"
    76187597    { (yyval.decl) = (yyvsp[(4) - (5)].decl); }
    76197598    break;
     
    76227601
    76237602/* Line 1806 of yacc.c  */
    7624 #line 1885 "parser.yy"
     7603#line 1882 "parser.yy"
    76257604    { (yyval.decl) = 0; }
    76267605    break;
     
    76297608
    76307609/* Line 1806 of yacc.c  */
     7610#line 1887 "parser.yy"
     7611    { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); }
     7612    break;
     7613
     7614  case 498:
     7615
     7616/* Line 1806 of yacc.c  */
    76317617#line 1890 "parser.yy"
    7632     { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); }
    7633     break;
    7634 
    7635   case 498:
    7636 
    7637 /* Line 1806 of yacc.c  */
    7638 #line 1893 "parser.yy"
    76397618    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); }
    76407619    break;
     
    76437622
    76447623/* Line 1806 of yacc.c  */
    7645 #line 1895 "parser.yy"
     7624#line 1892 "parser.yy"
    76467625    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    76477626    break;
     
    76507629
    76517630/* Line 1806 of yacc.c  */
    7652 #line 1900 "parser.yy"
     7631#line 1897 "parser.yy"
    76537632    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    76547633    break;
     
    76577636
    76587637/* Line 1806 of yacc.c  */
    7659 #line 1902 "parser.yy"
     7638#line 1899 "parser.yy"
    76607639    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); }
    76617640    break;
     
    76647643
    76657644/* Line 1806 of yacc.c  */
    7666 #line 1904 "parser.yy"
     7645#line 1901 "parser.yy"
    76677646    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); }
    76687647    break;
     
    76717650
    76727651/* Line 1806 of yacc.c  */
    7673 #line 1909 "parser.yy"
     7652#line 1906 "parser.yy"
    76747653    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); }
    76757654    break;
     
    76787657
    76797658/* Line 1806 of yacc.c  */
    7680 #line 1911 "parser.yy"
     7659#line 1908 "parser.yy"
    76817660    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); }
    76827661    break;
     
    76857664
    76867665/* Line 1806 of yacc.c  */
    7687 #line 1916 "parser.yy"
     7666#line 1913 "parser.yy"
    76887667    {
    76897668                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD );
     
    76957674
    76967675/* Line 1806 of yacc.c  */
    7697 #line 1921 "parser.yy"
     7676#line 1918 "parser.yy"
    76987677    {
    76997678                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG );
     
    77057684
    77067685/* Line 1806 of yacc.c  */
    7707 #line 1929 "parser.yy"
     7686#line 1926 "parser.yy"
    77087687    {
    77097688                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID );
     
    77157694
    77167695/* Line 1806 of yacc.c  */
    7717 #line 1934 "parser.yy"
     7696#line 1931 "parser.yy"
    77187697    {
    77197698                        typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) );
     
    77257704
    77267705/* Line 1806 of yacc.c  */
    7727 #line 1939 "parser.yy"
     7706#line 1936 "parser.yy"
    77287707    {
    77297708                        typedefTable.leaveTrait();
     
    77367715
    77377716/* Line 1806 of yacc.c  */
    7738 #line 1949 "parser.yy"
     7717#line 1946 "parser.yy"
    77397718    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    77407719    break;
     
    77437722
    77447723/* Line 1806 of yacc.c  */
    7745 #line 1959 "parser.yy"
     7724#line 1956 "parser.yy"
    77467725    {
    77477726                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77537732
    77547733/* Line 1806 of yacc.c  */
    7755 #line 1964 "parser.yy"
     7734#line 1961 "parser.yy"
    77567735    {
    77577736                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77637742
    77647743/* Line 1806 of yacc.c  */
    7765 #line 1969 "parser.yy"
     7744#line 1966 "parser.yy"
    77667745    {
    77677746                        typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    77737752
    77747753/* Line 1806 of yacc.c  */
    7775 #line 1977 "parser.yy"
     7754#line 1974 "parser.yy"
    77767755    {
    77777756                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77837762
    77847763/* Line 1806 of yacc.c  */
    7785 #line 1982 "parser.yy"
     7764#line 1979 "parser.yy"
    77867765    {
    77877766                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77937772
    77947773/* Line 1806 of yacc.c  */
    7795 #line 1992 "parser.yy"
     7774#line 1989 "parser.yy"
    77967775    {}
    77977776    break;
     
    78007779
    78017780/* Line 1806 of yacc.c  */
    7802 #line 1994 "parser.yy"
     7781#line 1991 "parser.yy"
    78037782    { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl);    }
    78047783    break;
     
    78077786
    78087787/* Line 1806 of yacc.c  */
    7809 #line 2000 "parser.yy"
     7788#line 1997 "parser.yy"
    78107789    { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); }
    78117790    break;
     
    78147793
    78157794/* Line 1806 of yacc.c  */
    7816 #line 2005 "parser.yy"
     7795#line 2002 "parser.yy"
    78177796    { (yyval.decl) = 0; }
    78187797    break;
     
    78217800
    78227801/* Line 1806 of yacc.c  */
    7823 #line 2013 "parser.yy"
     7802#line 2010 "parser.yy"
    78247803    {}
    78257804    break;
     
    78287807
    78297808/* Line 1806 of yacc.c  */
    7830 #line 2015 "parser.yy"
     7809#line 2012 "parser.yy"
    78317810    {
    78327811                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     
    78387817
    78397818/* Line 1806 of yacc.c  */
    7840 #line 2020 "parser.yy"
     7819#line 2017 "parser.yy"
    78417820    {
    78427821                        linkage = linkageStack.top();
     
    78497828
    78507829/* Line 1806 of yacc.c  */
    7851 #line 2026 "parser.yy"
     7830#line 2023 "parser.yy"
    78527831    {   // mark all fields in list
    78537832                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    78607839
    78617840/* Line 1806 of yacc.c  */
    7862 #line 2041 "parser.yy"
     7841#line 2038 "parser.yy"
    78637842    {
    78647843                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78717850
    78727851/* Line 1806 of yacc.c  */
    7873 #line 2047 "parser.yy"
     7852#line 2044 "parser.yy"
    78747853    {
    78757854                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78827861
    78837862/* Line 1806 of yacc.c  */
    7884 #line 2056 "parser.yy"
     7863#line 2053 "parser.yy"
    78857864    {
    78867865                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78937872
    78947873/* Line 1806 of yacc.c  */
    7895 #line 2062 "parser.yy"
     7874#line 2059 "parser.yy"
    78967875    {
    78977876                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79047883
    79057884/* Line 1806 of yacc.c  */
    7906 #line 2068 "parser.yy"
     7885#line 2065 "parser.yy"
    79077886    {
    79087887                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79157894
    79167895/* Line 1806 of yacc.c  */
    7917 #line 2074 "parser.yy"
     7896#line 2071 "parser.yy"
    79187897    {
    79197898                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79267905
    79277906/* Line 1806 of yacc.c  */
    7928 #line 2080 "parser.yy"
     7907#line 2077 "parser.yy"
    79297908    {
    79307909                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79377916
    79387917/* Line 1806 of yacc.c  */
    7939 #line 2088 "parser.yy"
     7918#line 2085 "parser.yy"
    79407919    {
    79417920                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79487927
    79497928/* Line 1806 of yacc.c  */
    7950 #line 2094 "parser.yy"
     7929#line 2091 "parser.yy"
    79517930    {
    79527931                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79597938
    79607939/* Line 1806 of yacc.c  */
    7961 #line 2102 "parser.yy"
     7940#line 2099 "parser.yy"
    79627941    {
    79637942                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79707949
    79717950/* Line 1806 of yacc.c  */
    7972 #line 2108 "parser.yy"
     7951#line 2105 "parser.yy"
    79737952    {
    79747953                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79817960
    79827961/* Line 1806 of yacc.c  */
    7983 #line 2123 "parser.yy"
     7962#line 2120 "parser.yy"
    79847963    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    79857964    break;
     
    79887967
    79897968/* Line 1806 of yacc.c  */
    7990 #line 2128 "parser.yy"
     7969#line 2125 "parser.yy"
    79917970    { delete (yyvsp[(3) - (5)].str); }
    79927971    break;
     
    79957974
    79967975/* Line 1806 of yacc.c  */
    7997 #line 2133 "parser.yy"
     7976#line 2130 "parser.yy"
    79987977    { (yyval.decl) = 0; }
    79997978    break;
     
    80027981
    80037982/* Line 1806 of yacc.c  */
    8004 #line 2140 "parser.yy"
     7983#line 2137 "parser.yy"
    80057984    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    80067985    break;
     
    80097988
    80107989/* Line 1806 of yacc.c  */
    8011 #line 2146 "parser.yy"
     7990#line 2143 "parser.yy"
    80127991    { (yyval.decl) = 0; }
    80137992    break;
     
    80167995
    80177996/* Line 1806 of yacc.c  */
    8018 #line 2157 "parser.yy"
     7997#line 2154 "parser.yy"
    80197998    { delete (yyvsp[(3) - (4)].en); }
    80207999    break;
     
    80238002
    80248003/* Line 1806 of yacc.c  */
     8004#line 2158 "parser.yy"
     8005    { delete (yyvsp[(1) - (1)].tok); }
     8006    break;
     8007
     8008  case 560:
     8009
     8010/* Line 1806 of yacc.c  */
     8011#line 2159 "parser.yy"
     8012    { delete (yyvsp[(1) - (1)].decl); }
     8013    break;
     8014
     8015  case 561:
     8016
     8017/* Line 1806 of yacc.c  */
     8018#line 2160 "parser.yy"
     8019    { delete (yyvsp[(1) - (1)].decl); }
     8020    break;
     8021
     8022  case 562:
     8023
     8024/* Line 1806 of yacc.c  */
    80258025#line 2161 "parser.yy"
    8026     { delete (yyvsp[(1) - (1)].tok); }
    8027     break;
    8028 
    8029   case 560:
    8030 
    8031 /* Line 1806 of yacc.c  */
    8032 #line 2162 "parser.yy"
    80338026    { delete (yyvsp[(1) - (1)].decl); }
    80348027    break;
    80358028
    8036   case 561:
    8037 
    8038 /* Line 1806 of yacc.c  */
    8039 #line 2163 "parser.yy"
    8040     { delete (yyvsp[(1) - (1)].decl); }
    8041     break;
    8042 
    8043   case 562:
    8044 
    8045 /* Line 1806 of yacc.c  */
    8046 #line 2164 "parser.yy"
    8047     { delete (yyvsp[(1) - (1)].decl); }
    8048     break;
    8049 
    80508029  case 563:
     8030
     8031/* Line 1806 of yacc.c  */
     8032#line 2196 "parser.yy"
     8033    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8034    break;
     8035
     8036  case 565:
    80518037
    80528038/* Line 1806 of yacc.c  */
     
    80558041    break;
    80568042
    8057   case 565:
    8058 
    8059 /* Line 1806 of yacc.c  */
    8060 #line 2202 "parser.yy"
     8043  case 566:
     8044
     8045/* Line 1806 of yacc.c  */
     8046#line 2201 "parser.yy"
    80618047    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    80628048    break;
    80638049
    8064   case 566:
    8065 
    8066 /* Line 1806 of yacc.c  */
    8067 #line 2204 "parser.yy"
    8068     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8069     break;
    8070 
    80718050  case 567:
    80728051
    80738052/* Line 1806 of yacc.c  */
    8074 #line 2209 "parser.yy"
     8053#line 2206 "parser.yy"
    80758054    {
    80768055                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    80828061
    80838062/* Line 1806 of yacc.c  */
    8084 #line 2214 "parser.yy"
     8063#line 2211 "parser.yy"
    80858064    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80868065    break;
     
    80898068
    80908069/* Line 1806 of yacc.c  */
    8091 #line 2219 "parser.yy"
     8070#line 2216 "parser.yy"
    80928071    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    80938072    break;
     
    80968075
    80978076/* Line 1806 of yacc.c  */
    8098 #line 2221 "parser.yy"
     8077#line 2218 "parser.yy"
    80998078    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    81008079    break;
     
    81038082
    81048083/* Line 1806 of yacc.c  */
    8105 #line 2223 "parser.yy"
     8084#line 2220 "parser.yy"
    81068085    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81078086    break;
     
    81108089
    81118090/* Line 1806 of yacc.c  */
    8112 #line 2228 "parser.yy"
     8091#line 2225 "parser.yy"
    81138092    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    81148093    break;
     
    81178096
    81188097/* Line 1806 of yacc.c  */
    8119 #line 2230 "parser.yy"
     8098#line 2227 "parser.yy"
    81208099    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81218100    break;
     
    81248103
    81258104/* Line 1806 of yacc.c  */
    8126 #line 2232 "parser.yy"
     8105#line 2229 "parser.yy"
    81278106    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81288107    break;
     
    81318110
    81328111/* Line 1806 of yacc.c  */
    8133 #line 2234 "parser.yy"
     8112#line 2231 "parser.yy"
    81348113    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81358114    break;
     
    81388117
    81398118/* Line 1806 of yacc.c  */
    8140 #line 2239 "parser.yy"
     8119#line 2236 "parser.yy"
    81418120    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    81428121    break;
     
    81458124
    81468125/* Line 1806 of yacc.c  */
    8147 #line 2241 "parser.yy"
     8126#line 2238 "parser.yy"
    81488127    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81498128    break;
    81508129
    81518130  case 578:
     8131
     8132/* Line 1806 of yacc.c  */
     8133#line 2247 "parser.yy"
     8134    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
     8135    break;
     8136
     8137  case 580:
    81528138
    81538139/* Line 1806 of yacc.c  */
     
    81568142    break;
    81578143
    8158   case 580:
    8159 
    8160 /* Line 1806 of yacc.c  */
    8161 #line 2253 "parser.yy"
     8144  case 581:
     8145
     8146/* Line 1806 of yacc.c  */
     8147#line 2255 "parser.yy"
     8148    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
     8149    break;
     8150
     8151  case 582:
     8152
     8153/* Line 1806 of yacc.c  */
     8154#line 2257 "parser.yy"
     8155    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
     8156    break;
     8157
     8158  case 583:
     8159
     8160/* Line 1806 of yacc.c  */
     8161#line 2259 "parser.yy"
     8162    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8163    break;
     8164
     8165  case 584:
     8166
     8167/* Line 1806 of yacc.c  */
     8168#line 2264 "parser.yy"
     8169    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
     8170    break;
     8171
     8172  case 585:
     8173
     8174/* Line 1806 of yacc.c  */
     8175#line 2266 "parser.yy"
     8176    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
     8177    break;
     8178
     8179  case 586:
     8180
     8181/* Line 1806 of yacc.c  */
     8182#line 2268 "parser.yy"
     8183    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8184    break;
     8185
     8186  case 587:
     8187
     8188/* Line 1806 of yacc.c  */
     8189#line 2273 "parser.yy"
     8190    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8191    break;
     8192
     8193  case 588:
     8194
     8195/* Line 1806 of yacc.c  */
     8196#line 2275 "parser.yy"
     8197    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8198    break;
     8199
     8200  case 589:
     8201
     8202/* Line 1806 of yacc.c  */
     8203#line 2277 "parser.yy"
     8204    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8205    break;
     8206
     8207  case 593:
     8208
     8209/* Line 1806 of yacc.c  */
     8210#line 2292 "parser.yy"
     8211    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); }
     8212    break;
     8213
     8214  case 594:
     8215
     8216/* Line 1806 of yacc.c  */
     8217#line 2294 "parser.yy"
     8218    { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); }
     8219    break;
     8220
     8221  case 595:
     8222
     8223/* Line 1806 of yacc.c  */
     8224#line 2296 "parser.yy"
     8225    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8226    break;
     8227
     8228  case 596:
     8229
     8230/* Line 1806 of yacc.c  */
     8231#line 2301 "parser.yy"
     8232    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
     8233    break;
     8234
     8235  case 597:
     8236
     8237/* Line 1806 of yacc.c  */
     8238#line 2303 "parser.yy"
     8239    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
     8240    break;
     8241
     8242  case 598:
     8243
     8244/* Line 1806 of yacc.c  */
     8245#line 2305 "parser.yy"
     8246    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8247    break;
     8248
     8249  case 599:
     8250
     8251/* Line 1806 of yacc.c  */
     8252#line 2310 "parser.yy"
     8253    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8254    break;
     8255
     8256  case 600:
     8257
     8258/* Line 1806 of yacc.c  */
     8259#line 2312 "parser.yy"
     8260    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8261    break;
     8262
     8263  case 601:
     8264
     8265/* Line 1806 of yacc.c  */
     8266#line 2314 "parser.yy"
     8267    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8268    break;
     8269
     8270  case 602:
     8271
     8272/* Line 1806 of yacc.c  */
     8273#line 2329 "parser.yy"
    81628274    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    81638275    break;
    81648276
    8165   case 581:
    8166 
    8167 /* Line 1806 of yacc.c  */
    8168 #line 2258 "parser.yy"
    8169     { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    8170     break;
    8171 
    8172   case 582:
    8173 
    8174 /* Line 1806 of yacc.c  */
    8175 #line 2260 "parser.yy"
    8176     { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    8177     break;
    8178 
    8179   case 583:
    8180 
    8181 /* Line 1806 of yacc.c  */
    8182 #line 2262 "parser.yy"
    8183     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8184     break;
    8185 
    8186   case 584:
    8187 
    8188 /* Line 1806 of yacc.c  */
    8189 #line 2267 "parser.yy"
    8190     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    8191     break;
    8192 
    8193   case 585:
    8194 
    8195 /* Line 1806 of yacc.c  */
    8196 #line 2269 "parser.yy"
    8197     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    8198     break;
    8199 
    8200   case 586:
    8201 
    8202 /* Line 1806 of yacc.c  */
    8203 #line 2271 "parser.yy"
    8204     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8205     break;
    8206 
    8207   case 587:
    8208 
    8209 /* Line 1806 of yacc.c  */
    8210 #line 2276 "parser.yy"
    8211     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8212     break;
    8213 
    8214   case 588:
    8215 
    8216 /* Line 1806 of yacc.c  */
    8217 #line 2278 "parser.yy"
    8218     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8219     break;
    8220 
    8221   case 589:
    8222 
    8223 /* Line 1806 of yacc.c  */
    8224 #line 2280 "parser.yy"
    8225     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8226     break;
    8227 
    8228   case 593:
    8229 
    8230 /* Line 1806 of yacc.c  */
    8231 #line 2295 "parser.yy"
    8232     { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); }
    8233     break;
    8234 
    8235   case 594:
    8236 
    8237 /* Line 1806 of yacc.c  */
    8238 #line 2297 "parser.yy"
    8239     { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); }
    8240     break;
    8241 
    8242   case 595:
    8243 
    8244 /* Line 1806 of yacc.c  */
    8245 #line 2299 "parser.yy"
    8246     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8247     break;
    8248 
    8249   case 596:
    8250 
    8251 /* Line 1806 of yacc.c  */
    8252 #line 2304 "parser.yy"
    8253     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    8254     break;
    8255 
    8256   case 597:
    8257 
    8258 /* Line 1806 of yacc.c  */
    8259 #line 2306 "parser.yy"
    8260     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    8261     break;
    8262 
    8263   case 598:
    8264 
    8265 /* Line 1806 of yacc.c  */
    8266 #line 2308 "parser.yy"
    8267     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8268     break;
    8269 
    8270   case 599:
    8271 
    8272 /* Line 1806 of yacc.c  */
    8273 #line 2313 "parser.yy"
    8274     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8275     break;
    8276 
    8277   case 600:
    8278 
    8279 /* Line 1806 of yacc.c  */
    8280 #line 2315 "parser.yy"
    8281     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8282     break;
    8283 
    8284   case 601:
    8285 
    8286 /* Line 1806 of yacc.c  */
    8287 #line 2317 "parser.yy"
    8288     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8289     break;
    8290 
    8291   case 602:
     8277  case 604:
    82928278
    82938279/* Line 1806 of yacc.c  */
     
    82968282    break;
    82978283
    8298   case 604:
    8299 
    8300 /* Line 1806 of yacc.c  */
    8301 #line 2335 "parser.yy"
     8284  case 605:
     8285
     8286/* Line 1806 of yacc.c  */
     8287#line 2334 "parser.yy"
    83028288    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83038289    break;
    83048290
    8305   case 605:
    8306 
    8307 /* Line 1806 of yacc.c  */
    8308 #line 2337 "parser.yy"
     8291  case 607:
     8292
     8293/* Line 1806 of yacc.c  */
     8294#line 2340 "parser.yy"
     8295    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8296    break;
     8297
     8298  case 608:
     8299
     8300/* Line 1806 of yacc.c  */
     8301#line 2345 "parser.yy"
     8302    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
     8303    break;
     8304
     8305  case 609:
     8306
     8307/* Line 1806 of yacc.c  */
     8308#line 2347 "parser.yy"
     8309    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
     8310    break;
     8311
     8312  case 610:
     8313
     8314/* Line 1806 of yacc.c  */
     8315#line 2349 "parser.yy"
     8316    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8317    break;
     8318
     8319  case 611:
     8320
     8321/* Line 1806 of yacc.c  */
     8322#line 2354 "parser.yy"
     8323    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
     8324    break;
     8325
     8326  case 612:
     8327
     8328/* Line 1806 of yacc.c  */
     8329#line 2356 "parser.yy"
     8330    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8331    break;
     8332
     8333  case 613:
     8334
     8335/* Line 1806 of yacc.c  */
     8336#line 2358 "parser.yy"
     8337    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8338    break;
     8339
     8340  case 614:
     8341
     8342/* Line 1806 of yacc.c  */
     8343#line 2360 "parser.yy"
     8344    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8345    break;
     8346
     8347  case 615:
     8348
     8349/* Line 1806 of yacc.c  */
     8350#line 2365 "parser.yy"
     8351    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
     8352    break;
     8353
     8354  case 616:
     8355
     8356/* Line 1806 of yacc.c  */
     8357#line 2367 "parser.yy"
     8358    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
     8359    break;
     8360
     8361  case 617:
     8362
     8363/* Line 1806 of yacc.c  */
     8364#line 2369 "parser.yy"
     8365    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8366    break;
     8367
     8368  case 618:
     8369
     8370/* Line 1806 of yacc.c  */
     8371#line 2379 "parser.yy"
    83098372    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83108373    break;
    83118374
    8312   case 607:
    8313 
    8314 /* Line 1806 of yacc.c  */
    8315 #line 2343 "parser.yy"
    8316     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8317     break;
    8318 
    8319   case 608:
    8320 
    8321 /* Line 1806 of yacc.c  */
    8322 #line 2348 "parser.yy"
    8323     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    8324     break;
    8325 
    8326   case 609:
    8327 
    8328 /* Line 1806 of yacc.c  */
    8329 #line 2350 "parser.yy"
    8330     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    8331     break;
    8332 
    8333   case 610:
    8334 
    8335 /* Line 1806 of yacc.c  */
    8336 #line 2352 "parser.yy"
    8337     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8338     break;
    8339 
    8340   case 611:
    8341 
    8342 /* Line 1806 of yacc.c  */
    8343 #line 2357 "parser.yy"
    8344     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    8345     break;
    8346 
    8347   case 612:
    8348 
    8349 /* Line 1806 of yacc.c  */
    8350 #line 2359 "parser.yy"
    8351     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8352     break;
    8353 
    8354   case 613:
    8355 
    8356 /* Line 1806 of yacc.c  */
    8357 #line 2361 "parser.yy"
    8358     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8359     break;
    8360 
    8361   case 614:
    8362 
    8363 /* Line 1806 of yacc.c  */
    8364 #line 2363 "parser.yy"
    8365     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8366     break;
    8367 
    8368   case 615:
    8369 
    8370 /* Line 1806 of yacc.c  */
    8371 #line 2368 "parser.yy"
    8372     { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    8373     break;
    8374 
    8375   case 616:
    8376 
    8377 /* Line 1806 of yacc.c  */
    8378 #line 2370 "parser.yy"
    8379     { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    8380     break;
    8381 
    8382   case 617:
    8383 
    8384 /* Line 1806 of yacc.c  */
    8385 #line 2372 "parser.yy"
    8386     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8387     break;
    8388 
    8389   case 618:
     8375  case 620:
    83908376
    83918377/* Line 1806 of yacc.c  */
     
    83948380    break;
    83958381
    8396   case 620:
    8397 
    8398 /* Line 1806 of yacc.c  */
    8399 #line 2385 "parser.yy"
     8382  case 621:
     8383
     8384/* Line 1806 of yacc.c  */
     8385#line 2384 "parser.yy"
    84008386    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84018387    break;
    84028388
    8403   case 621:
    8404 
    8405 /* Line 1806 of yacc.c  */
    8406 #line 2387 "parser.yy"
     8389  case 622:
     8390
     8391/* Line 1806 of yacc.c  */
     8392#line 2389 "parser.yy"
     8393    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
     8394    break;
     8395
     8396  case 623:
     8397
     8398/* Line 1806 of yacc.c  */
     8399#line 2391 "parser.yy"
     8400    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
     8401    break;
     8402
     8403  case 624:
     8404
     8405/* Line 1806 of yacc.c  */
     8406#line 2393 "parser.yy"
     8407    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8408    break;
     8409
     8410  case 625:
     8411
     8412/* Line 1806 of yacc.c  */
     8413#line 2398 "parser.yy"
     8414    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
     8415    break;
     8416
     8417  case 626:
     8418
     8419/* Line 1806 of yacc.c  */
     8420#line 2400 "parser.yy"
     8421    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8422    break;
     8423
     8424  case 627:
     8425
     8426/* Line 1806 of yacc.c  */
     8427#line 2402 "parser.yy"
     8428    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
     8429    break;
     8430
     8431  case 628:
     8432
     8433/* Line 1806 of yacc.c  */
     8434#line 2404 "parser.yy"
     8435    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8436    break;
     8437
     8438  case 629:
     8439
     8440/* Line 1806 of yacc.c  */
     8441#line 2409 "parser.yy"
     8442    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
     8443    break;
     8444
     8445  case 630:
     8446
     8447/* Line 1806 of yacc.c  */
     8448#line 2411 "parser.yy"
     8449    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
     8450    break;
     8451
     8452  case 631:
     8453
     8454/* Line 1806 of yacc.c  */
     8455#line 2413 "parser.yy"
     8456    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     8457    break;
     8458
     8459  case 632:
     8460
     8461/* Line 1806 of yacc.c  */
     8462#line 2444 "parser.yy"
    84078463    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84088464    break;
    84098465
    8410   case 622:
    8411 
    8412 /* Line 1806 of yacc.c  */
    8413 #line 2392 "parser.yy"
    8414     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    8415     break;
    8416 
    8417   case 623:
    8418 
    8419 /* Line 1806 of yacc.c  */
    8420 #line 2394 "parser.yy"
    8421     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    8422     break;
    8423 
    8424   case 624:
    8425 
    8426 /* Line 1806 of yacc.c  */
    8427 #line 2396 "parser.yy"
    8428     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8429     break;
    8430 
    8431   case 625:
    8432 
    8433 /* Line 1806 of yacc.c  */
    8434 #line 2401 "parser.yy"
    8435     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    8436     break;
    8437 
    8438   case 626:
    8439 
    8440 /* Line 1806 of yacc.c  */
    8441 #line 2403 "parser.yy"
    8442     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8443     break;
    8444 
    8445   case 627:
    8446 
    8447 /* Line 1806 of yacc.c  */
    8448 #line 2405 "parser.yy"
    8449     { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    8450     break;
    8451 
    8452   case 628:
    8453 
    8454 /* Line 1806 of yacc.c  */
    8455 #line 2407 "parser.yy"
    8456     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8457     break;
    8458 
    8459   case 629:
    8460 
    8461 /* Line 1806 of yacc.c  */
    8462 #line 2412 "parser.yy"
    8463     { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    8464     break;
    8465 
    8466   case 630:
    8467 
    8468 /* Line 1806 of yacc.c  */
    8469 #line 2414 "parser.yy"
    8470     { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    8471     break;
    8472 
    8473   case 631:
    8474 
    8475 /* Line 1806 of yacc.c  */
    8476 #line 2416 "parser.yy"
    8477     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    8478     break;
    8479 
    8480   case 632:
     8466  case 634:
    84818467
    84828468/* Line 1806 of yacc.c  */
     
    84858471    break;
    84868472
    8487   case 634:
    8488 
    8489 /* Line 1806 of yacc.c  */
    8490 #line 2450 "parser.yy"
     8473  case 635:
     8474
     8475/* Line 1806 of yacc.c  */
     8476#line 2449 "parser.yy"
    84918477    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84928478    break;
    84938479
    8494   case 635:
    8495 
    8496 /* Line 1806 of yacc.c  */
    8497 #line 2452 "parser.yy"
    8498     { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    8499     break;
    8500 
    85018480  case 636:
    85028481
    85038482/* Line 1806 of yacc.c  */
    8504 #line 2457 "parser.yy"
     8483#line 2454 "parser.yy"
    85058484    {
    85068485                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    85128491
    85138492/* Line 1806 of yacc.c  */
    8514 #line 2462 "parser.yy"
     8493#line 2459 "parser.yy"
    85158494    {
    85168495                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    85228501
    85238502/* Line 1806 of yacc.c  */
    8524 #line 2470 "parser.yy"
     8503#line 2467 "parser.yy"
    85258504    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    85268505    break;
     
    85298508
    85308509/* Line 1806 of yacc.c  */
    8531 #line 2472 "parser.yy"
     8510#line 2469 "parser.yy"
    85328511    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    85338512    break;
     
    85368515
    85378516/* Line 1806 of yacc.c  */
    8538 #line 2474 "parser.yy"
     8517#line 2471 "parser.yy"
    85398518    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    85408519    break;
     
    85438522
    85448523/* Line 1806 of yacc.c  */
    8545 #line 2479 "parser.yy"
     8524#line 2476 "parser.yy"
    85468525    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    85478526    break;
     
    85508529
    85518530/* Line 1806 of yacc.c  */
    8552 #line 2481 "parser.yy"
     8531#line 2478 "parser.yy"
    85538532    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    85548533    break;
     
    85578536
    85588537/* Line 1806 of yacc.c  */
    8559 #line 2486 "parser.yy"
     8538#line 2483 "parser.yy"
    85608539    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    85618540    break;
     
    85648543
    85658544/* Line 1806 of yacc.c  */
    8566 #line 2488 "parser.yy"
     8545#line 2485 "parser.yy"
    85678546    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    85688547    break;
     
    85718550
    85728551/* Line 1806 of yacc.c  */
    8573 #line 2503 "parser.yy"
     8552#line 2500 "parser.yy"
    85748553    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85758554    break;
     
    85788557
    85798558/* Line 1806 of yacc.c  */
    8580 #line 2505 "parser.yy"
     8559#line 2502 "parser.yy"
    85818560    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85828561    break;
     
    85858564
    85868565/* Line 1806 of yacc.c  */
    8587 #line 2510 "parser.yy"
     8566#line 2507 "parser.yy"
    85888567    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    85898568    break;
     
    85928571
    85938572/* Line 1806 of yacc.c  */
    8594 #line 2512 "parser.yy"
     8573#line 2509 "parser.yy"
    85958574    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    85968575    break;
     
    85998578
    86008579/* Line 1806 of yacc.c  */
    8601 #line 2514 "parser.yy"
     8580#line 2511 "parser.yy"
    86028581    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    86038582    break;
     
    86068585
    86078586/* Line 1806 of yacc.c  */
    8608 #line 2516 "parser.yy"
     8587#line 2513 "parser.yy"
    86098588    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    86108589    break;
     
    86138592
    86148593/* Line 1806 of yacc.c  */
    8615 #line 2518 "parser.yy"
     8594#line 2515 "parser.yy"
    86168595    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86178596    break;
     
    86208599
    86218600/* Line 1806 of yacc.c  */
    8622 #line 2524 "parser.yy"
     8601#line 2521 "parser.yy"
    86238602    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    86248603    break;
     
    86278606
    86288607/* Line 1806 of yacc.c  */
    8629 #line 2526 "parser.yy"
     8608#line 2523 "parser.yy"
    86308609    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    86318610    break;
     
    86348613
    86358614/* Line 1806 of yacc.c  */
    8636 #line 2528 "parser.yy"
     8615#line 2525 "parser.yy"
    86378616    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86388617    break;
     
    86418620
    86428621/* Line 1806 of yacc.c  */
    8643 #line 2533 "parser.yy"
     8622#line 2530 "parser.yy"
    86448623    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    86458624    break;
     
    86488627
    86498628/* Line 1806 of yacc.c  */
    8650 #line 2535 "parser.yy"
     8629#line 2532 "parser.yy"
    86518630    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    86528631    break;
     
    86558634
    86568635/* Line 1806 of yacc.c  */
    8657 #line 2537 "parser.yy"
     8636#line 2534 "parser.yy"
    86588637    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86598638    break;
     
    86628641
    86638642/* Line 1806 of yacc.c  */
    8664 #line 2543 "parser.yy"
     8643#line 2540 "parser.yy"
    86658644    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    86668645    break;
     
    86698648
    86708649/* Line 1806 of yacc.c  */
    8671 #line 2545 "parser.yy"
     8650#line 2542 "parser.yy"
    86728651    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); }
    86738652    break;
     
    86768655
    86778656/* Line 1806 of yacc.c  */
    8678 #line 2551 "parser.yy"
     8657#line 2548 "parser.yy"
    86798658    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); }
    86808659    break;
     
    86838662
    86848663/* Line 1806 of yacc.c  */
    8685 #line 2553 "parser.yy"
     8664#line 2550 "parser.yy"
    86868665    { (yyval.decl) = DeclarationNode::newVarArray( 0 ); }
    86878666    break;
     
    86908669
    86918670/* Line 1806 of yacc.c  */
    8692 #line 2555 "parser.yy"
     8671#line 2552 "parser.yy"
    86938672    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); }
    86948673    break;
     
    86978676
    86988677/* Line 1806 of yacc.c  */
    8699 #line 2557 "parser.yy"
     8678#line 2554 "parser.yy"
    87008679    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); }
    87018680    break;
     
    87048683
    87058684/* Line 1806 of yacc.c  */
    8706 #line 2572 "parser.yy"
     8685#line 2569 "parser.yy"
    87078686    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    87088687    break;
     
    87118690
    87128691/* Line 1806 of yacc.c  */
    8713 #line 2574 "parser.yy"
     8692#line 2571 "parser.yy"
    87148693    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    87158694    break;
     
    87188697
    87198698/* Line 1806 of yacc.c  */
    8720 #line 2579 "parser.yy"
     8699#line 2576 "parser.yy"
    87218700    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    87228701    break;
     
    87258704
    87268705/* Line 1806 of yacc.c  */
    8727 #line 2581 "parser.yy"
     8706#line 2578 "parser.yy"
    87288707    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    87298708    break;
     
    87328711
    87338712/* Line 1806 of yacc.c  */
    8734 #line 2583 "parser.yy"
     8713#line 2580 "parser.yy"
    87358714    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    87368715    break;
     
    87398718
    87408719/* Line 1806 of yacc.c  */
    8741 #line 2585 "parser.yy"
     8720#line 2582 "parser.yy"
    87428721    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    87438722    break;
     
    87468725
    87478726/* Line 1806 of yacc.c  */
    8748 #line 2587 "parser.yy"
     8727#line 2584 "parser.yy"
    87498728    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87508729    break;
     
    87538732
    87548733/* Line 1806 of yacc.c  */
    8755 #line 2593 "parser.yy"
     8734#line 2590 "parser.yy"
    87568735    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87578736    break;
     
    87608739
    87618740/* Line 1806 of yacc.c  */
    8762 #line 2595 "parser.yy"
     8741#line 2592 "parser.yy"
    87638742    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87648743    break;
     
    87678746
    87688747/* Line 1806 of yacc.c  */
    8769 #line 2597 "parser.yy"
     8748#line 2594 "parser.yy"
    87708749    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87718750    break;
     
    87748753
    87758754/* Line 1806 of yacc.c  */
    8776 #line 2602 "parser.yy"
     8755#line 2599 "parser.yy"
    87778756    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    87788757    break;
     
    87818760
    87828761/* Line 1806 of yacc.c  */
    8783 #line 2604 "parser.yy"
     8762#line 2601 "parser.yy"
    87848763    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    87858764    break;
     
    87888767
    87898768/* Line 1806 of yacc.c  */
    8790 #line 2606 "parser.yy"
     8769#line 2603 "parser.yy"
    87918770    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87928771    break;
     
    87958774
    87968775/* Line 1806 of yacc.c  */
    8797 #line 2613 "parser.yy"
     8776#line 2610 "parser.yy"
    87988777    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    87998778    break;
     
    88028781
    88038782/* Line 1806 of yacc.c  */
     8783#line 2621 "parser.yy"
     8784    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
     8785    break;
     8786
     8787  case 686:
     8788
     8789/* Line 1806 of yacc.c  */
    88048790#line 2624 "parser.yy"
    8805     { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    8806     break;
    8807 
    8808   case 686:
    8809 
    8810 /* Line 1806 of yacc.c  */
    8811 #line 2627 "parser.yy"
    88128791    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    88138792    break;
     
    88168795
    88178796/* Line 1806 of yacc.c  */
     8797#line 2626 "parser.yy"
     8798    { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); }
     8799    break;
     8800
     8801  case 688:
     8802
     8803/* Line 1806 of yacc.c  */
    88188804#line 2629 "parser.yy"
    8819     { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); }
    8820     break;
    8821 
    8822   case 688:
    8823 
    8824 /* Line 1806 of yacc.c  */
    8825 #line 2632 "parser.yy"
    88268805    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    88278806    break;
     
    88308809
    88318810/* Line 1806 of yacc.c  */
    8832 #line 2634 "parser.yy"
     8811#line 2631 "parser.yy"
    88338812    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); }
    88348813    break;
     
    88378816
    88388817/* Line 1806 of yacc.c  */
    8839 #line 2636 "parser.yy"
     8818#line 2633 "parser.yy"
    88408819    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); }
    88418820    break;
     
    88448823
    88458824/* Line 1806 of yacc.c  */
    8846 #line 2650 "parser.yy"
     8825#line 2647 "parser.yy"
    88478826    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    88488827    break;
     
    88518830
    88528831/* Line 1806 of yacc.c  */
    8853 #line 2652 "parser.yy"
     8832#line 2649 "parser.yy"
    88548833    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    88558834    break;
     
    88588837
    88598838/* Line 1806 of yacc.c  */
    8860 #line 2657 "parser.yy"
     8839#line 2654 "parser.yy"
    88618840    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    88628841    break;
     
    88658844
    88668845/* Line 1806 of yacc.c  */
    8867 #line 2659 "parser.yy"
     8846#line 2656 "parser.yy"
    88688847    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    88698848    break;
     
    88728851
    88738852/* Line 1806 of yacc.c  */
    8874 #line 2661 "parser.yy"
     8853#line 2658 "parser.yy"
    88758854    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    88768855    break;
     
    88798858
    88808859/* Line 1806 of yacc.c  */
    8881 #line 2663 "parser.yy"
     8860#line 2660 "parser.yy"
    88828861    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    88838862    break;
     
    88868865
    88878866/* Line 1806 of yacc.c  */
    8888 #line 2665 "parser.yy"
     8867#line 2662 "parser.yy"
    88898868    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88908869    break;
     
    88938872
    88948873/* Line 1806 of yacc.c  */
    8895 #line 2671 "parser.yy"
     8874#line 2668 "parser.yy"
    88968875    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    88978876    break;
     
    89008879
    89018880/* Line 1806 of yacc.c  */
    8902 #line 2673 "parser.yy"
     8881#line 2670 "parser.yy"
    89038882    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    89048883    break;
     
    89078886
    89088887/* Line 1806 of yacc.c  */
    8909 #line 2675 "parser.yy"
     8888#line 2672 "parser.yy"
    89108889    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    89118890    break;
     
    89148893
    89158894/* Line 1806 of yacc.c  */
    8916 #line 2680 "parser.yy"
     8895#line 2677 "parser.yy"
    89178896    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    89188897    break;
     
    89218900
    89228901/* Line 1806 of yacc.c  */
    8923 #line 2682 "parser.yy"
     8902#line 2679 "parser.yy"
    89248903    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    89258904    break;
     
    89288907
    89298908/* Line 1806 of yacc.c  */
    8930 #line 2692 "parser.yy"
     8909#line 2689 "parser.yy"
    89318910    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    89328911    break;
     
    89358914
    89368915/* Line 1806 of yacc.c  */
    8937 #line 2702 "parser.yy"
     8916#line 2699 "parser.yy"
    89388917    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89398918    break;
     
    89428921
    89438922/* Line 1806 of yacc.c  */
    8944 #line 2704 "parser.yy"
     8923#line 2701 "parser.yy"
    89458924    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89468925    break;
     
    89498928
    89508929/* Line 1806 of yacc.c  */
    8951 #line 2706 "parser.yy"
     8930#line 2703 "parser.yy"
    89528931    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89538932    break;
     
    89568935
    89578936/* Line 1806 of yacc.c  */
    8958 #line 2708 "parser.yy"
     8937#line 2705 "parser.yy"
    89598938    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89608939    break;
     
    89638942
    89648943/* Line 1806 of yacc.c  */
    8965 #line 2710 "parser.yy"
     8944#line 2707 "parser.yy"
    89668945    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89678946    break;
     
    89708949
    89718950/* Line 1806 of yacc.c  */
    8972 #line 2712 "parser.yy"
     8951#line 2709 "parser.yy"
    89738952    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89748953    break;
     
    89778956
    89788957/* Line 1806 of yacc.c  */
    8979 #line 2719 "parser.yy"
     8958#line 2716 "parser.yy"
    89808959    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89818960    break;
     
    89848963
    89858964/* Line 1806 of yacc.c  */
    8986 #line 2721 "parser.yy"
     8965#line 2718 "parser.yy"
    89878966    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    89888967    break;
     
    89918970
    89928971/* Line 1806 of yacc.c  */
    8993 #line 2723 "parser.yy"
     8972#line 2720 "parser.yy"
    89948973    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89958974    break;
     
    89988977
    89998978/* Line 1806 of yacc.c  */
    9000 #line 2725 "parser.yy"
     8979#line 2722 "parser.yy"
    90018980    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    90028981    break;
     
    90058984
    90068985/* Line 1806 of yacc.c  */
    9007 #line 2727 "parser.yy"
     8986#line 2724 "parser.yy"
    90088987    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    90098988    break;
     
    90128991
    90138992/* Line 1806 of yacc.c  */
    9014 #line 2729 "parser.yy"
     8993#line 2726 "parser.yy"
    90158994    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    90168995    break;
     
    90198998
    90208999/* Line 1806 of yacc.c  */
    9021 #line 2731 "parser.yy"
     9000#line 2728 "parser.yy"
    90229001    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    90239002    break;
     
    90269005
    90279006/* Line 1806 of yacc.c  */
    9028 #line 2733 "parser.yy"
     9007#line 2730 "parser.yy"
    90299008    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    90309009    break;
     
    90339012
    90349013/* Line 1806 of yacc.c  */
    9035 #line 2735 "parser.yy"
     9014#line 2732 "parser.yy"
    90369015    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    90379016    break;
     
    90409019
    90419020/* Line 1806 of yacc.c  */
    9042 #line 2737 "parser.yy"
     9021#line 2734 "parser.yy"
    90439022    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    90449023    break;
     
    90479026
    90489027/* Line 1806 of yacc.c  */
    9049 #line 2742 "parser.yy"
     9028#line 2739 "parser.yy"
    90509029    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    90519030    break;
     
    90549033
    90559034/* Line 1806 of yacc.c  */
    9056 #line 2744 "parser.yy"
     9035#line 2741 "parser.yy"
    90579036    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    90589037    break;
     
    90619040
    90629041/* Line 1806 of yacc.c  */
    9063 #line 2749 "parser.yy"
     9042#line 2746 "parser.yy"
    90649043    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); }
    90659044    break;
     
    90689047
    90699048/* Line 1806 of yacc.c  */
    9070 #line 2751 "parser.yy"
     9049#line 2748 "parser.yy"
    90719050    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); }
    90729051    break;
     
    90759054
    90769055/* Line 1806 of yacc.c  */
    9077 #line 2778 "parser.yy"
     9056#line 2775 "parser.yy"
    90789057    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    90799058    break;
     
    90829061
    90839062/* Line 1806 of yacc.c  */
    9084 #line 2789 "parser.yy"
     9063#line 2786 "parser.yy"
    90859064    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90869065    break;
     
    90899068
    90909069/* Line 1806 of yacc.c  */
    9091 #line 2791 "parser.yy"
     9070#line 2788 "parser.yy"
    90929071    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90939072    break;
     
    90969075
    90979076/* Line 1806 of yacc.c  */
    9098 #line 2793 "parser.yy"
     9077#line 2790 "parser.yy"
    90999078    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    91009079    break;
     
    91039082
    91049083/* Line 1806 of yacc.c  */
    9105 #line 2795 "parser.yy"
     9084#line 2792 "parser.yy"
    91069085    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    91079086    break;
     
    91109089
    91119090/* Line 1806 of yacc.c  */
    9112 #line 2797 "parser.yy"
     9091#line 2794 "parser.yy"
    91139092    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    91149093    break;
     
    91179096
    91189097/* Line 1806 of yacc.c  */
    9119 #line 2799 "parser.yy"
     9098#line 2796 "parser.yy"
    91209099    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    91219100    break;
     
    91249103
    91259104/* Line 1806 of yacc.c  */
    9126 #line 2806 "parser.yy"
     9105#line 2803 "parser.yy"
    91279106    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91289107    break;
     
    91319110
    91329111/* Line 1806 of yacc.c  */
    9133 #line 2808 "parser.yy"
     9112#line 2805 "parser.yy"
    91349113    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91359114    break;
     
    91389117
    91399118/* Line 1806 of yacc.c  */
    9140 #line 2810 "parser.yy"
     9119#line 2807 "parser.yy"
    91419120    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    91429121    break;
     
    91459124
    91469125/* Line 1806 of yacc.c  */
    9147 #line 2812 "parser.yy"
     9126#line 2809 "parser.yy"
    91489127    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91499128    break;
     
    91529131
    91539132/* Line 1806 of yacc.c  */
    9154 #line 2814 "parser.yy"
     9133#line 2811 "parser.yy"
    91559134    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    91569135    break;
     
    91599138
    91609139/* Line 1806 of yacc.c  */
    9161 #line 2816 "parser.yy"
     9140#line 2813 "parser.yy"
    91629141    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    91639142    break;
     
    91669145
    91679146/* Line 1806 of yacc.c  */
    9168 #line 2821 "parser.yy"
     9147#line 2818 "parser.yy"
    91699148    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    91709149    break;
     
    91739152
    91749153/* Line 1806 of yacc.c  */
    9175 #line 2826 "parser.yy"
     9154#line 2823 "parser.yy"
    91769155    { (yyval.decl) = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), (yyvsp[(4) - (5)].decl), nullptr ); }
    91779156    break;
     
    91809159
    91819160/* Line 1806 of yacc.c  */
    9182 #line 2828 "parser.yy"
     9161#line 2825 "parser.yy"
    91839162    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91849163    break;
     
    91879166
    91889167/* Line 1806 of yacc.c  */
    9189 #line 2830 "parser.yy"
     9168#line 2827 "parser.yy"
    91909169    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91919170    break;
     
    91949173
    91959174/* Line 1806 of yacc.c  */
    9196 #line 2854 "parser.yy"
     9175#line 2851 "parser.yy"
    91979176    { (yyval.en) = 0; }
    91989177    break;
     
    92019180
    92029181/* Line 1806 of yacc.c  */
    9203 #line 2856 "parser.yy"
     9182#line 2853 "parser.yy"
    92049183    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    92059184    break;
     
    92089187
    92099188/* Line 1806 of yacc.c  */
    9210 #line 9211 "Parser/parser.cc"
     9189#line 9190 "Parser/parser.cc"
    92119190      default: break;
    92129191    }
     
    94399418
    94409419/* Line 2067 of yacc.c  */
    9441 #line 2859 "parser.yy"
     9420#line 2856 "parser.yy"
    94429421
    94439422// ----end of grammar----
  • src/Parser/parser.yy

    r7756647 rd58a39a0  
    379379                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    380380        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    381                 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    382381        | postfix_expression '.' INTEGERconstant
    383                 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
    384382        | postfix_expression ARROW no_attr_identifier
    385383                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    386384        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    387                         { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    388385        | postfix_expression ICR
    389386                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
  • src/ResolvExpr/Alternative.cc

    r7756647 rd58a39a0  
    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() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {}
     22        Alternative::Alternative() : 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;
    5237                return *this;
    5338        }
     
    6954                        expr->print( os, indent );
    7055                        os << "(types:" << std::endl;
    71                         os << std::string( indent+4, ' ' );
    72                         expr->get_result()->print( os, indent + 4 );
    73                         os << std::endl << ")" << std::endl;
     56                        printAll( expr->get_results(), os, indent + 4 );
     57                        os << ")" << std::endl;
    7458                } else {
    7559                        os << "Null expression!" << std::endl;
  • src/ResolvExpr/Alternative.h

    r7756647 rd58a39a0  
    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 );
    3634                ~Alternative();
    37 
     35 
    3836                void initialize( const Alternative &src, Alternative &dest );
    39 
     37 
    4038                void print( std::ostream &os, int indent = 0 ) const;
    41 
     39 
    4240                Cost cost;
    4341                Cost cvtCost;
  • src/ResolvExpr/AlternativeFinder.cc

    r7756647 rd58a39a0  
    3838#include "SynTree/TypeSubstitution.h"
    3939#include "SymTab/Validate.h"
    40 #include "Tuples/Tuples.h"
     40#include "Tuples/TupleAssignment.h"
     41#include "Tuples/NameMatcher.h"
    4142#include "Common/utility.h"
    4243#include "InitTweak/InitTweak.h"
     
    6364        }
    6465
    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 
    7366        namespace {
    7467                void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) {
     
    8376                                out.push_back( i->expr->clone() );
    8477                        }
     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;
    8586                }
    8687
     
    100101                                PruneStruct current( candidate );
    101102                                std::string mangleName;
    102                                 {
    103                                         Type * newType = candidate->expr->get_result()->clone();
     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();
    104105                                        candidate->env.apply( newType );
    105                                         mangleName = SymTab::Mangler::mangle( newType );
     106                                        mangleName += SymTab::Mangler::mangle( newType );
    106107                                        delete newType;
    107108                                }
     
    132133                                if ( ! target->second.isAmbiguous ) {
    133134                                        Alternative &alt = *target->second.candidate;
    134                                         alt.env.applyFree( alt.expr->get_result() );
     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                                        }
    135138                                        *out++ = alt;
    136139                                }
    137140                        }
     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                        }
    138169                }
    139170
    140171                void renameTypes( Expression *expr ) {
    141                         expr->get_result()->accept( global_renamer );
     172                        for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
     173                                (*i)->accept( global_renamer );
     174                        }
    142175                }
    143176        }
     
    171204                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    172205                        if ( adjust ) {
    173                                 adjustExprType( i->expr->get_result(), i->env, indexer );
     206                                adjustExprTypeList( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );
    174207                        }
    175208                }
     
    208241
    209242        template< typename StructOrUnionType >
    210         void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
    211                 // member must be either a tuple expression or a name expr
    212                 if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) {
    213                         const std::string & name = nameExpr->get_name();
    214                         std::list< Declaration* > members;
    215                         aggInst->lookup( name, members );
    216                         for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
    217                                 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) {
    218                                         alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) );
    219                                         renameTypes( alternatives.back().expr );
    220                                 } else {
    221                                         assert( false );
    222                                 }
    223                         }
    224                 } else if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( member ) ) {
    225                         assert( false );
    226                 } else {
    227                         // xxx - temporary
    228                         std::cerr << member << std::endl;
    229                         assertf( false, "reached unexpected case of addAggMembers" );
     243        void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) {
     244                std::list< Declaration* > members;
     245                aggInst->lookup( name, members );
     246                for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
     247                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) {
     248                                alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) );
     249                                renameTypes( alternatives.back().expr );
     250                        } else {
     251                                assert( false );
     252                        }
    230253                }
    231254        }
     
    236259
    237260        Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) {
    238                 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr );
    239                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    240                 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     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 );
    241267
    242268                Cost convCost( 0, 0, 0 );
     
    244270                std::list< DeclarationWithType* >::iterator formal = formals.begin();
    245271                std::list< Expression* >& actuals = appExpr->get_args();
    246 
    247                 std::list< Type * > formalTypes;
    248                 std::list< Type * >::iterator formalType = formalTypes.end();
    249 
    250272                for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
    251 
    252273                        PRINT(
    253274                                std::cerr << "actual expression:" << std::endl;
    254275                                (*actualExpr)->print( std::cerr, 8 );
    255276                                std::cerr << "--- results are" << std::endl;
    256                                 (*actualExpr)->get_result()->print( std::cerr, 8 );
     277                                printAll( (*actualExpr)->get_results(), std::cerr, 8 );
    257278                        )
    258279                        std::list< DeclarationWithType* >::iterator startFormal = formal;
    259280                        Cost actualCost;
    260                         std::list< Type * > flatActualTypes;
    261                         flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) );
    262                         for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) {
    263 
    264 
    265                                 // tuple handling code
    266                                 if ( formalType == formalTypes.end() ) {
    267                                         // the type of the formal parameter may be a tuple type. To make this easier to work with,
    268                                         // flatten the tuple type and traverse the resulting list of types, incrementing the formal
    269                                         // iterator once its types have been extracted. Once a particular formal parameter's type has
    270                                         // been exhausted load the next formal parameter's type.
    271                                         if ( formal == formals.end() ) {
    272                                                 if ( function->get_isVarArgs() ) {
    273                                                         convCost += Cost( 1, 0, 0 );
    274                                                         break;
    275                                                 } else {
    276                                                         return Cost::infinity;
    277                                                 }
     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;
    278288                                        }
    279                                         formalTypes.clear();
    280                                         flatten( (*formal)->get_type(), back_inserter( formalTypes ) );
    281                                         formalType = formalTypes.begin();
    282                                         ++formal;
    283289                                }
    284 
    285290                                PRINT(
    286291                                        std::cerr << std::endl << "converting ";
    287                                         (*actualType)->print( std::cerr, 8 );
     292                                        (*actual)->print( std::cerr, 8 );
    288293                                        std::cerr << std::endl << " to ";
    289294                                        (*formal)->get_type()->print( std::cerr, 8 );
    290295                                )
    291                                 Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env );
     296                                Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env );
    292297                                PRINT(
    293298                                        std::cerr << std::endl << "cost is" << newCost << std::endl;
     
    300305                                actualCost += newCost;
    301306
    302                                 convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 );
    303 
    304                                 formalType++;
     307                                convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );
     308
     309                                formal++;
    305310                        }
    306311                        if ( actualCost != Cost( 0, 0, 0 ) ) {
     
    351356        /// Adds type variables to the open variable set and marks their assertions
    352357        void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) {
    353                 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     358                for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    354359                        unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();
    355360                        for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {
     
    360365        }
    361366
    362         /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType,
    363         /// producing expression(s) in out and their total cost in cost.
    364         template< typename AltIterator, typename OutputIterator >
    365         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 ) {
    366                 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) {
    367                         // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType
    368                         TupleExpr * tupleExpr = new TupleExpr();
    369                         for ( Type * type : *tupleType ) {
    370                                 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) {
    371                                         delete tupleExpr;
    372                                         return false;
    373                                 }
    374                         }
    375                         tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) );
    376                         *out++ = tupleExpr;
    377                 } else if ( actualIt != actualEnd ) {
    378                         // both actualType and formalType are atomic (non-tuple) types - if they unify
    379                         // then accept actual as an argument, otherwise return false (fail to instantiate argument)
    380                         Expression * actual = actualIt->expr;
    381                         Type * actualType = actual->get_result();
    382                         PRINT(
    383                                 std::cerr << "formal type is ";
    384                                 formalType->print( std::cerr );
    385                                 std::cerr << std::endl << "actual type is ";
    386                                 actualType->print( std::cerr );
    387                                 std::cerr << std::endl;
    388                         )
    389                         if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    390                                 return false;
    391                         }
    392                         // move the expression from the alternative to the output iterator
    393                         *out++ = actual;
    394                         actualIt->expr = nullptr;
    395                         cost += actualIt->cost;
    396                         ++actualIt;
    397                 } else {
    398                         // End of actuals - Handle default values
    399                         if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) {
    400                                 // so far, only constant expressions are accepted as default values
    401                                 if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) {
    402                                         if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) {
    403                                                 if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    404                                                         // xxx - Don't know if this is right
    405                                                         *out++ = cnstexpr->clone();
    406                                                         return true;
    407                                                 } // if
    408                                         } // if
    409                                 } // if
    410                         } // if
    411                         return false;
    412                 } // if
    413                 return true;
    414         }
    415 
    416         bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) {
     367        bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) {
    417368                simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv );
    418369                // make sure we don't widen any existing bindings
     
    422373                resultEnv.extractOpenVars( openVars );
    423374
    424                 // flatten actuals so that each actual has an atomic (non-tuple) type
    425                 AltList exploded;
    426                 Tuples::explode( actuals, back_inserter( exploded ) );
    427 
    428                 AltList::iterator actualExpr = exploded.begin();
    429                 AltList::iterator actualEnd = exploded.end();
    430                 for ( DeclarationWithType * formal : formals ) {
    431                         // match flattened actuals with formal parameters - actuals will be grouped to match
    432                         // with formals as appropriate
    433                         Cost cost;
    434                         std::list< Expression * > newExprs;
    435                         ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal );
    436                         if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) {
    437                                 deleteAll( newExprs );
    438                                 return false;
    439                         }
    440                         // success - produce argument as a new alternative
    441                         assert( newExprs.size() == 1 );
    442                         out.push_back( Alternative( newExprs.front(), resultEnv, cost ) );
    443                 }
    444                 if ( actualExpr != actualEnd ) {
    445                         // there are still actuals remaining, but we've run out of formal parameters to match against
    446                         // this is okay only if the function is variadic
    447                         if ( ! isVarArgs ) {
    448                                 return false;
    449                         }
    450                         out.splice( out.end(), exploded, actualExpr, actualEnd );
     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;
    451416                }
    452417                return true;
     
    535500                                //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    536501                                Expression *varExpr = new VariableExpr( candDecl );
    537                                 delete varExpr->get_result();
    538                                 varExpr->set_result( adjType->clone() );
     502                                deleteAll( varExpr->get_results() );
     503                                varExpr->get_results().clear();
     504                                varExpr->get_results().push_front( adjType->clone() );
    539505                                PRINT(
    540506                                        std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
     
    579545
    580546        template< typename OutputIterator >
    581         void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) {
     547        void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {
    582548                OpenVarSet openVars;
    583549                AssertionSet resultNeed, resultHave;
    584550                TypeEnvironment resultEnv;
    585551                makeUnifiableVars( funcType, openVars, resultNeed );
    586                 AltList instantiatedActuals; // filled by instantiate function
    587                 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) {
     552                if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) {
    588553                        ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() );
    589                         Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) );
    590                         makeExprList( instantiatedActuals, appExpr->get_args() );
     554                        Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt ) );
     555                        makeExprList( actualAlt, appExpr->get_args() );
    591556                        PRINT(
    592557                                std::cerr << "need assertions:" << std::endl;
     
    609574                                PointerType pt( Type::Qualifiers(), v.clone() );
    610575                                UntypedExpr *vexpr = untypedExpr->clone();
    611                                 vexpr->set_result( pt.clone() );
     576                                vexpr->get_results().push_front( pt.clone() );
    612577                                alternatives.push_back( Alternative( vexpr, env, Cost()) );
    613578                                return;
     
    622587                combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) );
    623588
    624                 // take care of possible tuple assignments
    625                 // if not tuple assignment, assignment is taken care of as a normal function call
    626                 Tuples::handleTupleAssignment( *this, untypedExpr, possibilities );
     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 ...
    627594
    628595                AltList candidates;
     
    637604                                // check if the type is pointer to function
    638605                                PointerType *pointer;
    639                                 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) {
     606                                if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {
    640607                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    641608                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    673640                                                // check if the type is pointer to function
    674641                                                PointerType *pointer;
    675                                                 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) {
     642                                                if ( funcOp->expr->get_results().size() == 1
     643                                                        && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) {
    676644                                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    677645                                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    697665
    698666                        PRINT(
    699                                 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr );
    700                                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    701                                 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     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 );
    702673                                std::cerr << "Case +++++++++++++" << std::endl;
    703674                                std::cerr << "formals are:" << std::endl;
     
    721692
    722693        bool isLvalue( Expression *expr ) {
    723                 // xxx - recurse into tuples?
    724                 return expr->has_result() && expr->get_result()->get_isLvalue();
     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;
    725698        }
    726699
     
    736709
    737710        void AlternativeFinder::visit( CastExpr *castExpr ) {
    738                 Type *& toType = castExpr->get_result();
    739                 toType = resolveTypeof( toType, indexer );
    740                 SymTab::validateType( toType, &indexer );
    741                 adjustExprType( toType, env, indexer );
     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
    742716
    743717                AlternativeFinder finder( indexer, env );
     
    753727                        // that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
    754728                        // to.
    755                         int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size();
     729                        int discardedValues = (*i).expr->get_results().size() - castExpr->get_results().size();
    756730                        if ( discardedValues < 0 ) continue;
    757                         // xxx - may need to go into tuple types and extract relavent types and use unifyList
     731                        std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin();
     732                        std::advance( candidate_end, castExpr->get_results().size() );
    758733                        // unification run for side-effects
    759                         unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer );
    760                         Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env );
     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 );
    761740                        if ( thisCost != Cost::infinity ) {
    762741                                // count one safe conversion for each value that is thrown away
     
    781760
    782761                for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) {
    783                         if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) {
    784                                 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    785                         } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) {
    786                                 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     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
    787768                        } // if
    788769                } // for
     
    810791                        renameTypes( alternatives.back().expr );
    811792                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) {
    812                                 NameExpr nameExpr( "" );
    813                                 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
     793                                addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
    814794                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) {
    815                                 NameExpr nameExpr( "" );
    816                                 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
     795                                addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
    817796                        } // if
    818797                } // for
     
    915894                        alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) );
    916895                        for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    917                                 alternatives.back().expr->set_result( (*i)->get_type()->clone() );
     896                                alternatives.back().expr->get_results().push_back( (*i)->get_type()->clone() );
    918897                        } // for
    919898                } // if
     
    938917                                                        finder.find( attrExpr->get_expr() );
    939918                                                        for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    940                                                                 if ( choice->expr->get_result()->size() == 1 ) {
    941                                                                         resolveAttr(*i, function, choice->expr->get_result(), choice->env );
     919                                                                if ( choice->expr->get_results().size() == 1 ) {
     920                                                                        resolveAttr(*i, function, choice->expr->get_results().front(), choice->env );
    942921                                                                } // fi
    943922                                                        } // for
     
    981960                                        AssertionSet needAssertions, haveAssertions;
    982961                                        Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost );
    983                                         Type* commonType;
    984                                         if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     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 ) ) {
    985964                                                ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() );
    986                                                 newExpr->set_result( commonType ? commonType : second->expr->get_result()->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
    987974                                                newAlt.expr = newExpr;
    988975                                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
     
    1012999                        TupleExpr *newExpr = new TupleExpr;
    10131000                        makeExprList( *i, newExpr->get_exprs() );
    1014                         newExpr->set_result( Tuples::makeTupleType( 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
    10151006
    10161007                        TypeEnvironment compositeEnv;
     
    10331024                }
    10341025        }
    1035 
    1036         void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) {
    1037                 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
    1038         }
    1039 
    1040         void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) {
    1041                 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );
    1042         }
    10431026} // namespace ResolvExpr
    10441027
  • src/ResolvExpr/AlternativeFinder.h

    r7756647 rd58a39a0  
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    69                 virtual void visit( TupleIndexExpr *tupleExpr );
    70                 virtual void visit( TupleAssignExpr *tupleExpr );
    71                 /// Runs a new alternative finder on each element in [begin, end)
    72                 /// and writes each alternative finder to out.
     69          public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
    7370                template< typename InputIterator, typename OutputIterator >
    7471                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    7572
     73          private:
    7674                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    77                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     75                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name );
    7876                /// Adds alternatives for offsetof expressions, given the base type and name of the member
    7977                template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
    80                 bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out );
     78                bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave );
    8179                template< typename OutputIterator >
    82                 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out );
     80                void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );
    8381                template< typename OutputIterator >
    8482                void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out );
     
    9189
    9290        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
    93 
    94         template< typename InputIterator, typename OutputIterator >
    95         void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    96                 AltList alternatives;
    97 
    98                 // select the alternatives that have the minimum parameter cost
    99                 Cost minCost = Cost::infinity;
    100                 for ( InputIterator i = begin; i != end; ++i ) {
    101                         if ( i->cost < minCost ) {
    102                                 minCost = i->cost;
    103                                 i->cost = i->cvtCost;
    104                                 alternatives.clear();
    105                                 alternatives.push_back( *i );
    106                         } else if ( i->cost == minCost ) {
    107                                 i->cost = i->cvtCost;
    108                                 alternatives.push_back( *i );
    109                         }
    110                 }
    111                 std::copy( alternatives.begin(), alternatives.end(), out );
    112         }
    113 
    114         Cost sumCost( const AltList &in );
    115 
    116         template< typename InputIterator >
    117         void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
    118                 while ( begin != end ) {
    119                         result.simpleCombine( (*begin++).env );
    120                 }
    121         }
    12291} // namespace ResolvExpr
    12392
  • src/ResolvExpr/AlternativePrinter.cc

    r7756647 rd58a39a0  
    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                         i->expr->get_result()->print( os );
     35                        printAll( i->expr->get_results(), os );
    3636                        //    i->print( os );
    3737                        os << std::endl;
  • src/ResolvExpr/ConversionCost.cc

    r7756647 rd58a39a0  
    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() && destIt != destAsTuple->get_types().end() ) {
     242                        while ( srcIt != tupleType->get_types().end() ) {
    243243                                Cost newCost = conversionCost( *srcIt++, *destIt++, indexer, env );
    244244                                if ( newCost == Cost::infinity ) {
  • src/ResolvExpr/FindOpenVars.cc

    r7756647 rd58a39a0  
    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 ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     49                        for ( std::list< TypeDecl* >::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 ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     58                        for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    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 ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     127                        for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    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->has_result() && ! newExpr->get_result()->isVoid() );
    61                         Type *newType = newExpr->get_result();
     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
    6269                        delete typeofType;
    6370                        return newType;
  • src/ResolvExpr/Resolver.cc

    r7756647 rd58a39a0  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
    21 #include "typeops.h"
    2221#include "SynTree/Statement.h"
    2322#include "SynTree/Type.h"
     
    3837
    3938                virtual void visit( FunctionDecl *functionDecl );
    40                 virtual void visit( ObjectDecl *objectDecl );
     39                virtual void visit( ObjectDecl *functionDecl );
    4140                virtual void visit( TypeDecl *typeDecl );
    4241                virtual void visit( EnumDecl * enumDecl );
     
    6867          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6968          void fallbackInit( ConstructorInit * ctorInit );
    70                 Type * functionReturn;
     69                std::list< Type * > functionReturn;
    7170                Type *initContext;
    7271                Type *switchType;
     
    158157                        const TypeEnvironment *newEnv = 0;
    159158                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    160                                 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
     159                                if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
    161160                                        if ( newExpr ) {
    162161                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    235234                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    236235                functionDecl->set_type( new_type );
    237                 ValueGuard< Type * > oldFunctionReturn( functionReturn );
    238                 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
     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
    239241                SymTab::Indexer::visit( functionDecl );
     242                functionReturn = oldFunctionReturn;
    240243        }
    241244
     
    335338        void Resolver::visit( ReturnStmt *returnStmt ) {
    336339                if ( returnStmt->get_expr() ) {
    337                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
     340                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
     341                        cloneAll( functionReturn, castExpr->get_results() );
    338342                        Expression *newExpr = findSingleExpression( castExpr, *this );
    339343                        delete castExpr;
     
    380384                                if ( isCharType( at->get_base() ) ) {
    381385                                        // check if the resolved type is char *
    382                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
     386                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
    383387                                                if ( isCharType( pt->get_base() ) ) {
    384388                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    442446                                (*iter)->accept( *this );
    443447                        } // 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                         }
    450448                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    451449                        resolveAggrInit( st->get_baseStruct(), iter, end );
  • src/ResolvExpr/TypeEnvironment.cc

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

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

    r7756647 rd58a39a0  
    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         }
    614600} // namespace ResolvExpr
    615601
  • src/ResolvExpr/typeops.h

    r7756647 rd58a39a0  
    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 
    149146        // in CommonType.cc
    150147        Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
     
    155152        // in Occurs.cc
    156153        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         }
    169154} // namespace ResolvExpr
    170155
  • src/SymTab/Autogen.cc

    r7756647 rd58a39a0  
    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_result();
     118                Type *& assignVarExprType = assignVarExpr->get_results().front();
    119119                assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType );
    120                 assignVarExpr->set_result( assignVarExprType );
    121120                ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr );
    122121                assignExpr->get_args().push_back( new VariableExpr( dstParam ) );
  • src/SymTab/Indexer.cc

    r7756647 rd58a39a0  
    4040
    4141namespace SymTab {
    42         template< typename TreeType, typename VisitorType >
    43         inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
     42        template< typename Container, typename VisitorType >
     43        inline void acceptAllNewScope( Container &container, VisitorType &visitor ) {
    4444                visitor.enterScope();
    45                 maybeAccept( tree, visitor );
     45                acceptAll( container, 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                 acceptNewScope( applicationExpr->get_result(), *this );
     339                acceptAllNewScope( applicationExpr->get_results(), *this );
    340340                maybeAccept( applicationExpr->get_function(), *this );
    341341                acceptAll( applicationExpr->get_args(), *this );
     
    343343
    344344        void Indexer::visit( UntypedExpr *untypedExpr ) {
    345                 acceptNewScope( untypedExpr->get_result(), *this );
     345                acceptAllNewScope( untypedExpr->get_results(), *this );
    346346                acceptAll( untypedExpr->get_args(), *this );
    347347        }
    348348
    349349        void Indexer::visit( NameExpr *nameExpr ) {
    350                 acceptNewScope( nameExpr->get_result(), *this );
     350                acceptAllNewScope( nameExpr->get_results(), *this );
    351351        }
    352352
    353353        void Indexer::visit( AddressExpr *addressExpr ) {
    354                 acceptNewScope( addressExpr->get_result(), *this );
     354                acceptAllNewScope( addressExpr->get_results(), *this );
    355355                maybeAccept( addressExpr->get_arg(), *this );
    356356        }
    357357
    358358        void Indexer::visit( LabelAddressExpr *labAddressExpr ) {
    359                 acceptNewScope( labAddressExpr->get_result(), *this );
     359                acceptAllNewScope( labAddressExpr->get_results(), *this );
    360360                maybeAccept( labAddressExpr->get_arg(), *this );
    361361        }
    362362
    363363        void Indexer::visit( CastExpr *castExpr ) {
    364                 acceptNewScope( castExpr->get_result(), *this );
     364                acceptAllNewScope( castExpr->get_results(), *this );
    365365                maybeAccept( castExpr->get_arg(), *this );
    366366        }
    367367
    368368        void Indexer::visit( UntypedMemberExpr *memberExpr ) {
    369                 acceptNewScope( memberExpr->get_result(), *this );
     369                acceptAllNewScope( memberExpr->get_results(), *this );
    370370                maybeAccept( memberExpr->get_aggregate(), *this );
    371371        }
    372372
    373373        void Indexer::visit( MemberExpr *memberExpr ) {
    374                 acceptNewScope( memberExpr->get_result(), *this );
     374                acceptAllNewScope( memberExpr->get_results(), *this );
    375375                maybeAccept( memberExpr->get_aggregate(), *this );
    376376        }
    377377
    378378        void Indexer::visit( VariableExpr *variableExpr ) {
    379                 acceptNewScope( variableExpr->get_result(), *this );
     379                acceptAllNewScope( variableExpr->get_results(), *this );
    380380        }
    381381
    382382        void Indexer::visit( ConstantExpr *constantExpr ) {
    383                 acceptNewScope( constantExpr->get_result(), *this );
     383                acceptAllNewScope( constantExpr->get_results(), *this );
    384384                maybeAccept( constantExpr->get_constant(), *this );
    385385        }
    386386
    387387        void Indexer::visit( SizeofExpr *sizeofExpr ) {
    388                 acceptNewScope( sizeofExpr->get_result(), *this );
     388                acceptAllNewScope( sizeofExpr->get_results(), *this );
    389389                if ( sizeofExpr->get_isType() ) {
    390390                        maybeAccept( sizeofExpr->get_type(), *this );
     
    395395
    396396        void Indexer::visit( AlignofExpr *alignofExpr ) {
    397                 acceptNewScope( alignofExpr->get_result(), *this );
     397                acceptAllNewScope( alignofExpr->get_results(), *this );
    398398                if ( alignofExpr->get_isType() ) {
    399399                        maybeAccept( alignofExpr->get_type(), *this );
     
    404404
    405405        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
    406                 acceptNewScope( offsetofExpr->get_result(), *this );
     406                acceptAllNewScope( offsetofExpr->get_results(), *this );
    407407                maybeAccept( offsetofExpr->get_type(), *this );
    408408        }
    409409
    410410        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
    411                 acceptNewScope( offsetofExpr->get_result(), *this );
     411                acceptAllNewScope( offsetofExpr->get_results(), *this );
    412412                maybeAccept( offsetofExpr->get_type(), *this );
    413413                maybeAccept( offsetofExpr->get_member(), *this );
     
    415415
    416416        void Indexer::visit( OffsetPackExpr *offsetPackExpr ) {
    417                 acceptNewScope( offsetPackExpr->get_result(), *this );
     417                acceptAllNewScope( offsetPackExpr->get_results(), *this );
    418418                maybeAccept( offsetPackExpr->get_type(), *this );
    419419        }
    420420
    421421        void Indexer::visit( AttrExpr *attrExpr ) {
    422                 acceptNewScope( attrExpr->get_result(), *this );
     422                acceptAllNewScope( attrExpr->get_results(), *this );
    423423                if ( attrExpr->get_isType() ) {
    424424                        maybeAccept( attrExpr->get_type(), *this );
     
    429429
    430430        void Indexer::visit( LogicalExpr *logicalExpr ) {
    431                 acceptNewScope( logicalExpr->get_result(), *this );
     431                acceptAllNewScope( logicalExpr->get_results(), *this );
    432432                maybeAccept( logicalExpr->get_arg1(), *this );
    433433                maybeAccept( logicalExpr->get_arg2(), *this );
     
    435435
    436436        void Indexer::visit( ConditionalExpr *conditionalExpr ) {
    437                 acceptNewScope( conditionalExpr->get_result(), *this );
     437                acceptAllNewScope( conditionalExpr->get_results(), *this );
    438438                maybeAccept( conditionalExpr->get_arg1(), *this );
    439439                maybeAccept( conditionalExpr->get_arg2(), *this );
     
    442442
    443443        void Indexer::visit( CommaExpr *commaExpr ) {
    444                 acceptNewScope( commaExpr->get_result(), *this );
     444                acceptAllNewScope( commaExpr->get_results(), *this );
    445445                maybeAccept( commaExpr->get_arg1(), *this );
    446446                maybeAccept( commaExpr->get_arg2(), *this );
     
    448448
    449449        void Indexer::visit( TupleExpr *tupleExpr ) {
    450                 acceptNewScope( tupleExpr->get_result(), *this );
     450                acceptAllNewScope( tupleExpr->get_results(), *this );
    451451                acceptAll( tupleExpr->get_exprs(), *this );
    452452        }
    453453
    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();
     454        void Indexer::visit( SolvedTupleExpr *tupleExpr ) {
     455                acceptAllNewScope( tupleExpr->get_results(), *this );
     456                acceptAll( tupleExpr->get_exprs(), *this );
    460457        }
    461458
    462459        void Indexer::visit( TypeExpr *typeExpr ) {
    463                 acceptNewScope( typeExpr->get_result(), *this );
     460                acceptAllNewScope( typeExpr->get_results(), *this );
    464461                maybeAccept( typeExpr->get_type(), *this );
    465462        }
     
    472469
    473470        void Indexer::visit( UntypedValofExpr *valofExpr ) {
    474                 acceptNewScope( valofExpr->get_result(), *this );
     471                acceptAllNewScope( valofExpr->get_results(), *this );
    475472                maybeAccept( valofExpr->get_body(), *this );
    476473        }
  • src/SymTab/Indexer.h

    r7756647 rd58a39a0  
    6464                virtual void visit( ConditionalExpr *conditionalExpr );
    6565                virtual void visit( CommaExpr *commaExpr );
     66                virtual void visit( TupleExpr *tupleExpr );
     67                virtual void visit( SolvedTupleExpr *tupleExpr );
    6668                virtual void visit( TypeExpr *typeExpr );
    6769                virtual void visit( AsmExpr *asmExpr );
    6870                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

    r7756647 rd58a39a0  
    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 ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     260                        for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    2323// - All enumeration constants have type EnumInstType.
    2424//
    25 // - The type "void" never occurs in lists of function parameter or return types.  A function
    26 //   taking no arguments has no argument types.
     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.
    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 ( Type::ForallList::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
     431                for ( std::list< TypeDecl * >::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

    r7756647 rd58a39a0  
    1919
    2020AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
    21         if ( arg->has_result() ) {
    22                 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) );
    23         }
     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
    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

    r7756647 rd58a39a0  
    2121#include "TypeSubstitution.h"
    2222#include "Common/utility.h"
    23 #include "ResolvExpr/typeops.h"
     23
    2424
    2525ParamEntry::ParamEntry( const ParamEntry &other ) :
     
    4343
    4444ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
    45         PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
    46         FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     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 );
    4749
    48         set_result( ResolvExpr::extractResultType( function ) );
    49 
    50         assert( has_result() );
     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
    5153}
    5254
  • src/SynTree/CommaExpr.cc

    r7756647 rd58a39a0  
    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         set_result( maybeClone( arg2->get_result() ) );
    26         // get_type->set_isLvalue( false );
     25        cloneAll( arg2->get_results(), get_results() );
     26        // for ( Type *& type : get_results() ) {
     27        //      type->set_isLvalue( false );
     28        // }
    2729}
    2830
  • src/SynTree/Expression.cc

    r7756647 rd58a39a0  
    3131
    3232
    33 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
    34 
    35 Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     33Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
     34
     35Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     36        cloneAll( other.results, results );
    3637}
    3738
     
    3940        delete env;
    4041        delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    41         delete result;
     42        deleteAll( results );
     43}
     44
     45void 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
    4251}
    4352
     
    5968
    6069ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
    61         set_result( constant.get_type()->clone() );
     70        add_result( constant.get_type()->clone() );
    6271}
    6372
     
    7685        assert( var );
    7786        assert( var->get_type() );
    78         Type * type = var->get_type()->clone();
    79         type->set_isLvalue( true );
    80         set_result( 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
    8191}
    8292
     
    100110SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    101111                Expression( _aname ), expr(expr_), type(0), isType(false) {
    102         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     112        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    103113}
    104114
    105115SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    106116                Expression( _aname ), expr(0), type(type_), isType(true) {
    107         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     117        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    108118}
    109119
     
    131141AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    132142                Expression( _aname ), expr(expr_), type(0), isType(false) {
    133         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     143        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    134144}
    135145
    136146AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    137147                Expression( _aname ), expr(0), type(type_), isType(true) {
    138         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     148        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    139149}
    140150
     
    162172UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
    163173                Expression( _aname ), type(type_), member(member_) {
    164         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     174        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    165175}
    166176
     
    187197OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
    188198                Expression( _aname ), type(type_), member(member_) {
    189         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     199        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    190200}
    191201
     
    219229
    220230OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    221         set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     231        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    222232}
    223233
     
    274284
    275285CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    276         set_result(toType);
     286        add_result(toType);
    277287}
    278288
    279289CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    280         set_result( new VoidType( Type::Qualifiers() ) );
    281290}
    282291
     
    294303        arg->print(os, indent+2);
    295304        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
    296         os << std::string( indent+2, ' ' );
    297         if ( result->isVoid() ) {
    298                 os << "nothing";
     305        if ( results.empty() ) {
     306                os << std::string( indent+2, ' ' ) << "nothing" << std::endl;
    299307        } else {
    300                 result->print( os, indent+2 );
     308                printAll(results, os, indent+2);
    301309        } // if
    302         os << std::endl;
    303         Expression::print( os, indent );
    304 }
    305 
    306 UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) :
     310        Expression::print( os, indent );
     311}
     312
     313UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) :
    307314                Expression( _aname ), member(_member), aggregate(_aggregate) {}
    308315
    309316UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
    310                 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
     317                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
    311318}
    312319
    313320UntypedMemberExpr::~UntypedMemberExpr() {
    314321        delete aggregate;
    315         delete member;
    316322}
    317323
    318324void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    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, ' ' );
     325        os << "Untyped Member Expression, with field: " << get_member();
    323326
    324327        Expression *agg = get_aggregate();
    325         os << "from aggregate: " << std::endl;
     328        os << ", from aggregate: ";
    326329        if (agg != 0) {
    327                 os << std::string( indent + 4, ' ' );
    328                 agg->print(os, indent + 4);
     330                os << std::string( indent + 2, ' ' );
     331                agg->print(os, indent + 2);
    329332        }
    330333        os << std::string( indent+2, ' ' );
     
    335338MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    336339                Expression( _aname ), member(_member), aggregate(_aggregate) {
    337         set_result( member->get_type()->clone() );
    338         get_result()->set_isLvalue( true );
     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
    339344}
    340345
     
    367372}
    368373
    369 UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
    370                 Expression( _aname ), function(_function), args(_args) {}
     374
     375UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {}
    371376
    372377UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    374379        cloneAll( other.args, args );
    375380}
     381
     382UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :
     383                Expression( _aname ), function(_function), args(_args) {}
    376384
    377385UntypedExpr::~UntypedExpr() {
     
    411419LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    412420                Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    413         set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
     421        add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    414422}
    415423
     
    469477ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    470478        assert( callExpr );
    471         assert( callExpr->has_result() );
    472         set_result( callExpr->get_result()->clone() );
     479        cloneAll( callExpr->get_results(), results );
    473480}
    474481
     
    503510        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    504511        assert( arg );
    505         set_result( maybeClone( arg->get_result() ) );
     512        cloneAll( arg->get_results(), results );
    506513}
    507514
     
    523530
    524531CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    525         assert( type && initializer );
    526         set_result( type->clone() );
    527 }
    528 
    529 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {}
     532        add_result( type->clone() );
     533}
     534
     535CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
    530536
    531537CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    536542void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
    537543        os << "Compound Literal Expression: " << std::endl;
    538         os << std::string( indent+2, ' ' );
    539         type->print( os, indent + 2 );
    540         os << std::string( indent+2, ' ' );
    541         initializer->print( os, indent + 2 );
     544        if ( type ) type->print( os, indent + 2 );
     545        if ( initializer ) initializer->print( os, indent + 2 );
    542546}
    543547
     
    553557
    554558RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    555 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     559RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
    556560void RangeExpr::print( std::ostream &os, int indent ) const {
    557         os << "Range Expression: ";
     561        os << std::string( indent, ' ' ) << "Range Expression: ";
    558562        low->print( os, indent );
    559563        os << " ... ";
    560564        high->print( os, indent );
    561 }
    562 
    563 StmtExpr::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 }
    572 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {}
    573 StmtExpr::~StmtExpr() {
    574         delete statements;
    575 }
    576 void 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 
    582 UniqueExpr::UniqueExpr( Expression *expr ) : expr( new Expression* ) {
    583         set_expr( expr );
    584         assert( expr );
    585         assert( expr->has_result() );
    586         set_result( expr->get_result()->clone() );
    587 }
    588 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ) {
    589 }
    590 UniqueExpr::~UniqueExpr() {
    591         if ( expr.unique() ) {
    592                 delete *expr;
    593         }
    594 }
    595 void UniqueExpr::print( std::ostream &os, int indent ) const {
    596         os << "Unique Expression: " << std::endl << std::string( indent+2, ' ' );
    597         get_expr()->print( os, indent+2 );
    598565}
    599566
  • src/SynTree/Expression.h

    r7756647 rd58a39a0  
    3232        virtual ~Expression();
    3333
    34         Type *& get_result() { return result; }
    35         void set_result( Type *newValue ) { result = newValue; }
    36         bool has_result() const { return result != nullptr; }
     34        std::list<Type *>& get_results() { return results; }
     35        void add_result( Type *t );
    3736
    3837        TypeSubstitution *get_env() const { return env; }
     
    4847        virtual void print( std::ostream &os, int indent = 0 ) const;
    4948  protected:
    50         Type * result;
     49        std::list<Type *> results;
    5150        TypeSubstitution *env;
    5251        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     
    9998class UntypedExpr : public Expression {
    10099  public:
    101         UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr );
     100        UntypedExpr( Expression *function, Expression *_aname = nullptr );
    102101        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( Expression *member, Expression *aggregate, Expression *_aname = nullptr );
     202        UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr );
    203203        UntypedMemberExpr( const UntypedMemberExpr &other );
    204204        virtual ~UntypedMemberExpr();
    205205
    206         Expression * get_member() const { return member; }
    207         void set_member( Expression * newValue ) { member = newValue; }
     206        std::string get_member() const { return member; }
     207        void set_member( const std::string &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         Expression *member;
     216        std::string member;
    217217        Expression *aggregate;
    218218};
     
    483483};
    484484
     485/// TupleExpr represents a tuple expression ( [a, b, c] )
     486class 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
     504class 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
    485521/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    486522class TypeExpr : public Expression {
     
    582618        CompoundLiteralExpr( Type * type, Initializer * initializer );
    583619        CompoundLiteralExpr( const CompoundLiteralExpr &other );
    584         virtual ~CompoundLiteralExpr();
     620        ~CompoundLiteralExpr();
    585621
    586622        Type * get_type() const { return type; }
     
    634670  private:
    635671        Expression *low, *high;
    636 };
    637 
    638 /// TupleExpr represents a tuple expression ( [a, b, c] )
    639 class 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
    657 class 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
    678 class 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
    699 class 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; })
    718 class StmtExpr : public Expression {
    719 public:
    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;
    731 private:
    732         CompoundStmt * statements;
    733 };
    734 
    735 class UniqueExpr : public Expression {
    736 public:
    737         UniqueExpr( Expression * expr );
    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         virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); }
    745         virtual void accept( Visitor &v ) { v.visit( this ); }
    746         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    747         virtual void print( std::ostream &os, int indent = 0 ) const;
    748 private:
    749         std::shared_ptr< Expression * > expr;
    750672};
    751673
  • src/SynTree/Mutator.cc

    r7756647 rd58a39a0  
    178178
    179179Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    180         applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
     180        mutateAll( applicationExpr->get_results(), *this );
    181181        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    182182        mutateAll( applicationExpr->get_args(), *this );
     
    185185
    186186Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
    187         untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
     187        mutateAll( untypedExpr->get_results(), *this );
    188188        mutateAll( untypedExpr->get_args(), *this );
    189189        return untypedExpr;
     
    191191
    192192Expression *Mutator::mutate( NameExpr *nameExpr ) {
    193         nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
     193        mutateAll( nameExpr->get_results(), *this );
    194194        return nameExpr;
    195195}
    196196
    197197Expression *Mutator::mutate( AddressExpr *addressExpr ) {
    198         addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
     198        mutateAll( addressExpr->get_results(), *this );
    199199        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    200200        return addressExpr;
     
    202202
    203203Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    204         labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
     204        mutateAll( labelAddressExpr->get_results(), *this );
    205205        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    206206        return labelAddressExpr;
     
    208208
    209209Expression *Mutator::mutate( CastExpr *castExpr ) {
    210         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
     210        mutateAll( castExpr->get_results(), *this );
    211211        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    212212        return castExpr;
     
    214214
    215215Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    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 
    222 Expression *Mutator::mutate( MemberExpr *memberExpr ) {
    223         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     216        mutateAll( memberExpr->get_results(), *this );
    224217        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    225218        return memberExpr;
    226219}
    227220
     221Expression *Mutator::mutate( MemberExpr *memberExpr ) {
     222        mutateAll( memberExpr->get_results(), *this );
     223        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
     224        return memberExpr;
     225}
     226
    228227Expression *Mutator::mutate( VariableExpr *variableExpr ) {
    229         variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
     228        mutateAll( variableExpr->get_results(), *this );
    230229        return variableExpr;
    231230}
    232231
    233232Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
    234         constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
     233        mutateAll( constantExpr->get_results(), *this );
    235234//  maybeMutate( constantExpr->get_constant(), *this )
    236235        return constantExpr;
     
    238237
    239238Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
    240         sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
     239        mutateAll( sizeofExpr->get_results(), *this );
    241240        if ( sizeofExpr->get_isType() ) {
    242241                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
     
    248247
    249248Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
    250         alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
     249        mutateAll( alignofExpr->get_results(), *this );
    251250        if ( alignofExpr->get_isType() ) {
    252251                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
     
    258257
    259258Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    260         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     259        mutateAll( offsetofExpr->get_results(), *this );
    261260        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    262261        return offsetofExpr;
     
    264263
    265264Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    266         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
     265        mutateAll( offsetofExpr->get_results(), *this );
    267266        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    268267        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     
    271270
    272271Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    273         offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
     272        mutateAll( offsetPackExpr->get_results(), *this );
    274273        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
    275274        return offsetPackExpr;
     
    277276
    278277Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    279         attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
     278        mutateAll( attrExpr->get_results(), *this );
    280279        if ( attrExpr->get_isType() ) {
    281280                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
     
    287286
    288287Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
    289         logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
     288        mutateAll( logicalExpr->get_results(), *this );
    290289        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
    291290        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
     
    294293
    295294Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    296         conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
     295        mutateAll( conditionalExpr->get_results(), *this );
    297296        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
    298297        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
     
    302301
    303302Expression *Mutator::mutate( CommaExpr *commaExpr ) {
    304         commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
     303        mutateAll( commaExpr->get_results(), *this );
    305304        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
    306305        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
     
    308307}
    309308
     309Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
     310        mutateAll( tupleExpr->get_results(), *this );
     311        mutateAll( tupleExpr->get_exprs(), *this );
     312        return tupleExpr;
     313}
     314
     315Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {
     316        mutateAll( tupleExpr->get_results(), *this );
     317        mutateAll( tupleExpr->get_exprs(), *this );
     318        return tupleExpr;
     319}
     320
    310321Expression *Mutator::mutate( TypeExpr *typeExpr ) {
    311         typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
     322        mutateAll( typeExpr->get_results(), *this );
    312323        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
    313324        return typeExpr;
     
    329340
    330341Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
    331         ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
     342        mutateAll( ctorExpr->get_results(), *this );
    332343        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
    333344        return ctorExpr;
     
    335346
    336347Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    337         compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
     348        mutateAll( compLitExpr->get_results(), *this );
    338349        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    339350        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
     
    342353
    343354Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    344         valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
     355        mutateAll( valofExpr->get_results(), *this );
    345356        return valofExpr;
    346357}
     
    350361        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
    351362        return rangeExpr;
    352 }
    353 
    354 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
    355         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    356         mutateAll( tupleExpr->get_exprs(), *this );
    357         return tupleExpr;
    358 }
    359 
    360 Expression *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 
    366 Expression *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 
    373 Expression *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 
    380 Expression *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 
    386 Expression *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;
    390363}
    391364
  • src/SynTree/Mutator.h

    r7756647 rd58a39a0  
    7171        virtual Expression* mutate( ConditionalExpr *conditionalExpr );
    7272        virtual Expression* mutate( CommaExpr *commaExpr );
     73        virtual Expression* mutate( TupleExpr *tupleExpr );
     74        virtual Expression* mutate( SolvedTupleExpr *tupleExpr );
    7375        virtual Expression* mutate( TypeExpr *typeExpr );
    7476        virtual Expression* mutate( AsmExpr *asmExpr );
     
    7880        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    7981        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 );
    8682
    8783        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/ReferenceToType.cc

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

    r7756647 rd58a39a0  
    7676class ConditionalExpr;
    7777class CommaExpr;
     78class TupleExpr;
     79class SolvedTupleExpr;
    7880class TypeExpr;
    7981class AsmExpr;
     
    8385class UntypedValofExpr;
    8486class RangeExpr;
    85 class TupleExpr;
    86 class TupleIndexExpr;
    87 class MemberTupleExpr;
    88 class TupleAssignExpr;
    89 class StmtExpr;
    90 class UniqueExpr;
    9187
    9288class Type;
  • src/SynTree/TupleExpr.cc

    r7756647 rd58a39a0  
    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"
    2118
    22 TupleExpr::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         }
     19TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
    2820}
    2921
     
    3729
    3830void TupleExpr::print( std::ostream &os, int indent ) const {
    39         os << "Tuple:" << std::endl;
     31        os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
    4032        printAll( exprs, os, indent+2 );
    4133        Expression::print( os, indent );
    4234}
    4335
    44 TupleIndexExpr::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() );
     36SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
     37        std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
    4938}
    5039
    51 TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
     40SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
     41        cloneAll( other.exprs, exprs );
    5242}
    5343
    54 TupleIndexExpr::~TupleIndexExpr() {
    55         delete tuple;
    56 }
    57 
    58 void 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;
     44void SolvedTupleExpr::print( std::ostream &os, int indent ) const {
     45        os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl;
     46        printAll( exprs, os, indent+2 );
    6347        Expression::print( os, indent );
    6448}
    65 
    66 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
    67         set_result( maybeClone( member->get_result() ) ); // xxx - ???
    68 }
    69 
    70 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
    71 }
    72 
    73 MemberTupleExpr::~MemberTupleExpr() {
    74         delete member;
    75         delete aggregate;
    76 }
    77 
    78 void 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 
    89 TupleAssignExpr::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 
    93 TupleAssignExpr::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 
    98 TupleAssignExpr::~TupleAssignExpr() {
    99         deleteAll( assigns );
    100         // deleteAll( tempDecls );
    101 }
    102 
    103 void 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 
    11249
    11350// Local Variables: //
  • src/SynTree/TupleType.cc

    r7756647 rd58a39a0  
    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, const std::list< Type * > & types ) : Type( tq ), types( types ) {
     19TupleType::TupleType( const Type::Qualifiers &tq ) : Type( tq ) {
    2020}
    2121
  • src/SynTree/Type.h

    r7756647 rd58a39a0  
    2020#include "Visitor.h"
    2121#include "Mutator.h"
    22 #include "Common/utility.h"
    2322
    2423class Type {
     
    2827                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 ) {}
    2928
    30                 Qualifiers &operator&=( const Qualifiers &other );
    3129                Qualifiers &operator+=( const Qualifiers &other );
    3230                Qualifiers &operator-=( const Qualifiers &other );
     
    6563        void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    6664        void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    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; }
     65        std::list<TypeDecl*>& get_forall() { return forall; }
    7466
    7567        virtual Type *clone() const = 0;
     
    7971  private:
    8072        Qualifiers tq;
    81         ForallList forall;
     73        std::list<TypeDecl*> forall;
    8274};
    8375
     
    8577  public:
    8678        VoidType( const Type::Qualifiers &tq );
    87 
    88         virtual unsigned size() const { return 0; };
    8979
    9080        virtual VoidType *clone() const { return new VoidType( *this ); }
     
    244234  public:
    245235        StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
    246         StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );
    247236        StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    248237
     
    359348class TupleType : public Type {
    360349  public:
    361         TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );
     350        TupleType( const Type::Qualifiers &tq );
    362351        TupleType( const TupleType& );
    363352        virtual ~TupleType();
    364353
    365         typedef std::list<Type*> value_type;
    366         typedef value_type::iterator iterator;
    367 
    368354        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(); }
    373355
    374356        virtual TupleType *clone() const { return new TupleType( *this ); }
     
    460442};
    461443
    462 inline 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 
    471444inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    472445        isConst |= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    r7756647 rd58a39a0  
    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 ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     151                for ( std::list< TypeDecl* >::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 ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     165                for ( std::list< TypeDecl* >::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

    r7756647 rd58a39a0  
    150150
    151151void Visitor::visit( ApplicationExpr *applicationExpr ) {
    152         maybeAccept( applicationExpr->get_result(), *this );
     152        acceptAll( applicationExpr->get_results(), *this );
    153153        maybeAccept( applicationExpr->get_function(), *this );
    154154        acceptAll( applicationExpr->get_args(), *this );
     
    156156
    157157void Visitor::visit( UntypedExpr *untypedExpr ) {
    158         maybeAccept( untypedExpr->get_result(), *this );
     158        acceptAll( untypedExpr->get_results(), *this );
    159159        acceptAll( untypedExpr->get_args(), *this );
    160160}
    161161
    162162void Visitor::visit( NameExpr *nameExpr ) {
    163         maybeAccept( nameExpr->get_result(), *this );
     163        acceptAll( nameExpr->get_results(), *this );
    164164}
    165165
    166166void Visitor::visit( AddressExpr *addressExpr ) {
    167         maybeAccept( addressExpr->get_result(), *this );
     167        acceptAll( addressExpr->get_results(), *this );
    168168        maybeAccept( addressExpr->get_arg(), *this );
    169169}
    170170
    171171void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    172         maybeAccept( labAddressExpr->get_result(), *this );
     172        acceptAll( labAddressExpr->get_results(), *this );
    173173        maybeAccept( labAddressExpr->get_arg(), *this );
    174174}
    175175
    176176void Visitor::visit( CastExpr *castExpr ) {
    177         maybeAccept( castExpr->get_result(), *this );
     177        acceptAll( castExpr->get_results(), *this );
    178178        maybeAccept( castExpr->get_arg(), *this );
    179179}
    180180
    181181void Visitor::visit( UntypedMemberExpr *memberExpr ) {
    182         maybeAccept( memberExpr->get_result(), *this );
     182        acceptAll( memberExpr->get_results(), *this );
    183183        maybeAccept( memberExpr->get_aggregate(), *this );
    184         maybeAccept( memberExpr->get_member(), *this );
    185184}
    186185
    187186void Visitor::visit( MemberExpr *memberExpr ) {
    188         maybeAccept( memberExpr->get_result(), *this );
     187        acceptAll( memberExpr->get_results(), *this );
    189188        maybeAccept( memberExpr->get_aggregate(), *this );
    190189}
    191190
    192191void Visitor::visit( VariableExpr *variableExpr ) {
    193         maybeAccept( variableExpr->get_result(), *this );
     192        acceptAll( variableExpr->get_results(), *this );
    194193}
    195194
    196195void Visitor::visit( ConstantExpr *constantExpr ) {
    197         maybeAccept( constantExpr->get_result(), *this );
     196        acceptAll( constantExpr->get_results(), *this );
    198197        maybeAccept( constantExpr->get_constant(), *this );
    199198}
    200199
    201200void Visitor::visit( SizeofExpr *sizeofExpr ) {
    202         maybeAccept( sizeofExpr->get_result(), *this );
     201        acceptAll( sizeofExpr->get_results(), *this );
    203202        if ( sizeofExpr->get_isType() ) {
    204203                maybeAccept( sizeofExpr->get_type(), *this );
     
    209208
    210209void Visitor::visit( AlignofExpr *alignofExpr ) {
    211         maybeAccept( alignofExpr->get_result(), *this );
     210        acceptAll( alignofExpr->get_results(), *this );
    212211        if ( alignofExpr->get_isType() ) {
    213212                maybeAccept( alignofExpr->get_type(), *this );
     
    218217
    219218void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
    220         maybeAccept( offsetofExpr->get_result(), *this );
     219        acceptAll( offsetofExpr->get_results(), *this );
    221220        maybeAccept( offsetofExpr->get_type(), *this );
    222221}
    223222
    224223void Visitor::visit( OffsetofExpr *offsetofExpr ) {
    225         maybeAccept( offsetofExpr->get_result(), *this );
     224        acceptAll( offsetofExpr->get_results(), *this );
    226225        maybeAccept( offsetofExpr->get_type(), *this );
    227226        maybeAccept( offsetofExpr->get_member(), *this );
     
    229228
    230229void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
    231         maybeAccept( offsetPackExpr->get_result(), *this );
     230        acceptAll( offsetPackExpr->get_results(), *this );
    232231        maybeAccept( offsetPackExpr->get_type(), *this );
    233232}
    234233
    235234void Visitor::visit( AttrExpr *attrExpr ) {
    236         maybeAccept( attrExpr->get_result(), *this );
     235        acceptAll( attrExpr->get_results(), *this );
    237236        if ( attrExpr->get_isType() ) {
    238237                maybeAccept( attrExpr->get_type(), *this );
     
    243242
    244243void Visitor::visit( LogicalExpr *logicalExpr ) {
    245         maybeAccept( logicalExpr->get_result(), *this );
     244        acceptAll( logicalExpr->get_results(), *this );
    246245        maybeAccept( logicalExpr->get_arg1(), *this );
    247246        maybeAccept( logicalExpr->get_arg2(), *this );
     
    249248
    250249void Visitor::visit( ConditionalExpr *conditionalExpr ) {
    251         maybeAccept( conditionalExpr->get_result(), *this );
     250        acceptAll( conditionalExpr->get_results(), *this );
    252251        maybeAccept( conditionalExpr->get_arg1(), *this );
    253252        maybeAccept( conditionalExpr->get_arg2(), *this );
     
    256255
    257256void Visitor::visit( CommaExpr *commaExpr ) {
    258         maybeAccept( commaExpr->get_result(), *this );
     257        acceptAll( commaExpr->get_results(), *this );
    259258        maybeAccept( commaExpr->get_arg1(), *this );
    260259        maybeAccept( commaExpr->get_arg2(), *this );
    261260}
    262261
     262void Visitor::visit( TupleExpr *tupleExpr ) {
     263        acceptAll( tupleExpr->get_results(), *this );
     264        acceptAll( tupleExpr->get_exprs(), *this );
     265}
     266
     267void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
     268        acceptAll( tupleExpr->get_results(), *this );
     269        acceptAll( tupleExpr->get_exprs(), *this );
     270}
     271
    263272void Visitor::visit( TypeExpr *typeExpr ) {
    264         maybeAccept( typeExpr->get_result(), *this );
     273        acceptAll( typeExpr->get_results(), *this );
    265274        maybeAccept( typeExpr->get_type(), *this );
    266275}
     
    279288
    280289void Visitor::visit( ConstructorExpr * ctorExpr ) {
    281         maybeAccept( ctorExpr->get_result(), *this );
     290        acceptAll( ctorExpr->get_results(), *this );
    282291        maybeAccept( ctorExpr->get_callExpr(), *this );
    283292}
    284293
    285294void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    286         maybeAccept( compLitExpr->get_result(), *this );
     295        acceptAll( compLitExpr->get_results(), *this );
    287296        maybeAccept( compLitExpr->get_type(), *this );
    288297        maybeAccept( compLitExpr->get_initializer(), *this );
     
    290299
    291300void Visitor::visit( UntypedValofExpr *valofExpr ) {
    292         maybeAccept( valofExpr->get_result(), *this );
     301        acceptAll( valofExpr->get_results(), *this );
    293302        maybeAccept( valofExpr->get_body(), *this );
    294303}
     
    297306        maybeAccept( rangeExpr->get_low(), *this );
    298307        maybeAccept( rangeExpr->get_high(), *this );
    299 }
    300 
    301 void Visitor::visit( TupleExpr *tupleExpr ) {
    302         maybeAccept( tupleExpr->get_result(), *this );
    303         acceptAll( tupleExpr->get_exprs(), *this );
    304 }
    305 
    306 void Visitor::visit( TupleIndexExpr *tupleExpr ) {
    307         maybeAccept( tupleExpr->get_result(), *this );
    308         maybeAccept( tupleExpr->get_tuple(), *this );
    309 }
    310 
    311 void Visitor::visit( MemberTupleExpr *tupleExpr ) {
    312         maybeAccept( tupleExpr->get_result(), *this );
    313         maybeAccept( tupleExpr->get_member(), *this );
    314         maybeAccept( tupleExpr->get_aggregate(), *this );
    315 }
    316 
    317 void Visitor::visit( TupleAssignExpr *assignExpr ) {
    318         maybeAccept( assignExpr->get_result(), *this );
    319         acceptAll( assignExpr->get_tempDecls(), *this );
    320         acceptAll( assignExpr->get_assigns(), *this );
    321 }
    322 
    323 void Visitor::visit( StmtExpr *stmtExpr ) {
    324         maybeAccept( stmtExpr->get_result(), *this );
    325         maybeAccept( stmtExpr->get_statements(), *this );
    326 }
    327 
    328 void Visitor::visit( UniqueExpr *uniqueExpr ) {
    329         maybeAccept( uniqueExpr->get_result(), *this );
    330         maybeAccept( uniqueExpr->get_expr(), *this );
    331308}
    332309
  • src/SynTree/Visitor.h

    r7756647 rd58a39a0  
    7171        virtual void visit( ConditionalExpr *conditionalExpr );
    7272        virtual void visit( CommaExpr *commaExpr );
     73        virtual void visit( TupleExpr *tupleExpr );
     74        virtual void visit( SolvedTupleExpr *tupleExpr );
    7375        virtual void visit( TypeExpr *typeExpr );
    7476        virtual void visit( AsmExpr *asmExpr );
     
    7880        virtual void visit( UntypedValofExpr *valofExpr );
    7981        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 );
    8682
    8783        virtual void visit( VoidType *basicType );
  • src/Tuples/TupleAssignment.cc

    r7756647 rd58a39a0  
    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 "SynTree/Initializer.h"
    21 #include "Tuples.h"
     20#include "TupleAssignment.h"
    2221#include "Common/SemanticError.h"
    23 #include "InitTweak/InitTweak.h"
    2422
    2523#include <functional>
     
    2927#include <cassert>
    3028#include <set>
    31 #include <unordered_set>
    3229
    3330namespace Tuples {
    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 ) {
     31        TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f = 0 )
     32                : currentFinder(f), matcher(0), hasMatched( false ) {}
     33
     34        bool TupleAssignSpotter::pointsToTuple( Expression *expr ) {
     35                // 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;
     39                return false;
     40        }
     41
     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
    7250                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 ) {
    87                 // also check for function returning tuple of reference types
    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                 }
    93                 return false;
    94         }
    95 
    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 {
     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
    123150                                                        // mass assignment
    124                                                         matcher.reset( new MassAssignMatcher( *this,  *ali ) );
     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() ) );
    125178                                                }
    126                                                 match();
     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() ) );
    127189                                        }
    128190                                }
    129191                        }
    130192                }
    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
     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
     267                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 );
    148373                        }
    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?
    241                 if ( lhs.size() == rhs.size() ) {
    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                 }
     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;
    254408        }
    255409} // namespace Tuples
  • src/Tuples/module.mk

    r7756647 rd58a39a0  
    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/TupleExpansion.cc
     18        Tuples/NameMatcher.cc
  • src/main.cc

    r7756647 rd58a39a0  
    4242#include "Common/UnimplementedError.h"
    4343#include "../config.h"
    44 #include "Tuples/Tuples.h"
    4544
    4645using namespace std;
     
    250249                } // if
    251250
    252                 OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this?
    253                 Tuples::expandUniqueExpr( translationUnit );
    254 
    255251                // fix ObjectDecl - replaces ConstructorInit nodes
    256252                OPTPRINT( "fixInit" )
     
    276272                OPTPRINT( "box" )
    277273                GenPoly::box( translationUnit );
    278                 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
    279                 Tuples::expandTuples( translationUnit );
    280274
    281275                // print tree right before code generation
Note: See TracChangeset for help on using the changeset viewer.