Changes in src/Parser/ParseNode.h [25bca42:033ff37]
- File:
-
- 1 edited
-
src/Parser/ParseNode.h (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r25bca42 r033ff37 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 6 16:17:18 201813 // Update Count : 8 4312 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 876 14 14 // 15 15 … … 68 68 } 69 69 70 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}71 virtual void printList( std::ostream & os, int indent = 0 ) const {70 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 71 virtual void printList( std::ostream & os, int indent = 0 ) const { 72 72 print( os, indent ); 73 73 if ( next ) next->print( os, indent ); … … 103 103 InitializerNode * next_init() const { return kids; } 104 104 105 void print( std::ostream & os, int indent = 0 ) const;105 void print( std::ostream & os, int indent = 0 ) const; 106 106 void printOneLine( std::ostream & ) const; 107 107 … … 127 127 ExpressionNode * set_extension( bool exten ) { extension = exten; return this; } 128 128 129 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {130 os << expr.get() << std::endl;131 } 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}129 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override { 130 os << expr.get(); 131 } 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 133 133 134 134 template<typename T> … … 136 136 137 137 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); } 138 139 std::unique_ptr<Expression> expr; // public because of lifetime implications 138 140 private: 139 141 bool extension = false; 140 std::unique_ptr<Expression> expr;141 142 }; // ExpressionNode 142 143 … … 205 206 class DeclarationNode : public ParseNode { 206 207 public: 207 // These enumerations must harmonize with their names. 208 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, Int128, Float80, Float128, NoBasicType }; 208 // These enumerations must harmonize with their names in DeclarationNode.cc. 209 enum BasicType { Void, Bool, Char, Int, Int128, 210 Float, Double, LongDouble, uuFloat80, uuFloat128, 211 uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, NoBasicType }; 209 212 static const char * basicTypeNames[]; 210 enum ComplexType { Complex, Imaginary, NoComplexType };213 enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message 211 214 static const char * complexTypeNames[]; 212 215 enum Signedness { Signed, Unsigned, NoSignedness }; … … 218 221 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 219 222 static const char * typeClassNames[]; 220 enum BuiltinType { Valist, Zero, One, NoBuiltinType };223 enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType }; 221 224 static const char * builtinTypeNames[]; 222 225 … … 231 234 static DeclarationNode * newForall( DeclarationNode * ); 232 235 static DeclarationNode * newFromTypedef( const std::string * ); 236 static DeclarationNode * newFromGlobalScope(); 237 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 233 238 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 234 239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); … … 246 251 static DeclarationNode * newBitfield( ExpressionNode * size ); 247 252 static DeclarationNode * newTuple( DeclarationNode * members ); 248 static DeclarationNode * newTypeof( ExpressionNode * expr ); 249 static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes 250 static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes 253 static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false ); 251 254 static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 252 255 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement … … 288 291 } 289 292 290 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;291 virtual void printList( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;293 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override; 294 virtual void printList( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override; 292 295 293 296 Declaration * build() const; … … 301 304 bool get_extension() const { return extension; } 302 305 DeclarationNode * set_extension( bool exten ) { extension = exten; return this; } 306 307 bool get_inLine() const { return inLine; } 308 DeclarationNode * set_inLine( bool inL ) { inLine = inL; return this; } 303 309 public: 304 310 DeclarationNode * get_last() { return (DeclarationNode *)ParseNode::get_last(); } … … 325 331 StaticAssert_t assert; 326 332 327 BuiltinType builtin; 328 329 TypeData * type; 330 333 BuiltinType builtin = NoBuiltinType; 334 335 TypeData * type = nullptr; 336 337 bool inLine = false; 331 338 Type::FuncSpecifiers funcSpecs; 332 339 Type::StorageClasses storageClasses; 333 340 334 ExpressionNode * bitfieldWidth ;341 ExpressionNode * bitfieldWidth = nullptr; 335 342 std::unique_ptr<ExpressionNode> enumeratorValue; 336 bool hasEllipsis ;343 bool hasEllipsis = false; 337 344 LinkageSpec::Spec linkage; 338 Expression * asmName ;345 Expression * asmName = nullptr; 339 346 std::list< Attribute * > attributes; 340 InitializerNode * initializer ;347 InitializerNode * initializer = nullptr; 341 348 bool extension = false; 342 349 std::string error; 343 StatementNode * asmStmt ;350 StatementNode * asmStmt = nullptr; 344 351 345 352 static UniqueName anonymous; … … 375 382 virtual StatementNode * append_last_case( StatementNode * ); 376 383 377 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {384 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override { 378 385 os << stmt.get() << std::endl; 379 386 } … … 384 391 Statement * build_expr( ExpressionNode * ctl ); 385 392 386 struct IfCt l {387 IfCt l( DeclarationNode * decl, ExpressionNode * condition ) :393 struct IfCtrl { 394 IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) : 388 395 init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {} 389 396 … … 392 399 }; 393 400 394 struct ForCt l {395 ForCt l( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :401 struct ForCtrl { 402 ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) : 396 403 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 397 ForCt l( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :404 ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) : 398 405 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 399 406 … … 403 410 }; 404 411 405 Expression * build_if_control( IfCt l * ctl, std::list< Statement * > & init );406 Statement * build_if( IfCt l * ctl, StatementNode * then_stmt, StatementNode * else_stmt );412 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ); 413 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 407 414 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); 408 415 Statement * build_case( ExpressionNode * ctl ); 409 416 Statement * build_default(); 410 Statement * build_while( IfCt l * ctl, StatementNode * stmt );417 Statement * build_while( IfCtrl * ctl, StatementNode * stmt ); 411 418 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ); 412 Statement * build_for( ForCt l * forctl, StatementNode * stmt );419 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ); 413 420 Statement * build_branch( BranchStmt::Type kind ); 414 421 Statement * build_branch( std::string * identifier, BranchStmt::Type kind ); … … 428 435 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ); 429 436 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when ); 430 WithStmt * build_with( ExpressionNode * exprs, StatementNode * stmt );437 Statement * build_with( ExpressionNode * exprs, StatementNode * stmt ); 431 438 432 439 //############################################################################## 433 440 434 441 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 435 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) {442 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) { 436 443 SemanticErrorException errors; 437 444 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); … … 447 454 assertf(false, "buildList unknown type"); 448 455 } // if 449 } catch( SemanticErrorException & e ) {456 } catch( SemanticErrorException & e ) { 450 457 errors.append( e ); 451 458 } // try … … 458 465 459 466 // in DeclarationNode.cc 460 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList );461 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList );462 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList );467 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList ); 468 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList ); 469 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ); 463 470 464 471 template< typename SynTreeType, typename NodeType > 465 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) {472 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) { 466 473 buildList( firstNode, outputList ); 467 474 delete firstNode;
Note:
See TracChangeset
for help on using the changeset viewer.