Changes in src/Concurrency/Keywords.cpp [35eef3b:ed96731]
- File:
-
- 1 edited
-
src/Concurrency/Keywords.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cpp
r35eef3b red96731 10 10 // Created On : Tue Nov 16 9:53:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 26 15:16:16 202513 // Update Count : 1512 // Last Modified On : Thu Dec 14 18:02:25 2023 13 // Update Count : 6 14 14 // 15 15 … … 69 69 } 70 70 71 // Describe that it adds the generic parameters and the uses of the generic parameters on the72 // function and first "this" argument.71 // Describe that it adds the generic parameters and the uses of the generic 72 // parameters on the function and first "this" argument. 73 73 ast::FunctionDecl * fixupGenerics( 74 74 const ast::FunctionDecl * func, const ast::StructDecl * decl ) { … … 117 117 118 118 // -------------------------------------------------------------------------- 119 120 // This type describes the general information used to transform a generator, coroutine, monitor, or121 // thread aggregate kind. A pass is made over the AST in ConcurrentSueKeyword::postvisit looking122 // for each of these kinds. When found, this data structure is filled in with the information from123 // the specific structures below, and handleStruct is called to perform the common changes that124 // augment the aggregate kind with fields and generate appropriate companion routines. The location125 // of any extra fields is specified in addField.126 127 119 struct ConcurrentSueKeyword : public ast::WithDeclsToAdd { 128 120 ConcurrentSueKeyword( … … 179 171 }; 180 172 181 // Handles generatortype declarations:173 // Handles thread type declarations: 182 174 // 183 // generator MyGenerator { struct MyGenerator{184 // => int __generator_state;185 // int data; intdata;186 // a_struct_t more_data; a_struct_t more_data;175 // thread Mythread { struct MyThread { 176 // int data; int data; 177 // a_struct_t more_data; a_struct_t more_data; 178 // => thread$ __thrd_d; 187 179 // }; }; 180 // static inline thread$ * get_thread( MyThread * this ) { return &this->__thrd_d; } 188 181 // 189 struct GeneratorKeyword final : public ConcurrentSueKeyword {190 GeneratorKeyword() : ConcurrentSueKeyword(191 " generator$",192 "__ generator_state",193 "get_ generator",194 " Unable to find builtin type generator$\n",195 " ",182 struct ThreadKeyword final : public ConcurrentSueKeyword { 183 ThreadKeyword() : ConcurrentSueKeyword( 184 "thread$", 185 "__thrd", 186 "get_thread", 187 "thread keyword requires threads to be in scope, add #include <thread.hfa>\n", 188 "ThreadCancelled", 196 189 true, 197 ast::AggregateDecl:: Generator)190 ast::AggregateDecl::Thread ) 198 191 {} 199 192 200 virtual ~ GeneratorKeyword() {}193 virtual ~ThreadKeyword() {} 201 194 }; 202 195 … … 204 197 // 205 198 // coroutine MyCoroutine { struct MyCoroutine { 199 // int data; int data; 200 // a_struct_t more_data; a_struct_t more_data; 206 201 // => coroutine$ __cor_d; 207 // int data; int data;208 // a_struct_t more_data; a_struct_t more_data;209 202 // }; }; 210 203 // static inline coroutine$ * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; } … … 227 220 // 228 221 // monitor MyMonitor { struct MyMonitor { 222 // int data; int data; 223 // a_struct_t more_data; a_struct_t more_data; 229 224 // => monitor$ __mon_d; 230 // int data; int data;231 // a_struct_t more_data; a_struct_t more_data;232 225 // }; }; 233 226 // static inline monitor$ * get_coroutine( MyMonitor * this ) { … … 255 248 }; 256 249 257 // Handles threadtype declarations:250 // Handles generator type declarations: 258 251 // 259 // thread Mythread { struct MyThread{260 // => thread$ __thrd_d;261 // int data; intdata;262 // a_struct_t more_data; a_struct_t more_data;252 // generator MyGenerator { struct MyGenerator { 253 // int data; int data; 254 // a_struct_t more_data; a_struct_t more_data; 255 // => int __generator_state; 263 256 // }; }; 264 // static inline thread$ * get_thread( MyThread * this ) { return &this->__thrd_d; }265 257 // 266 struct ThreadKeyword final : public ConcurrentSueKeyword {267 ThreadKeyword() : ConcurrentSueKeyword(268 " thread$",269 "__ thrd",270 "get_ thread",271 " thread keyword requires threads to be in scope, add #include <thread.hfa>\n",272 " ThreadCancelled",258 struct GeneratorKeyword final : public ConcurrentSueKeyword { 259 GeneratorKeyword() : ConcurrentSueKeyword( 260 "generator$", 261 "__generator_state", 262 "get_generator", 263 "Unable to find builtin type generator$\n", 264 "", 273 265 true, 274 ast::AggregateDecl:: Thread)266 ast::AggregateDecl::Generator ) 275 267 {} 276 268 277 virtual ~ ThreadKeyword() {}269 virtual ~GeneratorKeyword() {} 278 270 }; 279 271 … … 362 354 363 355 if ( !exception_name.empty() ) { 364 if ( !typeid_decl || !vtable_decl ) {356 if( !typeid_decl || !vtable_decl ) { 365 357 SemanticError( decl, context_error ); 366 358 } … … 427 419 declsToAddBefore.push_back( 428 420 Virtual::makeTypeIdInstance( location, typeid_type ) ); 429 // If the typeid_type is going to be kept, the other reference will have been made by now, but430 // we also get to avoid extra mutates.421 // If the typeid_type is going to be kept, the other reference will have 422 // been made by now, but we also get to avoid extra mutates. 431 423 ast::ptr<ast::StructInstType> typeid_cleanup = typeid_type; 432 424 } … … 533 525 534 526 auto mutDecl = ast::mutate( decl ); 535 // Insert at start of special aggregate structures => front of vector536 //mutDecl->members.insert( mutDecl->members.begin(), field );537 527 mutDecl->members.push_back( field ); 538 528 … … 927 917 928 918 // If it is a monitor, then it is a monitor. 929 if ( baseStruct->base->is_monitor() || baseStruct->base->is_thread() ) {919 if( baseStruct->base->is_monitor() || baseStruct->base->is_thread() ) { 930 920 SemanticError( decl, "destructors for structures declared as \"monitor\" must use mutex parameters " ); 931 921 } … … 1041 1031 1042 1032 // Make sure that only the outer reference is mutex. 1043 if ( baseStruct->is_mutex() ) {1033 if( baseStruct->is_mutex() ) { 1044 1034 SemanticError( decl, "mutex keyword may only appear once per argument " ); 1045 1035 } … … 1189 1179 } 1190 1180 1191 // Generates a cast to the void ptr to the appropriate lock type and dereferences it before calling1192 // lock or unlock on it used to undo the type erasure done by storing all the lock pointers as void.1181 // generates a cast to the void ptr to the appropriate lock type and dereferences it before calling lock or unlock on it 1182 // used to undo the type erasure done by storing all the lock pointers as void 1193 1183 ast::ExprStmt * MutexKeyword::genVirtLockUnlockExpr( const std::string & fnName, ast::ptr<ast::Expr> expr, const CodeLocation & location, ast::Expr * param ) { 1194 1184 return new ast::ExprStmt( location,
Note:
See TracChangeset
for help on using the changeset viewer.