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