Ignore:
Timestamp:
Jun 20, 2019, 1:45:01 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
54dd994
Parents:
1e5dedc4 (diff), c0f9efe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1e5dedc4 r3c6e417  
    993993        const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
    994994                auto rslt = new UniqueExpr(
    995                         get<Expression>().accept1(node->expr)
     995                        get<Expression>().accept1(node->expr),
     996                        node->id
    996997                );
    997998
     
    10741075        }
    10751076
     1077        const ast::Type * visitType( const ast::Type * node, Type * type ) {
     1078                // Some types do this in their constructor so add a check.
     1079                if ( !node->attributes.empty() && type->attributes.empty() ) {
     1080                        type->attributes = get<Attribute>().acceptL( node->attributes );
     1081                }
     1082                this->node = type;
     1083                return nullptr;
     1084        }
     1085
    10761086        const ast::Type * visit( const ast::VoidType * node ) override final {
    1077                 this->node = new VoidType{ cv( node ) };
    1078                 return nullptr;
     1087                return visitType( node, new VoidType{ cv( node ) } );
    10791088        }
    10801089
     
    10851094                        Validate::SizeType = type;
    10861095                }
    1087                 this->node = type;
    1088                 return nullptr;
     1096                return visitType( node, type );
    10891097        }
    10901098
    10911099        const ast::Type * visit( const ast::PointerType * node ) override final {
    1092                 this->node = new PointerType{
     1100                return visitType( node, new PointerType{
    10931101                        cv( node ),
    10941102                        get<Type>().accept1( node->base ),
     
    10961104                        (bool)node->isVarLen,
    10971105                        (bool)node->isStatic
    1098                 };
    1099                 return nullptr;
     1106                } );
    11001107        }
    11011108
    11021109        const ast::Type * visit( const ast::ArrayType * node ) override final {
    1103                 this->node = new ArrayType{
     1110                return visitType( node, new ArrayType{
    11041111                        cv( node ),
    11051112                        get<Type>().accept1( node->base ),
     
    11071114                        (bool)node->isVarLen,
    11081115                        (bool)node->isStatic
    1109                 };
    1110                 return nullptr;
     1116                } );
    11111117        }
    11121118
    11131119        const ast::Type * visit( const ast::ReferenceType * node ) override final {
    1114                 this->node = new ReferenceType{
     1120                return visitType( node, new ReferenceType{
    11151121                        cv( node ),
    11161122                        get<Type>().accept1( node->base )
    1117                 };
    1118                 return nullptr;
     1123                } );
    11191124        }
    11201125
    11211126        const ast::Type * visit( const ast::QualifiedType * node ) override final {
    1122                 this->node = new QualifiedType{
     1127                return visitType( node, new QualifiedType{
    11231128                        cv( node ),
    11241129                        get<Type>().accept1( node->parent ),
    11251130                        get<Type>().accept1( node->child )
    1126                 };
    1127                 return nullptr;
     1131                } );
    11281132        }
    11291133
     
    11361140                ty->parameters = get<DeclarationWithType>().acceptL( node->params );
    11371141                ty->forall = get<TypeDecl>().acceptL( node->forall );
    1138                 this->node = ty;
    1139                 return nullptr;
    1140         }
    1141 
    1142         void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
     1142                return visitType( node, ty );
     1143        }
     1144
     1145        const ast::Type * postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
    11431146                ty->forall = get<TypeDecl>().acceptL( old->forall );
    11441147                ty->parameters = get<Expression>().acceptL( old->params );
    11451148                ty->hoistType = old->hoistType;
     1149                return visitType( old, ty );
    11461150        }
    11471151
     
    11611165                        };
    11621166                }
    1163                 postvisit( node, ty );
    1164                 this->node = ty;
    1165                 return nullptr;
     1167                return postvisit( node, ty );
    11661168        }
    11671169
     
    11811183                        };
    11821184                }
    1183                 postvisit( node, ty );
    1184                 this->node = ty;
    1185                 return nullptr;
     1185                return postvisit( node, ty );
    11861186        }
    11871187
     
    12011201                        };
    12021202                }
    1203                 postvisit( node, ty );
    1204                 this->node = ty;
    1205                 return nullptr;
     1203                return postvisit( node, ty );
    12061204        }
    12071205
     
    12211219                        };
    12221220                }
    1223                 postvisit( node, ty );
    1224                 this->node = ty;
    1225                 return nullptr;
     1221                return postvisit( node, ty );
    12261222        }
    12271223
     
    12431239                        };
    12441240                }
    1245                 postvisit( node, ty );
    1246                 this->node = ty;
    1247                 return nullptr;
     1241                return postvisit( node, ty );
    12481242        }
    12491243
    12501244        const ast::Type * visit( const ast::TupleType * node ) override final {
    1251                 this->node = new TupleType{
     1245                return visitType( node, new TupleType{
    12521246                        cv( node ),
    12531247                        get<Type>().acceptL( node->types )
    12541248                        // members generated by TupleType c'tor
    1255                 };
    1256                 return nullptr;
     1249                } );
    12571250        }
    12581251
    12591252        const ast::Type * visit( const ast::TypeofType * node ) override final {
    1260                 this->node = new TypeofType{
     1253                return visitType( node, new TypeofType{
    12611254                        cv( node ),
    12621255                        get<Expression>().accept1( node->expr ),
    12631256                        (bool)node->kind
    1264                 };
    1265                 return nullptr;
     1257                } );
    12661258        }
    12671259
    12681260        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    1269                 this->node = new VarArgsType{ cv( node ) };
    1270                 return nullptr;
     1261                return visitType( node, new VarArgsType{ cv( node ) } );
    12711262        }
    12721263
    12731264        const ast::Type * visit( const ast::ZeroType * node ) override final {
    1274                 this->node = new ZeroType{ cv( node ) };
    1275                 return nullptr;
     1265                return visitType( node, new ZeroType{ cv( node ) } );
    12761266        }
    12771267
    12781268        const ast::Type * visit( const ast::OneType * node ) override final {
    1279                 this->node = new OneType{ cv( node ) };
    1280                 return nullptr;
    1281         }
    1282 
    1283         const ast::Type * visit( const ast::GlobalScopeType * ) override final {
    1284                 this->node = new GlobalScopeType{};
    1285                 return nullptr;
     1269                return visitType( node, new OneType{ cv( node ) } );
     1270        }
     1271
     1272        const ast::Type * visit( const ast::GlobalScopeType * node ) override final {
     1273                return visitType( node, new GlobalScopeType{} );
    12861274        }
    12871275
     
    23672355                auto rslt = new ast::UniqueExpr(
    23682356                        old->location,
    2369                         GET_ACCEPT_1(expr, Expr)
     2357                        GET_ACCEPT_1(expr, Expr),
     2358                        old->get_id()
    23702359                );
    23712360                rslt->object = GET_ACCEPT_1(object, ObjectDecl);
     
    24402429        }
    24412430
     2431        void visitType( Type * old, ast::Type * type ) {
     2432                // Some types do this in their constructor so add a check.
     2433                if ( !old->attributes.empty() && type->attributes.empty() ) {
     2434                        type->attributes = GET_ACCEPT_V(attributes, Attribute);
     2435                }
     2436                this->node = type;
     2437        }
     2438
    24422439        virtual void visit( VoidType * old ) override final {
    2443                 this->node = new ast::VoidType{ cv( old ) };
     2440                visitType( old, new ast::VoidType{ cv( old ) } );
    24442441        }
    24452442
     
    24502447                        sizeType = type;
    24512448                }
    2452                 this->node = type;
     2449                visitType( old, type );
    24532450        }
    24542451
    24552452        virtual void visit( PointerType * old ) override final {
    2456                 this->node = new ast::PointerType{
     2453                visitType( old, new ast::PointerType{
    24572454                        GET_ACCEPT_1( base, Type ),
    24582455                        GET_ACCEPT_1( dimension, Expr ),
     
    24602457                        (ast::DimensionFlag)old->isStatic,
    24612458                        cv( old )
    2462                 };
     2459                } );
    24632460        }
    24642461
    24652462        virtual void visit( ArrayType * old ) override final {
    2466                 this->node = new ast::ArrayType{
     2463                visitType( old, new ast::ArrayType{
    24672464                        GET_ACCEPT_1( base, Type ),
    24682465                        GET_ACCEPT_1( dimension, Expr ),
     
    24702467                        (ast::DimensionFlag)old->isStatic,
    24712468                        cv( old )
    2472                 };
     2469                } );
    24732470        }
    24742471
    24752472        virtual void visit( ReferenceType * old ) override final {
    2476                 this->node = new ast::ReferenceType{
     2473                visitType( old, new ast::ReferenceType{
    24772474                        GET_ACCEPT_1( base, Type ),
    24782475                        cv( old )
    2479                 };
     2476                } );
    24802477        }
    24812478
    24822479        virtual void visit( QualifiedType * old ) override final {
    2483                 this->node = new ast::QualifiedType{
     2480                visitType( old, new ast::QualifiedType{
    24842481                        GET_ACCEPT_1( parent, Type ),
    24852482                        GET_ACCEPT_1( child, Type ),
    24862483                        cv( old )
    2487                 };
     2484                } );
    24882485        }
    24892486
     
    24962493                ty->params = GET_ACCEPT_V( parameters, DeclWithType );
    24972494                ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    2498                 this->node = ty;
     2495                visitType( old, ty );
    24992496        }
    25002497
     
    25032500                ty->params = GET_ACCEPT_V( parameters, Expr );
    25042501                ty->hoistType = old->hoistType;
     2502                visitType( old, ty );
    25052503        }
    25062504
     
    25212519                }
    25222520                postvisit( old, ty );
    2523                 this->node = ty;
    25242521        }
    25252522
     
    25402537                }
    25412538                postvisit( old, ty );
    2542                 this->node = ty;
    25432539        }
    25442540
     
    25592555                }
    25602556                postvisit( old, ty );
    2561                 this->node = ty;
    25622557        }
    25632558
     
    25782573                }
    25792574                postvisit( old, ty );
    2580                 this->node = ty;
    25812575        }
    25822576
     
    25992593                }
    26002594                postvisit( old, ty );
    2601                 this->node = ty;
    26022595        }
    26032596
    26042597        virtual void visit( TupleType * old ) override final {
    2605                 this->node = new ast::TupleType{
     2598                visitType( old, new ast::TupleType{
    26062599                        GET_ACCEPT_V( types, Type ),
    26072600                        // members generated by TupleType c'tor
    26082601                        cv( old )
    2609                 };
     2602                } );
    26102603        }
    26112604
    26122605        virtual void visit( TypeofType * old ) override final {
    2613                 this->node = new ast::TypeofType{
     2606                visitType( old, new ast::TypeofType{
    26142607                        GET_ACCEPT_1( expr, Expr ),
    26152608                        (ast::TypeofType::Kind)old->is_basetypeof,
    26162609                        cv( old )
    2617                 };
     2610                } );
    26182611        }
    26192612
     
    26232616
    26242617        virtual void visit( VarArgsType * old ) override final {
    2625                 this->node = new ast::VarArgsType{ cv( old ) };
     2618                visitType( old, new ast::VarArgsType{ cv( old ) } );
    26262619        }
    26272620
    26282621        virtual void visit( ZeroType * old ) override final {
    2629                 this->node = new ast::ZeroType{ cv( old ) };
     2622                visitType( old, new ast::ZeroType{ cv( old ) } );
    26302623        }
    26312624
    26322625        virtual void visit( OneType * old ) override final {
    2633                 this->node = new ast::OneType{ cv( old ) };
    2634         }
    2635 
    2636         virtual void visit( GlobalScopeType * ) override final {
    2637                 this->node = new ast::GlobalScopeType{};
     2626                visitType( old, new ast::OneType{ cv( old ) } );
     2627        }
     2628
     2629        virtual void visit( GlobalScopeType * old ) override final {
     2630                visitType( old, new ast::GlobalScopeType{} );
    26382631        }
    26392632
Note: See TracChangeset for help on using the changeset viewer.