Changeset 64b6913
- Timestamp:
- Mar 16, 2017, 8:19:39 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 26ba208
- Parents:
- 6e8bd43
- Location:
- src
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:32:08201713 // Update Count : 1 512 // Last Modified On : Thu Mar 16 07:50:30 2017 13 // Update Count : 16 14 14 // 15 15 … … 39 39 std::string mangle_main() { 40 40 FunctionType* main_type; 41 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall,41 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 42 42 main_type = new FunctionType( Type::Qualifiers(), true ), nullptr ) 43 43 }; 44 44 main_type->get_returnVals().push_back( 45 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )45 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 46 46 ); 47 47 … … 52 52 std::string mangle_main_args() { 53 53 FunctionType* main_type; 54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall,54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 55 55 main_type = new FunctionType( Type::Qualifiers(), false ), nullptr ) 56 56 }; 57 57 main_type->get_returnVals().push_back( 58 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )58 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 59 59 ); 60 60 61 61 mainDecl->get_functionType()->get_parameters().push_back( 62 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )62 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 63 63 ); 64 64 65 65 mainDecl->get_functionType()->get_parameters().push_back( 66 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0,66 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 67 67 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 68 68 nullptr ) -
src/Concurrency/Keywords.cc
r6e8bd43 r64b6913 12 12 // Last Modified By : 13 13 // Last Modified On : 14 // Update Count : 014 // Update Count : 1 15 15 // 16 16 … … 29 29 namespace { 30 30 const std::list<Label> noLabels; 31 DeclarationNode::StorageClasses noStorage;31 Type::StorageClasses noStorage; 32 32 Type::Qualifiers noQualifiers; 33 33 } -
src/GenPoly/Box.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 07:45:29201713 // Update Count : 33 412 // Last Modified On : Thu Mar 16 08:06:05 2017 13 // Update Count : 337 14 14 // 15 15 … … 289 289 TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param ); 290 290 std::string paramName = mangleType( ¶mType ); 291 layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );292 layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );291 layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) ); 292 layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) ); 293 293 } 294 294 } … … 299 299 // because each unit generates copies of the default routines for each aggregate. 300 300 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ),301 functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ), 302 302 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), 303 303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ); … … 368 368 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 369 369 370 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );370 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 371 371 layoutFnType->get_parameters().push_back( sizeParam ); 372 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );372 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 373 373 layoutFnType->get_parameters().push_back( alignParam ); 374 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );374 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 375 375 layoutFnType->get_parameters().push_back( offsetParam ); 376 376 addOtypeParams( layoutFnType, otypeParams ); … … 429 429 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 430 430 431 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );431 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 432 432 layoutFnType->get_parameters().push_back( sizeParam ); 433 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );433 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 434 434 layoutFnType->get_parameters().push_back( alignParam ); 435 435 addOtypeParams( layoutFnType, otypeParams ); … … 537 537 if ( adapters.find( mangleName ) == adapters.end() ) { 538 538 std::string adapterName = makeAdapterName( mangleName ); 539 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) );539 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) ); 540 540 } // if 541 541 } // for … … 656 656 657 657 ObjectDecl *Pass1::makeTemporary( Type *type ) { 658 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, type, 0 );658 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, type, 0 ); 659 659 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 660 660 return newObj; … … 765 765 Type * newType = param->clone(); 766 766 if ( env ) env->apply( newType ); 767 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, newType, 0 );767 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, newType, 0 ); 768 768 newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right??? 769 769 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); … … 831 831 makeRetParm( adapter ); 832 832 } // if 833 adapter->get_parameters().push_front( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) );833 adapter->get_parameters().push_front( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) ); 834 834 return adapter; 835 835 } … … 912 912 adapterBody->get_kids().push_back( bodyStmt ); 913 913 std::string adapterName = makeAdapterName( mangleName ); 914 return new FunctionDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, adapterType, adapterBody );914 return new FunctionDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, adapterType, adapterBody ); 915 915 } 916 916 … … 1273 1273 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 1274 1274 std::string adapterName = makeAdapterName( mangleName ); 1275 paramList.push_front( new ObjectDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );1275 paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ); 1276 1276 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1277 1277 } … … 1379 1379 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1380 1380 std::list< DeclarationWithType *> inferredParams; 1381 ObjectDecl newObj( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );1382 ObjectDecl newPtr( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0,1381 ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1382 ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0, 1383 1383 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1384 1384 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { … … 1634 1634 1635 1635 ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) { 1636 ObjectDecl *newObj = new ObjectDecl( name, DeclarationNode::StorageClasses(), LinkageSpec::C, 0, type, init );1636 ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, 0, type, init ); 1637 1637 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 1638 1638 return newObj; … … 1818 1818 memberDecl = origMember->clone(); 1819 1819 } else { 1820 memberDecl = new ObjectDecl( (*member)->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, offsetType->clone(), 0 );1820 memberDecl = new ObjectDecl( (*member)->get_name(), Type::StorageClasses(), LinkageSpec::Cforall, 0, offsetType->clone(), 0 ); 1821 1821 } 1822 1822 inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) ); -
src/GenPoly/Specialize.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:13:00201713 // Update Count : 3 012 // Last Modified On : Thu Mar 16 07:53:59 2017 13 // Update Count : 31 14 14 // 15 15 … … 155 155 } // if 156 156 // create new thunk with same signature as formal type (C linkage, empty body) 157 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ) );157 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), Type::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ) ); 158 158 thunkFunc->fixUniqueId(); 159 159 -
src/InitTweak/FixGlobalInit.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 13 23:58:27201713 // Update Count : 1 612 // Last Modified On : Thu Mar 16 07:53:11 2017 13 // Update Count : 18 14 14 // 15 15 … … 87 87 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 88 88 } 89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );89 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 90 90 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 92 92 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 93 93 } -
src/InitTweak/FixInit.cc
r6e8bd43 r64b6913 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 08:05:28201713 // Update Count : 6 312 // Last Modified On : Thu Mar 16 08:08:04 2017 13 // Update Count : 67 14 14 // 15 15 … … 437 437 result = result->clone(); 438 438 env->apply( result ); 439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 );439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 440 440 tmp->get_type()->set_isConst( false ); 441 441 … … 483 483 result = result->clone(); 484 484 env->apply( result ); 485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 );485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 486 486 ret->get_type()->set_isConst( false ); 487 487 impCpCtorExpr->get_returnDecls().push_back( ret ); … … 506 506 result = result->clone(); 507 507 env->apply( result ); 508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 );508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 509 509 ret->get_type()->set_isConst( false ); 510 510 stmtExpr->get_returnDecls().push_front( ret ); … … 538 538 } else { 539 539 // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression 540 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );540 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), Type::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) ); 541 541 unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) ); 542 542 } … … 704 704 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 705 705 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators ); 706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr ); 707 707 isUninitializedVar->fixUniqueId(); 708 708 … … 731 731 732 732 // void __objName_dtor_atexitN(...) {...} 733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 734 734 dtorCaller->fixUniqueId(); 735 735 dtorCaller->get_statements()->push_back( dtorStmt ); … … 764 764 // create a new object which is never used 765 765 static UniqueName dummyNamer( "_dummy" ); 766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 767 767 return dummy; 768 768 } … … 1118 1118 1119 1119 // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary. 1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 1121 1121 addDeclaration( tmp ); 1122 1122 -
src/InitTweak/GenInit.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 13 23:59:09201713 // Update Count : 18 012 // Last Modified On : Thu Mar 16 08:01:25 2017 13 // Update Count : 181 14 14 // 15 15 … … 120 120 void hoist( Type * type ); 121 121 122 DeclarationNode::StorageClasses storageClasses;122 Type::StorageClasses storageClasses; 123 123 bool inFunction = false; 124 124 }; -
src/Parser/DeclarationNode.cc
r6e8bd43 r64b6913 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:36:49201713 // Update Count : 99712 // Last Modified On : Thu Mar 16 07:59:40 2017 13 // Update Count : 1003 14 14 // 15 15 … … 33 33 34 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 35 const char * DeclarationNode::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };36 35 const char * DeclarationNode::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" }; 37 36 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; … … 181 180 182 181 183 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) {182 DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) { 184 183 DeclarationNode * newnode = new DeclarationNode; 185 184 newnode->storageClasses = sc; … … 458 457 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 459 458 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 460 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { // find duplicates459 for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates 461 460 if ( storageClasses[i] && src->storageClasses[i] ) { 462 appendError( error, string( "duplicate " ) + StorageClasses::Names[i] );461 appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] ); 463 462 } // if 464 463 } // for 465 464 // src is the new item being added and has a single bit 466 465 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 467 appendError( error, string( "conflicting " ) + StorageClasses::Names[ffs( storageClasses.val ) - 1] +468 " & " + StorageClasses::Names[ffs( src->storageClasses.val ) - 1] );466 appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] + 467 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] ); 469 468 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 470 469 } // if … … 970 969 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 971 970 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 972 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );971 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 973 972 obj->location = cur->location; 974 973 * out++ = obj; … … 976 975 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 977 976 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 978 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );977 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 979 978 obj->location = cur->location; 980 979 * out++ = obj; … … 1023 1022 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1024 1023 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1025 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );1024 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] ); 1026 1025 buildList( variable.assertions, ret->get_assertions() ); 1027 1026 return ret; -
src/Parser/ParseNode.h
r6e8bd43 r64b6913 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:31:02201713 // Update Count : 77 012 // Last Modified On : Thu Mar 16 07:46:33 2017 13 // Update Count : 772 14 14 // 15 15 … … 201 201 class DeclarationNode : public ParseNode { 202 202 public: 203 // These must remain in the same order as the corresponding DeclarationNode names.204 205 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };206 union StorageClasses {207 static const char * Names[];208 unsigned int val;209 struct {210 bool is_extern : 1;211 bool is_static : 1;212 bool is_auto : 1;213 bool is_register : 1;214 bool is_threadlocal : 1;215 };216 217 StorageClasses() : val( 0 ) {}218 StorageClasses( unsigned int val ) : val( val ) {}219 bool operator[]( unsigned int i ) const { return val & (1 << i); }220 bool any() const { return val != 0; }221 void print( std::ostream & os ) const {222 if ( (*this).any() ) { // any storage classes ?223 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) {224 if ( (*this)[i] ) {225 os << StorageClasses::Names[i] << ' ';226 } // if227 } // for228 } // if229 }230 }; // StorageClasses231 232 203 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 233 204 union FuncSpecifiers { … … 270 241 static const char * builtinTypeNames[]; 271 242 272 static DeclarationNode * newStorageClass( StorageClasses );243 static DeclarationNode * newStorageClass( Type::StorageClasses ); 273 244 static DeclarationNode * newFuncSpecifier( FuncSpecifiers ); 274 245 static DeclarationNode * newTypeQualifier( Type::Qualifiers ); … … 368 339 TypeData * type; 369 340 370 StorageClasses storageClasses;341 Type::StorageClasses storageClasses; 371 342 FuncSpecifiers funcSpecs; 372 343 -
src/Parser/TypeData.cc
r6e8bd43 r64b6913 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 22:53:04201713 // Update Count : 55 712 // Last Modified On : Thu Mar 16 07:54:50 2017 13 // Update Count : 558 14 14 // 15 15 … … 398 398 // add dtor: void ^?{}(T *) 399 399 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 400 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );401 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );400 dtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 401 td->get_assertions().push_front( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) ); 402 402 403 403 // add copy ctor: void ?{}(T *, T) 404 404 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 407 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) ); 408 408 409 409 // add default ctor: void ?{}(T *) 410 410 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 411 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );412 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );411 ctorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 412 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) ); 413 413 414 414 // add assignment operator: T * ?=?(T *, T) 415 415 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 416 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );417 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );418 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );416 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 417 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 418 assignType->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 419 td->get_assertions().push_front( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) ); 420 420 } // if 421 421 } // for … … 726 726 } // buildAggInst 727 727 728 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClasses scs ) {728 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) { 729 729 assert( td->kind == TypeData::Symbolic ); 730 730 NamedTypeDecl * ret; … … 778 778 } // buildTypeof 779 779 780 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {780 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 781 781 if ( td->kind == TypeData::Function ) { 782 782 if ( td->function.idList ) { // KR function ? … … 814 814 break; 815 815 default: 816 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", DeclarationNode::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );816 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 817 817 } // switch 818 818 } else { 819 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );819 ft->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 820 820 } // if 821 821 return ft; -
src/Parser/TypeData.h
r6e8bd43 r64b6913 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 22:10:23201713 // Update Count : 18 312 // Last Modified On : Thu Mar 16 07:53:41 2017 13 // Update Count : 184 14 14 // 15 15 … … 109 109 TupleType * buildTuple( const TypeData * ); 110 110 TypeofType * buildTypeof( const TypeData * ); 111 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );111 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 112 112 FunctionType * buildFunction( const TypeData * ); 113 113 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/parser.yy
r6e8bd43 r64b6913 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 22:06:22201713 // Update Count : 230 812 // Last Modified On : Thu Mar 16 08:00:59 2017 13 // Update Count : 2309 14 14 // 15 15 … … 1449 1449 storage_class: 1450 1450 EXTERN 1451 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }1451 { $$ = DeclarationNode::newStorageClass( Type::Extern ); } 1452 1452 | STATIC 1453 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); }1453 { $$ = DeclarationNode::newStorageClass( Type::Static ); } 1454 1454 | AUTO 1455 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }1455 { $$ = DeclarationNode::newStorageClass( Type::Auto ); } 1456 1456 | REGISTER 1457 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }1457 { $$ = DeclarationNode::newStorageClass( Type::Register ); } 1458 1458 | THREADLOCAL // C11 1459 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }1459 { $$ = DeclarationNode::newStorageClass( Type::Threadlocal ); } 1460 1460 // Put function specifiers here to simplify parsing rules, but separate them semantically. 1461 1461 | INLINE // C99 -
src/ResolvExpr/Unify.cc
r6e8bd43 r64b6913 10 10 // Created On : Sun May 17 12:27:10 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:37:38201713 // Update Count : 3912 // Last Modified On : Thu Mar 16 07:59:59 2017 13 // Update Count : 40 14 14 // 15 15 … … 541 541 flatten( dcl->get_type(), back_inserter( types ) ); 542 542 for ( Type * t : types ) { 543 dst.push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );543 dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) ); 544 544 } 545 545 delete dcl; -
src/SymTab/Autogen.cc
r6e8bd43 r64b6913 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 07:45:00201713 // Update Count : 5 412 // Last Modified On : Thu Mar 16 08:03:35 2017 13 // Update Count : 56 14 14 // 15 15 … … 125 125 FunctionType * genDefaultType( Type * paramType ) { 126 126 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );127 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr ); 128 128 ftype->get_parameters().push_back( dstParam ); 129 129 … … 134 134 FunctionType * genCopyType( Type * paramType ) { 135 135 FunctionType *ftype = genDefaultType( paramType ); 136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );136 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 137 137 ftype->get_parameters().push_back( srcParam ); 138 138 return ftype; … … 142 142 FunctionType * genAssignType( Type * paramType ) { 143 143 FunctionType *ftype = genCopyType( paramType ); 144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );144 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 145 145 ftype->get_returnVals().push_back( returnVal ); 146 146 return ftype; … … 162 162 // because each unit generates copies of the default routines for each aggregate. 163 163 // DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static );164 Type::StorageClasses scs = functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ); 165 165 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 166 166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), … … 460 460 continue; 461 461 } 462 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );462 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), Type::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 463 463 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 464 464 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout ); … … 540 540 for ( Declaration * member : aggregateDecl->get_members() ) { 541 541 if ( DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member ) ) { 542 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );542 ObjectDecl * srcParam = new ObjectDecl( "src", Type::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ); 543 543 544 544 FunctionType * memCtorType = ctorType->clone(); … … 605 605 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 606 606 typeInst->set_baseType( typeDecl ); 607 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr );608 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr );607 ObjectDecl *src = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr ); 608 ObjectDecl *dst = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr ); 609 609 610 610 std::list< Statement * > stmts; … … 618 618 } // if 619 619 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 620 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) );620 type->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) ); 621 621 type->get_parameters().push_back( dst ); 622 622 type->get_parameters().push_back( src ); … … 717 717 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 718 718 if ( ! done.count( ty->get_baseType() ) ) { 719 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any );719 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Any ); 720 720 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 729 729 typeParams.push_back( newDecl ); -
src/SymTab/Autogen.h
r6e8bd43 r64b6913 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 23:13:28201713 // Update Count : 712 // Last Modified On : Thu Mar 16 07:51:39 2017 13 // Update Count : 8 14 14 // 15 15 … … 103 103 } 104 104 105 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );105 ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) ); 106 106 107 107 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/Validate.cc
r6e8bd43 r64b6913 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 23:30:27201713 // Update Count : 35 012 // Last Modified On : Thu Mar 16 08:02:54 2017 13 // Update Count : 351 14 14 // 15 15 … … 208 208 209 209 class CompoundLiteral final : public GenPoly::DeclMutator { 210 DeclarationNode::StorageClasses storageClasses;210 Type::StorageClasses storageClasses; 211 211 212 212 using GenPoly::DeclMutator::mutate; … … 754 754 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 755 755 } // if 756 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::StorageClasses(), type ) );756 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type ) ); 757 757 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 758 758 } // if … … 857 857 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 858 858 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 859 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );859 ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 860 860 deleteAll( retVals ); 861 861 retVals.clear(); -
src/SynTree/AggregateDecl.cc
r6e8bd43 r64b6913 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:31:47 201713 // Update Count : 1912 // Last Modified On : Thu Mar 16 07:49:07 2017 13 // Update Count : 20 14 14 // 15 15 … … 20 20 21 21 22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) { 23 23 } 24 24 -
src/SynTree/Declaration.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:31:11201713 // Update Count : 2 312 // Last Modified On : Thu Mar 16 07:49:18 2017 13 // Update Count : 24 14 14 // 15 15 … … 27 27 static IdMapType idMap; 28 28 29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage )29 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) 30 30 : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) { 31 31 } … … 66 66 67 67 68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) { 69 69 } 70 70 -
src/SynTree/Declaration.h
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:40:42201713 // Update Count : 11 312 // Last Modified On : Thu Mar 16 07:48:23 2017 13 // Update Count : 117 14 14 // 15 15 … … 28 28 class Declaration : public BaseSyntaxNode { 29 29 public: 30 Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage );30 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 31 31 Declaration( const Declaration &other ); 32 32 virtual ~Declaration(); … … 35 35 void set_name( std::string newValue ) { name = newValue; } 36 36 37 DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; }37 Type::StorageClasses get_storageClasses() const { return storageClasses; } 38 38 39 39 LinkageSpec::Spec get_linkage() const { return linkage; } … … 56 56 private: 57 57 std::string name; 58 DeclarationNode::StorageClasses storageClasses;58 Type::StorageClasses storageClasses; 59 59 LinkageSpec::Spec linkage; 60 60 UniqueId uniqueId; … … 64 64 class DeclarationWithType : public Declaration { 65 65 public: 66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );66 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 104 104 typedef DeclarationWithType Parent; 105 105 public: 106 ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,106 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 107 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() ); 108 108 ObjectDecl( const ObjectDecl &other ); … … 132 132 typedef DeclarationWithType Parent; 133 133 public: 134 FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,134 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 135 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() ); 136 136 FunctionDecl( const FunctionDecl &other ); … … 158 158 typedef Declaration Parent; 159 159 public: 160 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type );160 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 161 161 NamedTypeDecl( const NamedTypeDecl &other ); 162 162 virtual ~NamedTypeDecl(); … … 193 193 }; 194 194 195 TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind );195 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ); 196 196 TypeDecl( const TypeDecl &other ); 197 197 … … 214 214 typedef NamedTypeDecl Parent; 215 215 public: 216 TypedefDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}216 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {} 217 217 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 218 218 -
src/SynTree/DeclarationWithType.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:32:14201713 // Update Count : 2 312 // Last Modified On : Thu Mar 16 07:49:27 2017 13 // Update Count : 24 14 14 // 15 15 … … 19 19 #include "Common/utility.h" 20 20 21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )21 DeclarationWithType::DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs ) 22 22 : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) { 23 23 } -
src/SynTree/FunctionDecl.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:33:43201713 // Update Count : 7 212 // Last Modified On : Thu Mar 16 07:49:35 2017 13 // Update Count : 73 14 14 // 15 15 … … 26 26 extern bool translation_unit_nomain; 27 27 28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )28 FunctionDecl::FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs ) 29 29 : Parent( name, scs, linkage, attributes, fs ), type( type ), statements( statements ) { 30 30 // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern -
src/SynTree/NamedTypeDecl.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:25:41201713 // Update Count : 1 212 // Last Modified On : Thu Mar 16 07:49:44 2017 13 // Update Count : 13 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base )20 NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base ) 21 21 : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} 22 22 -
src/SynTree/ObjectDecl.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:26:22201713 // Update Count : 5 712 // Last Modified On : Thu Mar 16 07:49:51 2017 13 // Update Count : 58 14 14 // 15 15 … … 22 22 #include "Statement.h" 23 23 24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )24 ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs ) 25 25 : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 26 26 } -
src/SynTree/Type.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:14:35 201713 // Update Count : 1912 // Last Modified On : Thu Mar 16 07:57:45 2017 13 // Update Count : 20 14 14 // 15 15 … … 59 59 } 60 60 61 // These must remain in the same order as the corresponding bit fields. 62 const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" }; 61 63 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 62 64 -
src/SynTree/Type.h
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 23:28:33201713 // Update Count : 8912 // Last Modified On : Thu Mar 16 07:45:29 2017 13 // Update Count : 90 14 14 // 15 15 … … 24 24 class Type : public BaseSyntaxNode { 25 25 public: 26 // enum must remain in the same order as the corresponding bit fields. 27 28 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 29 union StorageClasses { 30 static const char * Names[]; 31 unsigned int val; 32 struct { 33 bool is_extern : 1; 34 bool is_static : 1; 35 bool is_auto : 1; 36 bool is_register : 1; 37 bool is_threadlocal : 1; 38 }; 39 40 StorageClasses() : val( 0 ) {} 41 StorageClasses( unsigned int val ) : val( val ) {} 42 bool operator[]( unsigned int i ) const { return val & (1 << i); } 43 bool any() const { return val != 0; } 44 void print( std::ostream & os ) const { 45 if ( (*this).any() ) { // any storage classes ? 46 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { 47 if ( (*this)[i] ) { 48 os << StorageClasses::Names[i] << ' '; 49 } // if 50 } // for 51 } // if 52 } 53 }; // StorageClasses 54 26 55 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 27 56 union Qualifiers { -
src/SynTree/TypeDecl.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:39:09201713 // Update Count : 412 // Last Modified On : Thu Mar 16 07:49:58 2017 13 // Update Count : 5 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) { 21 21 } 22 22 -
src/Tuples/TupleAssignment.cc
r6e8bd43 r64b6913 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 08:00:44201713 // Update Count : 612 // Last Modified On : Thu Mar 16 08:04:51 2017 13 // Update Count : 7 14 14 // 15 15 … … 240 240 ObjectDecl * TupleAssignSpotter::Matcher::newObject( UniqueName & namer, Expression * expr ) { 241 241 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 242 ObjectDecl * ret = new ObjectDecl( namer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );242 ObjectDecl * ret = new ObjectDecl( namer.newName(), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 243 243 ConstructorInit * ctorInit = InitTweak::genCtorInit( ret ); 244 244 ret->set_init( ctorInit );
Note: See TracChangeset
for help on using the changeset viewer.