Changeset 1fbab5a
- Timestamp:
- Mar 16, 2017, 4:50:08 PM (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:
- 395fc37, 64ac636, ef42b143
- Parents:
- 2f26687a (diff), d6d747d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 57 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
r2f26687a r1fbab5a 20 20 21 21 parallel ( 22 gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) },23 gcc_6_x86: { trigger_build( 'gcc-6', 'x86' ) },24 gcc_5_x64: { trigger_build( 'gcc-5', 'x64' ) },25 gcc_5_x86: { trigger_build( 'gcc-5', 'x86' ) },26 gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64' ) },27 gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86' ) },28 clang_x64: { trigger_build( 'clang', 'x64' ) },29 clang_x86: { trigger_build( 'clang', 'x86' ) },22 gcc_6_x64: { trigger_build( 'gcc-6', 'x64', true ) }, 23 gcc_6_x86: { trigger_build( 'gcc-6', 'x86', true ) }, 24 gcc_5_x64: { trigger_build( 'gcc-5', 'x64', false ) }, 25 gcc_5_x86: { trigger_build( 'gcc-5', 'x86', false ) }, 26 gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64', false ) }, 27 gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86', false ) }, 28 clang_x64: { trigger_build( 'clang', 'x64', false ) }, 29 clang_x86: { trigger_build( 'clang', 'x86', false ) }, 30 30 ) 31 31 … … 62 62 //=========================================================================================================== 63 63 64 def trigger_build(String cc, String arch ) {64 def trigger_build(String cc, String arch, Boolean publish) { 65 65 def result = build job: 'Cforall/master', \ 66 66 parameters: [ \ … … 82 82 [$class: 'BooleanParameterValue', \ 83 83 name: 'pPublish', \ 84 value: true], \84 value: publish], \ 85 85 [$class: 'BooleanParameterValue', \ 86 86 name: 'pSilent', \ -
Jenkinsfile
r2f26687a r1fbab5a 131 131 [$class: 'BooleanParameterDefinition', \ 132 132 description: 'If true, jenkins also builds documentation', \ 133 name: 'pBuildDocumentation', 133 name: 'pBuildDocumentation', \ 134 134 defaultValue: true, \ 135 135 ], \ … … 137 137 description: 'If true, jenkins also publishes results', \ 138 138 name: 'pPublish', \ 139 defaultValue: true, \139 defaultValue: false, \ 140 140 ], \ 141 141 [$class: 'BooleanParameterDefinition', \ 142 142 description: 'If true, jenkins will not send emails', \ 143 name: 'pSilent', \143 name: 'pSilent', \ 144 144 defaultValue: false, \ 145 145 ], \ … … 159 159 echo """Compiler : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc}) 160 160 Architecture : ${arch_name} 161 Arc Flags 161 Arc Flags : ${architecture} 162 162 Run All Tests : ${ pRunAllTests.toString() } 163 163 Run Benchmark : ${ pRunBenchmark.toString() } -
doc/proposals/concurrency/thePlan.md
r2f26687a r1fbab5a 7 7 8 8 _Phase 2_ : Minimum Viable Product 9 Monitor type and enter/leave mutex member routines9 done - Monitor type and enter/leave mutex member routines 10 10 Monitors as a language feature (not calling enter/leave by hand) 11 11 Internal scheduling -
doc/proposals/flags.md
r2f26687a r1fbab5a 69 69 In each of the cases above, `FOO` could be replaced by `(BAR | BAZ)` to do the same operation or test on multiple flags at once. 70 70 71 ### Alternative/Additional Features ### 72 73 #### User-defined enum discriminant iterator #### 74 It may be useful to provide a more general method for changing the enum discriminant assignment function, e.g. the flag enum discriminants could be defined by something like the following: 75 76 ``` 77 enum(@ << 1) TCP_Flags { // each discriminant is left-shifted by 1 from the previous 78 FIN = 0x1, // first flag is 1 79 SYN, 80 ACK, 81 ... 82 } 83 ``` 84 85 #### Member expression for enums #### 86 As a more ergonomic way to set and unset enum flags, we could define a member expression for flags enums. Since only unions and structs can have member expressions now, this change would be backwards compatible. Basically, given a `FunFlags f`, `f.FOO` would return a proxy object which could be implicitly converted to `bool` (with semantics `f & FOO`, i.e. "check if `FOO` is set on `f`"), as well as having `bool` assigned to it (with semantics `f |= FOO` on true or `f -= FOO` on false, i.e. "set or unset `FOO` on `f` as appropriate"). With this member function, the operations above can be expressed as follows (possibly more ergonomically): 87 88 ``` 89 FunFlags f = some_val(); 90 if ( f.FOO ) { sout | "f has FOO set" | endl; } 91 f.FOO = true; // set FOO 92 f.FOO = false; // unset FOO 93 f.FOO = ! f.FOO; // toggle FOO 94 ``` 95 71 96 ### Related Work ### 72 97 C# has the [`[Flags]`][1] enum attribute, but their proposal does not go as far; specifically, the flag discriminants must be manually specified, and they do not automatically implement the bitwise operators on the flags. -
src/CodeGen/CodeGenerator.cc
r2f26687a r1fbab5a 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:56:59 201713 // Update Count : 4 7712 // Last Modified On : Thu Mar 16 09:09:09 2017 13 // Update Count : 480 14 14 // 15 15 … … 134 134 135 135 handleStorageClass( functionDecl ); 136 DeclarationNode::print_FuncSpec( output, functionDecl->get_funcSpec());136 functionDecl->get_funcSpec().print( output ); 137 137 138 138 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty ); … … 895 895 896 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 if ( decl->get_storageClasses(). val != 0) {898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses());897 if ( decl->get_storageClasses().any() ) { 898 decl->get_storageClasses().print( output ); 899 899 } // if 900 900 } // CodeGenerator::handleStorageClass -
src/CodeGen/FixNames.cc
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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 } … … 88 88 //Handles mutex routines definitions : 89 89 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { 90 // monitor_desc * __monitors[] = { a, b};90 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 91 91 // monitor_guard_t __guard = { __monitors, 2 }; 92 92 // /*Some code*/ => /*Some code*/ … … 98 98 using Visitor::visit; 99 99 virtual void visit( FunctionDecl *functionDecl ) override final; 100 virtual void visit( StructDecl *functionDecl ) override final; 100 101 101 102 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); … … 107 108 acceptAll( translationUnit, impl ); 108 109 } 110 111 private: 112 StructDecl* monitor_decl = nullptr; 109 113 }; 110 114 … … 133 137 if( ! body ) return; 134 138 139 assert(monitor_decl); 135 140 addStatments( body, mutexArgs ); 141 } 142 143 void MutexKeyword::visit(StructDecl* decl) { 144 if( decl->get_name() == "monitor_desc" ) { 145 assert( !monitor_decl ); 146 monitor_decl = decl; 147 } 136 148 } 137 149 … … 167 179 168 180 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 181 182 ObjectDecl * monitors = new ObjectDecl( 183 "__monitors", 184 noStorage, 185 LinkageSpec::Cforall, 186 nullptr, 187 new ArrayType( 188 noQualifiers, 189 new PointerType( 190 noQualifiers, 191 new StructInstType( 192 noQualifiers, 193 monitor_decl 194 ) 195 ), 196 new ConstantExpr( Constant::from_ulong( args.size() ) ), 197 false, 198 false 199 ), 200 new ListInit( 201 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){ 202 return new SingleInit( new UntypedExpr( 203 new NameExpr( "get_monitor" ), 204 { new VariableExpr( var ) } 205 ) ); 206 }) 207 ) 208 ); 209 169 210 //in reverse order : 170 211 // monitor_guard_t __guard = { __monitors, # }; … … 181 222 new ListInit( 182 223 { 183 new SingleInit( new NameExpr( "__monitors") ),224 new SingleInit( new VariableExpr( monitors ) ), 184 225 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 185 226 } … … 189 230 190 231 //monitor_desc * __monitors[] = { a, b }; 191 body->push_front( 192 new DeclStmt( noLabels, new ObjectDecl( 193 "__monitors", 194 noStorage, 195 LinkageSpec::Cforall, 196 nullptr, 197 new ArrayType( 198 noQualifiers, 199 new PointerType( 200 noQualifiers, 201 new StructInstType( 202 noQualifiers, 203 "monitor_desc" 204 ) 205 ), 206 new ConstantExpr( Constant::from_ulong( args.size() ) ), 207 false, 208 false 209 ), 210 new ListInit( 211 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){ 212 return new SingleInit( new VariableExpr( var ) ); 213 }) 214 ) 215 )) 216 ); 232 body->push_front( new DeclStmt( noLabels, monitors) ); 217 233 } 218 234 }; -
src/GenPoly/Box.cc
r2f26687a r1fbab5a 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:35:33 2017 13 // Update Count : 338 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 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );303 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ); 304 304 layoutDecl->fixUniqueId(); 305 305 return layoutDecl; … … 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 ); … … 381 381 // calculate struct layout in function body 382 382 383 // initialize size and alignment to 0 and 1 (will have at least one member to re-edit size 383 // initialize size and alignment to 0 and 1 (will have at least one member to re-edit size) 384 384 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "0" ) ) ) ); 385 385 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) ); … … 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 ) ) ); … … 1852 1852 1853 1853 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) ); 1854 ScrubTyVars::scrub( decl, scopeTyVars ); 1854 // ScrubTyVars::scrub( decl, scopeTyVars ); 1855 ScrubTyVars::scrubAll( decl ); 1855 1856 1856 1857 scopeTyVars.endScope(); -
src/GenPoly/GenPoly.cc
r2f26687a r1fbab5a 15 15 16 16 #include "GenPoly.h" 17 #include "assert.h" 17 18 18 19 #include "SynTree/Expression.h" 19 20 #include "SynTree/Type.h" 21 #include "ResolvExpr/typeops.h" 20 22 21 23 #include <iostream> 24 #include <iterator> 25 #include <list> 26 #include <typeindex> 27 #include <typeinfo> 28 #include <vector> 22 29 using namespace std; 23 30 … … 38 45 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) { 39 46 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 40 assert (paramType &&"Aggregate parameters should be type expressions");47 assertf(paramType, "Aggregate parameters should be type expressions"); 41 48 if ( isPolyType( paramType->get_type(), tyVars, env ) ) return true; 42 49 } … … 48 55 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) { 49 56 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 50 assert (paramType &&"Aggregate parameters should be type expressions");57 assertf(paramType, "Aggregate parameters should be type expressions"); 51 58 if ( isDynType( paramType->get_type(), tyVars, env ) ) return true; 59 } 60 return false; 61 } 62 63 /// Checks a parameter list for inclusion of polymorphic parameters; will substitute according to env if present 64 bool includesPolyParams( std::list< Expression* >& params, const TypeSubstitution *env ) { 65 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) { 66 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 67 assertf(paramType, "Aggregate parameters should be type expressions"); 68 if ( includesPolyType( paramType->get_type(), env ) ) return true; 69 } 70 return false; 71 } 72 73 /// Checks a parameter list for inclusion of polymorphic parameters from tyVars; will substitute according to env if present 74 bool includesPolyParams( std::list< Expression* >& params, const TyVarMap &tyVars, const TypeSubstitution *env ) { 75 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) { 76 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 77 assertf(paramType, "Aggregate parameters should be type expressions"); 78 if ( includesPolyType( paramType->get_type(), tyVars, env ) ) return true; 52 79 } 53 80 return false; … … 187 214 188 215 return isPolyType( type, tyVars, env ); 216 } 217 218 bool includesPolyType( Type *type, const TypeSubstitution *env ) { 219 type = replaceTypeInst( type, env ); 220 221 if ( dynamic_cast< TypeInstType * >( type ) ) { 222 return true; 223 } else if ( PointerType *pointerType = dynamic_cast< PointerType* >( type ) ) { 224 if ( includesPolyType( pointerType->get_base(), env ) ) return true; 225 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) { 226 if ( includesPolyParams( structType->get_parameters(), env ) ) return true; 227 } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) { 228 if ( includesPolyParams( unionType->get_parameters(), env ) ) return true; 229 } 230 return false; 231 } 232 233 bool includesPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 234 type = replaceTypeInst( type, env ); 235 236 if ( TypeInstType *typeInstType = dynamic_cast< TypeInstType * >( type ) ) { 237 if ( tyVars.find( typeInstType->get_name() ) != tyVars.end() ) { 238 return true; 239 } 240 } else if ( PointerType *pointerType = dynamic_cast< PointerType* >( type ) ) { 241 if ( includesPolyType( pointerType->get_base(), tyVars, env ) ) return true; 242 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) { 243 if ( includesPolyParams( structType->get_parameters(), tyVars, env ) ) return true; 244 } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) { 245 if ( includesPolyParams( unionType->get_parameters(), tyVars, env ) ) return true; 246 } 247 return false; 189 248 } 190 249 … … 237 296 } 238 297 298 namespace { 299 /// Checks if is a pointer to D 300 template<typename D, typename B> 301 bool is( const B* p ) { return type_index{typeid(D)} == type_index{typeid(*p)}; } 302 303 /// Converts to a pointer to D without checking for safety 304 template<typename D, typename B> 305 inline D* as( B* p ) { return reinterpret_cast<D*>(p); } 306 307 /// Flattens a declaration list 308 template<typename Output> 309 void flattenList( list< DeclarationWithType* > src, Output out ) { 310 for ( DeclarationWithType* decl : src ) { 311 ResolvExpr::flatten( decl->get_type(), out ); 312 } 313 } 314 315 /// Flattens a list of types 316 template<typename Output> 317 void flattenList( list< Type* > src, Output out ) { 318 for ( Type* ty : src ) { 319 ResolvExpr::flatten( ty, out ); 320 } 321 } 322 323 /// Checks if two lists of parameters are equal up to polymorphic substitution. 324 bool paramListsPolyCompatible( const list< Expression* >& aparams, const list< Expression* >& bparams ) { 325 if ( aparams.size() != bparams.size() ) return false; 326 327 for ( list< Expression* >::const_iterator at = aparams.begin(), bt = bparams.begin(); 328 at != aparams.end(); ++at, ++bt ) { 329 TypeExpr *aparam = dynamic_cast< TypeExpr* >(*at); 330 assertf(aparam, "Aggregate parameters should be type expressions"); 331 TypeExpr *bparam = dynamic_cast< TypeExpr* >(*bt); 332 assertf(bparam, "Aggregate parameters should be type expressions"); 333 334 // xxx - might need to let VoidType be a wildcard here too; could have some voids 335 // stuffed in for dtype-statics. 336 // if ( is<VoidType>( aparam->get_type() ) || is<VoidType>( bparam->get_type() ) ) continue; 337 if ( ! typesPolyCompatible( aparam->get_type(), bparam->get_type() ) ) return false; 338 } 339 340 return true; 341 } 342 } 343 344 bool typesPolyCompatible( Type *a, Type *b ) { 345 type_index aid{ typeid(*a) }; 346 // polymorphic types always match 347 if ( aid == type_index{typeid(TypeInstType)} ) return true; 348 349 type_index bid{ typeid(*b) }; 350 // polymorphic types always match 351 if ( bid == type_index{typeid(TypeInstType)} ) return true; 352 353 // can't match otherwise if different types 354 if ( aid != bid ) return false; 355 356 // recurse through type structure (conditions borrowed from Unify.cc) 357 if ( aid == type_index{typeid(BasicType)} ) { 358 return as<BasicType>(a)->get_kind() == as<BasicType>(b)->get_kind(); 359 } else if ( aid == type_index{typeid(PointerType)} ) { 360 PointerType *ap = as<PointerType>(a), *bp = as<PointerType>(b); 361 362 // void pointers should match any other pointer type 363 return is<VoidType>( ap->get_base() ) || is<VoidType>( bp->get_base() ) 364 || typesPolyCompatible( ap->get_base(), bp->get_base() ); 365 } else if ( aid == type_index{typeid(ArrayType)} ) { 366 ArrayType *aa = as<ArrayType>(a), *ba = as<ArrayType>(b); 367 368 if ( aa->get_isVarLen() ) { 369 if ( ! ba->get_isVarLen() ) return false; 370 } else { 371 if ( ba->get_isVarLen() ) return false; 372 373 ConstantExpr *ad = dynamic_cast<ConstantExpr*>( aa->get_dimension() ); 374 ConstantExpr *bd = dynamic_cast<ConstantExpr*>( ba->get_dimension() ); 375 if ( ad && bd 376 && ad->get_constant()->get_value() != bd->get_constant()->get_value() ) 377 return false; 378 } 379 380 return typesPolyCompatible( aa->get_base(), ba->get_base() ); 381 } else if ( aid == type_index{typeid(FunctionType)} ) { 382 FunctionType *af = as<FunctionType>(a), *bf = as<FunctionType>(b); 383 384 vector<Type*> aparams, bparams; 385 flattenList( af->get_parameters(), back_inserter( aparams ) ); 386 flattenList( bf->get_parameters(), back_inserter( bparams ) ); 387 if ( aparams.size() != bparams.size() ) return false; 388 389 vector<Type*> areturns, breturns; 390 flattenList( af->get_returnVals(), back_inserter( areturns ) ); 391 flattenList( bf->get_returnVals(), back_inserter( breturns ) ); 392 if ( areturns.size() != breturns.size() ) return false; 393 394 for ( unsigned i = 0; i < aparams.size(); ++i ) { 395 if ( ! typesPolyCompatible( aparams[i], bparams[i] ) ) return false; 396 } 397 for ( unsigned i = 0; i < areturns.size(); ++i ) { 398 if ( ! typesPolyCompatible( areturns[i], breturns[i] ) ) return false; 399 } 400 return true; 401 } else if ( aid == type_index{typeid(StructInstType)} ) { 402 StructInstType *aa = as<StructInstType>(a), *ba = as<StructInstType>(b); 403 404 if ( aa->get_name() != ba->get_name() ) return false; 405 return paramListsPolyCompatible( aa->get_parameters(), ba->get_parameters() ); 406 } else if ( aid == type_index{typeid(UnionInstType)} ) { 407 UnionInstType *aa = as<UnionInstType>(a), *ba = as<UnionInstType>(b); 408 409 if ( aa->get_name() != ba->get_name() ) return false; 410 return paramListsPolyCompatible( aa->get_parameters(), ba->get_parameters() ); 411 } else if ( aid == type_index{typeid(EnumInstType)} ) { 412 return as<EnumInstType>(a)->get_name() == as<EnumInstType>(b)->get_name(); 413 } else if ( aid == type_index{typeid(TraitInstType)} ) { 414 return as<TraitInstType>(a)->get_name() == as<TraitInstType>(b)->get_name(); 415 } else if ( aid == type_index{typeid(TupleType)} ) { 416 TupleType *at = as<TupleType>(a), *bt = as<TupleType>(b); 417 418 vector<Type*> atypes, btypes; 419 flattenList( at->get_types(), back_inserter( atypes ) ); 420 flattenList( bt->get_types(), back_inserter( btypes ) ); 421 if ( atypes.size() != btypes.size() ) return false; 422 423 for ( unsigned i = 0; i < atypes.size(); ++i ) { 424 if ( ! typesPolyCompatible( atypes[i], btypes[i] ) ) return false; 425 } 426 return true; 427 } else return true; // VoidType, VarArgsType, ZeroType & OneType just need the same type 428 } 429 239 430 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) { 240 431 tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar }; -
src/GenPoly/GenPoly.h
r2f26687a r1fbab5a 67 67 Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 ); 68 68 69 /// true iff this type or some base of this type after dereferencing pointers is either polymorphic or a generic type with at least one 70 /// polymorphic parameter; will look up substitution in env if provided. 71 bool includesPolyType( Type *type, const TypeSubstitution *env = 0 ); 72 73 /// true iff this type or some base of this type after dereferencing pointers is either polymorphic in tyVars, or a generic type with 74 /// at least one polymorphic parameter in tyVars; will look up substitution in env if provided. 75 bool includesPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 ); 76 69 77 /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise 70 78 FunctionType *getFunctionType( Type *ty ); … … 73 81 /// N will be stored in levels, if provided 74 82 VariableExpr *getBaseVar( Expression *expr, int *levels = 0 ); 83 84 /// true iff types are structurally identical, where TypeInstType's match any type. 85 bool typesPolyCompatible( Type *aty, Type *bty ); 75 86 76 87 /// Adds the type variable `tyVar` to `tyVarMap` -
src/GenPoly/InstantiateGeneric.cc
r2f26687a r1fbab5a 16 16 #include <cassert> 17 17 #include <list> 18 #include <unordered_map> 18 19 #include <utility> 19 20 #include <vector> 20 #include <unordered_map>21 21 22 22 #include "InstantiateGeneric.h" … … 25 25 #include "GenPoly.h" 26 26 #include "ScopedSet.h" 27 #include "ScrubTyVars.h" 27 28 #include "PolyMutator.h" 28 29 … … 77 78 if ( params.size() != that.params.size() ) return false; 78 79 79 SymTab::Indexer dummy;80 80 for ( std::list< Type* >::const_iterator it = params.begin(), jt = that.params.begin(); it != params.end(); ++it, ++jt ) { 81 if ( ! ResolvExpr::typesCompatible( *it, *jt, dummy) ) return false;81 if ( ! typesPolyCompatible( *it, *jt ) ) return false; 82 82 } 83 83 return true; … … 227 227 if ( (*baseParam)->isComplete() ) { 228 228 // substitute parameter for complete (otype or sized dtype) type 229 int pointerLevels = 0; 230 if ( hasPolyBase( paramType->get_type(), &pointerLevels ) && pointerLevels > 0 ) { 231 // Make a void* with equivalent nesting 232 Type* voidPtr = new VoidType( Type::Qualifiers() ); 233 while ( pointerLevels > 0 ) { 234 // Just about data layout, so qualifiers *shouldn't* matter 235 voidPtr = new PointerType( Type::Qualifiers(), voidPtr ); 236 --pointerLevels; 237 } 238 out.push_back( new TypeExpr( voidPtr ) ); 229 if ( isPolyType( paramType->get_type() ) ) { 230 // substitute polymorphic parameter type in to generic type 231 out.push_back( paramType->clone() ); 232 gt = genericType::dynamic; 239 233 } else { 240 // Just clone parameter type 241 out.push_back( paramType->clone() ); 234 // normalize possibly dtype-static parameter type 235 out.push_back( new TypeExpr{ 236 ScrubTyVars::scrubAll( paramType->get_type()->clone() ) } ); 237 gt |= genericType::concrete; 242 238 } 243 // make the struct concrete or dynamic depending on the parameter244 gt |= isPolyType( paramType->get_type() ) ? genericType::dynamic : genericType::concrete;245 239 } else switch ( (*baseParam)->get_kind() ) { 246 240 case TypeDecl::Dtype: … … 372 366 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 373 367 concDecl->set_body( inst->get_baseStruct()->has_body() ); 374 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, 368 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 375 369 DeclMutator::addDeclaration( concDecl ); 376 370 insert( inst, typeSubs, concDecl ); -
src/GenPoly/ScrubTyVars.cc
r2f26687a r1fbab5a 26 26 namespace GenPoly { 27 27 Type * ScrubTyVars::mutate( TypeInstType *typeInst ) { 28 TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); 29 if ( tyVar != tyVars.end() ) { 28 if ( ! tyVars ) { 29 if ( typeInst->get_isFtype() ) { 30 delete typeInst; 31 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 32 } else { 33 PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); 34 delete typeInst; 35 return ret; 36 } 37 } 38 39 TyVarMap::const_iterator tyVar = tyVars->find( typeInst->get_name() ); 40 if ( tyVar != tyVars->end() ) { 30 41 switch ( tyVar->second.kind ) { 31 42 case TypeDecl::Any: -
src/GenPoly/ScrubTyVars.h
r2f26687a r1fbab5a 26 26 namespace GenPoly { 27 27 class ScrubTyVars : public Mutator { 28 public:29 ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {}28 /// Whether to scrub all type variables from the provided map, dynamic type variables from the provided map, or all type variables 29 enum ScrubMode { FromMap, DynamicFromMap, All }; 30 30 31 ScrubTyVars() : tyVars(nullptr), mode( All ) {} 32 33 ScrubTyVars( const TyVarMap &tyVars, ScrubMode mode = FromMap ): tyVars( &tyVars ), mode( mode ) {} 34 35 public: 31 36 /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, 32 37 /// and sizeof/alignof expressions with the proper variable … … 38 43 template< typename SynTreeClass > 39 44 static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ); 45 46 /// For all polymorphic types, replaces generic types, dtypes, and ftypes with the appropriate void type, 47 /// and sizeof/alignof expressions with the proper variable 48 template< typename SynTreeClass > 49 static SynTreeClass *scrubAll( SynTreeClass *target ); 40 50 41 51 virtual Type* mutate( TypeInstType *typeInst ); … … 49 59 /// Returns the type if it should be scrubbed, NULL otherwise. 50 60 Type* shouldScrub( Type *ty ) { 51 return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars ); 52 // if ( ! dynamicOnly ) return isPolyType( ty, tyVars ); 53 // 54 // if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) { 55 // return tyVars.find( typeInst->get_name() ) != tyVars.end() ? ty : 0; 56 // } 57 // 58 // return isDynType( ty, tyVars ); 61 switch ( mode ) { 62 case FromMap: return isPolyType( ty, *tyVars ); 63 case DynamicFromMap: return isDynType( ty, *tyVars ); 64 case All: return isPolyType( ty ); 65 } 66 assert(false); return nullptr; // unreachable 67 // return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars ); 59 68 } 60 69 … … 62 71 Type* mutateAggregateType( Type *ty ); 63 72 64 const TyVarMap &tyVars; ///< Type variables to scrub65 bool dynamicOnly; ///< only scrub the types with dynamic layout? [false]73 const TyVarMap *tyVars; ///< Type variables to scrub 74 ScrubMode mode; ///< which type variables to scrub? [FromMap] 66 75 }; 67 76 … … 74 83 template< typename SynTreeClass > 75 84 SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) { 76 ScrubTyVars scrubber( tyVars, true ); 85 ScrubTyVars scrubber( tyVars, ScrubTyVars::DynamicFromMap ); 86 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 87 } 88 89 template< typename SynTreeClass > 90 SynTreeClass * ScrubTyVars::scrubAll( SynTreeClass *target ) { 91 ScrubTyVars scrubber; 77 92 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 78 93 } -
src/GenPoly/Specialize.cc
r2f26687a r1fbab5a 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 … … 179 179 } // if 180 180 // create new thunk with same signature as formal type (C linkage, empty body) 181 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ) );181 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), Type::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ) ); 182 182 thunkFunc->fixUniqueId(); 183 183 -
src/InitTweak/FixGlobalInit.cc
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 10:19:38201713 // Update Count : 96412 // Last Modified On : Thu Mar 16 09:10:57 2017 13 // Update Count : 1007 14 14 // 15 15 … … 33 33 34 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 35 const char * DeclarationNode::storageClassNames[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };36 const char * DeclarationNode::funcSpecifierNames[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };37 const char * DeclarationNode::typeQualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };38 35 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; 39 36 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; … … 116 113 } 117 114 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {119 if ( storageClasses.val != 0 ) { // storage classes ?120 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) {121 if ( storageClasses[i] ) {122 output << DeclarationNode::storageClassNames[i] << ' ';123 } // if124 } // for125 } // if126 } // print_StorageClass127 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {129 if ( funcSpec.val != 0 ) { // function specifiers ?130 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) {131 if ( funcSpec[i] ) {132 output << DeclarationNode::funcSpecifierNames[i] << ' ';133 } // if134 } // for135 } // if136 } // print_FuncSpec137 138 115 void DeclarationNode::print( std::ostream &os, int indent ) const { 139 116 os << string( indent, ' ' ); … … 148 125 } // if 149 126 150 print_StorageClass( os, storageClasses );151 print_FuncSpec( os, funcSpecs );127 storageClasses.print( os ); 128 funcSpecs.print( os ); 152 129 153 130 if ( type ) { … … 202 179 203 180 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) {181 DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) { 205 182 DeclarationNode * newnode = new DeclarationNode; 206 183 newnode->storageClasses = sc; … … 208 185 } // DeclarationNode::newStorageClass 209 186 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) {187 DeclarationNode * DeclarationNode::newFuncSpecifier( Type::FuncSpecifiers fs ) { 211 188 DeclarationNode * newnode = new DeclarationNode; 212 189 newnode->funcSpecs = fs; … … 214 191 } // DeclarationNode::newFuncSpecifier 215 192 216 DeclarationNode * DeclarationNode::newTypeQualifier( Type Qualifiertq ) {193 DeclarationNode * DeclarationNode::newTypeQualifier( Type::Qualifiers tq ) { 217 194 DeclarationNode * newnode = new DeclarationNode; 218 195 newnode->type = new TypeData(); 219 newnode->type-> typeQualifiers[ tq ] = true;196 newnode->type->qualifiers = tq; 220 197 return newnode; 221 198 } // DeclarationNode::newQualifier … … 457 434 458 435 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 459 const Type Data::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization460 461 if ( (qsrc & qdst).any() ) {// duplicates ?462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates436 const Type::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 437 438 if ( (qsrc.val & qdst.val) != 0 ) { // duplicates ? 439 for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates 463 440 if ( qsrc[i] && qdst[i] ) { 464 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] );441 appendError( error, string( "duplicate " ) + Type::Qualifiers::Names[i] ); 465 442 } // if 466 443 } // for … … 469 446 470 447 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 471 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { 472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates448 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 449 for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates 473 450 if ( funcSpecs[i] && src->funcSpecs[i] ) { 474 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );451 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] ); 475 452 } // if 476 453 } // for 477 454 } // if 478 455 479 if ( storageClasses. val != 0 && src->storageClasses.val != 0) { // any reason to check ?456 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 480 457 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 481 for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates458 for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates 482 459 if ( storageClasses[i] && src->storageClasses[i] ) { 483 appendError( error, string( "duplicate " ) + storageClassNames[i] );460 appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] ); 484 461 } // if 485 462 } // for 486 463 // src is the new item being added and has a single bit 487 464 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] +489 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] );465 appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] + 466 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] ); 490 467 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 491 468 } // if … … 496 473 497 474 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 498 funcSpecs.val = funcSpecs.val |q->funcSpecs.val;499 storageClasses.val = storageClasses.val |q->storageClasses.val;475 funcSpecs.val |= q->funcSpecs.val; 476 storageClasses.val |= q->storageClasses.val; 500 477 501 478 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 520 497 src = nullptr; 521 498 } else { 522 dst-> typeQualifiers |= src->typeQualifiers;499 dst->qualifiers += src->qualifiers; 523 500 } // if 524 501 } // addQualifiersToType … … 578 555 switch ( dst->kind ) { 579 556 case TypeData::Unknown: 580 src-> typeQualifiers |= dst->typeQualifiers;557 src->qualifiers += dst->qualifiers; 581 558 dst = src; 582 559 src = nullptr; 583 560 break; 584 561 case TypeData::Basic: 585 dst-> typeQualifiers |= src->typeQualifiers;562 dst->qualifiers += src->qualifiers; 586 563 if ( src->kind != TypeData::Unknown ) { 587 564 assert( src->kind == TypeData::Basic ); … … 619 596 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 620 597 } // if 621 dst->base-> typeQualifiers |= src->typeQualifiers;598 dst->base->qualifiers += src->qualifiers; 622 599 src = nullptr; 623 600 break; … … 651 628 type->aggInst.hoistType = o->type->enumeration.body; 652 629 } // if 653 type-> typeQualifiers |= o->type->typeQualifiers;630 type->qualifiers += o->type->qualifiers; 654 631 } else { 655 632 type = o->type; … … 807 784 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 808 785 } // if 809 p->type->base-> typeQualifiers |= type->typeQualifiers;786 p->type->base->qualifiers += type->qualifiers; 810 787 break; 811 788 … … 832 809 833 810 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 834 if ( a ) { 835 assert( a->type->kind == TypeData::Array ); 836 TypeData * lastArray = findLast( a->type ); 837 if ( type ) { 838 switch ( type->kind ) { 839 case TypeData::Aggregate: 840 case TypeData::Enum: 841 lastArray->base = new TypeData( TypeData::AggregateInst ); 842 lastArray->base->aggInst.aggregate = type; 843 if ( type->kind == TypeData::Aggregate ) { 844 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 845 } // if 846 lastArray->base->typeQualifiers |= type->typeQualifiers; 847 break; 848 default: 849 lastArray->base = type; 850 } // switch 851 type = nullptr; 852 } // if 853 delete this; 854 return a; 855 } else { 856 return this; 857 } // if 811 if ( ! a ) return this; 812 assert( a->type->kind == TypeData::Array ); 813 TypeData * lastArray = findLast( a->type ); 814 if ( type ) { 815 switch ( type->kind ) { 816 case TypeData::Aggregate: 817 case TypeData::Enum: 818 lastArray->base = new TypeData( TypeData::AggregateInst ); 819 lastArray->base->aggInst.aggregate = type; 820 if ( type->kind == TypeData::Aggregate ) { 821 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 822 } // if 823 lastArray->base->qualifiers += type->qualifiers; 824 break; 825 default: 826 lastArray->base = type; 827 } // switch 828 type = nullptr; 829 } // if 830 delete this; 831 return a; 858 832 } 859 833 … … 994 968 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 995 969 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 996 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );970 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 997 971 obj->location = cur->location; 998 972 * out++ = obj; … … 1000 974 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 1001 975 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 1002 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );976 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1003 977 obj->location = cur->location; 1004 978 * out++ = obj; … … 1047 1021 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1048 1022 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1049 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );1023 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] ); 1050 1024 buildList( variable.assertions, ret->get_assertions() ); 1051 1025 return ret; … … 1058 1032 // inline _Noreturn int g( int i ); // allowed 1059 1033 // inline _Noreturn int i; // disallowed 1060 if ( type->kind != TypeData::Function && funcSpecs. val != 0) {1034 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1061 1035 throw SemanticError( "invalid function specifier for ", this ); 1062 1036 } // if … … 1068 1042 // inlne _Noreturn struct S { ... }; // disallowed 1069 1043 // inlne _Noreturn enum E { ... }; // disallowed 1070 if ( funcSpecs. val != 0) {1044 if ( funcSpecs.any() ) { 1071 1045 throw SemanticError( "invalid function specifier for ", this ); 1072 1046 } // if -
src/Parser/ParseNode.h
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 11:05:05201713 // Update Count : 7 5212 // Last Modified On : Thu Mar 16 08:32:43 2017 13 // Update Count : 776 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset>22 21 #include <iterator> 23 22 #include <memory> … … 202 201 class DeclarationNode : public ParseNode { 203 202 public: 204 // These must remain in the same order as the corresponding DeclarationNode names.205 206 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };207 union StorageClasses {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 StorageClasses() : val( 0 ) {}217 StorageClasses( unsigned int val ) : val( val ) {}218 bool operator[]( unsigned int i ) const { return val & (1 << i); }219 }; // StorageClasses220 221 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 };222 union FuncSpecifiers {223 unsigned int val;224 struct {225 bool is_inline : 1;226 bool is_noreturn : 1;227 bool is_fortran : 1;228 };229 FuncSpecifiers() : val( 0 ) {}230 FuncSpecifiers( unsigned int val ) : val( val ) {}231 bool operator[]( unsigned int i ) const { return val & (1 << i); }232 }; // FuncSpecifiers233 234 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };235 203 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 236 204 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 241 209 enum BuiltinType { Valist, Zero, One, NoBuiltinType }; 242 210 243 static const char * storageClassNames[];244 static const char * funcSpecifierNames[];245 static const char * typeQualifierNames[];246 211 static const char * basicTypeNames[]; 247 212 static const char * complexTypeNames[]; … … 252 217 static const char * builtinTypeNames[]; 253 218 254 static DeclarationNode * newStorageClass( StorageClasses );255 static DeclarationNode * newFuncSpecifier( FuncSpecifiers );256 static DeclarationNode * newTypeQualifier( Type Qualifier);219 static DeclarationNode * newStorageClass( Type::StorageClasses ); 220 static DeclarationNode * newFuncSpecifier( Type::FuncSpecifiers ); 221 static DeclarationNode * newTypeQualifier( Type::Qualifiers ); 257 222 static DeclarationNode * newBasicType( BasicType ); 258 223 static DeclarationNode * newComplexType( ComplexType ); … … 350 315 TypeData * type; 351 316 352 StorageClasses storageClasses; 353 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 354 355 FuncSpecifiers funcSpecs; 356 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); 317 Type::FuncSpecifiers funcSpecs; 318 Type::StorageClasses storageClasses; 357 319 358 320 ExpressionNode * bitfieldWidth; -
src/Parser/TypeData.cc
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:08:21201713 // Update Count : 5 3812 // Last Modified On : Thu Mar 16 08:32:42 2017 13 // Update Count : 559 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 29 29 switch ( kind ) { 30 30 case Unknown: … … 50 50 function.newStyle = false; 51 51 break; 52 // Enum is an Aggregate, so both structures are initialized together. 53 case Enum: 54 // enumeration = new Enumeration_t; 55 enumeration.name = nullptr; 56 enumeration.constants = nullptr; 57 enumeration.body = false; 52 58 case Aggregate: 53 59 // aggregate = new Aggregate_t; … … 64 70 aggInst.hoistType = false;; 65 71 break; 66 case Enum:67 // enumeration = new Enumeration_t;68 enumeration.name = nullptr;69 enumeration.constants = nullptr;70 enumeration.body = false;71 break;72 72 case Symbolic: 73 73 case SymbolicInst: … … 157 157 TypeData * TypeData::clone() const { 158 158 TypeData * newtype = new TypeData( kind ); 159 newtype-> typeQualifiers = typeQualifiers;159 newtype->qualifiers = qualifiers; 160 160 newtype->base = maybeClone( base ); 161 161 newtype->forall = maybeClone( forall ); … … 226 226 227 227 void TypeData::print( ostream &os, int indent ) const { 228 for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) {229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';228 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { 229 if ( qualifiers[i] ) os << Type::Qualifiers::Names[ i ] << ' '; 230 230 } // for 231 231 … … 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 … … 493 493 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 Type::Qualifiers q; 496 q.isConst = td->typeQualifiers[ DeclarationNode::Const ]; 497 q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ]; 498 q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ]; 499 q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ]; 500 q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];; 501 return q; 495 return td->qualifiers; 502 496 } // buildQualifiers 503 497 … … 732 726 } // buildAggInst 733 727 734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClasses scs ) {728 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) { 735 729 assert( td->kind == TypeData::Symbolic ); 736 730 NamedTypeDecl * ret; … … 784 778 } // buildTypeof 785 779 786 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, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 787 781 if ( td->kind == TypeData::Function ) { 788 782 if ( td->function.idList ) { // KR function ? … … 820 814 break; 821 815 default: 822 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, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 823 817 } // switch 824 818 } else { 825 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 ) ); 826 820 } // if 827 821 return ft; -
src/Parser/TypeData.h
r2f26687a r1fbab5a 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 8 22:28:33201713 // Update Count : 1 7412 // Last Modified On : Thu Mar 16 08:32:39 2017 13 // Update Count : 185 14 14 // 15 15 16 16 #ifndef TYPEDATA_H 17 17 #define TYPEDATA_H 18 19 #include <bitset>20 18 21 19 #include "ParseNode.h" … … 77 75 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 76 79 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 80 TypeQualifiers typeQualifiers; 77 Type::Qualifiers qualifiers; 81 78 DeclarationNode * forall; 82 79 … … 112 109 TupleType * buildTuple( const TypeData * ); 113 110 TypeofType * buildTypeof( const TypeData * ); 114 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 *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 115 112 FunctionType * buildFunction( const TypeData * ); 116 113 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/parser.yy
r2f26687a r1fbab5a 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 9 21:40:20201713 // Update Count : 2 29212 // Last Modified On : Thu Mar 16 08:36:17 2017 13 // Update Count : 2310 14 14 // 15 15 … … 441 441 argument_expression: 442 442 // empty 443 { $$ = nullptr; } // use default argument 443 { $$ = nullptr; } 444 // | '@' // use default argument 445 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 444 446 | assignment_expression 445 447 ; … … 1408 1410 type_qualifier_name: 1409 1411 CONST 1410 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Const ); }1412 { $$ = DeclarationNode::newTypeQualifier( Type::Const ); } 1411 1413 | RESTRICT 1412 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Restrict ); }1414 { $$ = DeclarationNode::newTypeQualifier( Type::Restrict ); } 1413 1415 | VOLATILE 1414 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Volatile ); }1416 { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); } 1415 1417 | LVALUE // CFA 1416 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); }1418 { $$ = DeclarationNode::newTypeQualifier( Type::Lvalue ); } 1417 1419 | MUTEX 1418 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Mutex ); }1420 { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); } 1419 1421 | ATOMIC 1420 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Atomic ); }1422 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } 1421 1423 | FORALL '(' 1422 1424 { … … 1451 1453 storage_class: 1452 1454 EXTERN 1453 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }1455 { $$ = DeclarationNode::newStorageClass( Type::Extern ); } 1454 1456 | STATIC 1455 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); }1457 { $$ = DeclarationNode::newStorageClass( Type::Static ); } 1456 1458 | AUTO 1457 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }1459 { $$ = DeclarationNode::newStorageClass( Type::Auto ); } 1458 1460 | REGISTER 1459 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }1461 { $$ = DeclarationNode::newStorageClass( Type::Register ); } 1460 1462 | THREADLOCAL // C11 1461 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }1463 { $$ = DeclarationNode::newStorageClass( Type::Threadlocal ); } 1462 1464 // Put function specifiers here to simplify parsing rules, but separate them semantically. 1463 1465 | INLINE // C99 1464 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }1466 { $$ = DeclarationNode::newFuncSpecifier( Type::Inline ); } 1465 1467 | FORTRAN // C99 1466 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }1468 { $$ = DeclarationNode::newFuncSpecifier( Type::Fortran ); } 1467 1469 | NORETURN // C11 1468 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }1470 { $$ = DeclarationNode::newFuncSpecifier( Type::Noreturn ); } 1469 1471 ; 1470 1472 … … 1686 1688 // empty 1687 1689 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1690 // '@' // empty 1691 // { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1688 1692 | bit_subrange_size // no field name 1689 1693 { $$ = DeclarationNode::newBitfield( $1 ); } -
src/ResolvExpr/Unify.cc
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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:37:22 2017 13 // Update Count : 59 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 ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );167 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ); 168 168 decl->fixUniqueId(); 169 169 return decl; … … 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,722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 729 729 typeParams.push_back( newDecl ); 730 730 done.insert( ty->get_baseType() ); -
src/SymTab/Autogen.h
r2f26687a r1fbab5a 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:33:01201713 // Update Count : 412 // Last Modified On : Thu Mar 16 07:51:39 2017 13 // Update Count : 8 14 14 // 15 15 … … 58 58 assert( type ); 59 59 Type * castType = type->clone(); 60 castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 60 // castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 61 castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 61 62 castType->set_isLvalue( true ); // xxx - might not need this 62 63 dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) ); … … 102 103 } 103 104 104 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*>() ) ); 105 106 106 107 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/Validate.cc
r2f26687a r1fbab5a 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 7 07:51:36201713 // Update Count : 3 4912 // 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; … … 323 323 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i ); 324 324 assert( obj ); 325 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false), enumDecl->get_name() ) );325 obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) ); 326 326 } // for 327 327 Parent::visit( enumDecl ); … … 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
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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 08:34:11 2017 13 // Update Count : 118 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, Type::FuncSpecifiers fs ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 82 82 const std::list< Attribute * >& get_attributes() const { return attributes; } 83 83 84 DeclarationNode::FuncSpecifiers get_funcSpec() const { return fs; }85 //void set_functionSpecifiers( DeclarationNode::FuncSpecifiers newValue ) { fs = newValue; }84 Type::FuncSpecifiers get_funcSpec() const { return fs; } 85 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } 86 86 87 87 virtual DeclarationWithType *clone() const = 0; … … 98 98 ConstantExpr *asmName; 99 99 std::list< Attribute * > attributes; 100 DeclarationNode::FuncSpecifiers fs;100 Type::FuncSpecifiers fs; 101 101 }; 102 102 … … 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,107 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );106 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 108 108 ObjectDecl( const ObjectDecl &other ); 109 109 virtual ~ObjectDecl(); … … 132 132 typedef DeclarationWithType Parent; 133 133 public: 134 FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,135 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );134 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 136 136 FunctionDecl( const FunctionDecl &other ); 137 137 virtual ~FunctionDecl(); … … 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
r2f26687a r1fbab5a 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 08:34:35 2017 13 // Update Count : 25 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, Type::FuncSpecifiers fs ) 22 22 : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) { 23 23 } -
src/SynTree/FunctionDecl.cc
r2f26687a r1fbab5a 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:54:58201713 // Update Count : 6812 // Last Modified On : Thu Mar 16 08:33:41 2017 13 // Update Count : 74 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, Type::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 … … 65 65 printAll( get_attributes(), os, indent ); 66 66 67 DeclarationNode::print_StorageClass( os, get_storageClasses());68 DeclarationNode::print_FuncSpec( os, get_funcSpec());67 get_storageClasses().print( os ); 68 get_funcSpec().print( os ); 69 69 70 70 if ( get_type() ) { … … 91 91 // xxx - should printShort print attributes? 92 92 93 DeclarationNode::print_StorageClass( os, get_storageClasses());94 DeclarationNode::print_FuncSpec( os, get_funcSpec());93 get_storageClasses().print( os ); 94 get_funcSpec().print( os ); 95 95 96 96 if ( get_type() ) { -
src/SynTree/NamedTypeDecl.cc
r2f26687a r1fbab5a 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:41201713 // Update Count : 1 012 // 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 … … 39 39 os << get_name() << ": "; 40 40 } // if 41 DeclarationNode::print_StorageClass( os, get_storageClasses());41 get_storageClasses().print( os ); 42 42 os << typeString(); 43 43 if ( base ) { … … 61 61 os << get_name() << ": "; 62 62 } // if 63 DeclarationNode::print_StorageClass( os, get_storageClasses());63 get_storageClasses().print( os ); 64 64 os << typeString(); 65 65 if ( base ) { -
src/SynTree/ObjectDecl.cc
r2f26687a r1fbab5a 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:55:24201713 // Update Count : 5 412 // Last Modified On : Thu Mar 16 08:34:27 2017 13 // Update Count : 59 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, Type::FuncSpecifiers fs ) 25 25 : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 26 26 } … … 47 47 printAll( get_attributes(), os, indent ); 48 48 49 DeclarationNode::print_StorageClass( os, get_storageClasses());49 get_storageClasses().print( os ); 50 50 51 51 if ( get_type() ) { … … 81 81 // xxx - should printShort print attributes? 82 82 83 DeclarationNode::print_StorageClass( os, get_storageClasses());83 get_storageClasses().print( os ); 84 84 85 85 if ( get_type() ) { -
src/SynTree/Type.cc
r2f26687a r1fbab5a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:26:24201713 // Update Count : 1212 // Last Modified On : Thu Mar 16 10:25:06 2017 13 // Update Count : 23 14 14 // 15 15 … … 59 59 } 60 60 61 void Type::Qualifiers::print( std::ostream &os, int indent ) const { 62 if ( isConst ) { 63 os << "const "; 64 } // if 65 if ( isVolatile ) { 66 os << "volatile "; 67 } // if 68 if ( isRestrict ) { 69 os << "restrict "; 70 } // if 71 if ( isLvalue ) { 72 os << "lvalue "; 73 } // if 74 if ( isAtomic ) { 75 os << "_Atomic "; 76 } // if 77 } 61 // These must remain in the same order as the corresponding bit fields. 62 const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" }; 63 const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" }; 64 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 78 65 79 66 void Type::print( std::ostream &os, int indent ) const { … … 89 76 } // if 90 77 91 tq.print( os , indent);78 tq.print( os ); 92 79 } 93 80 -
src/SynTree/Type.h
r2f26687a r1fbab5a 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 1 09:11:45201713 // Update Count : 4112 // Last Modified On : Thu Mar 16 12:11:50 2017 13 // Update Count : 116 14 14 // 15 15 … … 24 24 class Type : public BaseSyntaxNode { 25 25 public: 26 struct Qualifiers { 27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {} 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {} 29 30 Qualifiers &operator&=( const Qualifiers &other ); 31 Qualifiers &operator+=( const Qualifiers &other ); 32 Qualifiers &operator-=( const Qualifiers &other ); 33 Qualifiers operator+( const Type::Qualifiers &other ); 34 bool operator==( const Qualifiers &other ); 35 bool operator!=( const Qualifiers &other ); 36 bool operator<=( const Qualifiers &other ); 37 bool operator>=( const Qualifiers &other ); 38 bool operator<( const Qualifiers &other ); 39 bool operator>( const Qualifiers &other ); 40 void print( std::ostream &os, int indent = 0 ) const; 41 42 bool isConst; 43 bool isVolatile; 44 bool isRestrict; 45 bool isLvalue; 46 bool isAtomic; 47 bool isMutex; 48 }; 49 50 Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ); 51 Type( const Type &other ); 26 #define CommonBF( N ) \ 27 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ 28 bool any() const { return val != 0; } \ 29 static const char * Names[]; \ 30 void print( std::ostream & os ) const { \ 31 if ( (*this).any() ) { \ 32 for ( unsigned int i = 0; i < N; i += 1 ) { \ 33 if ( (*this)[i] ) { \ 34 os << Names[i] << ' '; \ 35 } \ 36 } \ 37 } \ 38 } 39 40 // enum must remain in the same order as the corresponding bit fields. 41 42 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 43 union FuncSpecifiers { 44 unsigned int val; 45 struct { 46 bool is_inline : 1; 47 bool is_noreturn : 1; 48 bool is_fortran : 1; 49 }; 50 FuncSpecifiers() : val( 0 ) {} 51 FuncSpecifiers( unsigned int val ) : val( val ) {} 52 CommonBF( NumFuncSpecifier ) 53 }; // FuncSpecifiers 54 55 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 56 union StorageClasses { 57 unsigned int val; 58 struct { 59 bool is_extern : 1; 60 bool is_static : 1; 61 bool is_auto : 1; 62 bool is_register : 1; 63 bool is_threadlocal : 1; 64 }; 65 66 StorageClasses() : val( 0 ) {} 67 StorageClasses( unsigned int val ) : val( val ) {} 68 CommonBF( NumStorageClass ) 69 }; // StorageClasses 70 71 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 72 union Qualifiers { 73 enum { Mask = ~(Restrict | Lvalue) }; 74 unsigned int val; 75 struct { 76 bool isConst : 1; 77 bool isRestrict : 1; 78 bool isVolatile : 1; 79 bool isLvalue : 1; 80 bool isMutex : 1; 81 bool isAtomic : 1; 82 }; 83 84 Qualifiers() : val( 0 ) {} 85 Qualifiers( unsigned int val ) : val( val ) {} 86 bool operator==( Qualifiers other ) const { 87 return (val & Mask) == (other.val & Mask); 88 } 89 bool operator!=( Qualifiers other ) const { 90 return (val & Mask) != (other.val & Mask); 91 } 92 bool operator<=( Qualifiers other ) const { 93 return isConst <= other.isConst && isVolatile <= other.isVolatile && 94 isMutex == other.isMutex && isAtomic == other.isAtomic; 95 } 96 bool operator>=( Qualifiers other ) const { 97 return isConst >= other.isConst && isVolatile >= other.isVolatile && 98 isMutex == other.isMutex && isAtomic == other.isAtomic; 99 } 100 bool operator<( Qualifiers other ) const { 101 return *this != other && *this <= other; 102 } 103 bool operator>( Qualifiers other ) const { 104 return *this != other && *this >= other; 105 } 106 Qualifiers operator&=( Type::Qualifiers other ) { 107 val &= other.val; return *this; 108 } 109 Qualifiers operator+=( Qualifiers other ) { 110 val |= other.val; return *this; 111 } 112 Qualifiers operator-=( Qualifiers other ) { 113 val &= ~other.val; return *this; 114 } 115 Qualifiers operator+( Qualifiers other ) const { 116 Qualifiers q = other; 117 q += *this; 118 return q; 119 } 120 CommonBF( NumTypeQualifier ) 121 }; // Qualifiers 122 123 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 124 Type( const Type & other ); 52 125 virtual ~Type(); 53 126 54 Qualifiers & get_qualifiers() { return tq; }127 Qualifiers & get_qualifiers() { return tq; } 55 128 bool get_isConst() { return tq.isConst; } 56 129 bool get_isVolatile() { return tq.isVolatile; } … … 78 151 79 152 virtual Type *clone() const = 0; 80 virtual void accept( Visitor & v ) = 0;81 virtual Type *acceptMutator( Mutator & m ) = 0;82 virtual void print( std::ostream & os, int indent = 0 ) const;153 virtual void accept( Visitor & v ) = 0; 154 virtual Type *acceptMutator( Mutator & m ) = 0; 155 virtual void print( std::ostream & os, int indent = 0 ) const; 83 156 private: 84 157 Qualifiers tq; … … 91 164 class VoidType : public Type { 92 165 public: 93 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );166 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 94 167 95 168 virtual unsigned size() const { return 0; }; … … 97 170 98 171 virtual VoidType *clone() const { return new VoidType( *this ); } 99 virtual void accept( Visitor & v ) { v.visit( this ); }100 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }101 virtual void print( std::ostream & os, int indent = 0 ) const;172 virtual void accept( Visitor & v ) { v.visit( this ); } 173 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 174 virtual void print( std::ostream & os, int indent = 0 ) const; 102 175 }; 103 176 … … 131 204 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind 132 205 133 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );206 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 134 207 135 208 Kind get_kind() { return kind; } … … 137 210 138 211 virtual BasicType *clone() const { return new BasicType( *this ); } 139 virtual void accept( Visitor & v ) { v.visit( this ); }140 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }141 virtual void print( std::ostream & os, int indent = 0 ) const;212 virtual void accept( Visitor & v ) { v.visit( this ); } 213 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 214 virtual void print( std::ostream & os, int indent = 0 ) const; 142 215 143 216 bool isInteger() const; … … 148 221 class PointerType : public Type { 149 222 public: 150 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );151 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );223 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 224 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 152 225 PointerType( const PointerType& ); 153 226 virtual ~PointerType(); … … 163 236 164 237 virtual PointerType *clone() const { return new PointerType( *this ); } 165 virtual void accept( Visitor & v ) { v.visit( this ); }166 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }167 virtual void print( std::ostream & os, int indent = 0 ) const;238 virtual void accept( Visitor & v ) { v.visit( this ); } 239 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 240 virtual void print( std::ostream & os, int indent = 0 ) const; 168 241 private: 169 242 Type *base; … … 177 250 class ArrayType : public Type { 178 251 public: 179 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );252 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 180 253 ArrayType( const ArrayType& ); 181 254 virtual ~ArrayType(); … … 193 266 194 267 virtual ArrayType *clone() const { return new ArrayType( *this ); } 195 virtual void accept( Visitor & v ) { v.visit( this ); }196 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }197 virtual void print( std::ostream & os, int indent = 0 ) const;268 virtual void accept( Visitor & v ) { v.visit( this ); } 269 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 270 virtual void print( std::ostream & os, int indent = 0 ) const; 198 271 private: 199 272 Type *base; … … 205 278 class FunctionType : public Type { 206 279 public: 207 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );280 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 208 281 FunctionType( const FunctionType& ); 209 282 virtual ~FunctionType(); … … 216 289 217 290 virtual FunctionType *clone() const { return new FunctionType( *this ); } 218 virtual void accept( Visitor & v ) { v.visit( this ); }219 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }220 virtual void print( std::ostream & os, int indent = 0 ) const;291 virtual void accept( Visitor & v ) { v.visit( this ); } 292 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 293 virtual void print( std::ostream & os, int indent = 0 ) const; 221 294 private: 222 295 std::list<DeclarationWithType*> returnVals; … … 232 305 class ReferenceToType : public Type { 233 306 public: 234 ReferenceToType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes );235 ReferenceToType( const ReferenceToType & other );307 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 308 ReferenceToType( const ReferenceToType & other ); 236 309 virtual ~ReferenceToType(); 237 310 238 const std::string & get_name() const { return name; }311 const std::string & get_name() const { return name; } 239 312 void set_name( std::string newValue ) { name = newValue; } 240 313 std::list< Expression* >& get_parameters() { return parameters; } … … 243 316 244 317 virtual ReferenceToType *clone() const = 0; 245 virtual void accept( Visitor & v ) = 0;246 virtual Type *acceptMutator( Mutator & m ) = 0;247 virtual void print( std::ostream & os, int indent = 0 ) const;318 virtual void accept( Visitor & v ) = 0; 319 virtual Type *acceptMutator( Mutator & m ) = 0; 320 virtual void print( std::ostream & os, int indent = 0 ) const; 248 321 protected: 249 322 virtual std::string typeString() const = 0; … … 257 330 typedef ReferenceToType Parent; 258 331 public: 259 StructInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}260 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() );261 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}332 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 333 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 334 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {} 262 335 263 336 StructDecl *get_baseStruct() const { return baseStruct; } … … 271 344 /// Looks up the members of this struct named "name" and places them into "foundDecls". 272 345 /// Clones declarations into "foundDecls", caller responsible for freeing 273 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;346 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 274 347 275 348 virtual StructInstType *clone() const { return new StructInstType( *this ); } 276 virtual void accept( Visitor & v ) { v.visit( this ); }277 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }278 279 virtual void print( std::ostream & os, int indent = 0 ) const;349 virtual void accept( Visitor & v ) { v.visit( this ); } 350 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 351 352 virtual void print( std::ostream & os, int indent = 0 ) const; 280 353 private: 281 354 virtual std::string typeString() const; … … 289 362 typedef ReferenceToType Parent; 290 363 public: 291 UnionInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}292 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() );293 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}364 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 365 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 366 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {} 294 367 295 368 UnionDecl *get_baseUnion() const { return baseUnion; } … … 303 376 /// looks up the members of this union named "name" and places them into "foundDecls" 304 377 /// Clones declarations into "foundDecls", caller responsible for freeing 305 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;378 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 306 379 307 380 virtual UnionInstType *clone() const { return new UnionInstType( *this ); } 308 virtual void accept( Visitor & v ) { v.visit( this ); }309 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }310 311 virtual void print( std::ostream & os, int indent = 0 ) const;381 virtual void accept( Visitor & v ) { v.visit( this ); } 382 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 383 384 virtual void print( std::ostream & os, int indent = 0 ) const; 312 385 private: 313 386 virtual std::string typeString() const; … … 321 394 typedef ReferenceToType Parent; 322 395 public: 323 EnumInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}324 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() );325 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}396 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 397 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 398 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {} 326 399 327 400 EnumDecl *get_baseEnum() const { return baseEnum; } … … 331 404 332 405 virtual EnumInstType *clone() const { return new EnumInstType( *this ); } 333 virtual void accept( Visitor & v ) { v.visit( this ); }334 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }406 virtual void accept( Visitor & v ) { v.visit( this ); } 407 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 335 408 private: 336 409 virtual std::string typeString() const; … … 344 417 typedef ReferenceToType Parent; 345 418 public: 346 TraitInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}347 TraitInstType( const TraitInstType & other );419 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 420 TraitInstType( const TraitInstType & other ); 348 421 ~TraitInstType(); 349 422 … … 353 426 354 427 virtual TraitInstType *clone() const { return new TraitInstType( *this ); } 355 virtual void accept( Visitor & v ) { v.visit( this ); }356 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }428 virtual void accept( Visitor & v ) { v.visit( this ); } 429 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 357 430 private: 358 431 virtual std::string typeString() const; … … 366 439 typedef ReferenceToType Parent; 367 440 public: 368 TypeInstType( const Type::Qualifiers & tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );369 TypeInstType( const Type::Qualifiers & tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() );370 TypeInstType( const TypeInstType & other );441 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 442 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 443 TypeInstType( const TypeInstType & other ); 371 444 ~TypeInstType(); 372 445 … … 379 452 380 453 virtual TypeInstType *clone() const { return new TypeInstType( *this ); } 381 virtual void accept( Visitor & v ) { v.visit( this ); }382 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }383 virtual void print( std::ostream & os, int indent = 0 ) const;454 virtual void accept( Visitor & v ) { v.visit( this ); } 455 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 456 virtual void print( std::ostream & os, int indent = 0 ) const; 384 457 private: 385 458 virtual std::string typeString() const; … … 392 465 class TupleType : public Type { 393 466 public: 394 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() );467 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 395 468 TupleType( const TupleType& ); 396 469 virtual ~TupleType(); … … 413 486 414 487 virtual TupleType *clone() const { return new TupleType( *this ); } 415 virtual void accept( Visitor & v ) { v.visit( this ); }416 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }417 virtual void print( std::ostream & os, int indent = 0 ) const;488 virtual void accept( Visitor & v ) { v.visit( this ); } 489 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 490 virtual void print( std::ostream & os, int indent = 0 ) const; 418 491 private: 419 492 std::list<Type*> types; … … 422 495 class TypeofType : public Type { 423 496 public: 424 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );497 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 425 498 TypeofType( const TypeofType& ); 426 499 virtual ~TypeofType(); … … 432 505 433 506 virtual TypeofType *clone() const { return new TypeofType( *this ); } 434 virtual void accept( Visitor & v ) { v.visit( this ); }435 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }436 virtual void print( std::ostream & os, int indent = 0 ) const;507 virtual void accept( Visitor & v ) { v.visit( this ); } 508 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 509 virtual void print( std::ostream & os, int indent = 0 ) const; 437 510 private: 438 511 Expression *expr; … … 441 514 class AttrType : public Type { 442 515 public: 443 AttrType( const Type::Qualifiers & tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );444 AttrType( const Type::Qualifiers & tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() );516 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 517 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 445 518 AttrType( const AttrType& ); 446 519 virtual ~AttrType(); 447 520 448 const std::string & get_name() const { return name; }449 void set_name( const std::string & newValue ) { name = newValue; }521 const std::string & get_name() const { return name; } 522 void set_name( const std::string & newValue ) { name = newValue; } 450 523 Expression *get_expr() const { return expr; } 451 524 void set_expr( Expression *newValue ) { expr = newValue; } … … 458 531 459 532 virtual AttrType *clone() const { return new AttrType( *this ); } 460 virtual void accept( Visitor & v ) { v.visit( this ); }461 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }462 virtual void print( std::ostream & os, int indent = 0 ) const;533 virtual void accept( Visitor & v ) { v.visit( this ); } 534 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 535 virtual void print( std::ostream & os, int indent = 0 ) const; 463 536 private: 464 537 std::string name; … … 477 550 478 551 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 479 virtual void accept( Visitor & v ) { v.visit( this ); }480 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }481 virtual void print( std::ostream & os, int indent = 0 ) const;552 virtual void accept( Visitor & v ) { v.visit( this ); } 553 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 554 virtual void print( std::ostream & os, int indent = 0 ) const; 482 555 }; 483 556 … … 489 562 490 563 virtual ZeroType *clone() const { return new ZeroType( *this ); } 491 virtual void accept( Visitor & v ) { v.visit( this ); }492 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }493 virtual void print( std::ostream & os, int indent = 0 ) const;564 virtual void accept( Visitor & v ) { v.visit( this ); } 565 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 566 virtual void print( std::ostream & os, int indent = 0 ) const; 494 567 }; 495 568 … … 501 574 502 575 virtual OneType *clone() const { return new OneType( *this ); } 503 virtual void accept( Visitor &v ) { v.visit( this ); } 504 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 505 virtual void print( std::ostream &os, int indent = 0 ) const; 506 }; 507 508 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 509 isConst &= other.isConst; 510 isVolatile &= other.isVolatile; 511 isRestrict &= other.isRestrict; 512 isLvalue &= other.isLvalue; 513 isAtomic &= other.isAtomic; 514 isMutex &= other.isMutex; 515 return *this; 516 } 517 518 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 519 isConst |= other.isConst; 520 isVolatile |= other.isVolatile; 521 isRestrict |= other.isRestrict; 522 isLvalue |= other.isLvalue; 523 isAtomic |= other.isAtomic; 524 isMutex |= other.isMutex; 525 return *this; 526 } 527 528 inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) { 529 if ( other.isConst ) isConst = 0; 530 if ( other.isVolatile ) isVolatile = 0; 531 if ( other.isRestrict ) isRestrict = 0; 532 if ( other.isAtomic ) isAtomic = 0; 533 if ( other.isMutex ) isMutex = 0; 534 return *this; 535 } 536 537 inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) { 538 Qualifiers q = other; 539 q += *this; 540 return q; 541 } 542 543 inline bool Type::Qualifiers::operator==( const Qualifiers &other ) { 544 return isConst == other.isConst 545 && isVolatile == other.isVolatile 546 // && isRestrict == other.isRestrict 547 // && isLvalue == other.isLvalue 548 && isAtomic == other.isAtomic; 549 } 550 551 inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) { 552 return isConst != other.isConst 553 || isVolatile != other.isVolatile 554 // || isRestrict != other.isRestrict 555 // || isLvalue != other.isLvalue 556 || isAtomic != other.isAtomic; 557 } 558 559 inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) { 560 return isConst <= other.isConst 561 && isVolatile <= other.isVolatile 562 // && isRestrict <= other.isRestrict 563 // && isLvalue >= other.isLvalue 564 && isAtomic == other.isAtomic; 565 } 566 567 inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) { 568 return isConst >= other.isConst 569 && isVolatile >= other.isVolatile 570 // && isRestrict >= other.isRestrict 571 // && isLvalue <= other.isLvalue 572 && isAtomic == other.isAtomic; 573 } 574 575 inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) { 576 return operator!=( other ) && operator<=( other ); 577 } 578 579 inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) { 580 return operator!=( other ) && operator>=( other ); 581 } 576 virtual void accept( Visitor & v ) { v.visit( this ); } 577 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 578 virtual void print( std::ostream & os, int indent = 0 ) const; 579 }; 582 580 583 581 std::ostream & operator<<( std::ostream & out, const Type * type ); -
src/SynTree/TypeDecl.cc
r2f26687a r1fbab5a 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
r2f26687a r1fbab5a 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:40:14201713 // Update Count : 512 // Last Modified On : Thu Mar 16 08:04:51 2017 13 // Update Count : 7 14 14 // 15 15 … … 199 199 Type * type = InitTweak::getPointerBase( castType ); 200 200 assert( type ); 201 type->get_qualifiers() -= Type::Qualifiers( true, true, true, false, true, false);201 type->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 202 202 type->set_isLvalue( true ); // xxx - might not need this 203 203 expr = new CastExpr( expr, castType ); … … 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 ); -
src/Tuples/TupleExpansion.cc
r2f26687a r1fbab5a 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:43:56201713 // Update Count : 1 212 // Last Modified On : Thu Mar 16 08:05:17 2017 13 // Update Count : 15 14 14 // 15 15 … … 187 187 } 188 188 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 189 ObjectDecl * finished = new ObjectDecl( toString( "_unq_expr_finished_", id ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) );189 ObjectDecl * finished = new ObjectDecl( toString( "_unq_expr_finished_", id ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) ); 190 190 addDeclaration( finished ); 191 191 // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N)) … … 221 221 decl->set_body( true ); 222 222 for ( size_t i = 0; i < tupleSize; ++i ) { 223 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i ), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any );224 decl->get_members().push_back( new ObjectDecl( toString("field_", i ), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) );223 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any ); 224 decl->get_members().push_back( new ObjectDecl( toString("field_", i ), Type::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) ); 225 225 decl->get_parameters().push_back( tyParam ); 226 226 } 227 227 if ( tupleSize == 0 ) { 228 228 // empty structs are not standard C. Add a dummy field to empty tuples to silence warnings when a compound literal Tuple0 is created. 229 decl->get_members().push_back( new ObjectDecl( "dummy", DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );229 decl->get_members().push_back( new ObjectDecl( "dummy", Type::StorageClasses(), LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 230 230 } 231 231 typeMap[tupleSize] = decl; … … 305 305 Type * makeTupleType( const std::list< Expression * > & exprs ) { 306 306 // produce the TupleType which aggregates the types of the exprs 307 TupleType *tupleType = new TupleType( Type::Qualifiers( true, true, true, true, true, true) );307 TupleType *tupleType = new TupleType( Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ) ); 308 308 Type::Qualifiers &qualifiers = tupleType->get_qualifiers(); 309 309 for ( Expression * expr : exprs ) { -
src/benchmark/CorCtxSwitch.c
r2f26687a r1fbab5a 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 #include <unistd.h> // sysconf … … 24 24 25 25 struct GreatSuspender { 26 coroutine c;26 coroutine_desc c; 27 27 }; 28 28 -
src/benchmark/ThrdCtxSwitch.c
r2f26687a r1fbab5a 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 #include <unistd.h> // sysconf -
src/benchmark/bench.c
r2f26687a r1fbab5a 2 2 #include <fstream> 3 3 #include <stdlib> 4 #include <thread s>4 #include <thread> 5 5 6 6 #include <unistd.h> // sysconf … … 86 86 //======================================= 87 87 88 struct CoroutineDummy { coroutine c; };88 struct CoroutineDummy { coroutine_desc c; }; 89 89 DECL_COROUTINE(CoroutineDummy); 90 90 void main(CoroutineDummy * this) {} … … 119 119 struct CoroutineResume { 120 120 int N; 121 coroutine c;121 coroutine_desc c; 122 122 }; 123 123 … … 150 150 //======================================= 151 151 152 struct ThreadDummy { thread t; };152 struct ThreadDummy { thread_desc t; }; 153 153 DECL_THREAD(ThreadDummy); 154 154 void main(ThreadDummy * this) {} … … 180 180 int N; 181 181 long long result; 182 thread t;182 thread_desc t; 183 183 }; 184 184 -
src/benchmark/csv-data.c
r2f26687a r1fbab5a 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 extern "C" { … … 26 26 27 27 struct GreatSuspender { 28 coroutine c;28 coroutine_desc c; 29 29 }; 30 30 -
src/examples/multicore.c
r2f26687a r1fbab5a 1 1 #include <kernel> 2 #include <thread s>2 #include <thread> 3 3 4 struct MyThread { thread t; };4 struct MyThread { thread_desc t; }; 5 5 6 6 DECL_THREAD(MyThread); -
src/libcfa/Makefile.am
r2f26687a r1fbab5a 45 45 # not all platforms support concurrency, add option do disable it 46 46 if BUILD_CONCURRENCY 47 headers += containers/vector concurrency/coroutine s concurrency/threadsconcurrency/kernel concurrency/monitor47 headers += containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor 48 48 endif 49 49 -
src/libcfa/Makefile.in
r2f26687a r1fbab5a 43 43 44 44 # not all platforms support concurrency, add option do disable it 45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine s concurrency/threadsconcurrency/kernel concurrency/monitor45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor 46 46 47 47 # not all platforms support concurrency, add option do disable it … … 99 99 am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c \ 100 100 math.c iostream.c fstream.c iterator.c rational.c assert.c \ 101 containers/vector.c concurrency/coroutine s.c \102 concurrency/thread s.c concurrency/kernel.c \101 containers/vector.c concurrency/coroutine.c \ 102 concurrency/thread.c concurrency/kernel.c \ 103 103 concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \ 104 104 concurrency/invoke.c 105 105 am__dirstamp = $(am__leading_dot)dirstamp 106 106 @BUILD_CONCURRENCY_TRUE@am__objects_1 = containers/libcfa_d_a-vector.$(OBJEXT) \ 107 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-coroutine s.$(OBJEXT) \108 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-thread s.$(OBJEXT) \107 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-coroutine.$(OBJEXT) \ 108 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-thread.$(OBJEXT) \ 109 109 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-kernel.$(OBJEXT) \ 110 110 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-monitor.$(OBJEXT) … … 124 124 am__libcfa_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c math.c \ 125 125 iostream.c fstream.c iterator.c rational.c assert.c \ 126 containers/vector.c concurrency/coroutine s.c \127 concurrency/thread s.c concurrency/kernel.c \126 containers/vector.c concurrency/coroutine.c \ 127 concurrency/thread.c concurrency/kernel.c \ 128 128 concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \ 129 129 concurrency/invoke.c 130 130 @BUILD_CONCURRENCY_TRUE@am__objects_5 = \ 131 131 @BUILD_CONCURRENCY_TRUE@ containers/libcfa_a-vector.$(OBJEXT) \ 132 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-coroutine s.$(OBJEXT) \133 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread s.$(OBJEXT) \132 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-coroutine.$(OBJEXT) \ 133 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread.$(OBJEXT) \ 134 134 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-kernel.$(OBJEXT) \ 135 135 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-monitor.$(OBJEXT) … … 175 175 am__nobase_cfa_include_HEADERS_DIST = limits stdlib math iostream \ 176 176 fstream iterator rational assert containers/vector \ 177 concurrency/coroutine s concurrency/threadsconcurrency/kernel \177 concurrency/coroutine concurrency/thread concurrency/kernel \ 178 178 concurrency/monitor ${shell echo stdhdr/*} \ 179 179 concurrency/invoke.h … … 397 397 @$(MKDIR_P) concurrency/$(DEPDIR) 398 398 @: > concurrency/$(DEPDIR)/$(am__dirstamp) 399 concurrency/libcfa_d_a-coroutine s.$(OBJEXT): \399 concurrency/libcfa_d_a-coroutine.$(OBJEXT): \ 400 400 concurrency/$(am__dirstamp) \ 401 401 concurrency/$(DEPDIR)/$(am__dirstamp) 402 concurrency/libcfa_d_a-thread s.$(OBJEXT): concurrency/$(am__dirstamp) \402 concurrency/libcfa_d_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \ 403 403 concurrency/$(DEPDIR)/$(am__dirstamp) 404 404 concurrency/libcfa_d_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \ … … 417 417 containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \ 418 418 containers/$(DEPDIR)/$(am__dirstamp) 419 concurrency/libcfa_a-coroutines.$(OBJEXT): \ 420 concurrency/$(am__dirstamp) \ 419 concurrency/libcfa_a-coroutine.$(OBJEXT): concurrency/$(am__dirstamp) \ 421 420 concurrency/$(DEPDIR)/$(am__dirstamp) 422 concurrency/libcfa_a-thread s.$(OBJEXT): concurrency/$(am__dirstamp) \421 concurrency/libcfa_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \ 423 422 concurrency/$(DEPDIR)/$(am__dirstamp) 424 423 concurrency/libcfa_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \ … … 436 435 -rm -f *.$(OBJEXT) 437 436 -rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) 438 -rm -f concurrency/libcfa_a-coroutine s.$(OBJEXT)437 -rm -f concurrency/libcfa_a-coroutine.$(OBJEXT) 439 438 -rm -f concurrency/libcfa_a-invoke.$(OBJEXT) 440 439 -rm -f concurrency/libcfa_a-kernel.$(OBJEXT) 441 440 -rm -f concurrency/libcfa_a-monitor.$(OBJEXT) 442 -rm -f concurrency/libcfa_a-thread s.$(OBJEXT)443 -rm -f concurrency/libcfa_d_a-coroutine s.$(OBJEXT)441 -rm -f concurrency/libcfa_a-thread.$(OBJEXT) 442 -rm -f concurrency/libcfa_d_a-coroutine.$(OBJEXT) 444 443 -rm -f concurrency/libcfa_d_a-invoke.$(OBJEXT) 445 444 -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT) 446 445 -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT) 447 -rm -f concurrency/libcfa_d_a-thread s.$(OBJEXT)446 -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT) 448 447 -rm -f containers/libcfa_a-vector.$(OBJEXT) 449 448 -rm -f containers/libcfa_d_a-vector.$(OBJEXT) … … 471 470 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@ 472 471 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@ 473 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine s.Po@am__quote@472 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@ 474 473 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@ 475 474 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@ 476 475 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@ 477 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread s.Po@am__quote@478 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Po@am__quote@476 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@ 477 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po@am__quote@ 479 478 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-invoke.Po@am__quote@ 480 479 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@ 481 480 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@ 482 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread s.Po@am__quote@481 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@ 483 482 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@ 484 483 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@ … … 649 648 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi` 650 649 651 concurrency/libcfa_d_a-coroutine s.o: concurrency/coroutines.c652 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c653 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_d_a-coroutines.o' libtool=no @AMDEPBACKSLASH@655 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 656 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine s.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c657 658 concurrency/libcfa_d_a-coroutine s.obj: concurrency/coroutines.c659 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`660 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_d_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@662 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 663 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine s.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`664 665 concurrency/libcfa_d_a-thread s.o: concurrency/threads.c666 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c667 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po668 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_d_a-threads.o' libtool=no @AMDEPBACKSLASH@669 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 670 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread s.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c671 672 concurrency/libcfa_d_a-thread s.obj: concurrency/threads.c673 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`674 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po675 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_d_a-threads.obj' libtool=no @AMDEPBACKSLASH@676 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 677 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread s.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`650 concurrency/libcfa_d_a-coroutine.o: concurrency/coroutine.c 651 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 652 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po 653 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.o' libtool=no @AMDEPBACKSLASH@ 654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 655 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 656 657 concurrency/libcfa_d_a-coroutine.obj: concurrency/coroutine.c 658 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 659 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po 660 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@ 661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 662 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 663 664 concurrency/libcfa_d_a-thread.o: concurrency/thread.c 665 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 666 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po 667 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.o' libtool=no @AMDEPBACKSLASH@ 668 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 669 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 670 671 concurrency/libcfa_d_a-thread.obj: concurrency/thread.c 672 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 673 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po 674 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.obj' libtool=no @AMDEPBACKSLASH@ 675 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 676 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 678 677 679 678 concurrency/libcfa_d_a-kernel.o: concurrency/kernel.c … … 845 844 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi` 846 845 847 concurrency/libcfa_a-coroutine s.o: concurrency/coroutines.c848 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c849 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po850 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_a-coroutines.o' libtool=no @AMDEPBACKSLASH@851 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 852 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine s.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c853 854 concurrency/libcfa_a-coroutine s.obj: concurrency/coroutines.c855 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`856 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po857 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@858 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 859 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine s.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`860 861 concurrency/libcfa_a-thread s.o: concurrency/threads.c862 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c863 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po864 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_a-threads.o' libtool=no @AMDEPBACKSLASH@865 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 866 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread s.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c867 868 concurrency/libcfa_a-thread s.obj: concurrency/threads.c869 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`870 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po871 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_a-threads.obj' libtool=no @AMDEPBACKSLASH@872 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 873 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread s.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`846 concurrency/libcfa_a-coroutine.o: concurrency/coroutine.c 847 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 848 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po 849 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.o' libtool=no @AMDEPBACKSLASH@ 850 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 851 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 852 853 concurrency/libcfa_a-coroutine.obj: concurrency/coroutine.c 854 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 855 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po 856 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@ 857 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 858 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 859 860 concurrency/libcfa_a-thread.o: concurrency/thread.c 861 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 862 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po 863 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.o' libtool=no @AMDEPBACKSLASH@ 864 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 865 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 866 867 concurrency/libcfa_a-thread.obj: concurrency/thread.c 868 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 869 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po 870 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.obj' libtool=no @AMDEPBACKSLASH@ 871 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 872 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 874 873 875 874 concurrency/libcfa_a-kernel.o: concurrency/kernel.c -
src/libcfa/concurrency/coroutine
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // coroutine s--8 // coroutine -- 9 9 // 10 10 // Author : Thierry Delisle … … 27 27 trait is_coroutine(dtype T) { 28 28 void main(T * this); 29 coroutine * get_coroutine(T * this);29 coroutine_desc * get_coroutine(T * this); 30 30 }; 31 31 32 #define DECL_COROUTINE(X) static inline coroutine * get_coroutine(X* this) { return &this->c; } void main(X* this)32 #define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->c; } void main(X* this) 33 33 34 34 //----------------------------------------------------------------------------- 35 35 // Ctors and dtors 36 36 void ?{}(coStack_t * this); 37 void ?{}(coroutine * this);38 void ?{}(coroutine * this, const char * name);37 void ?{}(coroutine_desc * this); 38 void ?{}(coroutine_desc * this, const char * name); 39 39 void ^?{}(coStack_t * this); 40 void ^?{}(coroutine * this);40 void ^?{}(coroutine_desc * this); 41 41 42 42 //----------------------------------------------------------------------------- … … 63 63 64 64 // Get current coroutine 65 coroutine * this_coroutine(void);65 coroutine_desc * this_coroutine(void); 66 66 67 67 // Private wrappers for context switch and stack creation 68 extern void CoroutineCtxSwitch(coroutine * src, coroutine* dst);68 extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 69 69 extern void create_stack( coStack_t * this, unsigned int storageSize ); 70 70 71 71 // Suspend implementation inlined for performance 72 72 static inline void suspend() { 73 coroutine * src = this_coroutine(); // optimization73 coroutine_desc * src = this_coroutine(); // optimization 74 74 75 75 assertf( src->last != 0, … … 88 88 forall(dtype T | is_coroutine(T)) 89 89 static inline void resume(T * cor) { 90 coroutine * src = this_coroutine(); // optimization91 coroutine * dst = get_coroutine(cor);90 coroutine_desc * src = this_coroutine(); // optimization 91 coroutine_desc * dst = get_coroutine(cor); 92 92 93 93 if( unlikely(!dst->stack.base) ) { … … 111 111 } 112 112 113 static inline void resume(coroutine * dst) {114 coroutine * src = this_coroutine(); // optimization113 static inline void resume(coroutine_desc * dst) { 114 coroutine_desc * src = this_coroutine(); // optimization 115 115 116 116 // not resuming self ? -
src/libcfa/concurrency/coroutine.c
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // coroutine s.c --8 // coroutine.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 15 15 // 16 16 17 #include "coroutine s"17 #include "coroutine" 18 18 19 19 extern "C" { … … 32 32 #include "invoke.h" 33 33 34 extern processor * get_this_processor();34 extern thread_local processor * this_processor; 35 35 36 36 //----------------------------------------------------------------------------- … … 60 60 } 61 61 62 void ?{}(coroutine * this) {62 void ?{}(coroutine_desc* this) { 63 63 this{ "Anonymous Coroutine" }; 64 64 } 65 65 66 void ?{}(coroutine * this, const char * name) {66 void ?{}(coroutine_desc* this, const char * name) { 67 67 this->name = name; 68 68 this->errno_ = 0; … … 72 72 } 73 73 74 void ?{}(coroutine * this, size_t size) {74 void ?{}(coroutine_desc* this, size_t size) { 75 75 this{}; 76 76 (&this->stack){size}; … … 88 88 } 89 89 90 void ^?{}(coroutine * this) {}90 void ^?{}(coroutine_desc* this) {} 91 91 92 92 // Part of the Public API … … 94 94 forall(dtype T | is_coroutine(T)) 95 95 void prime(T* cor) { 96 coroutine * this = get_coroutine(cor);96 coroutine_desc* this = get_coroutine(cor); 97 97 assert(this->state == Start); 98 98 … … 102 102 103 103 // Wrapper for co 104 void CoroutineCtxSwitch(coroutine * src, coroutine* dst) {104 void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 105 105 // THREAD_GETMEM( This )->disableInterrupts(); 106 106 … … 109 109 110 110 // set new coroutine that task is executing 111 get_this_processor()->current_coroutine = dst;111 this_processor->current_coroutine = dst; 112 112 113 113 // context switch to specified coroutine -
src/libcfa/concurrency/invoke.c
r2f26687a r1fbab5a 29 29 30 30 extern void __suspend_internal(void); 31 extern void __thread_signal_termination(struct thread *);31 extern void __thread_signal_termination(struct thread_desc*); 32 32 33 33 void CtxInvokeCoroutine( 34 34 void (*main)(void *), 35 struct coroutine *(*get_coroutine)(void *),35 struct coroutine_desc *(*get_coroutine)(void *), 36 36 void *this 37 37 ) { 38 38 // LIB_DEBUG_PRINTF("Invoke Coroutine : Received %p (main %p, get_c %p)\n", this, main, get_coroutine); 39 39 40 struct coroutine * cor = get_coroutine( this );40 struct coroutine_desc* cor = get_coroutine( this ); 41 41 42 42 if(cor->state == Primed) { … … 57 57 void CtxInvokeThread( 58 58 void (*main)(void *), 59 struct thread *(*get_thread)(void *),59 struct thread_desc *(*get_thread)(void *), 60 60 void *this 61 61 ) { 62 62 __suspend_internal(); 63 63 64 struct thread * thrd = get_thread( this );65 struct coroutine * cor = &thrd->c;64 struct thread_desc* thrd = get_thread( this ); 65 struct coroutine_desc* cor = &thrd->c; 66 66 cor->state = Active; 67 67 … … 79 79 void CtxStart( 80 80 void (*main)(void *), 81 struct coroutine *(*get_coroutine)(void *),81 struct coroutine_desc *(*get_coroutine)(void *), 82 82 void *this, 83 83 void (*invoke)(void *) -
src/libcfa/concurrency/invoke.h
r2f26687a r1fbab5a 35 35 36 36 struct simple_thread_list { 37 struct thread * head;38 struct thread ** tail;37 struct thread_desc * head; 38 struct thread_desc ** tail; 39 39 }; 40 40 … … 48 48 extern "Cforall" { 49 49 void ?{}( struct simple_thread_list * ); 50 void append( struct simple_thread_list *, struct thread * );51 struct thread * pop_head( struct simple_thread_list * );50 void append( struct simple_thread_list *, struct thread_desc * ); 51 struct thread_desc * pop_head( struct simple_thread_list * ); 52 52 53 53 void ?{}(spinlock * this); … … 71 71 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 72 72 73 struct coroutine {73 struct coroutine_desc { 74 74 struct coStack_t stack; 75 75 const char *name; // textual name for coroutine/task, initialized by uC++ generated code 76 76 int errno_; // copy of global UNIX variable errno 77 77 enum coroutine_state state; // current execution status for coroutine 78 struct coroutine *starter; // first coroutine to resume this one79 struct coroutine *last; // last coroutine to resume this one78 struct coroutine_desc *starter; // first coroutine to resume this one 79 struct coroutine_desc *last; // last coroutine to resume this one 80 80 }; 81 81 82 struct thread {83 struct coroutine c; // coroutine body used to store context82 struct thread_desc { 83 struct coroutine_desc c; // coroutine body used to store context 84 84 struct signal_once terminated; // indicate if execuation state is not halted 85 struct thread * next; // instrusive link field for threads85 struct thread_desc * next; // instrusive link field for threads 86 86 }; 87 87 -
src/libcfa/concurrency/kernel
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // threads--8 // kernel -- 9 9 // 10 10 // Author : Thierry Delisle … … 49 49 struct FinishAction { 50 50 FinishOpCode action_code; 51 thread * thrd;51 thread_desc * thrd; 52 52 spinlock * lock; 53 53 }; … … 62 62 struct processorCtx_t * runner; 63 63 cluster * cltr; 64 coroutine * current_coroutine;65 thread * current_thread;64 coroutine_desc * current_coroutine; 65 thread_desc * current_thread; 66 66 pthread_t kernel_thread; 67 67 -
src/libcfa/concurrency/kernel.c
r2f26687a r1fbab5a 43 43 KERNEL_STORAGE(cluster, systemCluster); 44 44 KERNEL_STORAGE(processor, systemProcessor); 45 KERNEL_STORAGE(thread , mainThread);45 KERNEL_STORAGE(thread_desc, mainThread); 46 46 KERNEL_STORAGE(machine_context_t, mainThread_context); 47 47 48 48 cluster * systemCluster; 49 49 processor * systemProcessor; 50 thread * mainThread;50 thread_desc * mainThread; 51 51 52 52 //----------------------------------------------------------------------------- … … 55 55 thread_local processor * this_processor; 56 56 57 processor * get_this_processor() { 58 return this_processor; 59 } 60 61 coroutine * this_coroutine(void) { 57 coroutine_desc * this_coroutine(void) { 62 58 return this_processor->current_coroutine; 63 59 } 64 60 65 thread * this_thread(void) {61 thread_desc * this_thread(void) { 66 62 return this_processor->current_thread; 67 63 } … … 103 99 } 104 100 105 void ?{}( coroutine * this, current_stack_info_t * info) {101 void ?{}( coroutine_desc * this, current_stack_info_t * info) { 106 102 (&this->stack){ info }; 107 103 this->name = "Main Thread"; … … 110 106 } 111 107 112 void ?{}( thread * this, current_stack_info_t * info) {108 void ?{}( thread_desc * this, current_stack_info_t * info) { 113 109 (&this->c){ info }; 114 110 } … … 179 175 LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this); 180 176 181 thread * readyThread = NULL;177 thread_desc * readyThread = NULL; 182 178 for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ ) 183 179 { … … 206 202 // runThread runs a thread by context switching 207 203 // from the processor coroutine to the target thread 208 void runThread(processor * this, thread * dst) {209 coroutine * proc_cor = get_coroutine(this->runner);210 coroutine * thrd_cor = get_coroutine(dst);204 void runThread(processor * this, thread_desc * dst) { 205 coroutine_desc * proc_cor = get_coroutine(this->runner); 206 coroutine_desc * thrd_cor = get_coroutine(dst); 211 207 212 208 //Reset the terminating actions here … … 297 293 //----------------------------------------------------------------------------- 298 294 // Scheduler routines 299 void ScheduleThread( thread * thrd ) {295 void ScheduleThread( thread_desc * thrd ) { 300 296 assertf( thrd->next == NULL, "Expected null got %p", thrd->next ); 301 297 … … 305 301 } 306 302 307 thread * nextThread(cluster * this) {303 thread_desc * nextThread(cluster * this) { 308 304 lock( &this->lock ); 309 thread * head = pop_head( &this->ready_queue );305 thread_desc * head = pop_head( &this->ready_queue ); 310 306 unlock( &this->lock ); 311 307 return head; … … 317 313 318 314 void ScheduleInternal( spinlock * lock ) { 319 get_this_processor()->finish.action_code = Release;320 get_this_processor()->finish.lock = lock;315 this_processor->finish.action_code = Release; 316 this_processor->finish.lock = lock; 321 317 suspend(); 322 318 } 323 319 324 void ScheduleInternal( thread * thrd ) {325 get_this_processor()->finish.action_code = Schedule;326 get_this_processor()->finish.thrd = thrd;320 void ScheduleInternal( thread_desc * thrd ) { 321 this_processor->finish.action_code = Schedule; 322 this_processor->finish.thrd = thrd; 327 323 suspend(); 328 324 } 329 325 330 void ScheduleInternal( spinlock * lock, thread * thrd ) {331 get_this_processor()->finish.action_code = Release_Schedule;332 get_this_processor()->finish.lock = lock;333 get_this_processor()->finish.thrd = thrd;326 void ScheduleInternal( spinlock * lock, thread_desc * thrd ) { 327 this_processor->finish.action_code = Release_Schedule; 328 this_processor->finish.lock = lock; 329 this_processor->finish.thrd = thrd; 334 330 suspend(); 335 331 } … … 343 339 // SKULLDUGGERY: the mainThread steals the process main thread 344 340 // which will then be scheduled by the systemProcessor normally 345 mainThread = (thread *)&mainThread_storage;341 mainThread = (thread_desc *)&mainThread_storage; 346 342 current_stack_info_t info; 347 343 mainThread{ &info }; … … 440 436 this->condition = true; 441 437 442 thread * it;438 thread_desc * it; 443 439 while( it = pop_head( &this->blocked) ) { 444 440 ScheduleThread( it ); … … 455 451 } 456 452 457 void append( simple_thread_list * this, thread * t ) {453 void append( simple_thread_list * this, thread_desc * t ) { 458 454 assert(this->tail != NULL); 459 455 *this->tail = t; … … 461 457 } 462 458 463 thread * pop_head( simple_thread_list * this ) {464 thread * head = this->head;459 thread_desc * pop_head( simple_thread_list * this ) { 460 thread_desc * head = this->head; 465 461 if( head ) { 466 462 this->head = head->next; -
src/libcfa/concurrency/kernel_private.h
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // threads--8 // kernel_private.h -- 9 9 // 10 10 // Author : Thierry Delisle … … 19 19 20 20 #include "kernel" 21 #include "thread s"21 #include "thread" 22 22 23 23 //----------------------------------------------------------------------------- 24 24 // Scheduler 25 void ScheduleThread( thread * );26 thread * nextThread(cluster * this);25 void ScheduleThread( thread_desc * ); 26 thread_desc * nextThread(cluster * this); 27 27 28 28 void ScheduleInternal(); 29 29 void ScheduleInternal(spinlock * lock); 30 void ScheduleInternal(thread * thrd);31 void ScheduleInternal(spinlock * lock, thread * thrd);30 void ScheduleInternal(thread_desc * thrd); 31 void ScheduleInternal(spinlock * lock, thread_desc * thrd); 32 32 33 33 //----------------------------------------------------------------------------- … … 35 35 struct processorCtx_t { 36 36 processor * proc; 37 coroutine c;37 coroutine_desc c; 38 38 }; 39 39 … … 42 42 void main(processorCtx_t *); 43 43 void start(processor * this); 44 void runThread(processor * this, thread * dst);44 void runThread(processor * this, thread_desc * dst); 45 45 void finishRunning(processor * this); 46 46 void spin(processor * this, unsigned int * spin_count); … … 53 53 } 54 54 55 extern void ThreadCtxSwitch(coroutine * src, coroutine* dst);55 extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 56 56 57 57 #endif //KERNEL_PRIVATE_H -
src/libcfa/concurrency/monitor
r2f26687a r1fbab5a 22 22 #include "stdlib" 23 23 24 struct __monitor_t{24 struct monitor_desc { 25 25 spinlock lock; 26 thread * owner;26 thread_desc * owner; 27 27 simple_thread_list entry_queue; 28 28 unsigned int recursion; 29 29 }; 30 30 31 static inline void ?{}( __monitor_t* this) {31 static inline void ?{}(monitor_desc * this) { 32 32 this->owner = 0; 33 33 this->recursion = 0; … … 35 35 36 36 //Basic entering routine 37 void enter( __monitor_t*);38 void leave( __monitor_t*);37 void enter(monitor_desc *); 38 void leave(monitor_desc *); 39 39 40 40 //Array entering routine 41 void enter( __monitor_t**, int count);42 void leave( __monitor_t**, int count);41 void enter(monitor_desc **, int count); 42 void leave(monitor_desc **, int count); 43 43 44 44 struct monitor_guard_t { 45 __monitor_t** m;45 monitor_desc ** m; 46 46 int count; 47 47 }; 48 48 49 static inline int ?<?( __monitor_t* lhs, __monitor_t* rhs) {49 static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { 50 50 return ((intptr_t)lhs) < ((intptr_t)rhs); 51 51 } 52 52 53 static inline void ?{}( monitor_guard_t * this, __monitor_t** m ) {53 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) { 54 54 this->m = m; 55 55 this->count = 1; … … 57 57 } 58 58 59 static inline void ?{}( monitor_guard_t * this, __monitor_t** m, int count ) {59 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) { 60 60 this->m = m; 61 61 this->count = count; -
src/libcfa/concurrency/monitor.c
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // __monitor_t.c --8 // monitor_desc.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 19 19 #include "kernel_private.h" 20 20 21 void enter( __monitor_t* this) {21 void enter(monitor_desc * this) { 22 22 lock( &this->lock ); 23 thread * thrd = this_thread();23 thread_desc * thrd = this_thread(); 24 24 25 25 if( !this->owner ) { … … 45 45 } 46 46 47 void leave( __monitor_t* this) {47 void leave(monitor_desc * this) { 48 48 lock( &this->lock ); 49 49 50 thread * thrd = this_thread();50 thread_desc * thrd = this_thread(); 51 51 assert( thrd == this->owner ); 52 52 … … 55 55 56 56 //If we left the last level of recursion it means we are changing who owns the monitor 57 thread * new_owner = 0;57 thread_desc * new_owner = 0; 58 58 if( this->recursion == 0) { 59 59 //Get the next thread in the list … … 72 72 } 73 73 74 void enter( __monitor_t** monitors, int count) {74 void enter(monitor_desc ** monitors, int count) { 75 75 for(int i = 0; i < count; i++) { 76 76 // printf("%d\n", i); … … 79 79 } 80 80 81 void leave( __monitor_t** monitors, int count) {81 void leave(monitor_desc ** monitors, int count) { 82 82 for(int i = count - 1; i >= 0; i--) { 83 83 // printf("%d\n", i); -
src/libcfa/concurrency/thread
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // thread s--8 // thread -- 9 9 // 10 10 // Author : Thierry Delisle … … 21 21 #include "invoke.h" 22 22 23 #include "coroutine s"23 #include "coroutine" 24 24 25 25 //----------------------------------------------------------------------------- … … 29 29 trait is_thread(dtype T) { 30 30 void main(T* this); 31 thread * get_thread(T* this);31 thread_desc* get_thread(T* this); 32 32 }; 33 33 34 #define DECL_THREAD(X) thread * get_thread(X* this) { return &this->t; } void main(X* this)34 #define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->t; } void main(X* this) 35 35 36 36 forall( dtype T | is_thread(T) ) 37 static inline coroutine * get_coroutine(T* this) {37 static inline coroutine_desc* get_coroutine(T* this) { 38 38 return &get_thread(this)->c; 39 39 } 40 40 41 static inline coroutine * get_coroutine(thread* this) {41 static inline coroutine_desc* get_coroutine(thread_desc* this) { 42 42 return &this->c; 43 43 } 44 44 45 thread * this_thread(void);45 thread_desc * this_thread(void); 46 46 47 47 //----------------------------------------------------------------------------- 48 48 // Ctors and dtors 49 void ?{}(thread * this);50 void ^?{}(thread * this);49 void ?{}(thread_desc* this); 50 void ^?{}(thread_desc* this); 51 51 52 52 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/thread.c
r2f26687a r1fbab5a 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // thread s.c --8 // thread.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 15 15 // 16 16 17 #include "thread s"17 #include "thread" 18 18 19 19 #include "kernel_private.h" … … 28 28 } 29 29 30 extern processor * get_this_processor();30 extern thread_local processor * this_processor; 31 31 32 32 //----------------------------------------------------------------------------- … … 41 41 // Thread ctors and dtors 42 42 43 void ?{}(thread * this) {43 void ?{}(thread_desc* this) { 44 44 (&this->c){}; 45 45 this->c.name = "Anonymous Coroutine"; … … 48 48 } 49 49 50 void ^?{}(thread * this) {50 void ^?{}(thread_desc* this) { 51 51 ^(&this->c){}; 52 52 } … … 74 74 forall( dtype T | is_thread(T) ) 75 75 void start( T* this ) { 76 coroutine * thrd_c = get_coroutine(this);77 thread * thrd_h = get_thread (this);76 coroutine_desc* thrd_c = get_coroutine(this); 77 thread_desc* thrd_h = get_thread (this); 78 78 thrd_c->last = this_coroutine(); 79 get_this_processor()->current_coroutine = thrd_c;79 this_processor->current_coroutine = thrd_c; 80 80 81 81 LIB_DEBUG_PRINTF("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h); … … 94 94 95 95 void yield( void ) { 96 ScheduleInternal( get_this_processor()->current_thread );96 ScheduleInternal( this_processor->current_thread ); 97 97 } 98 98 99 void ThreadCtxSwitch(coroutine * src, coroutine* dst) {99 void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 100 100 // set state of current coroutine to inactive 101 101 src->state = Inactive; … … 107 107 // set new coroutine that the processor is executing 108 108 // and context switch to it 109 get_this_processor()->current_coroutine = dst;109 this_processor->current_coroutine = dst; 110 110 CtxSwitch( src->stack.context, dst->stack.context ); 111 get_this_processor()->current_coroutine = src;111 this_processor->current_coroutine = src; 112 112 113 113 // set state of new coroutine to active … … 116 116 } 117 117 118 // C Helper to signal the termination of a thread 118 // C Helper to signal the termination of a thread_desc 119 119 // Used in invoke.c 120 120 extern "C" { 121 void __thread_signal_termination( thread * this ) {121 void __thread_signal_termination( thread_desc * this ) { 122 122 this->c.state = Halted; 123 123 LIB_DEBUG_PRINTF("Thread end : %p\n", this); -
src/tests/coroutine.c
r2f26687a r1fbab5a 1 1 #include <fstream> 2 #include <coroutine s>2 #include <coroutine> 3 3 4 4 struct Fibonacci { 5 5 int fn; // used for communication 6 coroutine c;6 coroutine_desc c; 7 7 }; 8 8 … … 11 11 } 12 12 13 coroutine * get_coroutine(Fibonacci* this) {13 coroutine_desc* get_coroutine(Fibonacci* this) { 14 14 return &this->c; 15 15 } … … 47 47 #ifdef MORE_DEBUG 48 48 Fibonacci *pf1 = &f1, *pf2 = &f2; 49 coroutine *cf1 = &f1.c, *cf2 = &f2.c;49 coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c; 50 50 covptr_t *vf1 = vtable(pf1), *vf2 = vtable(pf2); 51 coroutine *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);51 coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2); 52 52 Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2); 53 53 -
src/tests/monitor.c
r2f26687a r1fbab5a 2 2 #include <kernel> 3 3 #include <monitor> 4 #include <thread s>4 #include <thread> 5 5 6 6 struct global_t { 7 7 int value; 8 __monitor_tm;8 monitor_desc m; 9 9 }; 10 10 … … 16 16 17 17 void increment( /*mutex*/ global_t * this ) { 18 __monitor_t* mon = &this->m;18 monitor_desc * mon = &this->m; 19 19 monitor_guard_t g1 = { &mon }; 20 20 { … … 27 27 } 28 28 29 struct MyThread { thread t; };29 struct MyThread { thread_desc t; }; 30 30 31 31 DECL_THREAD(MyThread); -
src/tests/multi-monitor.c
r2f26687a r1fbab5a 2 2 #include <kernel> 3 3 #include <monitor> 4 #include <thread s>4 #include <thread> 5 5 6 6 static int global12, global23, global13; 7 7 8 static __monitor_tm1, m2, m3;8 static monitor_desc m1, m2, m3; 9 9 10 void increment( /*mutex*/ __monitor_t * p1, /*mutex*/ __monitor_t* p2, int * value ) {11 __monitor_t* mons[] = { p1, p2 };10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) { 11 monitor_desc * mons[] = { p1, p2 }; 12 12 monitor_guard_t g = { mons, 2 }; 13 13 *value += 1; … … 15 15 16 16 struct MyThread { 17 thread t;17 thread_desc t; 18 18 int target; 19 19 }; -
src/tests/test.py
r2f26687a r1fbab5a 250 250 parser = argparse.ArgumentParser(description='Script which runs cforall tests') 251 251 parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no') 252 parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default=' no')252 parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default='yes') 253 253 parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true') 254 254 parser.add_argument('--list', help='List all test available', action='store_true') -
src/tests/thread.c
r2f26687a r1fbab5a 2 2 #include <kernel> 3 3 #include <stdlib> 4 #include <thread s>4 #include <thread> 5 5 6 struct First { thread t; signal_once* lock; };7 struct Second { thread t; signal_once* lock; };6 struct First { thread_desc t; signal_once* lock; }; 7 struct Second { thread_desc t; signal_once* lock; }; 8 8 9 9 DECL_THREAD(First);
Note: See TracChangeset
for help on using the changeset viewer.