Changeset 702e826 for src/Parser/ParseNode.h
- Timestamp:
- Mar 9, 2023, 2:37:53 PM (14 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- fed03b3
- Parents:
- a29477f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
ra29477f r702e826 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 … … 451 444 while ( cur ) { 452 445 try { 453 SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild < typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) );446 SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild( cur ) ); 454 447 if ( result ) { 455 448 result->location = cur->location;
Note: See TracChangeset
for help on using the changeset viewer.