Changes in / [737c98a:2cd949b]
- Files:
-
- 24 edited
-
libcfa/src/heap.cfa (modified) (2 diffs)
-
src/AST/Convert.cpp (modified) (5 diffs)
-
src/AST/Decl.cpp (modified) (4 diffs)
-
src/AST/Decl.hpp (modified) (10 diffs)
-
src/AST/Expr.cpp (modified) (2 diffs)
-
src/AST/Expr.hpp (modified) (3 diffs)
-
src/Concurrency/Keywords.cc (modified) (6 diffs)
-
src/Concurrency/Waitfor.cc (modified) (2 diffs)
-
src/Parser/DeclarationNode.cc (modified) (5 diffs)
-
src/Parser/ExpressionNode.cc (modified) (2 diffs)
-
src/Parser/ParseNode.h (modified) (5 diffs)
-
src/Parser/TypeData.cc (modified) (7 diffs)
-
src/Parser/TypeData.h (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (7 diffs)
-
src/SymTab/Validate.cc (modified) (2 diffs)
-
src/SynTree/AggregateDecl.cc (modified) (3 diffs)
-
src/SynTree/Declaration.cc (modified) (2 diffs)
-
src/SynTree/Declaration.h (modified) (12 diffs)
-
src/SynTree/Expression.cc (modified) (4 diffs)
-
src/SynTree/Expression.h (modified) (3 diffs)
-
src/SynTree/FunctionDecl.cc (modified) (2 diffs)
-
src/SynTree/NamedTypeDecl.cc (modified) (2 diffs)
-
src/SynTree/TypeDecl.cc (modified) (3 diffs)
-
tests/concurrent/.expect/keywordErrors.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r737c98a r2cd949b 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 8 21:01:31201913 // Update Count : 64 712 // Last Modified On : Wed Dec 4 21:42:46 2019 13 // Update Count : 646 14 14 // 15 15 … … 332 332 333 333 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 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 339 340 340 341 -
src/AST/Convert.cpp
r737c98a r2cd949b 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Dec 10 22:20:10201913 // Update Count : 3212 // Last Modified On : Thu Jul 25 22:21:46 2019 13 // Update Count : 13 14 14 // 15 15 … … 245 245 auto decl = new StructDecl( 246 246 node->name, 247 (AggregateDecl::Aggregate)node->kind,247 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 AggregateDecl::Aggregate castTarget = (AggregateDecl::Aggregate)node->target; 678 assert( AggregateDecl::Generator <= castTarget && castTarget <= AggregateDecl::Thread ); 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 ); 679 692 auto expr = visitBaseExpr( node, 680 693 new KeywordCastExpr( … … 1491 1504 old->location, 1492 1505 old->name, 1493 (ast::AggregateDecl::Aggregate)old->kind,1506 old->kind, 1494 1507 GET_ACCEPT_V(attributes, Attribute), 1495 1508 { old->linkage.val } … … 2032 2045 } 2033 2046 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 ); 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 ); 2037 2063 this->node = visitBaseExpr( old, 2038 2064 new ast::KeywordCastExpr( -
src/AST/Decl.cpp
r737c98a r2cd949b 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:41:39201913 // Update Count : 1 811 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, strict_dynamic_cast 19 19 #include <iostream> 20 #include <string> 20 21 #include <unordered_map> 21 22 … … 55 56 // --- TypeDecl 56 57 57 const char *TypeDecl::typeString() const {58 static const char * kindNames[] = { "sized object type", "sized function type", "sizedtuple type" };58 std::string TypeDecl::typeString() const { 59 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 59 60 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, 60 61 "typeString: kindNames is out of sync." ); 61 62 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 62 return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'63 return (sized ? "sized " : "") + kindNames[ kind ]; 63 64 } 64 65 65 const char *TypeDecl::genTypeString() const {66 static const char *kindNames[] = { "dtype", "ftype", "ttype" };66 std::string TypeDecl::genTypeString() const { 67 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 67 68 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 68 69 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); … … 72 73 std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) { 73 74 return out << data.kind << ", " << data.isComplete; 74 }75 76 // --- AggregateDecl77 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];83 75 } 84 76 -
src/AST/Decl.hpp
r737c98a r2cd949b 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 08:20:20 201913 // Update Count : 1 611 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 154 154 155 155 /// Produces a name for the kind of alias 156 virtual const char *typeString() const = 0;156 virtual std::string typeString() const = 0; 157 157 158 158 private: … … 190 190 init( i ) {} 191 191 192 const char *typeString() const override;192 std::string typeString() const override; 193 193 /// Produces a name for generated code 194 const char *genTypeString() const;194 std::string genTypeString() const; 195 195 196 196 /// convenience accessor to match Type::isComplete() … … 212 212 : NamedTypeDecl( loc, name, storage, b, spec ) {} 213 213 214 const char *typeString() const override { return "typedef"; }214 std::string 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 228 225 std::vector<ptr<Decl>> members; 229 226 std::vector<ptr<TypeDecl>> params; … … 240 237 241 238 /// Produces a name for the kind of aggregate 242 virtual const char *typeString() const = 0;239 virtual std::string typeString() const = 0; 243 240 244 241 private: … … 250 247 class StructDecl final : public AggregateDecl { 251 248 public: 252 Aggregate kind;249 DeclarationNode::Aggregate kind; 253 250 254 251 StructDecl( const CodeLocation& loc, const std::string& name, 255 Aggregate kind =Struct,252 DeclarationNode::Aggregate kind = DeclarationNode::Struct, 256 253 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall ) 257 254 : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {} 258 255 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 ); }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"; } 266 263 267 264 private: … … 279 276 const Decl * accept( Visitor& v ) const override { return v.visit( this ); } 280 277 281 const char * typeString() const override { return aggrString( Union ); }278 std::string typeString() const override { return "union"; } 282 279 283 280 private: … … 298 295 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 299 296 300 const char * typeString() const override { return aggrString( Enum ); }297 std::string typeString() const override { return "enum"; } 301 298 302 299 private: … … 317 314 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 318 315 319 const char *typeString() const override { return "trait"; }316 std::string typeString() const override { return "trait"; } 320 317 321 318 private: -
src/AST/Expr.cpp
r737c98a r2cd949b 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Peter A. Buhr11 // Last Modified By : Andrew Beach 12 12 // Created On : Thr Jun 13 13:38:00 2019 13 // Update Count : 613 // Update Count : 2 14 14 // 15 15 … … 141 141 // --- KeywordCastExpr 142 142 143 const char * KeywordCastExpr::targetString() const { 144 return AggregateDecl::aggrString( target ); 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]; 145 152 } 146 153 -
src/AST/Expr.hpp
r737c98a r2cd949b 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri May 10 10:30:00 2019 11 // Last Modified By : Peter A. Buhr11 // Last Modified By : Aaron B. Moss 12 12 // Created On : Fri May 10 10:30:00 2019 13 // Update Count : 713 // Update Count : 1 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" // for UniqueId 27 27 #include "Label.hpp" 28 #include "Decl.hpp"29 28 #include "ParseNode.hpp" 30 29 #include "Visitor.hpp" … … 301 300 public: 302 301 ptr<Expr> arg; 303 ast::AggregateDecl::Aggregatetarget;304 305 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregatet )302 enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS } target; 303 304 KeywordCastExpr( const CodeLocation & loc, const Expr * a, Target t ) 306 305 : Expr( loc ), arg( a ), target( t ) {} 307 306 308 307 /// Get a name for the target type 309 const char *targetString() const;308 const std::string& targetString() const; 310 309 311 310 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/Concurrency/Keywords.cc
r737c98a r2cd949b 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 913 // Update Count : 5 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, AggregateDecl::Aggregatecast_target ) :55 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, KeywordCastExpr::Target 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 AggregateDecl::Aggregatecast_target;78 KeywordCastExpr::Target 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 AggregateDecl::Thread103 KeywordCastExpr::Thread 104 104 ) 105 105 {} … … 133 133 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n", 134 134 true, 135 AggregateDecl::Coroutine135 KeywordCastExpr::Coroutine 136 136 ) 137 137 {} … … 165 165 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n", 166 166 false, 167 AggregateDecl::Monitor167 KeywordCastExpr::Monitor 168 168 ) 169 169 {} -
src/Concurrency/Waitfor.cc
r737c98a r2cd949b 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 1013 // Update Count : 7 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 UniqueName26 25 #include "Common/utility.h" // for deleteAll, map_range 27 26 #include "CodeGen/OperatorTable.h" // for isConstructor -
src/Parser/DeclarationNode.cc
r737c98a r2cd949b 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:40:14201913 // Update Count : 11 2312 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 1116 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" }; 49 50 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 50 51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; … … 266 267 } 267 268 268 DeclarationNode * DeclarationNode::newAggregate( Aggregate Decl::Aggregatekind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 269 270 DeclarationNode * newnode = new DeclarationNode; 270 271 newnode->type = new TypeData( TypeData::Aggregate ); … … 327 328 newnode->type = new TypeData( TypeData::Aggregate ); 328 329 newnode->type->aggregate.name = name; 329 newnode->type->aggregate.kind = AggregateDecl::Trait;330 newnode->type->aggregate.kind = Trait; 330 331 newnode->type->aggregate.params = params; 331 332 newnode->type->aggregate.fields = asserts; … … 337 338 newnode->type = new TypeData( TypeData::AggregateInst ); 338 339 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 339 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait;340 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 340 341 newnode->type->aggInst.aggregate->aggregate.name = name; 341 342 newnode->type->aggInst.params = params; -
src/Parser/ExpressionNode.cc
r737c98a r2cd949b 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 10 23:01:47201913 // Update Count : 9 8012 // Last Modified On : Sun Aug 4 20:57:55 2019 13 // Update Count : 978 14 14 // 15 15 … … 434 434 } // build_cast 435 435 436 Expression * build_keyword_cast( AggregateDecl::Aggregatetarget, ExpressionNode * expr_node ) {436 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) { 437 437 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 438 438 } -
src/Parser/ParseNode.h
r737c98a r2cd949b 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:40:07201913 // Update Count : 8 8212 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 876 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 Aggregate32 31 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 33 32 #include "SynTree/Label.h" // for Label … … 185 184 186 185 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 187 Expression * build_keyword_cast( AggregateDecl::Aggregatetarget, ExpressionNode * expr_node );186 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ); 188 187 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 189 188 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); … … 218 217 enum Length { Short, Long, LongLong, NoLength }; 219 218 static const char * lengthNames[]; 219 enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate }; 220 static const char * aggregateNames[]; 220 221 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 221 222 static const char * typeClassNames[]; … … 236 237 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 237 238 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 238 static DeclarationNode * newAggregate( Aggregate Decl::Aggregatekind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 239 240 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body ); 240 241 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); -
src/Parser/TypeData.cc
r737c98a r2cd949b 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:48:33 201913 // Update Count : 6 5912 // Last Modified On : Wed Feb 13 18:16:23 2019 13 // Update Count : 649 14 14 // 15 15 … … 67 67 case Aggregate: 68 68 // aggregate = new Aggregate_t; 69 aggregate.kind = AggregateDecl::NoAggregate;69 aggregate.kind = DeclarationNode::NoAggregate; 70 70 aggregate.name = nullptr; 71 71 aggregate.params = nullptr; … … 345 345 break; 346 346 case Aggregate: 347 os << AggregateDecl::aggrString( aggregate.kind )<< ' ' << *aggregate.name << endl;347 os << DeclarationNode::aggregateNames[ 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 AggregateDecl::Struct:771 case AggregateDecl::Coroutine:772 case AggregateDecl::Monitor:773 case AggregateDecl::Thread:770 case DeclarationNode::Struct: 771 case DeclarationNode::Coroutine: 772 case DeclarationNode::Monitor: 773 case DeclarationNode::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 AggregateDecl::Union:777 case DeclarationNode::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 AggregateDecl::Trait:781 case DeclarationNode::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 AggregateDecl::Struct:812 case AggregateDecl::Coroutine:813 case AggregateDecl::Monitor:814 case AggregateDecl::Thread:811 case DeclarationNode::Struct: 812 case DeclarationNode::Coroutine: 813 case DeclarationNode::Monitor: 814 case DeclarationNode::Thread: 815 815 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 816 816 break; 817 case AggregateDecl::Union:817 case DeclarationNode::Union: 818 818 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 819 819 break; 820 case AggregateDecl::Trait:820 case DeclarationNode::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 AggregateDecl::Struct:830 case AggregateDecl::Coroutine:831 case AggregateDecl::Monitor:832 case AggregateDecl::Thread:829 case DeclarationNode::Struct: 830 case DeclarationNode::Coroutine: 831 case DeclarationNode::Monitor: 832 case DeclarationNode::Thread: 833 833 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 834 834 break; 835 case AggregateDecl::Union:835 case DeclarationNode::Union: 836 836 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 837 837 break; 838 case AggregateDecl::Trait:838 case DeclarationNode::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 AggregateDecl::Struct:866 case AggregateDecl::Coroutine:867 case AggregateDecl::Monitor:868 case AggregateDecl::Thread:865 case DeclarationNode::Struct: 866 case DeclarationNode::Coroutine: 867 case DeclarationNode::Monitor: 868 case DeclarationNode::Thread: 869 869 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 870 870 break; 871 case AggregateDecl::Union:871 case DeclarationNode::Union: 872 872 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 873 873 break; 874 case AggregateDecl::Trait:874 case DeclarationNode::Trait: 875 875 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 876 876 break; -
src/Parser/TypeData.h
r737c98a r2cd949b 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Dec 10 23:01:07 201913 // Update Count : 19 812 // Last Modified On : Thu Nov 1 20:56:46 2018 13 // Update Count : 196 14 14 // 15 15 … … 30 30 31 31 struct Aggregate_t { 32 AggregateDecl::Aggregate kind;32 DeclarationNode::Aggregate kind; 33 33 const std::string * name = nullptr; 34 34 DeclarationNode * params = nullptr; -
src/Parser/parser.yy
r737c98a r2cd949b 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 10 23:07:17201913 // Update Count : 4 40012 // Last Modified On : Sat Dec 7 10:43:44 2019 13 // Update Count : 4394 14 14 // 15 15 … … 51 51 using namespace std; 52 52 53 #include "SynTree/Declaration.h"54 53 #include "ParseNode.h" 55 54 #include "TypedefTable.h" … … 212 211 } // forCtrl 213 212 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 } // switch 221 return target; 222 } // Aggregate2Target 223 224 214 225 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 215 226 … … 237 248 ExpressionNode * en; 238 249 DeclarationNode * decl; 239 AggregateDecl::Aggregate aggKey;250 DeclarationNode::Aggregate aggKey; 240 251 DeclarationNode::TypeClass tclass; 241 252 StatementNode * sn; … … 651 662 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 652 663 | postfix_expression '.' aggregate_control 653 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }664 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); } 654 665 | postfix_expression ARROW identifier 655 666 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 796 807 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 797 808 | '(' aggregate_control '&' ')' cast_expression // CFA 798 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }809 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); } 799 810 // VIRTUAL cannot be opt because of look ahead issues 800 811 | '(' VIRTUAL ')' cast_expression // CFA … … 2060 2071 aggregate_data: 2061 2072 STRUCT 2062 { yyy = true; $$ = AggregateDecl::Struct; }2073 { yyy = true; $$ = DeclarationNode::Struct; } 2063 2074 | UNION 2064 { yyy = true; $$ = AggregateDecl::Union; }2075 { yyy = true; $$ = DeclarationNode::Union; } 2065 2076 | EXCEPTION // CFA 2066 { yyy = true; $$ = AggregateDecl::Exception; }2077 { yyy = true; $$ = DeclarationNode::Exception; } 2067 2078 ; 2068 2079 2069 2080 aggregate_control: // CFA 2070 2081 GENERATOR 2071 { yyy = true; $$ = AggregateDecl::Coroutine; }2082 { yyy = true; $$ = DeclarationNode::Coroutine; } 2072 2083 | COROUTINE 2073 { yyy = true; $$ = AggregateDecl::Coroutine; }2084 { yyy = true; $$ = DeclarationNode::Coroutine; } 2074 2085 | MONITOR 2075 { yyy = true; $$ = AggregateDecl::Monitor; }2086 { yyy = true; $$ = DeclarationNode::Monitor; } 2076 2087 | THREAD 2077 { yyy = true; $$ = AggregateDecl::Thread; }2088 { yyy = true; $$ = DeclarationNode::Thread; } 2078 2089 ; 2079 2090 -
src/SymTab/Validate.cc
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Dec 10 22:22:01201913 // Update Count : 36 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 7 6:42:00 2019 13 // Update Count : 360 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, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) );1051 declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::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
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 23:56:39 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:31:55 201913 // Update Count : 2 911 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Aug 4 14:22:00 2017 13 // Update Count : 22 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"24 23 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 25 24 #include "Type.h" // for Type, Type::StorageClasses 26 25 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 }34 26 35 27 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) { … … 86 78 } 87 79 88 const char * StructDecl::typeString() const { return aggrString( kind ); }80 std::string StructDecl::typeString() const { return "struct"; } 89 81 90 const char * UnionDecl::typeString() const { return aggrString( Union ); }82 std::string UnionDecl::typeString() const { return "union"; } 91 83 92 const char * EnumDecl::typeString() const { return aggrString( Enum ); }84 std::string EnumDecl::typeString() const { return "enum"; } 93 85 94 const char * TraitDecl::typeString() const { return aggrString( Trait ); }86 std::string TraitDecl::typeString() const { return "trait"; } 95 87 96 88 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { -
src/SynTree/Declaration.cc
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:39:56 201913 // Update Count : 3611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:38:00 2017 13 // Update Count : 25 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"27 26 #include "Type.h" // for Type, Type::StorageClasses 28 27 29 // To canonicalize declarations30 28 static UniqueId lastUniqueId = 0; 31 29 -
src/SynTree/Declaration.h
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:48:20 201913 // Update Count : 1 4911 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 2 10:47:00 2019 13 // Update Count : 135 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... 27 28 #include "SynTree.h" // for UniqueId 28 29 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Type::Fu... … … 193 194 std::list< DeclarationWithType* >& get_assertions() { return assertions; } 194 195 195 virtual const char *typeString() const = 0;196 virtual std::string typeString() const = 0; 196 197 197 198 virtual NamedTypeDecl *clone() const override = 0; … … 236 237 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 237 238 238 virtual const char *typeString() const override;239 virtual const char *genTypeString() const;239 virtual std::string typeString() const override; 240 virtual std::string genTypeString() const; 240 241 241 242 virtual TypeDecl *clone() const override { return new TypeDecl( *this ); } … … 256 257 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 257 258 258 virtual const char *typeString() const override;259 virtual std::string typeString() const override; 259 260 260 261 virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); } … … 268 269 typedef Declaration Parent; 269 270 public: 270 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };271 static const char * aggrString( Aggregate aggr );272 273 271 std::list<Declaration*> members; 274 272 std::list<TypeDecl*> parameters; … … 293 291 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 294 292 protected: 295 virtual const char *typeString() const = 0;293 virtual std::string typeString() const = 0; 296 294 }; 297 295 … … 299 297 typedef AggregateDecl Parent; 300 298 public: 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 ) {}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 ) {} 302 300 StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {} 303 301 304 bool is_coroutine() { return kind == Coroutine; }305 bool is_monitor() { return kind == Monitor; }306 bool is_thread() { return kind == Thread; }302 bool is_coroutine() { return kind == DeclarationNode::Coroutine; } 303 bool is_monitor() { return kind == DeclarationNode::Monitor; } 304 bool is_thread() { return kind == DeclarationNode::Thread; } 307 305 308 306 virtual StructDecl *clone() const override { return new StructDecl( *this ); } … … 310 308 virtual void accept( Visitor & v ) const override { v.visit( this ); } 311 309 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 312 Aggregate kind;313 private: 314 virtual const char *typeString() const override;310 DeclarationNode::Aggregate kind; 311 private: 312 virtual std::string typeString() const override; 315 313 }; 316 314 … … 326 324 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 327 325 private: 328 virtual const char *typeString() const override;326 virtual std::string typeString() const override; 329 327 }; 330 328 … … 343 341 private: 344 342 std::unordered_map< std::string, long long int > enumValues; 345 virtual const char *typeString() const override;343 virtual std::string typeString() const override; 346 344 }; 347 345 … … 359 357 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 360 358 private: 361 virtual const char *typeString() const override;359 virtual std::string typeString() const override; 362 360 }; 363 361 -
src/SynTree/Expression.cc
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 07:55:15201913 // Update Count : 7011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:43:00 2019 13 // Update Count : 64 14 14 // 15 15 … … 22 22 23 23 #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll 24 #include "Declaration.h" // for ObjectDecl, DeclarationWithType 24 25 #include "Expression.h" // for Expression, ImplicitCopyCtorExpr 25 26 #include "InitTweak/InitTweak.h" // for getCallArg, getPointerBase … … 293 294 } 294 295 295 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregatetarget ) : Expression(), arg(arg), target( target ) {296 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) { 296 297 } 297 298 … … 303 304 } 304 305 305 const char * KeywordCastExpr::targetString() const { 306 return AggregateDecl::aggrString( target ); 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]; 307 315 } 308 316 -
src/SynTree/Expression.h
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:50:19201913 // Update Count : 6011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:46:00 2019 13 // Update Count : 54 14 14 // 15 15 … … 28 28 #include "Label.h" // for Label 29 29 #include "Mutator.h" // for Mutator 30 #include "Declaration.h" // for Aggregate31 30 #include "SynTree.h" // for UniqueId 32 31 #include "Visitor.h" // for Visitor … … 230 229 public: 231 230 Expression * arg; 231 enum Target { 232 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS 233 }; 232 234 struct Concrete { 233 235 std::string field; 234 236 std::string getter; 235 237 }; 236 AggregateDecl::Aggregatetarget;238 Target target; 237 239 Concrete concrete_target; 238 240 239 KeywordCastExpr( Expression * arg, AggregateDecl::Aggregatetarget );241 KeywordCastExpr( Expression * arg, Target target ); 240 242 KeywordCastExpr( const KeywordCastExpr & other ); 241 243 virtual ~KeywordCastExpr(); 242 244 243 const char *targetString() const;245 const std::string & targetString() const; 244 246 245 247 virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); } -
src/SynTree/FunctionDecl.cc
r737c98a r2cd949b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 7 17:40:09 201913 // Update Count : 7 512 // Last Modified On : Thu Mar 16 08:33:41 2017 13 // Update Count : 74 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"26 25 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 27 26 #include "Statement.h" // for CompoundStmt -
src/SynTree/NamedTypeDecl.cc
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 08:26:17 201913 // Update Count : 1 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 13:28:00 2017 13 // Update Count : 14 14 14 // 15 15 … … 78 78 } 79 79 80 const char *TypedefDecl::typeString() const { return "typedef"; }80 std::string TypedefDecl::typeString() const { return "typedef"; } 81 81 82 82 // Local Variables: // -
src/SynTree/TypeDecl.cc
r737c98a r2cd949b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 17:56:30 201913 // Update Count : 1011 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:35:00 2017 13 // Update Count : 6 14 14 // 15 15 … … 18 18 19 19 #include "Common/utility.h" // for maybeClone 20 #include "Parser/ParseNode.h"21 20 #include "Declaration.h" // for TypeDecl, TypeDecl::Data, TypeDecl::Kind... 22 21 #include "Type.h" // for Type, Type::StorageClasses … … 32 31 } 33 32 34 const char *TypeDecl::typeString() const {35 static const char * kindNames[] = { "sized object type", "sized function type", "sizedtuple type" };33 std::string TypeDecl::typeString() const { 34 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 36 35 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." ); 37 36 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 38 return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'37 return (isComplete() ? "sized " : "") + kindNames[ kind ]; 39 38 } 40 39 41 const char *TypeDecl::genTypeString() const {42 static const char *kindNames[] = { "dtype", "ftype", "ttype" };40 std::string TypeDecl::genTypeString() const { 41 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 43 42 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 44 43 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); -
tests/concurrent/.expect/keywordErrors.txt
r737c98a r2cd949b 1 1 concurrent/keywordErrors.cfa:1:1 error: thread keyword requires threads to be in scope, add #include <thread.hfa> 2 threadA: with body 12 struct 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 threadB: with body 15 struct B: with body 1 6 6
Note:
See TracChangeset
for help on using the changeset viewer.