Changeset 293dc1c for src/AST


Ignore:
Timestamp:
Nov 3, 2020, 4:06:20 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4406887
Parents:
daefe93
Message:

TranslationUnit? is now used at the top-level of the new-ast passes.

Location:
src/AST
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rdaefe93 r293dc1c  
    2525#include "AST/Init.hpp"
    2626#include "AST/Stmt.hpp"
     27#include "AST/TranslationUnit.hpp"
    2728#include "AST/TypeSubstitution.hpp"
    2829
     
    14041405};
    14051406
    1406 std::list< Declaration * > convert( const std::list< ast::ptr< ast::Decl > > && translationUnit ) {
     1407std::list< Declaration * > convert( const ast::TranslationUnit && translationUnit ) {
    14071408        ConverterNewToOld c;
    14081409        std::list< Declaration * > decls;
    1409         for(auto d : translationUnit) {
     1410        for(auto d : translationUnit.decls) {
    14101411                decls.emplace_back( c.decl( d ) );
    14111412        }
     
    28032804#undef GET_ACCEPT_1
    28042805
    2805 std::list< ast::ptr< ast::Decl > > convert( const std::list< Declaration * > && translationUnit ) {
     2806ast::TranslationUnit convert( const std::list< Declaration * > && translationUnit ) {
    28062807        ConverterOldToNew c;
    2807         std::list< ast::ptr< ast::Decl > > decls;
     2808        ast::TranslationUnit unit;
    28082809        for(auto d : translationUnit) {
    28092810                d->accept( c );
    2810                 decls.emplace_back( c.decl() );
     2811                unit.decls.emplace_back( c.decl() );
    28112812        }
    28122813        deleteAll(translationUnit);
    2813         return decls;
     2814        return unit;
    28142815}
  • src/AST/Convert.hpp

    rdaefe93 r293dc1c  
    1818#include <list>
    1919
    20 #include "AST/Node.hpp"
    21 
    2220class Declaration;
    2321namespace ast {
    24         class Decl;
     22        class TranslationUnit;
    2523};
    2624
    27 std::list< Declaration * > convert( const std::list< ast::ptr< ast::Decl > > && translationUnit );
    28 std::list< ast::ptr< ast::Decl > > convert( const std::list< Declaration * > && translationUnit );
     25std::list< Declaration * > convert( const ast::TranslationUnit && translationUnit );
     26ast::TranslationUnit convert( const std::list< Declaration * > && translationUnit );
  • src/AST/Fwd.hpp

    rdaefe93 r293dc1c  
    137137typedef unsigned int UniqueId;
    138138
     139class TranslationUnit;
     140// TODO: Get from the TranslationUnit:
    139141extern Type * sizeType;
    140142extern FunctionDecl * dereferenceOperator;
  • src/AST/Pass.hpp

    rdaefe93 r293dc1c  
    103103        /// Construct and run a pass on a translation unit.
    104104        template< typename... Args >
    105         static void run( std::list< ptr<Decl> > & decls, Args &&... args ) {
     105        static void run( TranslationUnit & decls, Args &&... args ) {
    106106                Pass<core_t> visitor( std::forward<Args>( args )... );
    107107                accept_all( decls, visitor );
     
    119119        // Versions of the above for older compilers.
    120120        template< typename... Args >
    121         static void run( std::list< ptr<Decl> > & decls ) {
     121        static void run( TranslationUnit & decls ) {
    122122                Pass<core_t> visitor;
    123123                accept_all( decls, visitor );
     
    303303void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<core_t> & visitor );
    304304
     305template<typename core_t>
     306void accept_all( ast::TranslationUnit &, ast::Pass<core_t> & visitor );
     307
    305308//-------------------------------------------------------------------------------------------------
    306309// PASS ACCESSORIES
  • src/AST/Pass.impl.hpp

    rdaefe93 r293dc1c  
    2020#include <unordered_map>
    2121
     22#include "AST/TranslationUnit.hpp"
    2223#include "AST/TypeSubstitution.hpp"
    2324
     
    430431        pass_visitor_stats.depth--;
    431432        if ( !errors.isEmpty() ) { throw errors; }
     433}
     434
     435template< typename core_t >
     436inline void ast::accept_all( ast::TranslationUnit & unit, ast::Pass< core_t > & visitor ) {
     437        return ast::accept_all( unit.decls, visitor );
    432438}
    433439
  • src/AST/Pass.proto.hpp

    rdaefe93 r293dc1c  
    2222template<typename core_t>
    2323class Pass;
     24
     25class TranslationUnit;
    2426
    2527struct PureVisitor;
Note: See TracChangeset for help on using the changeset viewer.