Ignore:
Timestamp:
Mar 14, 2023, 4:21:05 PM (3 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
1afd9ccb, 360bfe41, 6e6989c
Parents:
5217569 (diff), c19ca4b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r5217569 rdbae916  
    137137        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
    138138
    139         Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
     139        Expression * build() const {
     140                Expression * node = const_cast<ExpressionNode *>(this)->expr.release();
     141                node->set_extension( this->get_extension() );
     142                node->location = this->location;
     143                return node;
     144        }
    140145
    141146        std::unique_ptr<Expression> expr;                                       // public because of lifetime implications
     
    143148        bool extension = false;
    144149}; // ExpressionNode
    145 
    146 template< typename T >
    147 struct maybeBuild_t< Expression, T > {
    148         static inline Expression * doit( const T * orig ) {
    149                 if ( orig ) {
    150                         Expression * p = orig->build();
    151                         p->set_extension( orig->get_extension() );
    152                         p->location = orig->location;
    153                         return p;
    154                 } else {
    155                         return nullptr;
    156                 } // if
    157         }
    158 };
    159150
    160151// Must harmonize with OperName.
     
    199190Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind );
    200191Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node );
    201 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node );
    202192Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
    203193Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
     
    213203struct DeclarationNode : public ParseNode {
    214204        // These enumerations must harmonize with their names in DeclarationNode.cc.
    215         enum BasicType { Void, Bool, Char, Int, Int128,
    216                                          Float, Double, LongDouble, uuFloat80, uuFloat128,
    217                                          uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, NoBasicType };
     205        enum BasicType {
     206                Void, Bool, Char, Int, Int128,
     207                Float, Double, LongDouble, uuFloat80, uuFloat128,
     208                uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x,
     209                NoBasicType
     210        };
    218211        static const char * basicTypeNames[];
    219212        enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message
     
    401394
    402395struct ForCtrl {
    403         ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    404                 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    405         ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    406                 init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
     396        ForCtrl( StatementNode * stmt, ExpressionNode * condition, ExpressionNode * change ) :
     397                init( stmt ), condition( condition ), change( change ) {}
    407398
    408399        StatementNode * init;
     
    451442        while ( cur ) {
    452443                try {
    453                         SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild< typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) );
     444                        SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild( cur ) );
    454445                        if ( result ) {
    455446                                result->location = cur->location;
Note: See TracChangeset for help on using the changeset viewer.