Changes in / [737c98a:2cd949b]


Ignore:
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r737c98a r2cd949b  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec  8 21:01:31 2019
    13 // Update Count     : 647
     12// Last Modified On : Wed Dec  4 21:42:46 2019
     13// Update Count     : 646
    1414//
    1515
     
    332332
    333333
    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?
     335static 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
    339340
    340341
  • src/AST/Convert.cpp

    r737c98a r2cd949b  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 10 22:20:10 2019
    13 // Update Count     : 32
     12// Last Modified On : Thu Jul 25 22:21:46 2019
     13// Update Count     : 13
    1414//
    1515
     
    245245                auto decl = new StructDecl(
    246246                        node->name,
    247                         (AggregateDecl::Aggregate)node->kind,
     247                        node->kind,
    248248                        get<Attribute>().acceptL( node->attributes ),
    249249                        LinkageSpec::Spec( node->linkage.val )
     
    675675
    676676        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 );
    679692                auto expr = visitBaseExpr( node,
    680693                        new KeywordCastExpr(
     
    14911504                        old->location,
    14921505                        old->name,
    1493                         (ast::AggregateDecl::Aggregate)old->kind,
     1506                        old->kind,
    14941507                        GET_ACCEPT_V(attributes, Attribute),
    14951508                        { old->linkage.val }
     
    20322045        }
    20332046
    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 );
    20372063                this->node = visitBaseExpr( old,
    20382064                        new ast::KeywordCastExpr(
  • src/AST/Decl.cpp

    r737c98a r2cd949b  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:41:39 2019
    13 // Update Count     : 18
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Thu May 9 10:00:00 2019
     13// Update Count     : 1
    1414//
    1515
     
    1818#include <cassert>             // for assert, strict_dynamic_cast
    1919#include <iostream>
     20#include <string>
    2021#include <unordered_map>
    2122
     
    5556// --- TypeDecl
    5657
    57 const char * TypeDecl::typeString() const {
    58         static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" };
     58std::string TypeDecl::typeString() const {
     59        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
    5960        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1,
    6061                "typeString: kindNames is out of sync." );
    6162        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 ];
    6364}
    6465
    65 const char * TypeDecl::genTypeString() const {
    66         static const char * kindNames[] = { "dtype", "ftype", "ttype" };
     66std::string TypeDecl::genTypeString() const {
     67        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
    6768        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    6869        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     
    7273std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) {
    7374        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];
    8375}
    8476
  • src/AST/Decl.hpp

    r737c98a r2cd949b  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 08:20:20 2019
    13 // Update Count     : 16
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Thu May 9 10:00:00 2019
     13// Update Count     : 1
    1414//
    1515
     
    154154
    155155        /// Produces a name for the kind of alias
    156         virtual const char * typeString() const = 0;
     156        virtual std::string typeString() const = 0;
    157157
    158158private:
     
    190190          init( i ) {}
    191191
    192         const char * typeString() const override;
     192        std::string typeString() const override;
    193193        /// Produces a name for generated code
    194         const char * genTypeString() const;
     194        std::string genTypeString() const;
    195195
    196196        /// convenience accessor to match Type::isComplete()
     
    212212        : NamedTypeDecl( loc, name, storage, b, spec ) {}
    213213
    214         const char * typeString() const override { return "typedef"; }
     214        std::string typeString() const override { return "typedef"; }
    215215
    216216        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    223223class AggregateDecl : public Decl {
    224224public:
    225         enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
    226         static const char * aggrString( Aggregate aggr );
    227 
    228225        std::vector<ptr<Decl>> members;
    229226        std::vector<ptr<TypeDecl>> params;
     
    240237
    241238        /// Produces a name for the kind of aggregate
    242         virtual const char * typeString() const = 0;
     239        virtual std::string typeString() const = 0;
    243240
    244241private:
     
    250247class StructDecl final : public AggregateDecl {
    251248public:
    252         Aggregate kind;
     249        DeclarationNode::Aggregate kind;
    253250
    254251        StructDecl( const CodeLocation& loc, const std::string& name,
    255                 Aggregate kind = Struct,
     252                DeclarationNode::Aggregate kind = DeclarationNode::Struct,
    256253                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall )
    257254        : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {}
    258255
    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"; }
    266263
    267264private:
     
    279276        const Decl * accept( Visitor& v ) const override { return v.visit( this ); }
    280277
    281         const char * typeString() const override { return aggrString( Union ); }
     278        std::string typeString() const override { return "union"; }
    282279
    283280private:
     
    298295        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    299296
    300         const char * typeString() const override { return aggrString( Enum ); }
     297        std::string typeString() const override { return "enum"; }
    301298
    302299private:
     
    317314        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    318315
    319         const char * typeString() const override { return "trait"; }
     316        std::string typeString() const override { return "trait"; }
    320317
    321318private:
  • src/AST/Expr.cpp

    r737c98a r2cd949b  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Peter A. Buhr
     11// Last Modified By : Andrew Beach
    1212// Created On       : Thr Jun 13 13:38:00 2019
    13 // Update Count     : 6
     13// Update Count     : 2
    1414//
    1515
     
    141141// --- KeywordCastExpr
    142142
    143 const char * KeywordCastExpr::targetString() const {
    144         return AggregateDecl::aggrString( target );
     143const 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];
    145152}
    146153
  • src/AST/Expr.hpp

    r737c98a r2cd949b  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri May 10 10:30:00 2019
    11 // Last Modified By : Peter A. Buhr
     11// Last Modified By : Aaron B. Moss
    1212// Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 7
     13// Update Count     : 1
    1414//
    1515
     
    2626#include "Fwd.hpp"        // for UniqueId
    2727#include "Label.hpp"
    28 #include "Decl.hpp"
    2928#include "ParseNode.hpp"
    3029#include "Visitor.hpp"
     
    301300public:
    302301        ptr<Expr> arg;
    303         ast::AggregateDecl::Aggregate target;
    304 
    305         KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t )
     302        enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS } target;
     303
     304        KeywordCastExpr( const CodeLocation & loc, const Expr * a, Target t )
    306305        : Expr( loc ), arg( a ), target( t ) {}
    307306
    308307        /// Get a name for the target type
    309         const char * targetString() const;
     308        const std::string& targetString() const;
    310309
    311310        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/Concurrency/Keywords.cc

    r737c98a r2cd949b  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 9
     13// Update Count     : 5
    1414//
    1515
     
    5353          public:
    5454
    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 ) :
     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 ) :
    5656                  type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {}
    5757
     
    7676                const std::string context_error;
    7777                bool needs_main;
    78                 AggregateDecl::Aggregate cast_target;
     78                KeywordCastExpr::Target cast_target;
    7979
    8080                StructDecl   * type_decl = nullptr;
     
    101101                        "thread keyword requires threads to be in scope, add #include <thread.hfa>\n",
    102102                        true,
    103                         AggregateDecl::Thread
     103                        KeywordCastExpr::Thread
    104104                )
    105105                {}
     
    133133                        "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n",
    134134                        true,
    135                         AggregateDecl::Coroutine
     135                        KeywordCastExpr::Coroutine
    136136                )
    137137                {}
     
    165165                        "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n",
    166166                        false,
    167                         AggregateDecl::Monitor
     167                        KeywordCastExpr::Monitor
    168168                )
    169169                {}
  • src/Concurrency/Waitfor.cc

    r737c98a r2cd949b  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 10
     13// Update Count     : 7
    1414//
    1515
     
    2323#include "Common/PassVisitor.h"    // for PassVisitor
    2424#include "Common/SemanticError.h"  // for SemanticError
    25 #include "Common/UniqueName.h"     // for UniqueName
    2625#include "Common/utility.h"        // for deleteAll, map_range
    2726#include "CodeGen/OperatorTable.h" // for isConstructor
  • src/Parser/DeclarationNode.cc

    r737c98a r2cd949b  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 07:40:14 2019
    13 // Update Count     : 1123
     12// Last Modified On : Thu Jul 25 22:17:10 2019
     13// Update Count     : 1116
    1414//
    1515
     
    4747const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" };
    4848const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" };
     49const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    4950const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    5051const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" };
     
    266267}
    267268
    268 DeclarationNode * DeclarationNode::newAggregate( AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     269DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
    269270        DeclarationNode * newnode = new DeclarationNode;
    270271        newnode->type = new TypeData( TypeData::Aggregate );
     
    327328        newnode->type = new TypeData( TypeData::Aggregate );
    328329        newnode->type->aggregate.name = name;
    329         newnode->type->aggregate.kind = AggregateDecl::Trait;
     330        newnode->type->aggregate.kind = Trait;
    330331        newnode->type->aggregate.params = params;
    331332        newnode->type->aggregate.fields = asserts;
     
    337338        newnode->type = new TypeData( TypeData::AggregateInst );
    338339        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;
    340341        newnode->type->aggInst.aggregate->aggregate.name = name;
    341342        newnode->type->aggInst.params = params;
  • src/Parser/ExpressionNode.cc

    r737c98a r2cd949b  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 10 23:01:47 2019
    13 // Update Count     : 980
     12// Last Modified On : Sun Aug  4 20:57:55 2019
     13// Update Count     : 978
    1414//
    1515
     
    434434} // build_cast
    435435
    436 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ) {
     436Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
    437437        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
    438438}
  • src/Parser/ParseNode.h

    r737c98a r2cd949b  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 07:40:07 2019
    13 // Update Count     : 882
     12// Last Modified On : Thu Jul 25 22:17:10 2019
     13// Update Count     : 876
    1414//
    1515
     
    2929#include "Common/utility.h"        // for maybeClone, maybeBuild
    3030#include "Parser/LinkageSpec.h"    // for Spec
    31 #include "SynTree/Declaration.h"   // for Aggregate
    3231#include "SynTree/Expression.h"    // for Expression, ConstantExpr (ptr only)
    3332#include "SynTree/Label.h"         // for Label
     
    185184
    186185Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    187 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node );
     186Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    188187Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    189188Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    218217        enum Length { Short, Long, LongLong, NoLength };
    219218        static const char * lengthNames[];
     219        enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate };
     220        static const char * aggregateNames[];
    220221        enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
    221222        static const char * typeClassNames[];
     
    236237        static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
    237238        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    238         static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, 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 );
    239240        static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );
    240241        static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant );
  • src/Parser/TypeData.cc

    r737c98a r2cd949b  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 07:48:33 2019
    13 // Update Count     : 659
     12// Last Modified On : Wed Feb 13 18:16:23 2019
     13// Update Count     : 649
    1414//
    1515
     
    6767          case Aggregate:
    6868                // aggregate = new Aggregate_t;
    69                 aggregate.kind = AggregateDecl::NoAggregate;
     69                aggregate.kind = DeclarationNode::NoAggregate;
    7070                aggregate.name = nullptr;
    7171                aggregate.params = nullptr;
     
    345345                break;
    346346          case Aggregate:
    347                 os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl;
     347                os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl;
    348348                if ( aggregate.params ) {
    349349                        os << string( indent + 2, ' ' ) << "with type parameters" << endl;
     
    768768        AggregateDecl * at;
    769769        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:
    774774                at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage );
    775775                buildForall( td->aggregate.params, at->get_parameters() );
    776776                break;
    777           case AggregateDecl::Union:
     777          case DeclarationNode::Union:
    778778                at = new UnionDecl( *td->aggregate.name, attributes, linkage );
    779779                buildForall( td->aggregate.params, at->get_parameters() );
    780780                break;
    781           case AggregateDecl::Trait:
     781          case DeclarationNode::Trait:
    782782                at = new TraitDecl( *td->aggregate.name, attributes, linkage );
    783783                buildList( td->aggregate.params, at->get_parameters() );
     
    809809                          AggregateDecl * typedecl = buildAggregate( type, attributes, linkage );
    810810                          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:
    815815                                  ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl );
    816816                                  break;
    817                                 case AggregateDecl::Union:
     817                                case DeclarationNode::Union:
    818818                                  ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl );
    819819                                  break;
    820                                 case AggregateDecl::Trait:
     820                                case DeclarationNode::Trait:
    821821                                  assert( false );
    822822                                  //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );
     
    827827                  } else {
    828828                          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:
    833833                                  ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    834834                                  break;
    835                                 case AggregateDecl::Union:
     835                                case DeclarationNode::Union:
    836836                                  ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    837837                                  break;
    838                                 case AggregateDecl::Trait:
     838                                case DeclarationNode::Trait:
    839839                                  ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
    840840                                  break;
     
    863863          case TypeData::Aggregate: {
    864864                  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:
    869869                          ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    870870                          break;
    871                         case AggregateDecl::Union:
     871                        case DeclarationNode::Union:
    872872                          ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    873873                          break;
    874                         case AggregateDecl::Trait:
     874                        case DeclarationNode::Trait:
    875875                          ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
    876876                          break;
  • src/Parser/TypeData.h

    r737c98a r2cd949b  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 10 23:01:07 2019
    13 // Update Count     : 198
     12// Last Modified On : Thu Nov  1 20:56:46 2018
     13// Update Count     : 196
    1414//
    1515
     
    3030
    3131        struct Aggregate_t {
    32                 AggregateDecl::Aggregate kind;
     32                DeclarationNode::Aggregate kind;
    3333                const std::string * name = nullptr;
    3434                DeclarationNode * params = nullptr;
  • src/Parser/parser.yy

    r737c98a r2cd949b  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 10 23:07:17 2019
    13 // Update Count     : 4400
     12// Last Modified On : Sat Dec  7 10:43:44 2019
     13// Update Count     : 4394
    1414//
    1515
     
    5151using namespace std;
    5252
    53 #include "SynTree/Declaration.h"
    5453#include "ParseNode.h"
    5554#include "TypedefTable.h"
     
    212211} // forCtrl
    213212
     213KeywordCastExpr::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
    214225bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    215226
     
    237248        ExpressionNode * en;
    238249        DeclarationNode * decl;
    239         AggregateDecl::Aggregate aggKey;
     250        DeclarationNode::Aggregate aggKey;
    240251        DeclarationNode::TypeClass tclass;
    241252        StatementNode * sn;
     
    651662                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    652663        | postfix_expression '.' aggregate_control
    653                 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
     664                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }
    654665        | postfix_expression ARROW identifier
    655666                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    796807                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    797808        | '(' aggregate_control '&' ')' cast_expression         // CFA
    798                 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
     809                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }
    799810                // VIRTUAL cannot be opt because of look ahead issues
    800811        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    20602071aggregate_data:
    20612072        STRUCT
    2062                 { yyy = true; $$ = AggregateDecl::Struct; }
     2073                { yyy = true; $$ = DeclarationNode::Struct; }
    20632074        | UNION
    2064                 { yyy = true; $$ = AggregateDecl::Union; }
     2075                { yyy = true; $$ = DeclarationNode::Union; }
    20652076        | EXCEPTION                                                                                     // CFA
    2066                 { yyy = true; $$ = AggregateDecl::Exception; }
     2077                { yyy = true; $$ = DeclarationNode::Exception; }
    20672078        ;
    20682079
    20692080aggregate_control:                                                                              // CFA
    20702081        GENERATOR
    2071                 { yyy = true; $$ = AggregateDecl::Coroutine; }
     2082                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20722083        | COROUTINE
    2073                 { yyy = true; $$ = AggregateDecl::Coroutine; }
     2084                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20742085        | MONITOR
    2075                 { yyy = true; $$ = AggregateDecl::Monitor; }
     2086                { yyy = true; $$ = DeclarationNode::Monitor; }
    20762087        | THREAD
    2077                 { yyy = true; $$ = AggregateDecl::Thread; }
     2088                { yyy = true; $$ = DeclarationNode::Thread; }
    20782089        ;
    20792090
  • src/SymTab/Validate.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 10 22:22:01 2019
    13 // Update Count     : 362
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  7 6:42:00 2019
     13// Update Count     : 360
    1414//
    1515
     
    10491049                Type * designatorType = tyDecl->base->stripDeclarator();
    10501050                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 ) );
    10521052                } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    10531053                        declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) );
  • src/SynTree/AggregateDecl.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 23:56:39 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:31:55 2019
    13 // Update Count     : 29
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Aug  4 14:22:00 2017
     13// Update Count     : 22
    1414//
    1515
     
    2121#include "Common/utility.h"      // for printAll, cloneAll, deleteAll
    2222#include "Declaration.h"         // for AggregateDecl, TypeDecl, Declaration
    23 #include "Initializer.h"
    2423#include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
    2524#include "Type.h"                // for Type, Type::StorageClasses
    2625
    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 }
    3426
    3527AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) {
     
    8678}
    8779
    88 const char * StructDecl::typeString() const { return aggrString( kind ); }
     80std::string StructDecl::typeString() const { return "struct"; }
    8981
    90 const char * UnionDecl::typeString() const { return aggrString( Union ); }
     82std::string UnionDecl::typeString() const { return "union"; }
    9183
    92 const char * EnumDecl::typeString() const { return aggrString( Enum ); }
     84std::string EnumDecl::typeString() const { return "enum"; }
    9385
    94 const char * TraitDecl::typeString() const { return aggrString( Trait ); }
     86std::string TraitDecl::typeString() const { return "trait"; }
    9587
    9688bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
  • src/SynTree/Declaration.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:39:56 2019
    13 // Update Count     : 36
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:38:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    2424#include "SynTree/Statement.h"       // for AsmStmt
    2525#include "SynTree/SynTree.h"         // for UniqueId
    26 #include "SynTree/Expression.h"
    2726#include "Type.h"                    // for Type, Type::StorageClasses
    2827
    29 // To canonicalize declarations
    3028static UniqueId lastUniqueId = 0;
    3129
  • src/SynTree/Declaration.h

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:48:20 2019
    13 // Update Count     : 149
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr May  2 10:47:00 2019
     13// Update Count     : 135
    1414//
    1515
     
    2525#include "Mutator.h"             // for Mutator
    2626#include "Parser/LinkageSpec.h"  // for Spec, Cforall
     27#include "Parser/ParseNode.h"    // for DeclarationNode, DeclarationNode::Ag...
    2728#include "SynTree.h"             // for UniqueId
    2829#include "SynTree/Type.h"        // for Type, Type::StorageClasses, Type::Fu...
     
    193194        std::list< DeclarationWithType* >& get_assertions() { return assertions; }
    194195
    195         virtual const char * typeString() const = 0;
     196        virtual std::string typeString() const = 0;
    196197
    197198        virtual NamedTypeDecl *clone() const override = 0;
     
    236237        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    237238
    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;
    240241
    241242        virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
     
    256257        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    257258
    258         virtual const char * typeString() const override;
     259        virtual std::string typeString() const override;
    259260
    260261        virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
     
    268269        typedef Declaration Parent;
    269270  public:
    270         enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
    271         static const char * aggrString( Aggregate aggr );
    272 
    273271        std::list<Declaration*> members;
    274272        std::list<TypeDecl*> parameters;
     
    293291        virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
    294292  protected:
    295         virtual const char * typeString() const = 0;
     293        virtual std::string typeString() const = 0;
    296294};
    297295
     
    299297        typedef AggregateDecl Parent;
    300298  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 ) {}
    302300        StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {}
    303301
    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; }
    307305
    308306        virtual StructDecl *clone() const override { return new StructDecl( *this ); }
     
    310308        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    311309        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;
    315313};
    316314
     
    326324        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    327325  private:
    328         virtual const char * typeString() const override;
     326        virtual std::string typeString() const override;
    329327};
    330328
     
    343341  private:
    344342        std::unordered_map< std::string, long long int > enumValues;
    345         virtual const char * typeString() const override;
     343        virtual std::string typeString() const override;
    346344};
    347345
     
    359357        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    360358  private:
    361         virtual const char * typeString() const override;
     359        virtual std::string typeString() const override;
    362360};
    363361
  • src/SynTree/Expression.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 07:55:15 2019
    13 // Update Count     : 70
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 15 13:43:00 2019
     13// Update Count     : 64
    1414//
    1515
     
    2222
    2323#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     24#include "Declaration.h"             // for ObjectDecl, DeclarationWithType
    2425#include "Expression.h"              // for Expression, ImplicitCopyCtorExpr
    2526#include "InitTweak/InitTweak.h"     // for getCallArg, getPointerBase
     
    293294}
    294295
    295 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) {
     296KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
    296297}
    297298
     
    303304}
    304305
    305 const char * KeywordCastExpr::targetString() const {
    306         return AggregateDecl::aggrString( target );
     306const 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];
    307315}
    308316
  • src/SynTree/Expression.h

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:50:19 2019
    13 // Update Count     : 60
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 15 13:46:00 2019
     13// Update Count     : 54
    1414//
    1515
     
    2828#include "Label.h"                // for Label
    2929#include "Mutator.h"              // for Mutator
    30 #include "Declaration.h"          // for Aggregate
    3130#include "SynTree.h"              // for UniqueId
    3231#include "Visitor.h"              // for Visitor
     
    230229public:
    231230        Expression * arg;
     231        enum Target {
     232                Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
     233        };
    232234        struct Concrete {
    233235                std::string field;
    234236                std::string getter;
    235237        };
    236         AggregateDecl::Aggregate target;
     238        Target target;
    237239        Concrete concrete_target;
    238240
    239         KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target );
     241        KeywordCastExpr( Expression * arg, Target target );
    240242        KeywordCastExpr( const KeywordCastExpr & other );
    241243        virtual ~KeywordCastExpr();
    242244
    243         const char * targetString() const;
     245        const std::string & targetString() const;
    244246
    245247        virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); }
  • src/SynTree/FunctionDecl.cc

    r737c98a r2cd949b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec  7 17:40:09 2019
    13 // Update Count     : 75
     12// Last Modified On : Thu Mar 16 08:33:41 2017
     13// Update Count     : 74
    1414//
    1515
     
    2323#include "Common/utility.h"      // for maybeClone, printAll
    2424#include "Declaration.h"         // for FunctionDecl, FunctionDecl::Parent
    25 #include "Expression.h"
    2625#include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
    2726#include "Statement.h"           // for CompoundStmt
  • src/SynTree/NamedTypeDecl.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 08:26:17 2019
    13 // Update Count     : 15
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 13:28:00 2017
     13// Update Count     : 14
    1414//
    1515
     
    7878}
    7979
    80 const char * TypedefDecl::typeString() const { return "typedef"; }
     80std::string TypedefDecl::typeString() const { return "typedef"; }
    8181
    8282// Local Variables: //
  • src/SynTree/TypeDecl.cc

    r737c98a r2cd949b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 17:56:30 2019
    13 // Update Count     : 10
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:35:00 2017
     13// Update Count     : 6
    1414//
    1515
     
    1818
    1919#include "Common/utility.h"  // for maybeClone
    20 #include "Parser/ParseNode.h"
    2120#include "Declaration.h"     // for TypeDecl, TypeDecl::Data, TypeDecl::Kind...
    2221#include "Type.h"            // for Type, Type::StorageClasses
     
    3231}
    3332
    34 const char * TypeDecl::typeString() const {
    35         static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" };
     33std::string TypeDecl::typeString() const {
     34        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
    3635        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
    3736        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 ];
    3938}
    4039
    41 const char * TypeDecl::genTypeString() const {
    42         static const char * kindNames[] = { "dtype", "ftype", "ttype" };
     40std::string TypeDecl::genTypeString() const {
     41        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
    4342        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    4443        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
  • tests/concurrent/.expect/keywordErrors.txt

    r737c98a r2cd949b  
    11concurrent/keywordErrors.cfa:1:1 error: thread keyword requires threads to be in scope, add #include <thread.hfa>
    2 thread A: with body 1
     2struct A: with body 1
    33
    44concurrent/keywordErrors.cfa:6:1 error: thread keyword requires threads to be in scope, add #include <thread.hfa>
    5 thread B: with body 1
     5struct B: with body 1
    66
Note: See TracChangeset for help on using the changeset viewer.