Ignore:
Timestamp:
Apr 19, 2022, 3:00:04 PM (3 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
5b84a321
Parents:
ba897d21 (diff), bb7c77d (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:

added benchmark and evaluations chapter to thesis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rba897d21 r2e9b59b  
    99// Author           : Thierry Delisle
    1010// Created On       : Thu May 09 15::37::05 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 13:19:22 2022
    13 // Update Count     : 41
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Mar 16 15:01:00 2022
     13// Update Count     : 42
    1414//
    1515
     
    4949//================================================================================================
    5050namespace ast {
    51 
    52 // This is to preserve the FindSpecialDecls hack. It does not (and perhaps should not)
    53 // allow us to use the same stratagy in the new ast.
    54 // xxx - since convert back pass works, this concern seems to be unnecessary.
    55 
    56 // these need to be accessed in new FixInit now
    57 ast::ptr<ast::Type> sizeType = nullptr;
    58 const ast::FunctionDecl * dereferenceOperator = nullptr;
    59 const ast::StructDecl   * dtorStruct = nullptr;
    60 const ast::FunctionDecl * dtorStructDestroy = nullptr;
     51// These are the shared local information used by ConverterNewToOld and
     52// ConverterOldToNew to update the global information in the two versions.
     53
     54static ast::ptr<ast::Type> sizeType = nullptr;
     55static const ast::FunctionDecl * dereferenceOperator = nullptr;
     56static const ast::StructDecl   * dtorStruct = nullptr;
     57static const ast::FunctionDecl * dtorStructDestroy = nullptr;
    6158
    6259}
     
    276273                decl->parent = get<AggregateDecl>().accept1( node->parent );
    277274                declPostamble( decl, node );
    278                 return nullptr;
     275                return nullptr; // ??
    279276        }
    280277
     
    310307                        node->name,
    311308                        get<Attribute>().acceptL( node->attributes ),
    312                         LinkageSpec::Spec( node->linkage.val )
    313                 );
    314                 return aggregatePostamble( decl, node );
     309                        LinkageSpec::Spec( node->linkage.val ),
     310                        get<Type>().accept1(node->base)
     311                );
     312                return aggregatePostamble( decl, node ); // Node info, including members, processed in aggregatePostamble
    315313        }
    316314
     
    354352                this->node = stmt;
    355353                return nullptr;
     354        }
     355
     356        void clausePostamble( Statement * stmt, const ast::StmtClause * node ) {
     357                stmt->location = node->location;
     358                this->node = stmt;
    356359        }
    357360
     
    404407                auto stmt = new SwitchStmt(
    405408                        get<Expression>().accept1( node->cond ),
    406                         get<Statement>().acceptL( node->stmts )
     409                        get<Statement>().acceptL( node->cases )
    407410                );
    408411                return stmtPostamble( stmt, node );
    409412        }
    410413
    411         const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
     414        const ast::CaseClause * visit( const ast::CaseClause * node ) override final {
    412415                if ( inCache( node ) ) return nullptr;
    413416                auto stmt = new CaseStmt(
     
    416419                        node->isDefault()
    417420                );
    418                 return stmtPostamble( stmt, node );
     421                clausePostamble( stmt, node );
     422                return nullptr;
    419423        }
    420424
     
    512516        }
    513517
    514         const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
     518        const ast::CatchClause * visit( const ast::CatchClause * node ) override final {
    515519                if ( inCache( node ) ) return nullptr;
    516520                CatchStmt::Kind kind;
     
    523527                        break;
    524528                default:
    525                         assertf(false, "Invalid ast::CatchStmt::Kind: %d\n", node->kind);
     529                        assertf(false, "Invalid ast::ExceptionKind: %d\n", node->kind);
    526530                }
    527531                auto stmt = new CatchStmt(
     
    531535                        get<Statement>().accept1( node->body )
    532536                );
    533                 return stmtPostamble( stmt, node );
    534         }
    535 
    536         const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
     537                return clausePostamble( stmt, node ), nullptr;
     538        }
     539
     540        const ast::FinallyClause * visit( const ast::FinallyClause * node ) override final {
    537541                if ( inCache( node ) ) return nullptr;
    538542                auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) );
    539                 return stmtPostamble( stmt, node );
     543                return clausePostamble( stmt, node ), nullptr;
    540544        }
    541545
     
    947951        }
    948952
     953        const ast::Expr * visit( const ast::DimensionExpr * node ) override final {
     954                auto expr = visitBaseExpr( node, new DimensionExpr( node->name ) );
     955                this->node = expr;
     956                return nullptr;
     957        }
     958
    949959        const ast::Expr * visit( const ast::AsmExpr * node ) override final {
    950960                auto expr = visitBaseExpr( node,
     
    14671477                return strict_dynamic_cast< ast::Decl * >( node );
    14681478        }
    1469 
     1479       
    14701480        ConverterOldToNew() = default;
    14711481        ConverterOldToNew(const ConverterOldToNew &) = delete;
     
    14951505                getAccept1< ast::type, decltype( old->child ) >( old->child )
    14961506
     1507
    14971508        template<typename NewT, typename OldC>
    14981509        std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) {
     
    15091520#       define GET_ACCEPT_V(child, type) \
    15101521                getAcceptV< ast::type, decltype( old->child ) >( old->child )
     1522
     1523#       define GET_ACCEPT_E(child, type) \
     1524                getAccept1< ast::type, decltype( old->base ) >( old->base )
    15111525
    15121526        template<typename NewT, typename OldC>
     
    17101724        }
    17111725
     1726        // Convert SynTree::EnumDecl to AST::EnumDecl
    17121727        virtual void visit( const EnumDecl * old ) override final {
    17131728                if ( inCache( old ) ) return;
     
    17161731                        old->name,
    17171732                        GET_ACCEPT_V(attributes, Attribute),
    1718                         { old->linkage.val }
     1733                        { old->linkage.val },
     1734                        GET_ACCEPT_1(base, Type),
     1735                        old->enumValues
    17191736                );
    17201737                cache.emplace( old, decl );
     
    17261743                decl->uniqueId   = old->uniqueId;
    17271744                decl->storage    = { old->storageClasses.val };
    1728 
    17291745                this->node = decl;
    17301746        }
     
    18871903                        old->location,
    18881904                        GET_ACCEPT_1(condition, Expr),
    1889                         GET_ACCEPT_V(statements, Stmt),
     1905                        GET_ACCEPT_V(statements, CaseClause),
    18901906                        GET_LABELS_V(old->labels)
    18911907                );
     
    18951911        virtual void visit( const CaseStmt * old ) override final {
    18961912                if ( inCache( old ) ) return;
    1897                 this->node = new ast::CaseStmt(
     1913                this->node = new ast::CaseClause(
    18981914                        old->location,
    18991915                        GET_ACCEPT_1(condition, Expr),
    1900                         GET_ACCEPT_V(stmts, Stmt),
    1901                         GET_LABELS_V(old->labels)
    1902                 );
     1916                        GET_ACCEPT_V(stmts, Stmt)
     1917                );
     1918                auto labels = GET_LABELS_V(old->labels);
     1919                assertf(labels.empty(), "Labels found on CaseStmt.");
    19031920                cache.emplace( old, this->node );
    19041921        }
     
    20082025                        old->location,
    20092026                        GET_ACCEPT_1(block, CompoundStmt),
    2010                         GET_ACCEPT_V(handlers, CatchStmt),
    2011                         GET_ACCEPT_1(finallyBlock, FinallyStmt),
     2027                        GET_ACCEPT_V(handlers, CatchClause),
     2028                        GET_ACCEPT_1(finallyBlock, FinallyClause),
    20122029                        GET_LABELS_V(old->labels)
    20132030                );
     
    20292046                }
    20302047
    2031                 this->node = new ast::CatchStmt(
     2048                this->node = new ast::CatchClause(
    20322049                        old->location,
    20332050                        kind,
    20342051                        GET_ACCEPT_1(decl, Decl),
    20352052                        GET_ACCEPT_1(cond, Expr),
    2036                         GET_ACCEPT_1(body, Stmt),
    2037                         GET_LABELS_V(old->labels)
    2038                 );
     2053                        GET_ACCEPT_1(body, Stmt)
     2054                );
     2055                auto labels = GET_LABELS_V(old->labels);
     2056                assertf(labels.empty(), "Labels found on CatchStmt.");
    20392057                cache.emplace( old, this->node );
    20402058        }
     
    20422060        virtual void visit( const FinallyStmt * old ) override final {
    20432061                if ( inCache( old ) ) return;
    2044                 this->node = new ast::FinallyStmt(
    2045                         old->location,
    2046                         GET_ACCEPT_1(block, CompoundStmt),
    2047                         GET_LABELS_V(old->labels)
    2048                 );
     2062                this->node = new ast::FinallyClause(
     2063                        old->location,
     2064                        GET_ACCEPT_1(block, CompoundStmt)
     2065                );
     2066                auto labels = GET_LABELS_V(old->labels);
     2067                assertf(labels.empty(), "Labels found on FinallyStmt.");
    20492068                cache.emplace( old, this->node );
    20502069        }
     
    24502469
    24512470        virtual void visit( const DimensionExpr * old ) override final {
    2452                 // DimensionExpr gets desugared away in Validate.
    2453                 // As long as new-AST passes don't use it, this cheap-cheerful error
    2454                 // detection helps ensure that these occurrences have been compiled
    2455                 // away, as expected.  To move the DimensionExpr boundary downstream
    2456                 // or move the new-AST translation boundary upstream, implement
    2457                 // DimensionExpr in the new AST and implement a conversion.
    2458                 (void) old;
    2459                 assert(false && "DimensionExpr should not be present at new-AST boundary");
     2471                this->node = visitBaseExpr( old,
     2472                        new ast::DimensionExpr( old->location, old->name )
     2473                );
    24602474        }
    24612475
     
    27112725
    27122726                for (auto & param : foralls) {
    2713                         ty->forall.emplace_back(new ast::TypeInstType(param->name, param));
     2727                        ty->forall.emplace_back(new ast::TypeInstType(param));
    27142728                        for (auto asst : param->assertions) {
    27152729                                ty->assertions.emplace_back(new ast::VariableExpr({}, asst));
     
    27612775        }
    27622776
    2763         virtual void visit( const EnumInstType * old ) override final {
    2764                 ast::EnumInstType * ty;
     2777        virtual void visit( const EnumInstType * old ) override final { // Here is visiting the EnumInst Decl not the usage.
     2778                ast::EnumInstType * ty; 
    27652779                if ( old->baseEnum ) {
    2766                         ty = new ast::EnumInstType{
     2780                        ty = new ast::EnumInstType{ // Probably here: missing the specification of the base
    27672781                                GET_ACCEPT_1( baseEnum, EnumDecl ),
    27682782                                cv( old ),
Note: See TracChangeset for help on using the changeset viewer.