Ignore:
Timestamp:
Jun 10, 2019, 12:08:15 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
6e3e0717
Parents:
61c7239
Message:

Better support for loose labels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r61c7239 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,
     
    13901395        // Local Utilities:
    13911396
    1392         #define construct(T, key, ...) ({ \
    1393                 void * data = ::operator new(sizeof(T)); \
    1394                 cache.emplace( key, (T*)data ); \
    1395                 new (data) T( __VA_ARGS__ ); \
    1396         })
    1397 
    13981397        template<typename NewT, typename OldT>
    13991398        NewT * getAccept1( OldT old ) {
     
    14091408
    14101409        template<typename NewT, typename OldC>
    1411         std::vector< ast::ptr<NewT> > getAcceptV( OldC& old ) {
     1410        std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) {
    14121411                std::vector< ast::ptr<NewT> > ret;
    14131412                ret.reserve( old.size() );
     
    14221421#       define GET_ACCEPT_V(child, type) \
    14231422                getAcceptV< ast::type, decltype( old->child ) >( old->child )
    1424        
     1423
    14251424        template<typename NewT, typename OldC>
    1426         std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) {
     1425        std::deque< ast::ptr<NewT> > getAcceptD( const OldC& old ) {
    14271426                std::deque< ast::ptr<NewT> > ret;
    14281427                for ( auto a : old ) {
     
    14371436                getAcceptD< ast::type, decltype( old->child ) >( old->child )
    14381437
    1439         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();
    14401441                return ast::Label(
    1441                         old->labelled->location,
     1442                        location,
    14421443                        old->name,
    14431444                        GET_ACCEPT_V(attributes, Attribute)
     
    18271828                        }
    18281829
    1829                         Label label = old->originalTarget;
    18301830                        auto stmt = new ast::BranchStmt(
    18311831                                old->location,
    18321832                                kind,
    1833                                 make_label(&label),
     1833                                make_label(&old->originalTarget),
    18341834                                GET_LABELS_V(old->labels)
    18351835                        );
Note: See TracChangeset for help on using the changeset viewer.