Changeset 0f4527d
- Timestamp:
- Dec 14, 2019, 11:56:52 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b84ab40
- Parents:
- ae09808 (diff), 9853d9b0 (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:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/exception.c
rae09808 r0f4527d 69 69 70 70 71 // This macro should be the only thing that needs to change across machines. Used in the personality function, way down72 // in termination.71 // This macro should be the only thing that needs to change across machines. 72 // Used in the personality function, way down in termination. 73 73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *) 74 74 #define MATCHER_FROM_CONTEXT(ptr_to_context) \ … … 102 102 } 103 103 104 // Do we control where exceptions get thrown even with concurency? If not these are not quite thread safe, the cleanup 105 // hook has to be added after the node is built but before it is made the top node. 104 // Do we control where exceptions get thrown even with concurency? 105 // If not these are not quite thread safe, the cleanup hook has to 106 // be added after the node is built but before it is made the top node. 106 107 107 108 void __cfaabi_ehm__try_resume_setup(struct __cfaabi_ehm__try_resume_node * node, … … 212 213 _Unwind_Reason_Code ret = _Unwind_RaiseException( &this_exception_storage ); 213 214 214 // If we reach here it means something happened. For resumption to work we need to find a way to return back to 215 // here. Most of them will probably boil down to setting a global flag and making the phase 1 either stop or 216 // fail. Causing an error on purpose may help avoiding unnecessary work but it might have some weird side 217 // effects. If we just pretend no handler was found that would work but may be expensive for no reason since we 218 // will always search the whole stack. 215 // If we reach here it means something happened. For resumption to work we need to find a way 216 // to return back to here. Most of them will probably boil down to setting a global flag and 217 // making the phase 1 either stop or fail. Causing an error on purpose may help avoiding 218 // unnecessary work but it might have some weird side effects. If we just pretend no handler 219 // was found that would work but may be expensive for no reason since we will always search 220 // the whole stack. 219 221 220 222 if( ret == _URC_END_OF_STACK ) { 221 // No proper handler was found. This can be handled in several way. C++ calls std::terminate Here we222 // force unwind the stack, basically raising a cancellation.223 // No proper handler was found. This can be handled in many ways, C++ calls std::terminate. 224 // Here we force unwind the stack, basically raising a cancellation. 223 225 printf("Uncaught exception %p\n", &this_exception_storage); 224 226 … … 228 230 } 229 231 230 // We did not simply reach the end of the stack without finding a handler. Something wen't wrong232 // We did not simply reach the end of the stack without finding a handler. This is an error. 231 233 printf("UNWIND ERROR %d after raise exception\n", ret); 232 234 abort(); … … 254 256 abort(); 255 257 } 256 #else 257 // This is our personality routine. For every stack frame anotated with ".cfi_personality 0x3,__gcfa_personality_v0". 258 // This function will be called twice when unwinding. Once in the search phased and once in the cleanup phase. 258 #else // PIC 259 // This is our personality routine. For every stack frame annotated with 260 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. 261 // Once in the search phase and once in the cleanup phase. 259 262 _Unwind_Reason_Code __gcfa_personality_v0 ( 260 263 int version, _Unwind_Action actions, unsigned long long exceptionClass, … … 264 267 265 268 //__cfaabi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context)); 266 __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):", version, actions, exceptionClass, unwind_exception, context); 269 __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):", 270 version, actions, exceptionClass, unwind_exception, context); 267 271 268 272 // If we've reached the end of the stack then there is nothing much we can do... … … 291 295 // Get the instuction pointer and a reading pointer into the exception table 292 296 lsda_header_info lsd_info; 293 const unsigned char * cur_ptr = parse_lsda_header( 297 const unsigned char * cur_ptr = parse_lsda_header(context, lsd, &lsd_info); 294 298 _Unwind_Ptr instruction_ptr = _Unwind_GetIP( context ); 295 299 … … 302 306 303 307 // Decode the common stuff we have in here 304 cur_ptr = read_encoded_value 305 cur_ptr = read_encoded_value 306 cur_ptr = read_encoded_value 307 cur_ptr = read_uleb128 308 cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_start); 309 cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_len); 310 cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_landing_pad); 311 cur_ptr = read_uleb128(cur_ptr, &callsite_action); 308 312 309 313 // Have we reach the correct frame info yet? … … 316 320 void * ep = (void*)lsd_info.Start + callsite_start + callsite_len; 317 321 void * ip = (void*)instruction_ptr; 318 __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip); 322 __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n", 323 bp, ep, ls, cs, cl, ip); 319 324 #endif // __CFA_DEBUG_PRINT__ 320 325 continue; 321 326 } 322 327 323 // Have we gone too far 328 // Have we gone too far? 324 329 if( lsd_info.Start + callsite_start > instruction_ptr ) { 325 330 printf(" gone too far"); … … 331 336 // Which phase are we in 332 337 if (actions & _UA_SEARCH_PHASE) { 333 // Search phase, this means we probably found a potential handler and must check if it is a match334 335 // If we have arbitrarily decided that 0 means nothing to do and 1 means there is a potential handler336 // This doesn't seem to conflict the gcc default behavior338 // In search phase, these means we found a potential handler we must check. 339 340 // We have arbitrarily decided that 0 means nothing to do and 1 means there is 341 // a potential handler. This doesn't seem to conflict the gcc default behavior. 337 342 if (callsite_action != 0) { 338 343 // Now we want to run some code to see if the handler matches … … 351 356 // The current apprach uses one exception table entry per try block 352 357 _uleb128_t imatcher; 353 // Get the relative offset to the 354 cur_ptr = read_uleb128 (cur_ptr, &imatcher); 355 356 // Get a function pointer from the relative offset and call it 357 // _Unwind_Reason_Code (*matcher)() = (_Unwind_Reason_Code (*)())lsd_info.LPStart + imatcher; 358 // Get the relative offset to the {...}? 359 cur_ptr = read_uleb128(cur_ptr, &imatcher); 358 360 359 361 _Unwind_Reason_Code (*matcher)(exception_t *) = … … 414 416 } 415 417 416 // Try statements are hoisted out see comments for details. With this could probably be unique and simply linked from417 // libcfa but there is one problem left, see the exception table for details418 // Try statements are hoisted out see comments for details. While this could probably be unique 419 // and simply linked from libcfa but there is one problem left, see the exception table for details 418 420 __attribute__((noinline)) 419 421 void __cfaabi_ehm__try_terminate(void (*try_block)(), … … 428 430 // assembly works. 429 431 430 // Setup the personality routine 432 // Setup the personality routine and exception table. 431 433 asm volatile (".cfi_personality 0x3,__gcfa_personality_v0"); 432 // Setup the exception table433 434 asm volatile (".cfi_lsda 0x3, .LLSDACFA2"); 434 435 … … 442 443 asm volatile goto ("" : : : : CATCH ); 443 444 444 // Normal return 445 // Normal return for when there is no throw. 445 446 return; 446 447 … … 459 460 } 460 461 461 // Exception table data we need to generate. While this is almost generic, the custom data refers to foo_try_match try 462 // match, which is no way generic. Some more works need to be done if we want to have a single call to the try routine. 462 // Exception table data we need to generate. While this is almost generic, the custom data refers 463 // to {*}try_terminate, which is no way generic. Some more works need to be done if we want to 464 // have a single call to the try routine. 463 465 464 466 #if defined( __i386 ) || defined( __x86_64 ) 465 467 asm ( 466 // HEADER468 // HEADER 467 469 ".LFECFA1:\n" 468 470 " .globl __gcfa_personality_v0\n" 469 471 " .section .gcc_except_table,\"a\",@progbits\n" 470 ".LLSDACFA2:\n" //TABLE header 472 // TABLE HEADER (important field is the BODY length at the end) 473 ".LLSDACFA2:\n" 471 474 " .byte 0xff\n" 472 475 " .byte 0xff\n" 473 476 " .byte 0x1\n" 474 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" // BODY length 475 // Body uses language specific data and therefore could be modified arbitrarily 476 ".LLSDACSBCFA2:\n" // BODY start 477 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" // Handled area start (relative to start of function) 478 " .uleb128 .TRYEND-.TRYSTART\n" // Handled area length 479 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" // Hanlder landing pad adress (relative to start of function) 480 " .uleb128 1\n" // Action code, gcc seems to use always 0 481 ".LLSDACSECFA2:\n" // BODY end 482 " .text\n" // TABLE footer 477 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" 478 // BODY (language specific data) 479 ".LLSDACSBCFA2:\n" 480 // Handled area start (relative to start of function) 481 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" 482 // Handled area length 483 " .uleb128 .TRYEND-.TRYSTART\n" 484 // Handler landing pad address (relative to start of function) 485 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" 486 // Action code, gcc seems to always use 0. 487 " .uleb128 1\n" 488 // TABLE FOOTER 489 ".LLSDACSECFA2:\n" 490 " .text\n" 483 491 " .size __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n" 484 492 " .ident \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n" … … 486 494 ); 487 495 #endif // __i386 || __x86_64 488 #endif // PIC496 #endif // PIC -
libcfa/src/heap.cfa
rae09808 r0f4527d 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 21:42:46201913 // Update Count : 64 612 // Last Modified On : Sun Dec 8 21:01:31 2019 13 // Update Count : 647 14 14 // 15 15 … … 332 332 333 333 334 // #comment TD : Is this the samething as Out-of-Memory? 335 static inline void noMemory() { 336 abort( "Heap memory exhausted at %zu bytes.\n" 337 "Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.", 338 ((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) ); 339 } // noMemory 334 // static inline void noMemory() { 335 // abort( "Heap memory exhausted at %zu bytes.\n" 336 // "Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.", 337 // ((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) ); 338 // } // noMemory 340 339 341 340 -
src/AST/Convert.cpp
rae09808 r0f4527d 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jul 25 22:21:46201913 // Update Count : 1312 // Last Modified On : Tue Dec 10 22:20:10 2019 13 // Update Count : 32 14 14 // 15 15 … … 245 245 auto decl = new StructDecl( 246 246 node->name, 247 node->kind,247 (AggregateDecl::Aggregate)node->kind, 248 248 get<Attribute>().acceptL( node->attributes ), 249 249 LinkageSpec::Spec( node->linkage.val ) … … 675 675 676 676 const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final { 677 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS; 678 switch (node->target) { 679 case ast::KeywordCastExpr::Coroutine: 680 castTarget = KeywordCastExpr::Coroutine; 681 break; 682 case ast::KeywordCastExpr::Thread: 683 castTarget = KeywordCastExpr::Thread; 684 break; 685 case ast::KeywordCastExpr::Monitor: 686 castTarget = KeywordCastExpr::Monitor; 687 break; 688 default: 689 break; 690 } 691 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS ); 677 AggregateDecl::Aggregate castTarget = (AggregateDecl::Aggregate)node->target; 678 assert( AggregateDecl::Generator <= castTarget && castTarget <= AggregateDecl::Thread ); 692 679 auto expr = visitBaseExpr( node, 693 680 new KeywordCastExpr( … … 1504 1491 old->location, 1505 1492 old->name, 1506 old->kind,1493 (ast::AggregateDecl::Aggregate)old->kind, 1507 1494 GET_ACCEPT_V(attributes, Attribute), 1508 1495 { old->linkage.val } … … 2045 2032 } 2046 2033 2047 virtual void visit( const KeywordCastExpr * old) override final { 2048 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS; 2049 switch (old->target) { 2050 case KeywordCastExpr::Coroutine: 2051 castTarget = ast::KeywordCastExpr::Coroutine; 2052 break; 2053 case KeywordCastExpr::Thread: 2054 castTarget = ast::KeywordCastExpr::Thread; 2055 break; 2056 case KeywordCastExpr::Monitor: 2057 castTarget = ast::KeywordCastExpr::Monitor; 2058 break; 2059 default: 2060 break; 2061 } 2062 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS ); 2034 virtual void visit( const KeywordCastExpr * old ) override final { 2035 ast::AggregateDecl::Aggregate castTarget = (ast::AggregateDecl::Aggregate)old->target; 2036 assert( ast::AggregateDecl::Generator <= castTarget && castTarget <= ast::AggregateDecl::Thread ); 2063 2037 this->node = visitBaseExpr( old, 2064 2038 new ast::KeywordCastExpr( -
src/AST/Decl.cpp
rae09808 r0f4527d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00201913 // Update Count : 1 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:41:39 2019 13 // Update Count : 18 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, strict_dynamic_cast 19 19 #include <iostream> 20 #include <string>21 20 #include <unordered_map> 22 21 … … 56 55 // --- TypeDecl 57 56 58 std::stringTypeDecl::typeString() const {59 static const std::string kindNames[] = { "object type", "function type", "tuple type" };57 const char * TypeDecl::typeString() const { 58 static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" }; 60 59 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, 61 60 "typeString: kindNames is out of sync." ); 62 61 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 63 return (sized ? "sized " : "") + kindNames[ kind ];62 return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 64 63 } 65 64 66 std::stringTypeDecl::genTypeString() const {67 static const std::stringkindNames[] = { "dtype", "ftype", "ttype" };65 const char * TypeDecl::genTypeString() const { 66 static const char * kindNames[] = { "dtype", "ftype", "ttype" }; 68 67 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 69 68 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); … … 73 72 std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) { 74 73 return out << data.kind << ", " << data.isComplete; 74 } 75 76 // --- AggregateDecl 77 78 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations. 79 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" }; 80 81 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) { 82 return aggregateNames[aggr]; 75 83 } 76 84 -
src/AST/Decl.hpp
rae09808 r0f4527d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00 201913 // Update Count : 1 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 08:20:20 2019 13 // Update Count : 16 14 14 // 15 15 … … 154 154 155 155 /// Produces a name for the kind of alias 156 virtual std::stringtypeString() const = 0;156 virtual const char * typeString() const = 0; 157 157 158 158 private: … … 190 190 init( i ) {} 191 191 192 std::stringtypeString() const override;192 const char * typeString() const override; 193 193 /// Produces a name for generated code 194 std::stringgenTypeString() const;194 const char * genTypeString() const; 195 195 196 196 /// convenience accessor to match Type::isComplete() … … 212 212 : NamedTypeDecl( loc, name, storage, b, spec ) {} 213 213 214 std::stringtypeString() const override { return "typedef"; }214 const char * typeString() const override { return "typedef"; } 215 215 216 216 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } … … 223 223 class AggregateDecl : public Decl { 224 224 public: 225 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate }; 226 static const char * aggrString( Aggregate aggr ); 227 225 228 std::vector<ptr<Decl>> members; 226 229 std::vector<ptr<TypeDecl>> params; … … 237 240 238 241 /// Produces a name for the kind of aggregate 239 virtual std::stringtypeString() const = 0;242 virtual const char * typeString() const = 0; 240 243 241 244 private: … … 247 250 class StructDecl final : public AggregateDecl { 248 251 public: 249 DeclarationNode::Aggregate kind;252 Aggregate kind; 250 253 251 254 StructDecl( const CodeLocation& loc, const std::string& name, 252 DeclarationNode::Aggregate kind = DeclarationNode::Struct,255 Aggregate kind = Struct, 253 256 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall ) 254 257 : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {} 255 258 256 bool is_coroutine() { return kind == DeclarationNode::Coroutine; }257 bool is_monitor() { return kind == DeclarationNode::Monitor; }258 bool is_thread() { return kind == DeclarationNode::Thread; }259 260 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 261 262 std::string typeString() const override { return "struct"; }259 bool is_coroutine() { return kind == Coroutine; } 260 bool is_monitor() { return kind == Monitor; } 261 bool is_thread() { return kind == Thread; } 262 263 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 264 265 const char * typeString() const override { return aggrString( kind ); } 263 266 264 267 private: … … 276 279 const Decl * accept( Visitor& v ) const override { return v.visit( this ); } 277 280 278 std::string typeString() const override { return "union"; }281 const char * typeString() const override { return aggrString( Union ); } 279 282 280 283 private: … … 295 298 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 296 299 297 std::string typeString() const override { return "enum"; }300 const char * typeString() const override { return aggrString( Enum ); } 298 301 299 302 private: … … 314 317 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 315 318 316 std::stringtypeString() const override { return "trait"; }319 const char * typeString() const override { return "trait"; } 317 320 318 321 private: -
src/AST/Expr.cpp
rae09808 r0f4527d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Andrew Beach11 // Last Modified By : Peter A. Buhr 12 12 // Created On : Thr Jun 13 13:38:00 2019 13 // Update Count : 213 // Update Count : 6 14 14 // 15 15 … … 141 141 // --- KeywordCastExpr 142 142 143 const std::string & KeywordCastExpr::targetString() const { 144 static const std::string targetStrs[] = { 145 "coroutine", "thread", "monitor" 146 }; 147 static_assert( 148 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 149 "Each KeywordCastExpr::Target should have a corresponding string representation" 150 ); 151 return targetStrs[(unsigned long)target]; 143 const char * KeywordCastExpr::targetString() const { 144 return AggregateDecl::aggrString( target ); 152 145 } 153 146 -
src/AST/Expr.hpp
rae09808 r0f4527d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri May 10 10:30:00 2019 11 // Last Modified By : Aaron B. Moss11 // Last Modified By : Peter A. Buhr 12 12 // Created On : Fri May 10 10:30:00 2019 13 // Update Count : 113 // Update Count : 7 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" // for UniqueId 27 27 #include "Label.hpp" 28 #include "Decl.hpp" 28 29 #include "ParseNode.hpp" 29 30 #include "Visitor.hpp" … … 300 301 public: 301 302 ptr<Expr> arg; 302 enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS }target;303 304 KeywordCastExpr( const CodeLocation & loc, const Expr * a, Targett )303 ast::AggregateDecl::Aggregate target; 304 305 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t ) 305 306 : Expr( loc ), arg( a ), target( t ) {} 306 307 307 308 /// Get a name for the target type 308 const std::string&targetString() const;309 const char * targetString() const; 309 310 310 311 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/Concurrency/Keywords.cc
rae09808 r0f4527d 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 513 // Update Count : 9 14 14 // 15 15 … … 53 53 public: 54 54 55 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, KeywordCastExpr::Targetcast_target ) :55 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, AggregateDecl::Aggregate cast_target ) : 56 56 type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {} 57 57 … … 76 76 const std::string context_error; 77 77 bool needs_main; 78 KeywordCastExpr::Targetcast_target;78 AggregateDecl::Aggregate cast_target; 79 79 80 80 StructDecl * type_decl = nullptr; … … 101 101 "thread keyword requires threads to be in scope, add #include <thread.hfa>\n", 102 102 true, 103 KeywordCastExpr::Thread103 AggregateDecl::Thread 104 104 ) 105 105 {} … … 133 133 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n", 134 134 true, 135 KeywordCastExpr::Coroutine135 AggregateDecl::Coroutine 136 136 ) 137 137 {} … … 165 165 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n", 166 166 false, 167 KeywordCastExpr::Monitor167 AggregateDecl::Monitor 168 168 ) 169 169 {} -
src/Concurrency/Waitfor.cc
rae09808 r0f4527d 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 713 // Update Count : 10 14 14 // 15 15 … … 23 23 #include "Common/PassVisitor.h" // for PassVisitor 24 24 #include "Common/SemanticError.h" // for SemanticError 25 #include "Common/UniqueName.h" // for UniqueName 25 26 #include "Common/utility.h" // for deleteAll, map_range 26 27 #include "CodeGen/OperatorTable.h" // for isConstructor -
src/Parser/DeclarationNode.cc
rae09808 r0f4527d 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:17:10201913 // Update Count : 11 1612 // Last Modified On : Wed Dec 11 07:40:14 2019 13 // Update Count : 1123 14 14 // 15 15 … … 47 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };50 49 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 51 50 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; … … 267 266 } 268 267 269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {268 DeclarationNode * DeclarationNode::newAggregate( AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 270 269 DeclarationNode * newnode = new DeclarationNode; 271 270 newnode->type = new TypeData( TypeData::Aggregate ); … … 328 327 newnode->type = new TypeData( TypeData::Aggregate ); 329 328 newnode->type->aggregate.name = name; 330 newnode->type->aggregate.kind = Trait;329 newnode->type->aggregate.kind = AggregateDecl::Trait; 331 330 newnode->type->aggregate.params = params; 332 331 newnode->type->aggregate.fields = asserts; … … 338 337 newnode->type = new TypeData( TypeData::AggregateInst ); 339 338 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 340 newnode->type->aggInst.aggregate->aggregate.kind = Trait;339 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait; 341 340 newnode->type->aggInst.aggregate->aggregate.name = name; 342 341 newnode->type->aggInst.params = params; -
src/Parser/ExpressionNode.cc
rae09808 r0f4527d 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 4 20:57:55201913 // Update Count : 9 7812 // Last Modified On : Tue Dec 10 23:01:47 2019 13 // Update Count : 980 14 14 // 15 15 … … 434 434 } // build_cast 435 435 436 Expression * build_keyword_cast( KeywordCastExpr::Targettarget, ExpressionNode * expr_node ) {436 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ) { 437 437 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 438 438 } -
src/Parser/ParseNode.h
rae09808 r0f4527d 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:17:10201913 // Update Count : 8 7612 // Last Modified On : Wed Dec 11 07:40:07 2019 13 // Update Count : 882 14 14 // 15 15 … … 29 29 #include "Common/utility.h" // for maybeClone, maybeBuild 30 30 #include "Parser/LinkageSpec.h" // for Spec 31 #include "SynTree/Declaration.h" // for Aggregate 31 32 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 32 33 #include "SynTree/Label.h" // for Label … … 184 185 185 186 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 186 Expression * build_keyword_cast( KeywordCastExpr::Targettarget, ExpressionNode * expr_node );187 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ); 187 188 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 188 189 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); … … 217 218 enum Length { Short, Long, LongLong, NoLength }; 218 219 static const char * lengthNames[]; 219 enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate };220 static const char * aggregateNames[];221 220 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 222 221 static const char * typeClassNames[]; … … 237 236 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 238 237 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );238 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 240 239 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body ); 241 240 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); -
src/Parser/TypeData.cc
rae09808 r0f4527d 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 13 18:16:23 201913 // Update Count : 6 4912 // Last Modified On : Wed Dec 11 07:48:33 2019 13 // Update Count : 659 14 14 // 15 15 … … 67 67 case Aggregate: 68 68 // aggregate = new Aggregate_t; 69 aggregate.kind = DeclarationNode::NoAggregate;69 aggregate.kind = AggregateDecl::NoAggregate; 70 70 aggregate.name = nullptr; 71 71 aggregate.params = nullptr; … … 345 345 break; 346 346 case Aggregate: 347 os << DeclarationNode::aggregateNames[ aggregate.kind ]<< ' ' << *aggregate.name << endl;347 os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl; 348 348 if ( aggregate.params ) { 349 349 os << string( indent + 2, ' ' ) << "with type parameters" << endl; … … 768 768 AggregateDecl * at; 769 769 switch ( td->aggregate.kind ) { 770 case DeclarationNode::Struct:771 case DeclarationNode::Coroutine:772 case DeclarationNode::Monitor:773 case DeclarationNode::Thread:770 case AggregateDecl::Struct: 771 case AggregateDecl::Coroutine: 772 case AggregateDecl::Monitor: 773 case AggregateDecl::Thread: 774 774 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage ); 775 775 buildForall( td->aggregate.params, at->get_parameters() ); 776 776 break; 777 case DeclarationNode::Union:777 case AggregateDecl::Union: 778 778 at = new UnionDecl( *td->aggregate.name, attributes, linkage ); 779 779 buildForall( td->aggregate.params, at->get_parameters() ); 780 780 break; 781 case DeclarationNode::Trait:781 case AggregateDecl::Trait: 782 782 at = new TraitDecl( *td->aggregate.name, attributes, linkage ); 783 783 buildList( td->aggregate.params, at->get_parameters() ); … … 809 809 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 810 810 switch ( type->aggregate.kind ) { 811 case DeclarationNode::Struct:812 case DeclarationNode::Coroutine:813 case DeclarationNode::Monitor:814 case DeclarationNode::Thread:811 case AggregateDecl::Struct: 812 case AggregateDecl::Coroutine: 813 case AggregateDecl::Monitor: 814 case AggregateDecl::Thread: 815 815 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 816 816 break; 817 case DeclarationNode::Union:817 case AggregateDecl::Union: 818 818 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 819 819 break; 820 case DeclarationNode::Trait:820 case AggregateDecl::Trait: 821 821 assert( false ); 822 822 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); … … 827 827 } else { 828 828 switch ( type->aggregate.kind ) { 829 case DeclarationNode::Struct:830 case DeclarationNode::Coroutine:831 case DeclarationNode::Monitor:832 case DeclarationNode::Thread:829 case AggregateDecl::Struct: 830 case AggregateDecl::Coroutine: 831 case AggregateDecl::Monitor: 832 case AggregateDecl::Thread: 833 833 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 834 834 break; 835 case DeclarationNode::Union:835 case AggregateDecl::Union: 836 836 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 837 837 break; 838 case DeclarationNode::Trait:838 case AggregateDecl::Trait: 839 839 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 840 840 break; … … 863 863 case TypeData::Aggregate: { 864 864 switch ( type->aggregate.kind ) { 865 case DeclarationNode::Struct:866 case DeclarationNode::Coroutine:867 case DeclarationNode::Monitor:868 case DeclarationNode::Thread:865 case AggregateDecl::Struct: 866 case AggregateDecl::Coroutine: 867 case AggregateDecl::Monitor: 868 case AggregateDecl::Thread: 869 869 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 870 870 break; 871 case DeclarationNode::Union:871 case AggregateDecl::Union: 872 872 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 873 873 break; 874 case DeclarationNode::Trait:874 case AggregateDecl::Trait: 875 875 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 876 876 break; -
src/Parser/TypeData.h
rae09808 r0f4527d 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 1 20:56:46 201813 // Update Count : 19 612 // Last Modified On : Tue Dec 10 23:01:07 2019 13 // Update Count : 198 14 14 // 15 15 … … 30 30 31 31 struct Aggregate_t { 32 DeclarationNode::Aggregate kind;32 AggregateDecl::Aggregate kind; 33 33 const std::string * name = nullptr; 34 34 DeclarationNode * params = nullptr; -
src/Parser/parser.yy
rae09808 r0f4527d 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 7 10:43:44201913 // Update Count : 4 39412 // Last Modified On : Thu Dec 12 17:54:22 2019 13 // Update Count : 4404 14 14 // 15 15 … … 51 51 using namespace std; 52 52 53 #include "SynTree/Declaration.h" 53 54 #include "ParseNode.h" 54 55 #include "TypedefTable.h" … … 211 212 } // forCtrl 212 213 213 KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) {214 KeywordCastExpr::Target target;215 switch ( aggr ) {216 case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break;217 case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break;218 case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break;219 default: abort();220 } // switch221 return target;222 } // Aggregate2Target223 224 225 214 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 226 215 … … 248 237 ExpressionNode * en; 249 238 DeclarationNode * decl; 250 DeclarationNode::Aggregate aggKey;239 AggregateDecl::Aggregate aggKey; 251 240 DeclarationNode::TypeClass tclass; 252 241 StatementNode * sn; … … 662 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 663 652 | postfix_expression '.' aggregate_control 664 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }653 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); } 665 654 | postfix_expression ARROW identifier 666 655 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 807 796 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 808 797 | '(' aggregate_control '&' ')' cast_expression // CFA 809 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }798 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 810 799 // VIRTUAL cannot be opt because of look ahead issues 811 800 | '(' VIRTUAL ')' cast_expression // CFA … … 1201 1190 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1202 1191 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1192 | '=' comma_expression // CFA 1193 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1194 OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1203 1195 | comma_expression inclexcl comma_expression // CFA 1204 1196 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1208 1200 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1209 1201 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1202 | comma_expression ';' '=' comma_expression // CFA 1203 { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1204 OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1210 1205 | comma_expression ';' comma_expression inclexcl comma_expression // CFA 1211 1206 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 2071 2066 aggregate_data: 2072 2067 STRUCT 2073 { yyy = true; $$ = DeclarationNode::Struct; }2068 { yyy = true; $$ = AggregateDecl::Struct; } 2074 2069 | UNION 2075 { yyy = true; $$ = DeclarationNode::Union; }2070 { yyy = true; $$ = AggregateDecl::Union; } 2076 2071 | EXCEPTION // CFA 2077 { yyy = true; $$ = DeclarationNode::Exception; }2072 { yyy = true; $$ = AggregateDecl::Exception; } 2078 2073 ; 2079 2074 2080 2075 aggregate_control: // CFA 2081 2076 GENERATOR 2082 { yyy = true; $$ = DeclarationNode::Coroutine; }2077 { yyy = true; $$ = AggregateDecl::Coroutine; } 2083 2078 | COROUTINE 2084 { yyy = true; $$ = DeclarationNode::Coroutine; }2079 { yyy = true; $$ = AggregateDecl::Coroutine; } 2085 2080 | MONITOR 2086 { yyy = true; $$ = DeclarationNode::Monitor; }2081 { yyy = true; $$ = AggregateDecl::Monitor; } 2087 2082 | THREAD 2088 { yyy = true; $$ = DeclarationNode::Thread; }2083 { yyy = true; $$ = AggregateDecl::Thread; } 2089 2084 ; 2090 2085 -
src/SymTab/Validate.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 7 6:42:00201913 // Update Count : 36 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 10 22:22:01 2019 13 // Update Count : 362 14 14 // 15 15 … … 1049 1049 Type * designatorType = tyDecl->base->stripDeclarator(); 1050 1050 if ( StructInstType * aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) { 1051 declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage ) );1051 declsToAddBefore.push_back( new StructDecl( aggDecl->name, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) ); 1052 1052 } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) { 1053 1053 declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) ); -
src/SynTree/AggregateDecl.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 23:56:39 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Aug 4 14:22:00 201713 // Update Count : 2 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:31:55 2019 13 // Update Count : 29 14 14 // 15 15 … … 21 21 #include "Common/utility.h" // for printAll, cloneAll, deleteAll 22 22 #include "Declaration.h" // for AggregateDecl, TypeDecl, Declaration 23 #include "Initializer.h" 23 24 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 24 25 #include "Type.h" // for Type, Type::StorageClasses 25 26 27 28 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations. 29 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" }; 30 31 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) { 32 return aggregateNames[aggr]; 33 } 26 34 27 35 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) { … … 78 86 } 79 87 80 std::string StructDecl::typeString() const { return "struct"; }88 const char * StructDecl::typeString() const { return aggrString( kind ); } 81 89 82 std::string UnionDecl::typeString() const { return "union"; }90 const char * UnionDecl::typeString() const { return aggrString( Union ); } 83 91 84 std::string EnumDecl::typeString() const { return "enum"; }92 const char * EnumDecl::typeString() const { return aggrString( Enum ); } 85 93 86 std::string TraitDecl::typeString() const { return "trait"; }94 const char * TraitDecl::typeString() const { return aggrString( Trait ); } 87 95 88 96 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { -
src/SynTree/Declaration.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 9 14:38:00 201713 // Update Count : 2511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:39:56 2019 13 // Update Count : 36 14 14 // 15 15 … … 24 24 #include "SynTree/Statement.h" // for AsmStmt 25 25 #include "SynTree/SynTree.h" // for UniqueId 26 #include "SynTree/Expression.h" 26 27 #include "Type.h" // for Type, Type::StorageClasses 27 28 29 // To canonicalize declarations 28 30 static UniqueId lastUniqueId = 0; 29 31 -
src/SynTree/Declaration.h
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr May 2 10:47:00 201913 // Update Count : 1 3511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:48:20 2019 13 // Update Count : 149 14 14 // 15 15 … … 25 25 #include "Mutator.h" // for Mutator 26 26 #include "Parser/LinkageSpec.h" // for Spec, Cforall 27 #include "Parser/ParseNode.h" // for DeclarationNode, DeclarationNode::Ag...28 27 #include "SynTree.h" // for UniqueId 29 28 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Type::Fu... … … 194 193 std::list< DeclarationWithType* >& get_assertions() { return assertions; } 195 194 196 virtual std::stringtypeString() const = 0;195 virtual const char * typeString() const = 0; 197 196 198 197 virtual NamedTypeDecl *clone() const override = 0; … … 237 236 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 238 237 239 virtual std::stringtypeString() const override;240 virtual std::stringgenTypeString() const;238 virtual const char * typeString() const override; 239 virtual const char * genTypeString() const; 241 240 242 241 virtual TypeDecl *clone() const override { return new TypeDecl( *this ); } … … 257 256 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 258 257 259 virtual std::stringtypeString() const override;258 virtual const char * typeString() const override; 260 259 261 260 virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); } … … 269 268 typedef Declaration Parent; 270 269 public: 270 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate }; 271 static const char * aggrString( Aggregate aggr ); 272 271 273 std::list<Declaration*> members; 272 274 std::list<TypeDecl*> parameters; … … 291 293 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 292 294 protected: 293 virtual std::stringtypeString() const = 0;295 virtual const char * typeString() const = 0; 294 296 }; 295 297 … … 297 299 typedef AggregateDecl Parent; 298 300 public: 299 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}301 StructDecl( const std::string &name, Aggregate kind = Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {} 300 302 StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {} 301 303 302 bool is_coroutine() { return kind == DeclarationNode::Coroutine; }303 bool is_monitor() { return kind == DeclarationNode::Monitor; }304 bool is_thread() { return kind == DeclarationNode::Thread; }304 bool is_coroutine() { return kind == Coroutine; } 305 bool is_monitor() { return kind == Monitor; } 306 bool is_thread() { return kind == Thread; } 305 307 306 308 virtual StructDecl *clone() const override { return new StructDecl( *this ); } … … 308 310 virtual void accept( Visitor & v ) const override { v.visit( this ); } 309 311 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 310 DeclarationNode::Aggregate kind;311 private: 312 virtual std::stringtypeString() const override;312 Aggregate kind; 313 private: 314 virtual const char * typeString() const override; 313 315 }; 314 316 … … 324 326 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 325 327 private: 326 virtual std::stringtypeString() const override;328 virtual const char * typeString() const override; 327 329 }; 328 330 … … 341 343 private: 342 344 std::unordered_map< std::string, long long int > enumValues; 343 virtual std::stringtypeString() const override;345 virtual const char * typeString() const override; 344 346 }; 345 347 … … 357 359 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 358 360 private: 359 virtual std::stringtypeString() const override;361 virtual const char * typeString() const override; 360 362 }; 361 363 -
src/SynTree/Expression.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 15 13:43:00201913 // Update Count : 6411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:55:15 2019 13 // Update Count : 70 14 14 // 15 15 … … 22 22 23 23 #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll 24 #include "Declaration.h" // for ObjectDecl, DeclarationWithType25 24 #include "Expression.h" // for Expression, ImplicitCopyCtorExpr 26 25 #include "InitTweak/InitTweak.h" // for getCallArg, getPointerBase … … 294 293 } 295 294 296 KeywordCastExpr::KeywordCastExpr( Expression * arg, Targettarget ) : Expression(), arg(arg), target( target ) {295 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) { 297 296 } 298 297 … … 304 303 } 305 304 306 const std::string & KeywordCastExpr::targetString() const { 307 static const std::string targetStrs[] = { 308 "coroutine", "thread", "monitor" 309 }; 310 static_assert( 311 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 312 "Each KeywordCastExpr::Target should have a corresponding string representation" 313 ); 314 return targetStrs[(unsigned long)target]; 305 const char * KeywordCastExpr::targetString() const { 306 return AggregateDecl::aggrString( target ); 315 307 } 316 308 -
src/SynTree/Expression.h
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 15 13:46:00201913 // Update Count : 5411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:50:19 2019 13 // Update Count : 60 14 14 // 15 15 … … 28 28 #include "Label.h" // for Label 29 29 #include "Mutator.h" // for Mutator 30 #include "Declaration.h" // for Aggregate 30 31 #include "SynTree.h" // for UniqueId 31 32 #include "Visitor.h" // for Visitor … … 229 230 public: 230 231 Expression * arg; 231 enum Target {232 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS233 };234 232 struct Concrete { 235 233 std::string field; 236 234 std::string getter; 237 235 }; 238 Targettarget;236 AggregateDecl::Aggregate target; 239 237 Concrete concrete_target; 240 238 241 KeywordCastExpr( Expression * arg, Targettarget );239 KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ); 242 240 KeywordCastExpr( const KeywordCastExpr & other ); 243 241 virtual ~KeywordCastExpr(); 244 242 245 const std::string &targetString() const;243 const char * targetString() const; 246 244 247 245 virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); } -
src/SynTree/FunctionDecl.cc
rae09808 r0f4527d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 08:33:41 201713 // Update Count : 7 412 // Last Modified On : Sat Dec 7 17:40:09 2019 13 // Update Count : 75 14 14 // 15 15 … … 23 23 #include "Common/utility.h" // for maybeClone, printAll 24 24 #include "Declaration.h" // for FunctionDecl, FunctionDecl::Parent 25 #include "Expression.h" 25 26 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 26 27 #include "Statement.h" // for CompoundStmt -
src/SynTree/NamedTypeDecl.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 9 13:28:00 201713 // Update Count : 1 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 08:26:17 2019 13 // Update Count : 15 14 14 // 15 15 … … 78 78 } 79 79 80 std::stringTypedefDecl::typeString() const { return "typedef"; }80 const char * TypedefDecl::typeString() const { return "typedef"; } 81 81 82 82 // Local Variables: // -
src/SynTree/TypeDecl.cc
rae09808 r0f4527d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 9 14:35:00 201713 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 17:56:30 2019 13 // Update Count : 10 14 14 // 15 15 … … 18 18 19 19 #include "Common/utility.h" // for maybeClone 20 #include "Parser/ParseNode.h" 20 21 #include "Declaration.h" // for TypeDecl, TypeDecl::Data, TypeDecl::Kind... 21 22 #include "Type.h" // for Type, Type::StorageClasses … … 31 32 } 32 33 33 std::stringTypeDecl::typeString() const {34 static const std::string kindNames[] = { "object type", "function type", "tuple type" };34 const char * TypeDecl::typeString() const { 35 static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" }; 35 36 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." ); 36 37 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 37 return (isComplete() ? "sized " : "") + kindNames[ kind ];38 return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 38 39 } 39 40 40 std::stringTypeDecl::genTypeString() const {41 static const std::stringkindNames[] = { "dtype", "ftype", "ttype" };41 const char * TypeDecl::genTypeString() const { 42 static const char * kindNames[] = { "dtype", "ftype", "ttype" }; 42 43 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 43 44 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); -
tests/.expect/loopctrl.txt
rae09808 r0f4527d 6 6 A 7 7 A A A A A A A A A A 8 A A A A A A A A A A A 8 9 B B B B B 9 10 C C C C C … … 12 13 13 14 0 1 2 3 4 5 6 7 8 9 15 0 1 2 3 4 5 6 7 8 9 10 14 16 1 3 5 7 9 15 17 10 8 6 4 2 … … 28 30 N N N N N N N N N N 29 31 0 1 2 3 4 5 6 7 8 9 32 0 1 2 3 4 5 6 7 8 9 10 30 33 10 9 8 7 6 5 4 3 2 1 31 34 -
tests/concurrent/.expect/keywordErrors.txt
rae09808 r0f4527d 1 1 concurrent/keywordErrors.cfa:1:1 error: thread keyword requires threads to be in scope, add #include <thread.hfa> 2 structA: with body 12 thread A: with body 1 3 3 4 4 concurrent/keywordErrors.cfa:6:1 error: thread keyword requires threads to be in scope, add #include <thread.hfa> 5 structB: with body 15 thread B: with body 1 6 6 -
tests/loopctrl.cfa
rae09808 r0f4527d 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 12 12:05:05201913 // Update Count : 10 612 // Last Modified On : Thu Dec 12 17:55:26 2019 13 // Update Count : 108 14 14 // 15 15 … … 43 43 for ( 1 ) { sout | "A"; } sout | nl; 44 44 for ( 10 ) { sout | "A"; } sout | nl; 45 for ( = 10 ) { sout | "A"; } sout | nl; 45 46 for ( 1 ~= 10 ~ 2 ) { sout | "B"; } sout | nl; 46 47 for ( 10 -~= 1 ~ 2 ) { sout | "C"; } sout | nl; … … 49 50 50 51 for ( i; 10 ) { sout | i; } sout | nl; 52 for ( i; = 10 ) { sout | i; } sout | nl; 51 53 for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | nl; 52 54 for ( i; 10 -~= 1 ~ 2 ) { sout | i; } sout | nl; … … 87 89 for ( N ) { sout | "N"; } sout | nl; 88 90 for ( i; N ) { sout | i; } sout | nl; 91 for ( i; = N ) { sout | i; } sout | nl; 89 92 for ( i; N -~ 0 ) { sout | i; } sout | nl | nl; 90 93
Note: See TracChangeset
for help on using the changeset viewer.