Changeset 019b2d3 for src


Ignore:
Timestamp:
Dec 22, 2022, 3:17:52 PM (16 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
64b3cda
Parents:
be3b952
Message:

Moved new to old ast conversion up into the RunParser? module. As far as main is concerned the new ast is used from the beginning (except for LinkageSpec::Spec).

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/RunParser.cpp

    rbe3b952 r019b2d3  
    1010// Created On       : Mon Dec 19 11:00:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Dec 19 11:15:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Thr Dec 22 10:18:00 2022
     13// Update Count     : 1
    1414//
    1515
    1616#include "RunParser.hpp"
    1717
     18#include "AST/Convert.hpp"                  // for convert
     19#include "AST/TranslationUnit.hpp"          // for TranslationUnit
     20#include "CodeTools/TrackLoc.h"             // for fillLocations
     21#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
    1822#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
    1923#include "Parser/TypedefTable.h"            // for TypedefTable
     
    4751}
    4852
    49 std::list<Declaration *> buildUnit(void) {
     53ast::TranslationUnit buildUnit(void) {
    5054        std::list<Declaration *> translationUnit;
    5155        buildList( parseTree, translationUnit );
     
    5458        parseTree = nullptr;
    5559
    56         return translationUnit;
     60        // When the parse/buildList code is translated to the new ast, these
     61        // fill passes (and the one after 'Hoist Type Decls') should be redundent
     62        // because the code locations should already be filled.
     63        CodeTools::fillLocations( translationUnit );
     64        ast::TranslationUnit transUnit = convert( std::move( translationUnit ) );
     65        forceFillCodeLocations( transUnit );
     66        return transUnit;
    5767}
    5868
  • src/Parser/RunParser.hpp

    rbe3b952 r019b2d3  
    1010// Created On       : Mon Dec 19 10:42:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Dec 19 11:15:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Thr Dec 22 10:23:00 2022
     13// Update Count     : 1
    1414//
    1515
     
    1717
    1818#include <iosfwd>                           // for ostream
    19 #include <list>                             // for list
    2019
    2120#include "SynTree/LinkageSpec.h"            // for Spec
    22 class Declaration;
     21namespace ast {
     22        class TranslationUnit;
     23}
    2324
    2425// The Parser does not have an enclosing namespace.
     
    3536/// Drain the internal accumulator of parsed code and build a translation
    3637/// unit from it.
    37 std::list<Declaration *> buildUnit(void);
     38ast::TranslationUnit buildUnit(void);
    3839
    3940// Local Variables: //
  • src/main.cc

    rbe3b952 r019b2d3  
    299299                } // if
    300300
    301                 translationUnit = buildUnit();
     301                auto transUnit = buildUnit();
    302302
    303303                if ( astp ) {
    304                         dump( translationUnit );
    305                         return EXIT_SUCCESS;
    306                 } // if
    307 
    308                 // Temporary: fill locations after parsing so that every node has a location, for early error messages.
    309                 // Eventually we should pass the locations from the parser to every node, but this quick and dirty solution
    310                 // works okay for now.
    311                 CodeTools::fillLocations( translationUnit );
     304                        dump( std::move( transUnit ) );
     305                        return EXIT_SUCCESS;
     306                } // if
     307
    312308                Stats::Time::StopBlock();
    313309
     
    316312                        ast::pass_visitor_stats.max = Stats::Counters::build<Stats::Counters::MaxCounter<double>>("Max depth - New");
    317313                }
    318                 auto transUnit = convert( std::move( translationUnit ) );
    319 
    320                 forceFillCodeLocations( transUnit );
    321314
    322315                PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) );
Note: See TracChangeset for help on using the changeset viewer.