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