Changeset b8524ca for src/AST


Ignore:
Timestamp:
Jun 20, 2019, 6:50:42 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
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:
9af00d23
Parents:
234b1cb
Message:

new AST porting

  • mostly InitTweak? autogeneration
  • added some convenience methods
    • nullptr assignment for ast::ptr
    • convenience wrapper ctors for AddressExpr?, CastExpr? that draw location from first arg
Location:
src/AST
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    r234b1cb rb8524ca  
    248248        AddressExpr( const CodeLocation & loc, const Expr * a );
    249249
     250        /// Generate AddressExpr wrapping given expression at same location
     251        AddressExpr( const Expr * a ) : AddressExpr( a->location, a ) {}
     252
    250253        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    251254private:
     
    281284        /// Cast-to-void
    282285        CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast );
     286
     287        /// Wrap a cast expression around an existing expression (always generated)
     288        CastExpr( const Expr * a, const Type * to ) : CastExpr( a->location, a, to, GeneratedCast ) {}
     289
     290        /// Wrap a cast-to-void expression around an existing expression (always generated)
     291        CastExpr( const Expr * a ) : CastExpr( a->location, a, GeneratedCast ) {}
    283292
    284293        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/Node.hpp

    r234b1cb rb8524ca  
    1717
    1818#include <cassert>
     19#include <cstddef>     // for nullptr_t
    1920#include <iosfwd>
    2021#include <type_traits> // for remove_reference
     
    181182        }
    182183
     184        ptr_base & operator=( std::nullptr_t ) {
     185                if ( node ) _dec(node);
     186                node = nullptr;
     187                return *this;
     188        }
     189
    183190        ptr_base & operator=( const ptr_base & o ) {
    184191                assign(o.node);
  • src/AST/Stmt.hpp

    r234b1cb rb8524ca  
    6161        CompoundStmt( CompoundStmt&& o ) = default;
    6262
    63         void push_back( Stmt * s ) { kids.emplace_back( s ); }
    64         void push_front( Stmt * s ) { kids.emplace_front( s ); }
     63        void push_back( const Stmt * s ) { kids.emplace_back( s ); }
     64        void push_front( const Stmt * s ) { kids.emplace_front( s ); }
    6565
    6666        const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.