Changeset dbae916 for src/Parser/ParseNode.h
- Timestamp:
- Mar 14, 2023, 4:21:05 PM (3 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r5217569 rdbae916 137 137 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } 138 138 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 } 140 145 141 146 std::unique_ptr<Expression> expr; // public because of lifetime implications … … 143 148 bool extension = false; 144 149 }; // 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 } // if157 }158 };159 150 160 151 // Must harmonize with OperName. … … 199 190 Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ); 200 191 Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ); 201 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node );202 192 Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ); 203 193 Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ); … … 213 203 struct DeclarationNode : public ParseNode { 214 204 // 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 }; 218 211 static const char * basicTypeNames[]; 219 212 enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message … … 401 394 402 395 struct 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 ) {} 407 398 408 399 StatementNode * init; … … 451 442 while ( cur ) { 452 443 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 ) ); 454 445 if ( result ) { 455 446 result->location = cur->location;
Note:
See TracChangeset
for help on using the changeset viewer.