Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    ra62749f r6355ba7  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Man Jun 10 11:51:00 2019
    13 // Update Count     : 11
     12// Last Modified On : Thu May 06 19:51:00 2019
     13// Update Count     : 10
    1414//
    1515
     
    9292
    9393        Label makeLabel(Statement * labelled, const ast::Label& label) {
    94                 // This probably will leak memory, but only until we get rid of the old tree.
    95                 if ( nullptr == labelled && label.location.isSet() ) {
    96                         labelled = new NullStmt();
    97                         labelled->location = label.location;
    98                 }
    9994                return Label(
    10095                        label.name,
     
    159154                auto&& attr = get<Attribute>().acceptL( node->attributes );
    160155                if ( inCache( node ) ) {
    161                         if(node->name == "tmp") {
    162                                 std::cerr << (void*)node << "(new) in cache " << (void*)this->node << "(old)" << std::endl;
    163                         }
    164156                        return nullptr;
    165157                }
     
    174166                        Type::FuncSpecifiers( node->funcSpec.val )
    175167                );
    176                 if(node->name == "tmp") {
    177                         std::cerr << (void*)node << "(new) created " << (void*)decl << "(old)" << std::endl;
    178                 }
    179168                return declWithTypePostamble( decl, node );
    180169        }
     
    13951384        // Local Utilities:
    13961385
     1386        #define construct(T, key, ...) ({ \
     1387                void * data = ::operator new(sizeof(T)); \
     1388                cache.emplace( key, (T*)data ); \
     1389                new (data) T( __VA_ARGS__ ); \
     1390        })
     1391
    13971392        template<typename NewT, typename OldT>
    13981393        NewT * getAccept1( OldT old ) {
     
    14081403
    14091404        template<typename NewT, typename OldC>
    1410         std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) {
     1405        std::vector< ast::ptr<NewT> > getAcceptV( OldC& old ) {
    14111406                std::vector< ast::ptr<NewT> > ret;
    14121407                ret.reserve( old.size() );
     
    14231418
    14241419        template<typename NewT, typename OldC>
    1425         std::deque< ast::ptr<NewT> > getAcceptD( const OldC& old ) {
     1420        std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) {
    14261421                std::deque< ast::ptr<NewT> > ret;
    14271422                for ( auto a : old ) {
     
    14361431                getAcceptD< ast::type, decltype( old->child ) >( old->child )
    14371432
    1438         ast::Label make_label(const Label* old) {
    1439                 CodeLocation const & location =
    1440                     ( old->labelled ) ? old->labelled->location : CodeLocation();
     1433        ast::Label make_label(Label* old) {
    14411434                return ast::Label(
    1442                         location,
     1435                        old->labelled->location,
    14431436                        old->name,
    14441437                        GET_ACCEPT_V(attributes, Attribute)
     
    14711464
    14721465        virtual void visit( ObjectDecl * old ) override final {
    1473                 if( old->name == "tmp" ) {
    1474                         std::cerr << "building parameters for" << (void*)old << std::endl;
    1475                 }
    14761466                auto&& type = GET_ACCEPT_1(type, Type);
    14771467                auto&& init = GET_ACCEPT_1(init, Init);
    14781468                auto&& bfwd = GET_ACCEPT_1(bitfieldWidth, Expr);
    14791469                auto&& attr = GET_ACCEPT_V(attributes, Attribute);
    1480                 if( old->name == "tmp" ) {
    1481                         std::cerr << "checking cache for " << (void*)old << std::endl;
    1482                 }
    14831470                if ( inCache( old ) ) {
    1484                         if( old->name == "tmp" ) {
    1485                                 std::cerr << (void*)old << "(old) in cache " << (void*)this->node << "(new)" << std::endl;
    1486                         }
    14871471                        return;
    14881472                }
     
    14991483                );
    15001484                cache.emplace(old, decl);
    1501                 if( old->name == "tmp" ) {
    1502                         std::cerr << (void*)old << "(old) added to cache with " << (void*)decl << "(new)" << std::endl;
    1503                 }
    15041485                assert(cache.find( old ) != cache.end());
    15051486                decl->scopeLevel = old->scopeLevel;
     
    15101491
    15111492                this->node = decl;
    1512 
    1513                 if( old->name == "tmp" ) {
    1514                         std::cerr << (void*)old << "(old) created " << (void*)this->node << "(new)" << std::endl;
    1515                 }
    15161493        }
    15171494
     
    18281805                        }
    18291806
     1807                        Label label = old->originalTarget;
    18301808                        auto stmt = new ast::BranchStmt(
    18311809                                old->location,
    18321810                                kind,
    1833                                 make_label(&old->originalTarget),
     1811                                make_label(&label),
    18341812                                GET_LABELS_V(old->labels)
    18351813                        );
Note: See TracChangeset for help on using the changeset viewer.