Changes in src/InitTweak/GenInit.cc [b8524ca:a16764a6]
- File:
-
- 1 edited
-
src/InitTweak/GenInit.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
rb8524ca ra16764a6 15 15 #include "GenInit.h" 16 16 17 #include <stddef.h> // for NULL 18 #include <algorithm> // for any_of 19 #include <cassert> // for assert, strict_dynamic_cast, assertf 20 #include <deque> 21 #include <iterator> // for back_inserter, inserter, back_inse... 22 #include <list> // for _List_iterator, list 23 24 #include "AST/Decl.hpp" 25 #include "AST/Init.hpp" 26 #include "AST/Node.hpp" 27 #include "AST/Stmt.hpp" 17 #include <stddef.h> // for NULL 18 #include <algorithm> // for any_of 19 #include <cassert> // for assert, strict_dynamic_cast, assertf 20 #include <iterator> // for back_inserter, inserter, back_inse... 21 #include <list> // for _List_iterator, list 22 28 23 #include "CodeGen/OperatorTable.h" 29 #include "Common/PassVisitor.h" // for PassVisitor, WithGuards, WithShort...30 #include "Common/SemanticError.h" // for SemanticError31 #include "Common/UniqueName.h" // for UniqueName32 #include "Common/utility.h" // for ValueGuard, maybeClone33 #include "GenPoly/GenPoly.h" // for getFunctionType, isPolyType34 #include "GenPoly/ScopedSet.h" // for ScopedSet, ScopedSet<>::const_iter...35 #include "InitTweak.h" // for isConstExpr, InitExpander, checkIn...36 #include "Parser/LinkageSpec.h" // for isOverridable, C24 #include "Common/PassVisitor.h" // for PassVisitor, WithGuards, WithShort... 25 #include "Common/SemanticError.h" // for SemanticError 26 #include "Common/UniqueName.h" // for UniqueName 27 #include "Common/utility.h" // for ValueGuard, maybeClone 28 #include "GenPoly/GenPoly.h" // for getFunctionType, isPolyType 29 #include "GenPoly/ScopedSet.h" // for ScopedSet, ScopedSet<>::const_iter... 30 #include "InitTweak.h" // for isConstExpr, InitExpander, checkIn... 31 #include "Parser/LinkageSpec.h" // for isOverridable, C 37 32 #include "ResolvExpr/Resolver.h" 38 #include "SymTab/Autogen.h" // for genImplicitCall 39 #include "SymTab/Mangler.h" // for Mangler 40 #include "SynTree/Declaration.h" // for ObjectDecl, DeclarationWithType 41 #include "SynTree/Expression.h" // for VariableExpr, UntypedExpr, Address... 42 #include "SynTree/Initializer.h" // for ConstructorInit, SingleInit, Initi... 43 #include "SynTree/Label.h" // for Label 44 #include "SynTree/Mutator.h" // for mutateAll 45 #include "SynTree/Statement.h" // for CompoundStmt, ImplicitCtorDtorStmt 46 #include "SynTree/Type.h" // for Type, ArrayType, Type::Qualifiers 47 #include "SynTree/Visitor.h" // for acceptAll, maybeAccept 48 #include "Tuples/Tuples.h" // for maybeImpure 49 #include "Validate/FindSpecialDecls.h" // for SizeType 33 #include "SymTab/Autogen.h" // for genImplicitCall, SizeType 34 #include "SymTab/Mangler.h" // for Mangler 35 #include "SynTree/Declaration.h" // for ObjectDecl, DeclarationWithType 36 #include "SynTree/Expression.h" // for VariableExpr, UntypedExpr, Address... 37 #include "SynTree/Initializer.h" // for ConstructorInit, SingleInit, Initi... 38 #include "SynTree/Label.h" // for Label 39 #include "SynTree/Mutator.h" // for mutateAll 40 #include "SynTree/Statement.h" // for CompoundStmt, ImplicitCtorDtorStmt 41 #include "SynTree/Type.h" // for Type, ArrayType, Type::Qualifiers 42 #include "SynTree/Visitor.h" // for acceptAll, maybeAccept 43 #include "Tuples/Tuples.h" // for maybeImpure 50 44 51 45 namespace InitTweak { … … 192 186 193 187 // need to resolve array dimensions in order to accurately determine if constexpr 194 ResolvExpr::findSingleExpression( arrayType->dimension, Validate::SizeType->clone(), indexer );188 ResolvExpr::findSingleExpression( arrayType->dimension, SymTab::SizeType->clone(), indexer ); 195 189 // array is variable-length when the dimension is not constexpr 196 190 arrayType->isVarLen = ! isConstExpr( arrayType->dimension ); … … 198 192 if ( ! Tuples::maybeImpure( arrayType->dimension ) ) return; 199 193 200 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, Validate::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );194 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) ); 201 195 arrayDimension->get_type()->set_const( true ); 202 196 … … 279 273 assertf( objDecl, "genCtorDtor passed null objDecl" ); 280 274 std::list< Statement * > stmts; 281 InitExpander _oldsrcParam( maybeClone( arg ) );275 InitExpander srcParam( maybeClone( arg ) ); 282 276 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), fname, back_inserter( stmts ), objDecl ); 283 277 assert( stmts.size() <= 1 ); … … 291 285 std::list< Statement * > dtor; 292 286 293 InitExpander _oldsrcParam( objDecl->get_init() );294 InitExpander _oldnullParam( (Initializer *)NULL );287 InitExpander srcParam( objDecl->get_init() ); 288 InitExpander nullParam( (Initializer *)NULL ); 295 289 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 296 290 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); … … 358 352 GuardScope( managedTypes ); 359 353 } 360 361 ast::ConstructorInit * genCtorInit( const CodeLocation & loc, const ast::ObjectDecl * objDecl ) {362 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor for each363 // constructable object364 InitExpander_new srcParam{ objDecl->init }, nullParam{ (const ast::Init *)nullptr };365 366 ast::ptr< ast::Stmt > ctor = SymTab::genImplicitCall(367 srcParam, new ast::VariableExpr{ loc, objDecl }, loc, "?{}", objDecl );368 ast::ptr< ast::Stmt > dtor = SymTab::genImplicitCall(369 nullParam, new ast::VariableExpr{ loc, objDecl }, loc, "^?{}", objDecl,370 SymTab::LoopBackward );371 372 // check that either both ctor and dtor are present, or neither373 assert( (bool)ctor == (bool)dtor );374 375 if ( ctor ) {376 // need to remember init expression, in case no ctors exist. If ctor does exist, want to377 // use ctor expression instead of init.378 ctor.strict_as< ast::ImplicitCtorDtorStmt >();379 dtor.strict_as< ast::ImplicitCtorDtorStmt >();380 381 return new ast::ConstructorInit{ loc, ctor, dtor, objDecl->init };382 }383 384 return nullptr;385 }386 387 354 } // namespace InitTweak 388 355
Note:
See TracChangeset
for help on using the changeset viewer.