Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r6355ba7 ra62749f  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu May 06 19:51:00 2019
    13 // Update Count     : 10
     12// Last Modified On : Man Jun 10 11:51:00 2019
     13// Update Count     : 11
    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                }
    9499                return Label(
    95100                        label.name,
     
    154159                auto&& attr = get<Attribute>().acceptL( node->attributes );
    155160                if ( inCache( node ) ) {
     161                        if(node->name == "tmp") {
     162                                std::cerr << (void*)node << "(new) in cache " << (void*)this->node << "(old)" << std::endl;
     163                        }
    156164                        return nullptr;
    157165                }
     
    166174                        Type::FuncSpecifiers( node->funcSpec.val )
    167175                );
     176                if(node->name == "tmp") {
     177                        std::cerr << (void*)node << "(new) created " << (void*)decl << "(old)" << std::endl;
     178                }
    168179                return declWithTypePostamble( decl, node );
    169180        }
     
    13841395        // Local Utilities:
    13851396
    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 
    13921397        template<typename NewT, typename OldT>
    13931398        NewT * getAccept1( OldT old ) {
     
    14031408
    14041409        template<typename NewT, typename OldC>
    1405         std::vector< ast::ptr<NewT> > getAcceptV( OldC& old ) {
     1410        std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) {
    14061411                std::vector< ast::ptr<NewT> > ret;
    14071412                ret.reserve( old.size() );
     
    14181423
    14191424        template<typename NewT, typename OldC>
    1420         std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) {
     1425        std::deque< ast::ptr<NewT> > getAcceptD( const OldC& old ) {
    14211426                std::deque< ast::ptr<NewT> > ret;
    14221427                for ( auto a : old ) {
     
    14311436                getAcceptD< ast::type, decltype( old->child ) >( old->child )
    14321437
    1433         ast::Label make_label(Label* old) {
     1438        ast::Label make_label(const Label* old) {
     1439                CodeLocation const & location =
     1440                    ( old->labelled ) ? old->labelled->location : CodeLocation();
    14341441                return ast::Label(
    1435                         old->labelled->location,
     1442                        location,
    14361443                        old->name,
    14371444                        GET_ACCEPT_V(attributes, Attribute)
     
    14641471
    14651472        virtual void visit( ObjectDecl * old ) override final {
     1473                if( old->name == "tmp" ) {
     1474                        std::cerr << "building parameters for" << (void*)old << std::endl;
     1475                }
    14661476                auto&& type = GET_ACCEPT_1(type, Type);
    14671477                auto&& init = GET_ACCEPT_1(init, Init);
    14681478                auto&& bfwd = GET_ACCEPT_1(bitfieldWidth, Expr);
    14691479                auto&& attr = GET_ACCEPT_V(attributes, Attribute);
     1480                if( old->name == "tmp" ) {
     1481                        std::cerr << "checking cache for " << (void*)old << std::endl;
     1482                }
    14701483                if ( inCache( old ) ) {
     1484                        if( old->name == "tmp" ) {
     1485                                std::cerr << (void*)old << "(old) in cache " << (void*)this->node << "(new)" << std::endl;
     1486                        }
    14711487                        return;
    14721488                }
     
    14831499                );
    14841500                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                }
    14851504                assert(cache.find( old ) != cache.end());
    14861505                decl->scopeLevel = old->scopeLevel;
     
    14911510
    14921511                this->node = decl;
     1512
     1513                if( old->name == "tmp" ) {
     1514                        std::cerr << (void*)old << "(old) created " << (void*)this->node << "(new)" << std::endl;
     1515                }
    14931516        }
    14941517
     
    18051828                        }
    18061829
    1807                         Label label = old->originalTarget;
    18081830                        auto stmt = new ast::BranchStmt(
    18091831                                old->location,
    18101832                                kind,
    1811                                 make_label(&label),
     1833                                make_label(&old->originalTarget),
    18121834                                GET_LABELS_V(old->labels)
    18131835                        );
Note: See TracChangeset for help on using the changeset viewer.