Changeset 87701b6
- Timestamp:
- May 16, 2019, 4:13:19 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- e61207e7
- Parents:
- 1fb7bfd
- Location:
- src
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Attribute.hpp
r1fb7bfd r87701b6 50 50 /// Must be copied in ALL derived classes 51 51 template<typename node_t> 52 friend automutate(const node_t * node);52 friend node_t * mutate(const node_t * node); 53 53 }; 54 54 55 56 57 //=================================================================================================58 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency59 /// remove only if there is a better solution60 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with61 /// forward declarations62 inline void increment( const class Attribute * node, Node::ref_type ref ) { node->increment( ref ); }63 inline void decrement( const class Attribute * node, Node::ref_type ref ) { node->decrement( ref ); }64 55 } 65 56 -
src/AST/Convert.cpp
r1fb7bfd r87701b6 158 158 decl->parent = parent; 159 159 decl->body = old->body; 160 decl->param eters = params;160 decl->params = params; 161 161 decl->members = members; 162 162 decl->extension = old->extension; … … 181 181 decl->parent = parent; 182 182 decl->body = old->body; 183 decl->param eters = params;183 decl->params = params; 184 184 decl->members = members; 185 185 decl->extension = old->extension; … … 204 204 decl->parent = parent; 205 205 decl->body = old->body; 206 decl->param eters = params;206 decl->params = params; 207 207 decl->members = members; 208 208 decl->extension = old->extension; … … 230 230 231 231 decl->assertions = asserts; 232 decl->param eters= params;232 decl->params = params; 233 233 decl->extension = old->extension; 234 234 decl->uniqueId = old->uniqueId; -
src/AST/Decl.cpp
r1fb7bfd r87701b6 20 20 #include <unordered_map> 21 21 22 #include "Common/utility.h" 23 22 24 #include "Fwd.hpp" // for UniqueId 23 25 #include "Init.hpp" 24 26 #include "Node.hpp" // for readonly 27 #include "Type.hpp" // for readonly 25 28 #include "Parser/ParseNode.h" // for DeclarationNode 26 29 … … 47 50 // --- FunctionDecl 48 51 49 const Type * FunctionDecl::get_type() const override{ return type.get(); }50 void FunctionDecl::set_type(Type * t) override{ type = strict_dynamic_cast< FunctionType* >( t ); }52 const Type * FunctionDecl::get_type() const { return type.get(); } 53 void FunctionDecl::set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); } 51 54 52 55 // --- TypeDecl … … 75 78 const ObjectDecl* field = strict_dynamic_cast< const ObjectDecl* >( member ); 76 79 if ( field->init ) { 77 const SingleInit * init = strict_dynamic_cast< const SingleInit* >( field->init);80 const SingleInit * init = strict_dynamic_cast< const SingleInit* >( field->init.get() ); 78 81 auto result = eval( init->value ); 79 82 if ( ! result.second ) { -
src/AST/Decl.hpp
r1fb7bfd r87701b6 111 111 /// Must be copied in ALL derived classes 112 112 template<typename node_t> 113 friend automutate(const node_t * node);113 friend node_t * mutate(const node_t * node); 114 114 }; 115 115 … … 138 138 /// Must be copied in ALL derived classes 139 139 template<typename node_t> 140 friend automutate(const node_t * node);140 friend node_t * mutate(const node_t * node); 141 141 }; 142 142 … … 201 201 /// Must be copied in ALL derived classes 202 202 template<typename node_t> 203 friend automutate(const node_t * node);203 friend node_t * mutate(const node_t * node); 204 204 }; 205 205 … … 219 219 /// Must be copied in ALL derived classes 220 220 template<typename node_t> 221 friend automutate(const node_t * node);221 friend node_t * mutate(const node_t * node); 222 222 }; 223 223 … … 263 263 /// Must be copied in ALL derived classes 264 264 template<typename node_t> 265 friend automutate(const node_t * node);265 friend node_t * mutate(const node_t * node); 266 266 267 267 std::string typeString() const override { return "struct"; } … … 281 281 /// Must be copied in ALL derived classes 282 282 template<typename node_t> 283 friend automutate(const node_t * node);283 friend node_t * mutate(const node_t * node); 284 284 285 285 std::string typeString() const override { return "union"; } … … 302 302 /// Must be copied in ALL derived classes 303 303 template<typename node_t> 304 friend automutate(const node_t * node);304 friend node_t * mutate(const node_t * node); 305 305 306 306 std::string typeString() const override { return "enum"; } … … 323 323 /// Must be copied in ALL derived classes 324 324 template<typename node_t> 325 friend automutate(const node_t * node);325 friend node_t * mutate(const node_t * node); 326 326 327 327 std::string typeString() const override { return "trait"; } … … 341 341 /// Must be copied in ALL derived classes 342 342 template<typename node_t> 343 friend automutate(const node_t * node);343 friend node_t * mutate(const node_t * node); 344 344 }; 345 345 … … 358 358 /// Must be copied in ALL derived classes 359 359 template<typename node_t> 360 friend auto mutate(const node_t * node); 361 }; 362 363 //================================================================================================= 364 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency 365 /// remove only if there is a better solution 366 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with 367 /// forward declarations 368 inline void increment( const class Decl * node, Node::ref_type ref ) { node->increment(ref); } 369 inline void decrement( const class Decl * node, Node::ref_type ref ) { node->decrement(ref); } 370 inline void increment( const class DeclWithType * node, Node::ref_type ref ) { node->increment(ref); } 371 inline void decrement( const class DeclWithType * node, Node::ref_type ref ) { node->decrement(ref); } 372 inline void increment( const class ObjectDecl * node, Node::ref_type ref ) { node->increment(ref); } 373 inline void decrement( const class ObjectDecl * node, Node::ref_type ref ) { node->decrement(ref); } 374 inline void increment( const class FunctionDecl * node, Node::ref_type ref ) { node->increment(ref); } 375 inline void decrement( const class FunctionDecl * node, Node::ref_type ref ) { node->decrement(ref); } 376 inline void increment( const class AggregateDecl * node, Node::ref_type ref ) { node->increment(ref); } 377 inline void decrement( const class AggregateDecl * node, Node::ref_type ref ) { node->decrement(ref); } 378 inline void increment( const class StructDecl * node, Node::ref_type ref ) { node->increment(ref); } 379 inline void decrement( const class StructDecl * node, Node::ref_type ref ) { node->decrement(ref); } 380 inline void increment( const class UnionDecl * node, Node::ref_type ref ) { node->increment(ref); } 381 inline void decrement( const class UnionDecl * node, Node::ref_type ref ) { node->decrement(ref); } 382 inline void increment( const class EnumDecl * node, Node::ref_type ref ) { node->increment(ref); } 383 inline void decrement( const class EnumDecl * node, Node::ref_type ref ) { node->decrement(ref); } 384 inline void increment( const class TraitDecl * node, Node::ref_type ref ) { node->increment(ref); } 385 inline void decrement( const class TraitDecl * node, Node::ref_type ref ) { node->decrement(ref); } 386 inline void increment( const class NamedTypeDecl * node, Node::ref_type ref ) { node->increment(ref); } 387 inline void decrement( const class NamedTypeDecl * node, Node::ref_type ref ) { node->decrement(ref); } 388 inline void increment( const class TypeDecl * node, Node::ref_type ref ) { node->increment(ref); } 389 inline void decrement( const class TypeDecl * node, Node::ref_type ref ) { node->decrement(ref); } 390 inline void increment( const class TypedefDecl * node, Node::ref_type ref ) { node->increment(ref); } 391 inline void decrement( const class TypedefDecl * node, Node::ref_type ref ) { node->decrement(ref); } 392 inline void increment( const class AsmDecl * node, Node::ref_type ref ) { node->increment(ref); } 393 inline void decrement( const class AsmDecl * node, Node::ref_type ref ) { node->decrement(ref); } 394 inline void increment( const class StaticAssertDecl * node, Node::ref_type ref ) { node->increment(ref); } 395 inline void decrement( const class StaticAssertDecl * node, Node::ref_type ref ) { node->decrement(ref); } 360 friend node_t * mutate(const node_t * node); 361 }; 396 362 397 363 } -
src/AST/Expr.cpp
r1fb7bfd r87701b6 30 30 // --- ApplicationExpr 31 31 32 ApplicationExpr::ApplicationExpr( const CodeLocation & loc, const Expr * f, 33 std::vector<ptr<Expr>> && as ) 34 : Expr( loc ), func( f ), args( std::move(a rgs) ) {32 ApplicationExpr::ApplicationExpr( const CodeLocation & loc, const Expr * f, 33 std::vector<ptr<Expr>> && as ) 34 : Expr( loc ), func( f ), args( std::move(as) ) { 35 35 // ensure that `ApplicationExpr` result type is `FuncExpr` 36 36 const PointerType * pt = strict_dynamic_cast< const PointerType * >( f->result.get() ); … … 46 46 assert( arg ); 47 47 48 UntypedExpr * ret = new UntypedExpr{ 49 loc, new NameExpr{loc, "*?"}, std::vector<ptr<Expr>>{ ptr<Expr>{ arg } } 48 UntypedExpr * ret = new UntypedExpr{ 49 loc, new NameExpr{loc, "*?"}, std::vector<ptr<Expr>>{ ptr<Expr>{ arg } } 50 50 }; 51 51 if ( const Type * ty = arg->result ) { … … 57 57 ret->result = new ReferenceType{ base }; 58 58 } else { 59 // references have been removed, in which case dereference returns an lvalue of the 59 // references have been removed, in which case dereference returns an lvalue of the 60 60 // base type 61 61 ret->result.set_and_mutate( base )->set_lvalue( true ); … … 110 110 } else { 111 111 // taking address of non-lvalue, must be a reference, loses one layer of reference 112 if ( const ReferenceType * refType = 112 if ( const ReferenceType * refType = 113 113 dynamic_cast< const ReferenceType * >( arg->result.get() ) ) { 114 114 Type * res = addrType( refType->base ); … … 116 116 result = res; 117 117 } else { 118 SemanticError( loc, arg->result, 118 SemanticError( loc, arg->result, 119 119 "Attempt to take address of non-lvalue expression: " ); 120 120 } … … 126 126 127 127 // label address always has type `void*` 128 LabelAddressExpr::LabelAddressExpr( const CodeLocation & loc, Label && a ) 128 LabelAddressExpr::LabelAddressExpr( const CodeLocation & loc, Label && a ) 129 129 : Expr( loc, new PointerType{ new VoidType{} } ), arg( a ) {} 130 130 131 131 // --- CastExpr 132 132 133 CastExpr::CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g ) 133 CastExpr::CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g ) 134 134 : Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ) {} 135 135 … … 167 167 } 168 168 169 VariableExpr * VariableExpr::functionPointer( 169 VariableExpr * VariableExpr::functionPointer( 170 170 const CodeLocation & loc, const FunctionDecl * decl ) { 171 171 // wrap usually-determined result type in a pointer … … 200 200 201 201 ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) { 202 return new ConstantExpr{ 202 return new ConstantExpr{ 203 203 loc, new BasicType{ BasicType::Bool }, b ? "1" : "0", (unsigned long long)b }; 204 204 } 205 205 206 206 ConstantExpr * ConstantExpr::from_char( const CodeLocation & loc, char c ) { 207 return new ConstantExpr{ 207 return new ConstantExpr{ 208 208 loc, new BasicType{ BasicType::Char }, std::to_string( c ), (unsigned long long)c }; 209 209 } 210 210 211 211 ConstantExpr * ConstantExpr::from_int( const CodeLocation & loc, int i ) { 212 return new ConstantExpr{ 212 return new ConstantExpr{ 213 213 loc, new BasicType{ BasicType::SignedInt }, std::to_string( i ), (unsigned long long)i }; 214 214 } 215 215 216 216 ConstantExpr * ConstantExpr::from_ulong( const CodeLocation & loc, unsigned long i ) { 217 return new ConstantExpr{ 218 loc, new BasicType{ BasicType::LongUnsignedInt }, std::to_string( i ), 217 return new ConstantExpr{ 218 loc, new BasicType{ BasicType::LongUnsignedInt }, std::to_string( i ), 219 219 (unsigned long long)i }; 220 220 } … … 227 227 return new ConstantExpr{ 228 228 loc, 229 new ArrayType{ 229 new ArrayType{ 230 230 new BasicType{ BasicType::Char, CV::Const }, 231 231 ConstantExpr::from_int( loc, s.size() + 1 /* null terminator */ ), … … 258 258 // --- UntypedOffsetofExpr 259 259 260 UntypedOffsetofExpr::UntypedOffsetofExpr( 260 UntypedOffsetofExpr::UntypedOffsetofExpr( 261 261 const CodeLocation & loc, const Type * ty, const std::string & mem ) 262 262 : Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), type( ty ), member( mem ) { … … 275 275 276 276 OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty ) 277 : Expr( loc, new ArrayType{ 278 new BasicType{ BasicType::LongUnsignedInt }, nullptr, FixedLen, DynamicDim } 277 : Expr( loc, new ArrayType{ 278 new BasicType{ BasicType::LongUnsignedInt }, nullptr, FixedLen, DynamicDim } 279 279 ), type( ty ) { 280 280 assert( type ); … … 283 283 // --- LogicalExpr 284 284 285 LogicalExpr::LogicalExpr( 285 LogicalExpr::LogicalExpr( 286 286 const CodeLocation & loc, const Expr * a1, const Expr * a2, LogicalFlag ia ) 287 287 : Expr( loc, new BasicType{ BasicType::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {} -
src/AST/Expr.hpp
r1fb7bfd r87701b6 129 129 }; 130 130 131 /// The application of a function to a set of parameters. 131 /// The application of a function to a set of parameters. 132 132 /// Post-resolver form of `UntypedExpr` 133 133 class ApplicationExpr final : public Expr { … … 209 209 GeneratedFlag isGenerated; 210 210 211 CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 211 CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 212 212 GeneratedFlag g = GeneratedCast ) : Expr( loc, to ), arg( a ), isGenerated( g ) {} 213 213 /// Cast-to-void … … 296 296 unsigned long long ival; 297 297 double dval; 298 298 299 299 Val( unsigned long long i ) : ival( i ) {} 300 300 Val( double d ) : dval( d ) {} … … 303 303 std::string rep; 304 304 305 ConstantExpr( 305 ConstantExpr( 306 306 const CodeLocation & loc, const Type * ty, const std::string & r, unsigned long long v ) 307 307 : Expr( loc, ty ), val( v ), rep( r ) {} 308 308 ConstantExpr( const CodeLocation & loc, const Type * ty, const std::string & r, double v ) 309 309 : Expr( loc, ty ), val( v ), rep( r ) {} 310 310 311 311 /// Gets the value of this constant as an integer 312 312 long long int intValue() const; … … 441 441 ptr<Expr> arg2; 442 442 443 CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 443 CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 444 444 : Expr( loc ), arg1( a1 ), arg2( a2 ) {} 445 445 … … 466 466 public: 467 467 ptr<Expr> inout; 468 ptr<Expr> constraint; 469 }; 470 471 //================================================================================================= 472 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency 473 /// remove only if there is a better solution 474 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with 475 /// forward declarations 476 inline void increment( const class Expr * node, Node::ref_type ref ) { node->increment(ref); } 477 inline void decrement( const class Expr * node, Node::ref_type ref ) { node->decrement(ref); } 478 inline void increment( const class ApplicationExpr * node, Node::ref_type ref ) { node->increment(ref); } 479 inline void decrement( const class ApplicationExpr * node, Node::ref_type ref ) { node->decrement(ref); } 480 inline void increment( const class UntypedExpr * node, Node::ref_type ref ) { node->increment(ref); } 481 inline void decrement( const class UntypedExpr * node, Node::ref_type ref ) { node->decrement(ref); } 482 inline void increment( const class NameExpr * node, Node::ref_type ref ) { node->increment(ref); } 483 inline void decrement( const class NameExpr * node, Node::ref_type ref ) { node->decrement(ref); } 484 inline void increment( const class AddressExpr * node, Node::ref_type ref ) { node->increment(ref); } 485 inline void decrement( const class AddressExpr * node, Node::ref_type ref ) { node->decrement(ref); } 486 inline void increment( const class LabelAddressExpr * node, Node::ref_type ref ) { node->increment(ref); } 487 inline void decrement( const class LabelAddressExpr * node, Node::ref_type ref ) { node->decrement(ref); } 488 inline void increment( const class CastExpr * node, Node::ref_type ref ) { node->increment(ref); } 489 inline void decrement( const class CastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 490 inline void increment( const class KeywordCastExpr * node, Node::ref_type ref ) { node->increment(ref); } 491 inline void decrement( const class KeywordCastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 492 inline void increment( const class VirtualCastExpr * node, Node::ref_type ref ) { node->increment(ref); } 493 inline void decrement( const class VirtualCastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 494 inline void increment( const class MemberExpr * node, Node::ref_type ref ) { node->increment(ref); } 495 inline void decrement( const class MemberExpr * node, Node::ref_type ref ) { node->decrement(ref); } 496 inline void increment( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->increment(ref); } 497 inline void decrement( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->decrement(ref); } 498 inline void increment( const class VariableExpr * node, Node::ref_type ref ) { node->increment(ref); } 499 inline void decrement( const class VariableExpr * node, Node::ref_type ref ) { node->decrement(ref); } 500 inline void increment( const class ConstantExpr * node, Node::ref_type ref ) { node->increment(ref); } 501 inline void decrement( const class ConstantExpr * node, Node::ref_type ref ) { node->decrement(ref); } 502 inline void increment( const class SizeofExpr * node, Node::ref_type ref ) { node->increment(ref); } 503 inline void decrement( const class SizeofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 504 inline void increment( const class AlignofExpr * node, Node::ref_type ref ) { node->increment(ref); } 505 inline void decrement( const class AlignofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 506 inline void increment( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); } 507 inline void decrement( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 508 inline void increment( const class OffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); } 509 inline void decrement( const class OffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 510 inline void increment( const class OffsetPackExpr * node, Node::ref_type ref ) { node->increment(ref); } 511 inline void decrement( const class OffsetPackExpr * node, Node::ref_type ref ) { node->decrement(ref); } 512 inline void increment( const class LogicalExpr * node, Node::ref_type ref ) { node->increment(ref); } 513 inline void decrement( const class LogicalExpr * node, Node::ref_type ref ) { node->decrement(ref); } 514 inline void increment( const class ConditionalExpr * node, Node::ref_type ref ) { node->increment(ref); } 515 inline void decrement( const class ConditionalExpr * node, Node::ref_type ref ) { node->decrement(ref); } 516 inline void increment( const class CommaExpr * node, Node::ref_type ref ) { node->increment(ref); } 517 inline void decrement( const class CommaExpr * node, Node::ref_type ref ) { node->decrement(ref); } 518 inline void increment( const class TypeExpr * node, Node::ref_type ref ) { node->increment(ref); } 519 inline void decrement( const class TypeExpr * node, Node::ref_type ref ) { node->decrement(ref); } 520 inline void increment( const class AsmExpr * node, Node::ref_type ref ) { node->increment(ref); } 521 inline void decrement( const class AsmExpr * node, Node::ref_type ref ) { node->decrement(ref); } 522 // inline void increment( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->increment(ref); } 523 // inline void decrement( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->decrement(ref); } 524 // inline void increment( const class ConstructorExpr * node, Node::ref_type ref ) { node->increment(ref); } 525 // inline void decrement( const class ConstructorExpr * node, Node::ref_type ref ) { node->decrement(ref); } 526 // inline void increment( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->increment(ref); } 527 // inline void decrement( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->decrement(ref); } 528 // inline void increment( const class UntypedValofExpr * node, Node::ref_type ref ) { node->increment(ref); } 529 // inline void decrement( const class UntypedValofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 530 // inline void increment( const class RangeExpr * node, Node::ref_type ref ) { node->increment(ref); } 531 // inline void decrement( const class RangeExpr * node, Node::ref_type ref ) { node->decrement(ref); } 532 // inline void increment( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->increment(ref); } 533 // inline void decrement( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->decrement(ref); } 534 // inline void increment( const class TupleExpr * node, Node::ref_type ref ) { node->increment(ref); } 535 // inline void decrement( const class TupleExpr * node, Node::ref_type ref ) { node->decrement(ref); } 536 // inline void increment( const class TupleIndexExpr * node, Node::ref_type ref ) { node->increment(ref); } 537 // inline void decrement( const class TupleIndexExpr * node, Node::ref_type ref ) { node->decrement(ref); } 538 // inline void increment( const class TupleAssignExpr * node, Node::ref_type ref ) { node->increment(ref); } 539 // inline void decrement( const class TupleAssignExpr * node, Node::ref_type ref ) { node->decrement(ref); } 540 // inline void increment( const class StmtExpr * node, Node::ref_type ref ) { node->increment(ref); } 541 // inline void decrement( const class StmtExpr * node, Node::ref_type ref ) { node->decrement(ref); } 542 // inline void increment( const class UniqueExpr * node, Node::ref_type ref ) { node->increment(ref); } 543 // inline void decrement( const class UniqueExpr * node, Node::ref_type ref ) { node->decrement(ref); } 544 // inline void increment( const class UntypedInitExpr * node, Node::ref_type ref ) { node->increment(ref); } 545 // inline void decrement( const class UntypedInitExpr * node, Node::ref_type ref ) { node->decrement(ref); } 546 // inline void increment( const class InitExpr * node, Node::ref_type ref ) { node->increment(ref); } 547 // inline void decrement( const class InitExpr * node, Node::ref_type ref ) { node->decrement(ref); } 548 // inline void increment( const class DeletedExpr * node, Node::ref_type ref ) { node->increment(ref); } 549 // inline void decrement( const class DeletedExpr * node, Node::ref_type ref ) { node->decrement(ref); } 550 // inline void increment( const class DefaultArgExpr * node, Node::ref_type ref ) { node->increment(ref); } 551 // inline void decrement( const class DefaultArgExpr * node, Node::ref_type ref ) { node->decrement(ref); } 552 // inline void increment( const class GenericExpr * node, Node::ref_type ref ) { node->increment(ref); } 553 // inline void decrement( const class GenericExpr * node, Node::ref_type ref ) { node->decrement(ref); } 468 ptr<Expr> constraint; 469 }; 470 554 471 } 555 472 -
src/AST/Fwd.hpp
r1fb7bfd r87701b6 136 136 std::string toString( const Node * ); 137 137 138 //=================================================================================================139 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency140 /// remove only if there is a better solution141 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with142 /// forward declarations143 inline void decrement( const class Node * node, Node::ref_type ref ) { node->decrement(ref); }144 inline void increment( const class Node * node, Node::ref_type ref ) { node->increment(ref); }145 inline void increment( const class ParseNode *, Node::ref_type );146 inline void decrement( const class ParseNode *, Node::ref_type );147 inline void increment( const class Decl *, Node::ref_type );148 inline void decrement( const class Decl *, Node::ref_type );149 inline void increment( const class DeclWithType *, Node::ref_type );150 inline void decrement( const class DeclWithType *, Node::ref_type );151 inline void increment( const class ObjectDecl *, Node::ref_type );152 inline void decrement( const class ObjectDecl *, Node::ref_type );153 inline void increment( const class FunctionDecl *, Node::ref_type );154 inline void decrement( const class FunctionDecl *, Node::ref_type );155 inline void increment( const class AggregateDecl *, Node::ref_type );156 inline void decrement( const class AggregateDecl *, Node::ref_type );157 inline void increment( const class StructDecl *, Node::ref_type );158 inline void decrement( const class StructDecl *, Node::ref_type );159 inline void increment( const class UnionDecl *, Node::ref_type );160 inline void decrement( const class UnionDecl *, Node::ref_type );161 inline void increment( const class EnumDecl *, Node::ref_type );162 inline void decrement( const class EnumDecl *, Node::ref_type );163 inline void increment( const class TraitDecl *, Node::ref_type );164 inline void decrement( const class TraitDecl *, Node::ref_type );165 inline void increment( const class NamedTypeDecl *, Node::ref_type );166 inline void decrement( const class NamedTypeDecl *, Node::ref_type );167 inline void increment( const class TypeDecl *, Node::ref_type );168 inline void decrement( const class TypeDecl *, Node::ref_type );169 inline void increment( const class TypedefDecl *, Node::ref_type );170 inline void decrement( const class TypedefDecl *, Node::ref_type );171 inline void increment( const class AsmDecl *, Node::ref_type );172 inline void decrement( const class AsmDecl *, Node::ref_type );173 inline void increment( const class StaticAssertDecl *, Node::ref_type );174 inline void decrement( const class StaticAssertDecl *, Node::ref_type );175 inline void increment( const class Stmt *, Node::ref_type );176 inline void decrement( const class Stmt *, Node::ref_type );177 inline void increment( const class CompoundStmt *, Node::ref_type );178 inline void decrement( const class CompoundStmt *, Node::ref_type );179 inline void increment( const class ExprStmt *, Node::ref_type );180 inline void decrement( const class ExprStmt *, Node::ref_type );181 inline void increment( const class AsmStmt *, Node::ref_type );182 inline void decrement( const class AsmStmt *, Node::ref_type );183 inline void increment( const class DirectiveStmt *, Node::ref_type );184 inline void decrement( const class DirectiveStmt *, Node::ref_type );185 inline void increment( const class IfStmt *, Node::ref_type );186 inline void decrement( const class IfStmt *, Node::ref_type );187 inline void increment( const class WhileStmt *, Node::ref_type );188 inline void decrement( const class WhileStmt *, Node::ref_type );189 inline void increment( const class ForStmt *, Node::ref_type );190 inline void decrement( const class ForStmt *, Node::ref_type );191 inline void increment( const class SwitchStmt *, Node::ref_type );192 inline void decrement( const class SwitchStmt *, Node::ref_type );193 inline void increment( const class CaseStmt *, Node::ref_type );194 inline void decrement( const class CaseStmt *, Node::ref_type );195 inline void increment( const class BranchStmt *, Node::ref_type );196 inline void decrement( const class BranchStmt *, Node::ref_type );197 inline void increment( const class ReturnStmt *, Node::ref_type );198 inline void decrement( const class ReturnStmt *, Node::ref_type );199 inline void increment( const class ThrowStmt *, Node::ref_type );200 inline void decrement( const class ThrowStmt *, Node::ref_type );201 inline void increment( const class TryStmt *, Node::ref_type );202 inline void decrement( const class TryStmt *, Node::ref_type );203 inline void increment( const class CatchStmt *, Node::ref_type );204 inline void decrement( const class CatchStmt *, Node::ref_type );205 inline void increment( const class FinallyStmt *, Node::ref_type );206 inline void decrement( const class FinallyStmt *, Node::ref_type );207 inline void increment( const class WaitForStmt *, Node::ref_type );208 inline void decrement( const class WaitForStmt *, Node::ref_type );209 inline void increment( const class WithStmt *, Node::ref_type );210 inline void decrement( const class WithStmt *, Node::ref_type );211 inline void increment( const class DeclStmt *, Node::ref_type );212 inline void decrement( const class DeclStmt *, Node::ref_type );213 inline void increment( const class NullStmt *, Node::ref_type );214 inline void decrement( const class NullStmt *, Node::ref_type );215 inline void increment( const class ImplicitCtorDtorStmt *, Node::ref_type );216 inline void decrement( const class ImplicitCtorDtorStmt *, Node::ref_type );217 inline void increment( const class Expr *, Node::ref_type );218 inline void decrement( const class Expr *, Node::ref_type );219 inline void increment( const class ApplicationExpr *, Node::ref_type );220 inline void decrement( const class ApplicationExpr *, Node::ref_type );221 inline void increment( const class UntypedExpr *, Node::ref_type );222 inline void decrement( const class UntypedExpr *, Node::ref_type );223 inline void increment( const class NameExpr *, Node::ref_type );224 inline void decrement( const class NameExpr *, Node::ref_type );225 inline void increment( const class AddressExpr *, Node::ref_type );226 inline void decrement( const class AddressExpr *, Node::ref_type );227 inline void increment( const class LabelAddressExpr *, Node::ref_type );228 inline void decrement( const class LabelAddressExpr *, Node::ref_type );229 inline void increment( const class CastExpr *, Node::ref_type );230 inline void decrement( const class CastExpr *, Node::ref_type );231 inline void increment( const class KeywordCastExpr *, Node::ref_type );232 inline void decrement( const class KeywordCastExpr *, Node::ref_type );233 inline void increment( const class VirtualCastExpr *, Node::ref_type );234 inline void decrement( const class VirtualCastExpr *, Node::ref_type );235 inline void increment( const class MemberExpr *, Node::ref_type );236 inline void decrement( const class MemberExpr *, Node::ref_type );237 inline void increment( const class UntypedMemberExpr *, Node::ref_type );238 inline void decrement( const class UntypedMemberExpr *, Node::ref_type );239 inline void increment( const class VariableExpr *, Node::ref_type );240 inline void decrement( const class VariableExpr *, Node::ref_type );241 inline void increment( const class ConstantExpr *, Node::ref_type );242 inline void decrement( const class ConstantExpr *, Node::ref_type );243 inline void increment( const class SizeofExpr *, Node::ref_type );244 inline void decrement( const class SizeofExpr *, Node::ref_type );245 inline void increment( const class AlignofExpr *, Node::ref_type );246 inline void decrement( const class AlignofExpr *, Node::ref_type );247 inline void increment( const class UntypedOffsetofExpr *, Node::ref_type );248 inline void decrement( const class UntypedOffsetofExpr *, Node::ref_type );249 inline void increment( const class OffsetofExpr *, Node::ref_type );250 inline void decrement( const class OffsetofExpr *, Node::ref_type );251 inline void increment( const class OffsetPackExpr *, Node::ref_type );252 inline void decrement( const class OffsetPackExpr *, Node::ref_type );253 inline void increment( const class LogicalExpr *, Node::ref_type );254 inline void decrement( const class LogicalExpr *, Node::ref_type );255 inline void increment( const class ConditionalExpr *, Node::ref_type );256 inline void decrement( const class ConditionalExpr *, Node::ref_type );257 inline void increment( const class CommaExpr *, Node::ref_type );258 inline void decrement( const class CommaExpr *, Node::ref_type );259 inline void increment( const class TypeExpr *, Node::ref_type );260 inline void decrement( const class TypeExpr *, Node::ref_type );261 inline void increment( const class AsmExpr *, Node::ref_type );262 inline void decrement( const class AsmExpr *, Node::ref_type );263 inline void increment( const class ImplicitCopyCtorExpr *, Node::ref_type );264 inline void decrement( const class ImplicitCopyCtorExpr *, Node::ref_type );265 inline void increment( const class ConstructorExpr *, Node::ref_type );266 inline void decrement( const class ConstructorExpr *, Node::ref_type );267 inline void increment( const class CompoundLiteralExpr *, Node::ref_type );268 inline void decrement( const class CompoundLiteralExpr *, Node::ref_type );269 inline void increment( const class UntypedValofExpr *, Node::ref_type );270 inline void decrement( const class UntypedValofExpr *, Node::ref_type );271 inline void increment( const class RangeExpr *, Node::ref_type );272 inline void decrement( const class RangeExpr *, Node::ref_type );273 inline void increment( const class UntypedTupleExpr *, Node::ref_type );274 inline void decrement( const class UntypedTupleExpr *, Node::ref_type );275 inline void increment( const class TupleExpr *, Node::ref_type );276 inline void decrement( const class TupleExpr *, Node::ref_type );277 inline void increment( const class TupleIndexExpr *, Node::ref_type );278 inline void decrement( const class TupleIndexExpr *, Node::ref_type );279 inline void increment( const class TupleAssignExpr *, Node::ref_type );280 inline void decrement( const class TupleAssignExpr *, Node::ref_type );281 inline void increment( const class StmtExpr *, Node::ref_type );282 inline void decrement( const class StmtExpr *, Node::ref_type );283 inline void increment( const class UniqueExpr *, Node::ref_type );284 inline void decrement( const class UniqueExpr *, Node::ref_type );285 inline void increment( const class UntypedInitExpr *, Node::ref_type );286 inline void decrement( const class UntypedInitExpr *, Node::ref_type );287 inline void increment( const class InitExpr *, Node::ref_type );288 inline void decrement( const class InitExpr *, Node::ref_type );289 inline void increment( const class DeletedExpr *, Node::ref_type );290 inline void decrement( const class DeletedExpr *, Node::ref_type );291 inline void increment( const class DefaultArgExpr *, Node::ref_type );292 inline void decrement( const class DefaultArgExpr *, Node::ref_type );293 inline void increment( const class GenericExpr *, Node::ref_type );294 inline void decrement( const class GenericExpr *, Node::ref_type );295 inline void increment( const class Type *, Node::ref_type );296 inline void decrement( const class Type *, Node::ref_type );297 inline void increment( const class VoidType *, Node::ref_type );298 inline void decrement( const class VoidType *, Node::ref_type );299 inline void increment( const class BasicType *, Node::ref_type );300 inline void decrement( const class BasicType *, Node::ref_type );301 inline void increment( const class PointerType *, Node::ref_type );302 inline void decrement( const class PointerType *, Node::ref_type );303 inline void increment( const class ArrayType *, Node::ref_type );304 inline void decrement( const class ArrayType *, Node::ref_type );305 inline void increment( const class ReferenceType *, Node::ref_type );306 inline void decrement( const class ReferenceType *, Node::ref_type );307 inline void increment( const class QualifiedType *, Node::ref_type );308 inline void decrement( const class QualifiedType *, Node::ref_type );309 inline void increment( const class FunctionType *, Node::ref_type );310 inline void decrement( const class FunctionType *, Node::ref_type );311 inline void increment( const class ReferenceToType *, Node::ref_type );312 inline void decrement( const class ReferenceToType *, Node::ref_type );313 inline void increment( const class StructInstType *, Node::ref_type );314 inline void decrement( const class StructInstType *, Node::ref_type );315 inline void increment( const class UnionInstType *, Node::ref_type );316 inline void decrement( const class UnionInstType *, Node::ref_type );317 inline void increment( const class EnumInstType *, Node::ref_type );318 inline void decrement( const class EnumInstType *, Node::ref_type );319 inline void increment( const class TraitInstType *, Node::ref_type );320 inline void decrement( const class TraitInstType *, Node::ref_type );321 inline void increment( const class TypeInstType *, Node::ref_type );322 inline void decrement( const class TypeInstType *, Node::ref_type );323 inline void increment( const class TupleType *, Node::ref_type );324 inline void decrement( const class TupleType *, Node::ref_type );325 inline void increment( const class TypeofType *, Node::ref_type );326 inline void decrement( const class TypeofType *, Node::ref_type );327 inline void increment( const class VarArgsType *, Node::ref_type );328 inline void decrement( const class VarArgsType *, Node::ref_type );329 inline void increment( const class ZeroType *, Node::ref_type );330 inline void decrement( const class ZeroType *, Node::ref_type );331 inline void increment( const class OneType *, Node::ref_type );332 inline void decrement( const class OneType *, Node::ref_type );333 inline void increment( const class GlobalScopeType *, Node::ref_type );334 inline void decrement( const class GlobalScopeType *, Node::ref_type );335 inline void increment( const class Designation *, Node::ref_type );336 inline void decrement( const class Designation *, Node::ref_type );337 inline void increment( const class Init *, Node::ref_type );338 inline void decrement( const class Init *, Node::ref_type );339 inline void increment( const class SingleInit *, Node::ref_type );340 inline void decrement( const class SingleInit *, Node::ref_type );341 inline void increment( const class ListInit *, Node::ref_type );342 inline void decrement( const class ListInit *, Node::ref_type );343 inline void increment( const class ConstructorInit *, Node::ref_type );344 inline void decrement( const class ConstructorInit *, Node::ref_type );345 inline void increment( const class Constant *, Node::ref_type );346 inline void decrement( const class Constant *, Node::ref_type );347 inline void increment( const class Attribute *, Node::ref_type );348 inline void decrement( const class Attribute *, Node::ref_type );349 inline void increment( const class TypeSubstitution *, Node::ref_type );350 inline void decrement( const class TypeSubstitution *, Node::ref_type );351 352 138 typedef unsigned int UniqueId; 353 139 -
src/AST/Init.cpp
r1fb7bfd r87701b6 22 22 namespace ast { 23 23 24 ListInit::ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is, 25 std::vector<ptr<Designation>>&& ds, boolmc)24 ListInit::ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is, 25 std::vector<ptr<Designation>>&& ds, ConstructFlag mc) 26 26 : Init( loc, mc ), initializers( std::move(is) ), designations( std::move(ds) ) { 27 // handle common case where ListInit is created without designations by making an 27 // handle common case where ListInit is created without designations by making an 28 28 // equivalent-length empty list 29 29 if ( designations.empty() ) { … … 32 32 } 33 33 } 34 34 35 35 assertf( initializers.size() == designations.size(), "Created ListInit with mismatching " 36 36 "initializers (%zd) and designations (%zd)", initializers.size(), designations.size() ); -
src/AST/Init.hpp
r1fb7bfd r87701b6 54 54 const Init * accept( Visitor& v ) const override = 0; 55 55 private: 56 constInit * clone() const override = 0;56 Init * clone() const override = 0; 57 57 }; 58 58 … … 72 72 /// Must be copied in ALL derived classes 73 73 template<typename node_t> 74 friend automutate(const node_t * node);74 friend node_t * mutate(const node_t * node); 75 75 }; 76 76 … … 100 100 /// Must be copied in ALL derived classes 101 101 template<typename node_t> 102 friend automutate(const node_t * node);102 friend node_t * mutate(const node_t * node); 103 103 }; 104 104 … … 123 123 /// Must be copied in ALL derived classes 124 124 template<typename node_t> 125 friend automutate(const node_t * node);125 friend node_t * mutate(const node_t * node); 126 126 }; 127 127 128 129 //=================================================================================================130 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency131 /// remove only if there is a better solution132 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with133 /// forward declarations134 inline void increment( const class Init * node, Node::ref_type ref ) { node->increment( ref ); }135 inline void decrement( const class Init * node, Node::ref_type ref ) { node->decrement( ref ); }136 inline void increment( const class SingleInit * node, Node::ref_type ref ) { node->increment( ref ); }137 inline void decrement( const class SingleInit * node, Node::ref_type ref ) { node->decrement( ref ); }138 inline void increment( const class ListInit * node, Node::ref_type ref ) { node->increment( ref ); }139 inline void decrement( const class ListInit * node, Node::ref_type ref ) { node->decrement( ref ); }140 inline void increment( const class ConstructorInit * node, Node::ref_type ref ) { node->increment( ref ); }141 inline void decrement( const class ConstructorInit * node, Node::ref_type ref ) { node->decrement( ref ); }142 128 } 143 129 -
src/AST/LinkageSpec.cpp
r1fb7bfd r87701b6 43 43 44 44 std::string name( Spec spec ) { 45 switch ( spec ) {46 case Intrinsic : return "intrinsic";47 case C : return "C";48 case Cforall : return "Cforall";49 case AutoGen : return "autogenerated cfa";50 case Compiler : return "compiler built-in";51 case BuiltinCFA : return "cfa built-in";52 case BuiltinC : return "c built-in";45 switch ( spec.val ) { 46 case Intrinsic.val: return "intrinsic"; 47 case C.val: return "C"; 48 case Cforall.val: return "Cforall"; 49 case AutoGen.val: return "autogenerated cfa"; 50 case Compiler.val: return "compiler built-in"; 51 case BuiltinCFA.val: return "cfa built-in"; 52 case BuiltinC.val: return "c built-in"; 53 53 default: return "<unnamed linkage spec>"; 54 54 } -
src/AST/Node.hpp
r1fb7bfd r87701b6 44 44 }; 45 45 46 inline void increment(ref_type ref) const { 46 private: 47 /// Make a copy of this node; should be overridden in subclass with more precise return type 48 virtual Node * clone() const = 0; 49 50 /// Must be copied in ALL derived classes 51 template<typename node_t> 52 friend node_t * mutate(const node_t * node); 53 54 mutable size_t strong_count = 0; 55 mutable size_t weak_count = 0; 56 57 void increment(ref_type ref) const { 47 58 switch (ref) { 48 59 case ref_type::strong: strong_count++; break; … … 51 62 } 52 63 53 inline void decrement(ref_type ref) const {64 void decrement(ast::Node::ref_type ref) const { 54 65 switch (ref) { 55 66 case ref_type::strong: strong_count--; break; … … 61 72 } 62 73 } 63 private:64 /// Make a copy of this node; should be overridden in subclass with more precise return type65 virtual const Node * clone() const = 0;66 74 67 /// Must be copied in ALL derived classes 68 template<typename node_t> 69 friend auto mutate(const node_t * node); 70 71 mutable size_t strong_count = 0; 72 mutable size_t weak_count = 0; 75 template< typename node_t, enum Node::ref_type ref_t > 76 friend class ptr_base; 73 77 }; 74 78 … … 76 80 // problems and be able to use auto return 77 81 template<typename node_t> 78 auto mutate( const node_t * node ) { 79 assertf( 80 node->strong_count >= 1, 81 "Error: attempting to mutate a node that appears to have been linked" 82 ); 83 if (node->strong_count == 1) { 82 node_t * mutate( const node_t * node ) { 83 if (node->strong_count <= 1) { 84 84 return const_cast<node_t *>(node); 85 85 } … … 100 100 public: 101 101 ptr_base() : node(nullptr) {} 102 ptr_base( const node_t * n ) : node(n) { if( node ) increment(node, ref_t); }103 ~ptr_base() { if( node ) decrement(node, ref_t); }102 ptr_base( const node_t * n ) : node(n) { if( node ) _inc(node); } 103 ~ptr_base() { if( node ) _dec(node); } 104 104 105 105 template< enum Node::ref_type o_ref_t > 106 106 ptr_base( const ptr_base<node_t, o_ref_t> & o ) : node(o.node) { 107 if( node ) increment(node, ref_t);107 if( node ) _inc(node); 108 108 } 109 109 110 110 template< enum Node::ref_type o_ref_t > 111 111 ptr_base( ptr_base<node_t, o_ref_t> && o ) : node(o.node) { 112 if( node ) increment(node, ref_t);112 if( node ) _inc(node); 113 113 } 114 114 … … 147 147 assign( n ); 148 148 // get mutable version of `n` 149 auto r = mutate( node ); 149 auto r = mutate( node ); 150 150 // re-assign mutable version in case `mutate()` produced a new pointer 151 151 assign( r ); … … 157 157 private: 158 158 void assign( const node_t * other ) { 159 if( other ) increment(other, ref_t);160 if( node ) decrement(node , ref_t);159 if( other ) _inc(other); 160 if( node ) _dec(node ); 161 161 node = other; 162 162 } 163 164 void _inc( const node_t * other ); 165 void _dec( const node_t * other ); 163 166 164 167 protected: -
src/AST/ParseNode.hpp
r1fb7bfd r87701b6 34 34 35 35 ParseNode( const ParseNode& o ) = default; 36 private: 37 ParseNode * clone() const override = 0; 38 39 /// Must be copied in ALL derived classes 40 template<typename node_t> 41 friend node_t * mutate(const node_t * node); 36 42 }; 37 43 38 39 //=================================================================================================40 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency41 /// remove only if there is a better solution42 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with43 /// forward declarations44 inline void increment( const class ParseNode * node, Node::ref_type ref ) { node->increment( ref ); }45 inline void decrement( const class ParseNode * node, Node::ref_type ref ) { node->decrement( ref ); }46 44 } 47 45 -
src/AST/Pass.hpp
r1fb7bfd r87701b6 133 133 const ast::Expr * visit( const ast::OffsetofExpr * ) override final; 134 134 const ast::Expr * visit( const ast::OffsetPackExpr * ) override final; 135 const ast::Expr * visit( const ast::AttrExpr * ) override final;136 135 const ast::Expr * visit( const ast::LogicalExpr * ) override final; 137 136 const ast::Expr * visit( const ast::ConditionalExpr * ) override final; -
src/AST/Pass.impl.hpp
r1fb7bfd r87701b6 462 462 VISIT({ 463 463 guard_indexer guard { * this }; 464 maybe_accept( node, &StructDecl::param eters);465 maybe_accept( node, &StructDecl::members 464 maybe_accept( node, &StructDecl::params ); 465 maybe_accept( node, &StructDecl::members ); 466 466 }) 467 467 … … 483 483 VISIT({ 484 484 guard_indexer guard { * this }; 485 maybe_accept( node, &UnionDecl::param eters);486 maybe_accept( node, &UnionDecl::members 485 maybe_accept( node, &UnionDecl::params ); 486 maybe_accept( node, &UnionDecl::members ); 487 487 }) 488 488 … … 502 502 VISIT( 503 503 // unlike structs, traits, and unions, enums inject their members into the global scope 504 maybe_accept( node, &EnumDecl::param eters);505 maybe_accept( node, &EnumDecl::members 504 maybe_accept( node, &EnumDecl::params ); 505 maybe_accept( node, &EnumDecl::members ); 506 506 ) 507 507 … … 517 517 VISIT({ 518 518 guard_indexer guard { *this }; 519 maybe_accept( node, &TraitDecl::param eters);520 maybe_accept( node, &TraitDecl::members 519 maybe_accept( node, &TraitDecl::params ); 520 maybe_accept( node, &TraitDecl::members ); 521 521 }) 522 522 … … 534 534 VISIT({ 535 535 guard_indexer guard { *this }; 536 maybe_accept( node, &TypeDecl::param eters );537 maybe_accept( node, &TypeDecl::base 536 maybe_accept( node, &TypeDecl::params ); 537 maybe_accept( node, &TypeDecl::base ); 538 538 }) 539 539 … … 563 563 VISIT({ 564 564 guard_indexer guard { *this }; 565 maybe_accept( node, &TypedefDecl::param eters );566 maybe_accept( node, &TypedefDecl::base 565 maybe_accept( node, &TypedefDecl::params ); 566 maybe_accept( node, &TypedefDecl::base ); 567 567 }) 568 568 … … 690 690 691 691 VISIT_END( Stmt, node ); 692 } 693 694 //-------------------------------------------------------------------------- 695 // ForStmt 696 template< typename pass_t > 697 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ForStmt * node ) { 698 VISIT_START( node ); 699 700 VISIT({ 701 // for statements introduce a level of scope (for the initialization) 702 guard_indexer guard { *this }; 703 maybe_accept( node, &ForStmt::inits ); 704 maybe_accept( node, &ForStmt::cond ); 705 maybe_accept( node, &ForStmt::inc ); 706 maybe_accept( node, &ForStmt::body ); 707 }) 708 709 VISIT_END( Stmt, node ); 710 } 711 712 //-------------------------------------------------------------------------- 713 // SwitchStmt 714 template< typename pass_t > 715 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SwitchStmt * node ) { 716 VISIT_START( node ); 717 718 VISIT( 719 maybe_accept( node, &SwitchStmt::cond ); 720 maybe_accept( node, &SwitchStmt::stmts ); 721 ) 722 723 VISIT_END( Stmt, node ); 724 } 725 726 //-------------------------------------------------------------------------- 727 // CaseStmt 728 template< typename pass_t > 729 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CaseStmt * node ) { 730 VISIT_START( node ); 731 732 VISIT( 733 maybe_accept( node, &CaseStmt::cond ); 734 maybe_accept( node, &CaseStmt::stmts ); 735 ) 736 737 VISIT_END( Stmt, node ); 738 } 739 740 //-------------------------------------------------------------------------- 741 // BranchStmt 742 template< typename pass_t > 743 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::BranchStmt * node ) { 744 VISIT_START( node ); 745 VISIT_END( Stmt, node ); 746 } 747 748 //-------------------------------------------------------------------------- 749 // ReturnStmt 750 template< typename pass_t > 751 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ReturnStmt * node ) { 752 VISIT_START( node ); 753 754 maybe_accept( node, &ReturnStmt::expr ); 755 756 VISIT_END( Stmt, node ); 757 } 758 759 //-------------------------------------------------------------------------- 760 // ThrowStmt 761 762 template< typename pass_type > 763 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { 764 VISIT_START( node ); 765 766 maybeAccept_impl( node->expr, *this ); 767 maybeAccept_impl( node->target, *this ); 768 769 VISIT_END( node ); 692 770 } 693 771 -
src/AST/Pass.proto.hpp
r1fb7bfd r87701b6 247 247 static inline auto addStructFwd( pass_t & pass, int, const ast::StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) { 248 248 ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name ); 249 fwd->param eters = decl->parameters;249 fwd->params = decl->params; 250 250 pass.indexer.addStruct( fwd ); 251 251 } … … 257 257 static inline auto addUnionFwd( pass_t & pass, int, const ast::UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) { 258 258 UnionDecl * fwd = new UnionDecl( decl->location, decl->name ); 259 fwd->param eters = decl->parameters;259 fwd->params = decl->params; 260 260 pass.indexer.addUnion( fwd ); 261 261 } -
src/AST/Stmt.cpp
r1fb7bfd r87701b6 26 26 27 27 // --- BranchStmt 28 BranchStmt ( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels )28 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels ) 29 29 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) { 30 30 // Make sure a syntax error hasn't slipped through. … … 34 34 const char * BranchStmt::kindNames[] = { 35 35 "Goto", "Break", "Continue", "FallThrough", "FallThroughDefault" 36 } 36 }; 37 37 38 38 } -
src/AST/Stmt.hpp
r1fb7bfd r87701b6 65 65 /// Must be copied in ALL derived classes 66 66 template<typename node_t> 67 friend automutate(const node_t * node);67 friend node_t * mutate(const node_t * node); 68 68 }; 69 69 … … 80 80 /// Must be copied in ALL derived classes 81 81 template<typename node_t> 82 friend automutate(const node_t * node);82 friend node_t * mutate(const node_t * node); 83 83 }; 84 84 … … 96 96 /// Must be copied in ALL derived classes 97 97 template<typename node_t> 98 friend automutate(const node_t * node);98 friend node_t * mutate(const node_t * node); 99 99 }; 100 100 … … 121 121 /// Must be copied in ALL derived classes 122 122 template<typename node_t> 123 friend automutate(const node_t * node);123 friend node_t * mutate(const node_t * node); 124 124 }; 125 125 … … 138 138 /// Must be copied in ALL derived classes 139 139 template<typename node_t> 140 friend automutate(const node_t * node);140 friend node_t * mutate(const node_t * node); 141 141 }; 142 142 … … 160 160 /// Must be copied in ALL derived classes 161 161 template<typename node_t> 162 friend automutate(const node_t * node);162 friend node_t * mutate(const node_t * node); 163 163 }; 164 164 … … 178 178 /// Must be copied in ALL derived classes 179 179 template<typename node_t> 180 friend automutate(const node_t * node);180 friend node_t * mutate(const node_t * node); 181 181 }; 182 182 … … 198 198 /// Must be copied in ALL derived classes 199 199 template<typename node_t> 200 friend automutate(const node_t * node);200 friend node_t * mutate(const node_t * node); 201 201 }; 202 202 … … 219 219 /// Must be copied in ALL derived classes 220 220 template<typename node_t> 221 friend automutate(const node_t * node);221 friend node_t * mutate(const node_t * node); 222 222 }; 223 223 … … 240 240 /// Must be copied in ALL derived classes 241 241 template<typename node_t> 242 friend automutate(const node_t * node);242 friend node_t * mutate(const node_t * node); 243 243 }; 244 244 … … 268 268 /// Must be copied in ALL derived classes 269 269 template<typename node_t> 270 friend automutate(const node_t * node);270 friend node_t * mutate(const node_t * node); 271 271 272 272 static const char * kindNames[kindEnd]; … … 286 286 /// Must be copied in ALL derived classes 287 287 template<typename node_t> 288 friend automutate(const node_t * node);288 friend node_t * mutate(const node_t * node); 289 289 }; 290 290 … … 307 307 /// Must be copied in ALL derived classes 308 308 template<typename node_t> 309 friend automutate(const node_t * node);309 friend node_t * mutate(const node_t * node); 310 310 }; 311 311 … … 327 327 /// Must be copied in ALL derived classes 328 328 template<typename node_t> 329 friend automutate(const node_t * node);329 friend node_t * mutate(const node_t * node); 330 330 }; 331 331 … … 349 349 /// Must be copied in ALL derived classes 350 350 template<typename node_t> 351 friend automutate(const node_t * node);351 friend node_t * mutate(const node_t * node); 352 352 }; 353 353 … … 366 366 /// Must be copied in ALL derived classes 367 367 template<typename node_t> 368 friend automutate(const node_t * node);368 friend node_t * mutate(const node_t * node); 369 369 }; 370 370 … … 406 406 /// Must be copied in ALL derived classes 407 407 template<typename node_t> 408 friend automutate(const node_t * node);408 friend node_t * mutate(const node_t * node); 409 409 }; 410 410 … … 424 424 /// Must be copied in ALL derived classes 425 425 template<typename node_t> 426 friend automutate(const node_t * node);426 friend node_t * mutate(const node_t * node); 427 427 }; 428 428 … … 440 440 /// Must be copied in ALL derived classes 441 441 template<typename node_t> 442 friend automutate(const node_t * node);442 friend node_t * mutate(const node_t * node); 443 443 }; 444 444 … … 457 457 /// Must be copied in ALL derived classes 458 458 template<typename node_t> 459 friend auto mutate(const node_t * node); 460 }; 461 462 //================================================================================================= 463 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency 464 /// remove only if there is a better solution 465 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with 466 /// forward declarations 467 inline void increment( const class Stmt * node, Node::ref_type ref ) { node->increment( ref ); } 468 inline void decrement( const class Stmt * node, Node::ref_type ref ) { node->decrement( ref ); } 469 inline void increment( const class CompoundStmt * node, Node::ref_type ref ) { node->increment( ref ); } 470 inline void decrement( const class CompoundStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 471 inline void increment( const class ExprStmt * node, Node::ref_type ref ) { node->increment( ref ); } 472 inline void decrement( const class ExprStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 473 inline void increment( const class AsmStmt * node, Node::ref_type ref ) { node->increment( ref ); } 474 inline void decrement( const class AsmStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 475 inline void increment( const class DirectiveStmt * node, Node::ref_type ref ) { node->increment( ref ); } 476 inline void decrement( const class DirectiveStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 477 inline void increment( const class IfStmt * node, Node::ref_type ref ) { node->increment( ref ); } 478 inline void decrement( const class IfStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 479 inline void increment( const class WhileStmt * node, Node::ref_type ref ) { node->increment( ref ); } 480 inline void decrement( const class WhileStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 481 inline void increment( const class ForStmt * node, Node::ref_type ref ) { node->increment( ref ); } 482 inline void decrement( const class ForStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 483 inline void increment( const class SwitchStmt * node, Node::ref_type ref ) { node->increment( ref ); } 484 inline void decrement( const class SwitchStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 485 inline void increment( const class CaseStmt * node, Node::ref_type ref ) { node->increment( ref ); } 486 inline void decrement( const class CaseStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 487 inline void increment( const class BranchStmt * node, Node::ref_type ref ) { node->increment( ref ); } 488 inline void decrement( const class BranchStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 489 inline void increment( const class ReturnStmt * node, Node::ref_type ref ) { node->increment( ref ); } 490 inline void decrement( const class ReturnStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 491 inline void increment( const class ThrowStmt * node, Node::ref_type ref ) { node->increment( ref ); } 492 inline void decrement( const class ThrowStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 493 inline void increment( const class TryStmt * node, Node::ref_type ref ) { node->increment( ref ); } 494 inline void decrement( const class TryStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 495 inline void increment( const class CatchStmt * node, Node::ref_type ref ) { node->increment( ref ); } 496 inline void decrement( const class CatchStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 497 inline void increment( const class FinallyStmt * node, Node::ref_type ref ) { node->increment( ref ); } 498 inline void decrement( const class FinallyStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 499 inline void increment( const class WaitForStmt * node, Node::ref_type ref ) { node->increment( ref ); } 500 inline void decrement( const class WaitForStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 501 inline void increment( const class WithStmt * node, Node::ref_type ref ) { node->increment( ref ); } 502 inline void decrement( const class WithStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 503 inline void increment( const class DeclStmt * node, Node::ref_type ref ) { node->increment( ref ); } 504 inline void decrement( const class DeclStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 505 inline void increment( const class NullStmt * node, Node::ref_type ref ) { node->increment( ref ); } 506 inline void decrement( const class NullStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 507 inline void increment( const class ImplicitCtorDtorStmt * node, Node::ref_type ref ) { node->increment( ref ); } 508 inline void decrement( const class ImplicitCtorDtorStmt * node, Node::ref_type ref ) { node->decrement( ref ); } 459 friend node_t * mutate(const node_t * node); 460 }; 509 461 510 462 } -
src/AST/Type.hpp
r1fb7bfd r87701b6 34 34 public: 35 35 CV::Qualifiers qualifiers; 36 36 37 37 Type( CV::Qualifiers q = {} ) : qualifiers(q) {} 38 38 … … 76 76 public: 77 77 VoidType( CV::Qualifiers q = {} ) : Type( q ) {} 78 78 79 79 unsigned size() const override { return 0; } 80 80 bool isVoid() const override { return true; } … … 165 165 166 166 PointerType( const Type * b, CV::Qualifiers q = {} ) : Type(q), base(b), dimension() {} 167 PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 167 PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 168 168 CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {} 169 169 … … 186 186 DimensionFlag isStatic; 187 187 188 ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 188 ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 189 189 CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {} 190 190 … … 224 224 ptr<Type> child; 225 225 226 QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} ) 226 QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} ) 227 227 : Type(q), parent(p), child(c) {} 228 228 … … 239 239 ForallList forall; 240 240 241 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 241 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 242 242 : Type(q), forall(std::move(fs)) {} 243 243 ParameterizedType( CV::Qualifiers q ) : Type(q), forall() {} … … 256 256 std::vector<ptr<DeclWithType>> params; 257 257 258 /// Does the function accept a variable number of arguments following the arguments specified 258 /// Does the function accept a variable number of arguments following the arguments specified 259 259 /// in the parameters list. 260 260 /// This could be because of … … 284 284 bool hoistType = false; 285 285 286 ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 286 ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 287 287 std::vector<ptr<Attribute>> && as = {} ) 288 288 : ParameterizedType(q), params(), attributes(std::move(as)), name(n) {} … … 306 306 readonly<StructDecl> base; 307 307 308 StructInstType( const std::string& n, CV::Qualifiers q = {}, 308 StructInstType( const std::string& n, CV::Qualifiers q = {}, 309 309 std::vector<ptr<Attribute>> && as = {} ) 310 310 : ReferenceToType( n, q, std::move(as) ), base() {} 311 StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 311 StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 312 312 std::vector<ptr<Attribute>> && as = {} ); 313 313 314 314 bool isComplete() const override; 315 315 … … 328 328 readonly<UnionDecl> base; 329 329 330 UnionInstType( const std::string& n, CV::Qualifiers q = {}, 330 UnionInstType( const std::string& n, CV::Qualifiers q = {}, 331 331 std::vector<ptr<Attribute>> && as = {} ) 332 332 : ReferenceToType( n, q, std::move(as) ), base() {} 333 UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 333 UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 334 334 std::vector<ptr<Attribute>> && as = {} ); 335 335 336 336 bool isComplete() const override; 337 337 … … 350 350 readonly<EnumDecl> base; 351 351 352 EnumInstType( const std::string& n, CV::Qualifiers q = {}, 352 EnumInstType( const std::string& n, CV::Qualifiers q = {}, 353 353 std::vector<ptr<Attribute>> && as = {} ) 354 354 : ReferenceToType( n, q, std::move(as) ), base() {} 355 EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 355 EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 356 356 std::vector<ptr<Attribute>> && as = {} ); 357 357 358 358 bool isComplete() const override; 359 359 … … 372 372 readonly<TraitDecl> base; 373 373 374 TraitInstType( const std::string& n, CV::Qualifiers q = {}, 374 TraitInstType( const std::string& n, CV::Qualifiers q = {}, 375 375 std::vector<ptr<Attribute>> && as = {} ) 376 376 : ReferenceToType( n, q, std::move(as) ), base() {} 377 TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 377 TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 378 378 std::vector<ptr<Attribute>> && as = {} ); 379 379 380 380 // not meaningful for TraitInstType 381 381 bool isComplete() const override { assert(false); } … … 396 396 TypeVar::Kind kind; 397 397 398 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 398 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 399 399 std::vector<ptr<Attribute>> && as = {} ) 400 400 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 401 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 401 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 402 402 std::vector<ptr<Attribute>> && as = {} ) 403 403 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {} … … 430 430 iterator begin() const { return types.begin(); } 431 431 iterator end() const { return types.end(); } 432 432 433 433 unsigned size() const override { return types.size(); } 434 434 435 435 const Type * getComponent( unsigned i ) override { 436 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", 436 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", 437 437 i, size() ); 438 438 return *(begin()+i); … … 450 450 enum Kind { Typeof, Basetypeof } kind; 451 451 452 TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} ) 452 TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} ) 453 453 : Type(q), expr(e), kind(k) {} 454 454 … … 462 462 public: 463 463 VarArgsType( CV::Qualifiers q = {} ) : Type( q ) {} 464 464 465 465 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 466 466 private: … … 472 472 public: 473 473 ZeroType( CV::Qualifiers q = {} ) : Type( q ) {} 474 475 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 476 private: 477 ZeroType * clone() const override { return new ZeroType{ *this }; } 474 475 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 476 private: 477 ZeroType * clone() const override { return new ZeroType{ *this }; } 478 478 }; 479 479 … … 497 497 GlobalScopeType * clone() const override { return new GlobalScopeType{ *this }; } 498 498 }; 499 500 //=================================================================================================501 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency502 /// remove only if there is a better solution.503 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with504 /// forward declarations505 inline void increment( const class Type * node, Node::ref_type ref ) { node->increment( ref ); }506 inline void decrement( const class Type * node, Node::ref_type ref ) { node->decrement( ref ); }507 inline void increment( const class VoidType * node, Node::ref_type ref ) { node->increment( ref ); }508 inline void decrement( const class VoidType * node, Node::ref_type ref ) { node->decrement( ref ); }509 inline void increment( const class BasicType * node, Node::ref_type ref ) { node->increment( ref ); }510 inline void decrement( const class BasicType * node, Node::ref_type ref ) { node->decrement( ref ); }511 inline void increment( const class PointerType * node, Node::ref_type ref ) { node->increment( ref ); }512 inline void decrement( const class PointerType * node, Node::ref_type ref ) { node->decrement( ref ); }513 inline void increment( const class ArrayType * node, Node::ref_type ref ) { node->increment( ref ); }514 inline void decrement( const class ArrayType * node, Node::ref_type ref ) { node->decrement( ref ); }515 inline void increment( const class ReferenceType * node, Node::ref_type ref ) { node->increment( ref ); }516 inline void decrement( const class ReferenceType * node, Node::ref_type ref ) { node->decrement( ref ); }517 inline void increment( const class QualifiedType * node, Node::ref_type ref ) { node->increment( ref ); }518 inline void decrement( const class QualifiedType * node, Node::ref_type ref ) { node->decrement( ref ); }519 inline void increment( const class FunctionType * node, Node::ref_type ref ) { node->increment( ref ); }520 inline void decrement( const class FunctionType * node, Node::ref_type ref ) { node->decrement( ref ); }521 inline void increment( const class ReferenceToType * node, Node::ref_type ref ) { node->increment( ref ); }522 inline void decrement( const class ReferenceToType * node, Node::ref_type ref ) { node->decrement( ref ); }523 inline void increment( const class StructInstType * node, Node::ref_type ref ) { node->increment( ref ); }524 inline void decrement( const class StructInstType * node, Node::ref_type ref ) { node->decrement( ref ); }525 inline void increment( const class UnionInstType * node, Node::ref_type ref ) { node->increment( ref ); }526 inline void decrement( const class UnionInstType * node, Node::ref_type ref ) { node->decrement( ref ); }527 inline void increment( const class EnumInstType * node, Node::ref_type ref ) { node->increment( ref ); }528 inline void decrement( const class EnumInstType * node, Node::ref_type ref ) { node->decrement( ref ); }529 inline void increment( const class TraitInstType * node, Node::ref_type ref ) { node->increment( ref ); }530 inline void decrement( const class TraitInstType * node, Node::ref_type ref ) { node->decrement( ref ); }531 inline void increment( const class TypeInstType * node, Node::ref_type ref ) { node->increment( ref ); }532 inline void decrement( const class TypeInstType * node, Node::ref_type ref ) { node->decrement( ref ); }533 inline void increment( const class TupleType * node, Node::ref_type ref ) { node->increment( ref ); }534 inline void decrement( const class TupleType * node, Node::ref_type ref ) { node->decrement( ref ); }535 inline void increment( const class TypeofType * node, Node::ref_type ref ) { node->increment( ref ); }536 inline void decrement( const class TypeofType * node, Node::ref_type ref ) { node->decrement( ref ); }537 inline void increment( const class VarArgsType * node, Node::ref_type ref ) { node->increment( ref ); }538 inline void decrement( const class VarArgsType * node, Node::ref_type ref ) { node->decrement( ref ); }539 inline void increment( const class ZeroType * node, Node::ref_type ref ) { node->increment( ref ); }540 inline void decrement( const class ZeroType * node, Node::ref_type ref ) { node->decrement( ref ); }541 inline void increment( const class OneType * node, Node::ref_type ref ) { node->increment( ref ); }542 inline void decrement( const class OneType * node, Node::ref_type ref ) { node->decrement( ref ); }543 inline void increment( const class GlobalScopeType * node, Node::ref_type ref ) { node->increment( ref ); }544 inline void decrement( const class GlobalScopeType * node, Node::ref_type ref ) { node->decrement( ref ); }545 499 546 500 } -
src/AST/porting.md
r1fb7bfd r87701b6 48 48 /// Must be copied in ALL derived classes 49 49 template<typename node_t> 50 friend automutate(const node_t * node);50 friend node_t * mutate(const node_t * node); 51 51 52 52 All leaves of the `Node` inheritance tree are now declared `final` -
src/Common/utility.h
r1fb7bfd r87701b6 463 463 std::pair<long long int, bool> eval(Expression * expr); 464 464 465 // ----------------------------------------------------------------------------- 466 /// Reorders the input range in-place so that the minimal-value elements according to the 467 /// comparator are in front; 465 namespace ast { 466 class Expr; 467 } 468 469 std::pair<long long int, bool> eval(const ast::Expr * expr); 470 471 // ----------------------------------------------------------------------------- 472 /// Reorders the input range in-place so that the minimal-value elements according to the 473 /// comparator are in front; 468 474 /// returns the iterator after the last minimal-value element. 469 475 template<typename Iter, typename Compare> 470 476 Iter sort_mins( Iter begin, Iter end, Compare& lt ) { 471 477 if ( begin == end ) return end; 472 478 473 479 Iter min_pos = begin; 474 480 for ( Iter i = begin + 1; i != end; ++i ) {
Note: See TracChangeset
for help on using the changeset viewer.