Changeset 7030dab for src/AST


Ignore:
Timestamp:
Apr 6, 2020, 4:46:28 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
e3bc51c
Parents:
71d6bd8 (diff), 057298e (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.
Message:

Merge branch 'master' into new-ast

Location:
src/AST
Files:
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r71d6bd8 r7030dab  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:21:46 2019
    13 // Update Count     : 13
     12// Last Modified On : Wed Dec 11 21:39:32 2019
     13// Update Count     : 33
    1414//
    1515
     
    245245                auto decl = new StructDecl(
    246246                        node->name,
    247                         node->kind,
     247                        (AggregateDecl::Aggregate)node->kind,
    248248                        get<Attribute>().acceptL( node->attributes ),
    249249                        LinkageSpec::Spec( node->linkage.val )
     
    493493        }
    494494
     495        const ast::Stmt * visit(const ast::SuspendStmt * node ) override final {
     496                if ( inCache( node ) ) return nullptr;
     497                auto stmt = new SuspendStmt();
     498                stmt->then   = get<CompoundStmt>().accept1( node->then   );
     499                switch(node->type) {
     500                        case ast::SuspendStmt::None     : stmt->type = SuspendStmt::None     ; break;
     501                        case ast::SuspendStmt::Coroutine: stmt->type = SuspendStmt::Coroutine; break;
     502                        case ast::SuspendStmt::Generator: stmt->type = SuspendStmt::Generator; break;
     503                }
     504                return stmtPostamble( stmt, node );
     505        }
     506
    495507        const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
    496508                if ( inCache( node ) ) return nullptr;
     
    686698
    687699        const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
    688                 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS;
    689                 switch (node->target) {
    690                         case ast::KeywordCastExpr::Coroutine:
    691                                 castTarget = KeywordCastExpr::Coroutine;
    692                                 break;
    693                         case ast::KeywordCastExpr::Thread:
    694                                 castTarget = KeywordCastExpr::Thread;
    695                                 break;
    696                         case ast::KeywordCastExpr::Monitor:
    697                                 castTarget = KeywordCastExpr::Monitor;
    698                                 break;
    699                         default:
    700                                 break;
    701                 }
    702                 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS );
     700                AggregateDecl::Aggregate castTarget = (AggregateDecl::Aggregate)node->target;
     701                assert( AggregateDecl::Generator <= castTarget && castTarget <= AggregateDecl::Thread );
    703702                auto expr = visitBaseExpr( node,
    704703                        new KeywordCastExpr(
     
    12471246                                cv( node ),
    12481247                                node->name,
    1249                                 node->kind == ast::TypeVar::Ftype,
     1248                                node->kind == ast::TypeDecl::Ftype,
    12501249                                get<Attribute>().acceptL( node->attributes )
    12511250                        };
     
    15151514                        old->location,
    15161515                        old->name,
    1517                         old->kind,
     1516                        (ast::AggregateDecl::Aggregate)old->kind,
    15181517                        GET_ACCEPT_V(attributes, Attribute),
    15191518                        { old->linkage.val }
     
    16021601                        { old->storageClasses.val },
    16031602                        GET_ACCEPT_1(base, Type),
    1604                         (ast::TypeVar::Kind)(unsigned)old->kind,
     1603                        (ast::TypeDecl::Kind)(unsigned)old->kind,
    16051604                        old->sized,
    16061605                        GET_ACCEPT_1(init, Type)
     
    18831882        }
    18841883
     1884        virtual void visit( const SuspendStmt * old ) override final {
     1885                if ( inCache( old ) ) return;
     1886                ast::SuspendStmt::Type type;
     1887                switch (old->type) {
     1888                        case SuspendStmt::Coroutine: type = ast::SuspendStmt::Coroutine; break;
     1889                        case SuspendStmt::Generator: type = ast::SuspendStmt::Generator; break;
     1890                        case SuspendStmt::None     : type = ast::SuspendStmt::None     ; break;
     1891                        default: abort();
     1892                }
     1893                this->node = new ast::SuspendStmt(
     1894                        old->location,
     1895                        GET_ACCEPT_1(then  , CompoundStmt),
     1896                        type,
     1897                        GET_LABELS_V(old->labels)
     1898                );
     1899                cache.emplace( old, this->node );
     1900        }
     1901
    18851902        virtual void visit( const WaitForStmt * old ) override final {
    18861903                if ( inCache( old ) ) return;
     
    20562073        }
    20572074
    2058         virtual void visit( const KeywordCastExpr * old) override final {
    2059                 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS;
    2060                 switch (old->target) {
    2061                         case KeywordCastExpr::Coroutine:
    2062                                 castTarget = ast::KeywordCastExpr::Coroutine;
    2063                                 break;
    2064                         case KeywordCastExpr::Thread:
    2065                                 castTarget = ast::KeywordCastExpr::Thread;
    2066                                 break;
    2067                         case KeywordCastExpr::Monitor:
    2068                                 castTarget = ast::KeywordCastExpr::Monitor;
    2069                                 break;
    2070                         default:
    2071                                 break;
    2072                 }
    2073                 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS );
     2075        virtual void visit( const KeywordCastExpr * old ) override final {
     2076                ast::AggregateDecl::Aggregate castTarget = (ast::AggregateDecl::Aggregate)old->target;
     2077                assert( ast::AggregateDecl::Generator <= castTarget && castTarget <= ast::AggregateDecl::Thread );
    20742078                this->node = visitBaseExpr( old,
    20752079                        new ast::KeywordCastExpr(
     
    25992603                        ty = new ast::TypeInstType{
    26002604                                old->name,
    2601                                 old->isFtype ? ast::TypeVar::Ftype : ast::TypeVar::Dtype,
     2605                                old->isFtype ? ast::TypeDecl::Ftype : ast::TypeDecl::Dtype,
    26022606                                cv( old ),
    26032607                                GET_ACCEPT_V( attributes, Attribute )
  • src/AST/Decl.cpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 16:23:15 2019
     13// Update Count     : 20
    1414//
    1515
     
    1818#include <cassert>             // for assert, strict_dynamic_cast
    1919#include <iostream>
    20 #include <string>
    2120#include <unordered_map>
    2221
     
    2726#include "Node.hpp"            // for readonly
    2827#include "Type.hpp"            // for readonly
    29 #include "Parser/ParseNode.h"  // for DeclarationNode
    3028
    3129namespace ast {
     
    5856// --- TypeDecl
    5957
    60 std::string TypeDecl::typeString() const {
    61         static const std::string kindNames[] = { "object type", "function type", "tuple type" };
    62         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1,
    63                 "typeString: kindNames is out of sync." );
    64         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    65         return (sized ? "sized " : "") + kindNames[ kind ];
     58const char * TypeDecl::typeString() const {
     59        static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
     60        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
     61        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
     62        return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    6663}
    6764
    68 std::string TypeDecl::genTypeString() const {
    69         static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
    70         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    71         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     65const char * TypeDecl::genTypeString() const {
     66        static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
     67        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
     68        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    7269        return kindNames[ kind ];
    7370}
     
    7572std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) {
    7673        return out << data.kind << ", " << data.isComplete;
     74}
     75
     76// --- AggregateDecl
     77
     78// These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.
     79static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };
     80
     81const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {
     82        return aggregateNames[aggr];
    7783}
    7884
  • src/AST/Decl.hpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 17:38:33 2019
     13// Update Count     : 29
    1414//
    1515
     
    2020#include <unordered_map>
    2121#include <vector>
     22#include <algorithm>
    2223
    2324#include "FunctionSpec.hpp"
     
    2728#include "ParseNode.hpp"
    2829#include "StorageClasses.hpp"
    29 #include "TypeVar.hpp"
    3030#include "Visitor.hpp"
    31 #include "Parser/ParseNode.h"  // for DeclarationNode::Aggregate
     31#include "Common/utility.h"
     32#include "Common/SemanticError.h"                                               // error_str
    3233
    3334// Must be included in *all* AST classes; should be #undef'd at the end of the file
     
    127128        std::vector< ptr<Expr> > withExprs;
    128129
    129         FunctionDecl( const CodeLocation & loc, const std::string &name, FunctionType * type,
     130        FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,
    130131                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
    131132                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
     
    138139        bool has_body() const { return stmts; }
    139140
    140         const DeclWithType * accept( Visitor &v ) const override { return v.visit( this ); }
     141        const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }
    141142private:
    142143        FunctionDecl * clone() const override { return new FunctionDecl( *this ); }
     
    151152        std::vector<ptr<DeclWithType>> assertions;
    152153
    153         NamedTypeDecl( 
     154        NamedTypeDecl(
    154155                const CodeLocation & loc, const std::string & name, Storage::Classes storage,
    155156                const Type * b, Linkage::Spec spec = Linkage::Cforall )
     
    157158
    158159        /// Produces a name for the kind of alias
    159         virtual std::string typeString() const = 0;
     160        virtual const char * typeString() const = 0;
    160161
    161162private:
     
    166167/// Cforall type variable: `dtype T`
    167168class TypeDecl final : public NamedTypeDecl {
    168 public:
    169         TypeVar::Kind kind;
     169  public:
     170        enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     171
     172        Kind kind;
    170173        bool sized;
    171174        ptr<Type> init;
     
    173176        /// Data extracted from a type decl
    174177        struct Data {
    175                 TypeVar::Kind kind;
     178                Kind kind;
    176179                bool isComplete;
    177180
    178                 Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {}
     181                Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {}
    179182                Data( const TypeDecl * d ) : kind( d->kind ), isComplete( d->sized ) {}
    180                 Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {}
     183                Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}
    181184                Data( const Data & d1, const Data & d2 )
    182                 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
    183 
    184                 bool operator== ( const Data & o ) const {
    185                         return kind == o.kind && isComplete == o.isComplete;
    186                 }
    187                 bool operator!= ( const Data & o ) const { return !(*this == o); }
     185                        : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
     186
     187                bool operator==( const Data & o ) const { return kind == o.kind && isComplete == o.isComplete; }
     188                bool operator!=( const Data & o ) const { return !(*this == o); }
    188189        };
    189190
    190         TypeDecl( 
    191                 const CodeLocation & loc, const std::string & name, Storage::Classes storage, 
     191        TypeDecl(
     192                const CodeLocation & loc, const std::string & name, Storage::Classes storage,
    192193                const Type * b, TypeVar::Kind k, bool s, const Type * i = nullptr )
    193194        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),
    194195          init( i ) {}
    195196
    196         std::string typeString() const override;
     197        const char * typeString() const override;
    197198        /// Produces a name for generated code
    198         std::string genTypeString() const;
     199        const char * genTypeString() const;
    199200
    200201        /// convenience accessor to match Type::isComplete()
     
    202203
    203204        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    204 private:
     205  private:
    205206        TypeDecl * clone() const override { return new TypeDecl{ *this }; }
    206207        MUTATE_FRIEND
     
    216217        : NamedTypeDecl( loc, name, storage, b, spec ) {}
    217218
    218         std::string typeString() const override { return "typedef"; }
     219        const char * typeString() const override { return "typedef"; }
    219220
    220221        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    227228class AggregateDecl : public Decl {
    228229public:
     230        enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
     231        static const char * aggrString( Aggregate aggr );
     232
    229233        std::vector<ptr<Decl>> members;
    230234        std::vector<ptr<TypeDecl>> params;
     
    241245
    242246        /// Produces a name for the kind of aggregate
    243         virtual std::string typeString() const = 0;
     247        virtual const char * typeString() const = 0;
    244248
    245249private:
     
    251255class StructDecl final : public AggregateDecl {
    252256public:
    253         DeclarationNode::Aggregate kind;
     257        Aggregate kind;
    254258
    255259        StructDecl( const CodeLocation& loc, const std::string& name,
    256                 DeclarationNode::Aggregate kind = DeclarationNode::Struct,
     260                Aggregate kind = Struct,
    257261                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall )
    258262        : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {}
    259263
    260         bool is_coroutine() { return kind == DeclarationNode::Coroutine; }
    261         bool is_monitor() { return kind == DeclarationNode::Monitor; }
    262         bool is_thread() { return kind == DeclarationNode::Thread; }
    263 
    264         const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    265 
    266         std::string typeString() const override { return "struct"; }
     264        bool is_coroutine() { return kind == Coroutine; }
     265        bool is_generator() { return kind == Generator; }
     266        bool is_monitor  () { return kind == Monitor  ; }
     267        bool is_thread   () { return kind == Thread   ; }
     268
     269        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     270
     271        const char * typeString() const override { return aggrString( kind ); }
    267272
    268273private:
     
    280285        const Decl * accept( Visitor& v ) const override { return v.visit( this ); }
    281286
    282         std::string typeString() const override { return "union"; }
     287        const char * typeString() const override { return aggrString( Union ); }
    283288
    284289private:
     
    299304        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    300305
    301         std::string typeString() const override { return "enum"; }
     306        const char * typeString() const override { return aggrString( Enum ); }
    302307
    303308private:
     
    318323        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    319324
    320         std::string typeString() const override { return "trait"; }
     325        const char * typeString() const override { return "trait"; }
    321326
    322327private:
     
    344349        ptr<AsmStmt> stmt;
    345350
    346         AsmDecl( const CodeLocation & loc, AsmStmt *stmt )
     351        AsmDecl( const CodeLocation & loc, AsmStmt * stmt )
    347352        : Decl( loc, "", {}, {} ), stmt(stmt) {}
    348353
    349         const AsmDecl * accept( Visitor &v ) const override { return v.visit( this ); }
    350 private:
    351         AsmDecl *clone() const override { return new AsmDecl( *this ); }
     354        const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }
     355private:
     356        AsmDecl * clone() const override { return new AsmDecl( *this ); }
    352357        MUTATE_FRIEND
    353358};
     
    361366        : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {}
    362367
    363         const StaticAssertDecl * accept( Visitor &v ) const override { return v.visit( this ); }
     368        const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }
    364369private:
    365370        StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
  • src/AST/Expr.cpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Created On       : Fri Oct  4 15:34:00 2019
    13 // Update Count     : 4
     11// Last Modified By : Peter A. Buhr
     12// Created On       : Thr Jun 13 13:38:00 2019
     13// Update Count     : 6
    1414//
    1515
     
    163163// --- KeywordCastExpr
    164164
    165 const std::string & KeywordCastExpr::targetString() const {
    166         static const std::string targetStrs[] = {
    167                 "coroutine", "thread", "monitor"
    168         };
    169         static_assert(
    170                 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
    171                 "Each KeywordCastExpr::Target should have a corresponding string representation"
    172         );
    173         return targetStrs[(unsigned long)target];
     165const char * KeywordCastExpr::targetString() const {
     166        return AggregateDecl::aggrString( target );
    174167}
    175168
  • src/AST/Expr.hpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri May 10 10:30:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Created On       : Thr Sep 26 12:51:00 2019
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Created On       : Fri May 10 10:30:00 2019
     13// Update Count     : 7
    1414//
    1515
     
    2626#include "Fwd.hpp"        // for UniqueId
    2727#include "Label.hpp"
     28#include "Decl.hpp"
    2829#include "ParseNode.hpp"
    2930#include "Visitor.hpp"
     
    310311public:
    311312        ptr<Expr> arg;
    312         enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS } target;
    313 
    314         KeywordCastExpr( const CodeLocation & loc, const Expr * a, Target t )
     313        ast::AggregateDecl::Aggregate target;
     314
     315        KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t )
    315316        : Expr( loc ), arg( a ), target( t ) {}
    316317
    317318        /// Get a name for the target type
    318         const std::string& targetString() const;
     319        const char * targetString() const;
    319320
    320321        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/Fwd.hpp

    r71d6bd8 r7030dab  
    5353class CatchStmt;
    5454class FinallyStmt;
     55class SuspendStmt;
    5556class WaitForStmt;
    5657class WithStmt;
  • src/AST/Pass.hpp

    r71d6bd8 r7030dab  
    114114        const ast::Stmt *             visit( const ast::CatchStmt            * ) override final;
    115115        const ast::Stmt *             visit( const ast::FinallyStmt          * ) override final;
     116        const ast::Stmt *             visit( const ast::SuspendStmt          * ) override final;
    116117        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
    117118        const ast::Decl *             visit( const ast::WithStmt             * ) override final;
  • src/AST/Pass.impl.hpp

    r71d6bd8 r7030dab  
    838838
    839839//--------------------------------------------------------------------------
     840// FinallyStmt
     841template< typename pass_t >
     842const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SuspendStmt * node ) {
     843        VISIT_START( node );
     844
     845        VISIT(
     846                maybe_accept( node, &SuspendStmt::then   );
     847        )
     848
     849        VISIT_END( Stmt, node );
     850}
     851
     852//--------------------------------------------------------------------------
    840853// WaitForStmt
    841854template< typename pass_t >
  • src/AST/Print.cpp

    r71d6bd8 r7030dab  
    674674                safe_print( node->body );
    675675                --indent;
     676
     677                return node;
     678        }
     679
     680        virtual const ast::Stmt * visit( const ast::SuspendStmt * node ) override final {
     681                os << "Suspend Statement";
     682                switch (node->type) {
     683                        case ast::SuspendStmt::None     : os << " with implicit target"; break;
     684                        case ast::SuspendStmt::Generator: os << " for generator"; break;
     685                        case ast::SuspendStmt::Coroutine: os << " for coroutine"; break;
     686                }
     687                os << endl;
     688
     689                ++indent;
     690                if(node->then) {
     691                        os << indent << " with post statement :" << endl;
     692                        safe_print( node->then );
     693                }
     694                ++indent;
    676695
    677696                return node;
     
    13591378                preprint( node );
    13601379                os << "instance of type " << node->name
    1361                    << " (" << (node->kind == ast::TypeVar::Ftype ? "" : "not ") << "function type)";
     1380                   << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
    13621381                print( node->params );
    13631382
  • src/AST/Stmt.hpp

    r71d6bd8 r7030dab  
    344344};
    345345
     346/// Suspend statement
     347class SuspendStmt final : public Stmt {
     348public:
     349        ptr<CompoundStmt> then;
     350        enum Type { None, Coroutine, Generator } type = None;
     351
     352        SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} )
     353        : Stmt(loc, std::move(labels)), then(then), type(type) {}
     354
     355        const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     356private:
     357        SuspendStmt * clone() const override { return new SuspendStmt{ *this }; }
     358        MUTATE_FRIEND
     359};
     360
    346361/// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...`
    347362class WaitForStmt final : public Stmt {
  • src/AST/Type.cpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Mon May 13 15:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Mon May 13 15:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Dec 15 16:56:28 2019
     13// Update Count     : 4
    1414//
    1515
     
    5050// --- BasicType
    5151
    52 const char *BasicType::typeNames[] = {
     52// GENERATED START, DO NOT EDIT
     53// GENERATED BY BasicTypes-gen.cc
     54const char * BasicType::typeNames[] = {
    5355        "_Bool",
    5456        "char",
     
    8890        "_Float128x _Complex",
    8991};
    90 static_assert(
    91         sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
    92         "Each basic type name should have a corresponding kind enum value"
    93 );
     92// GENERATED END
    9493
    9594// --- ParameterizedType
  • src/AST/Type.hpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:56:46 2019
     13// Update Count     : 5
    1414//
    1515
     
    2626#include "Fwd.hpp"
    2727#include "Node.hpp"          // for Node, ptr, ptr_base
    28 #include "TypeVar.hpp"
    2928#include "Visitor.hpp"
    3029
     
    448447public:
    449448        readonly<TypeDecl> base;
    450         TypeVar::Kind kind;
     449        TypeDecl::Kind kind;
    451450
    452451        TypeInstType(
     
    454453                std::vector<ptr<Attribute>> && as = {} )
    455454        : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}
    456 
    457         TypeInstType(
    458                 const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {},
     455        TypeInstType( const std::string& n, TypeDecl::Kind k, CV::Qualifiers q = {},
    459456                std::vector<ptr<Attribute>> && as = {} )
    460457        : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {}
  • src/AST/TypeEnvironment.cpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 29 11:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Wed May 29 11:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:49:13 2019
     13// Update Count     : 4
    1414//
    1515
     
    240240                return true;
    241241        } else if ( auto typeInst = dynamic_cast< const TypeInstType * >( type ) ) {
    242                 return typeInst->kind == TypeVar::Ftype;
     242                return typeInst->kind == TypeDecl::Ftype;
    243243        } else return false;
    244244}
     
    248248        bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) {
    249249                switch ( data.kind ) {
    250                   case TypeVar::Dtype:
     250                  case TypeDecl::Dtype:
    251251                        // to bind to an object type variable, the type must not be a function type.
    252252                        // if the type variable is specified to be a complete type then the incoming
     
    254254                        // xxx - should this also check that type is not a tuple type and that it's not a ttype?
    255255                        return ! isFtype( type ) && ( ! data.isComplete || type->isComplete() );
    256                   case TypeVar::Ftype:
     256                  case TypeDecl::Ftype:
    257257                        return isFtype( type );
    258                   case TypeVar::Ttype:
     258                  case TypeDecl::Ttype:
    259259                        // ttype unifies with any tuple type
    260260                        return dynamic_cast< const TupleType * >( type ) || Tuples::isTtype( type );
  • src/AST/TypeEnvironment.hpp

    r71d6bd8 r7030dab  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 29 11:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Wed May 29 11:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:55:54 2019
     13// Update Count     : 3
    1414//
    1515
     
    2828#include "Type.hpp"
    2929#include "TypeSubstitution.hpp"
    30 #include "TypeVar.hpp"
    3130#include "Common/Indenter.h"
    3231#include "ResolvExpr/WidenMode.h"
     
    107106        /// Singleton class constructor from substitution
    108107        EqvClass( const std::string & v, const Type * b )
    109         : vars{ v }, bound( b ), allowWidening( false ), data( TypeVar::Dtype, false ) {}
     108        : vars{ v }, bound( b ), allowWidening( false ), data( TypeDecl::Dtype, false ) {}
    110109
    111110        /// Single-var constructor (strips qualifiers from bound type)
  • src/AST/Visitor.hpp

    r71d6bd8 r7030dab  
    4747    virtual const ast::Stmt *             visit( const ast::CatchStmt            * ) = 0;
    4848    virtual const ast::Stmt *             visit( const ast::FinallyStmt          * ) = 0;
     49    virtual const ast::Stmt *             visit( const ast::SuspendStmt          * ) = 0;
    4950    virtual const ast::Stmt *             visit( const ast::WaitForStmt          * ) = 0;
    5051    virtual const ast::Decl *             visit( const ast::WithStmt             * ) = 0;
  • src/AST/module.mk

    r71d6bd8 r7030dab  
    1010## Author           : Thierry Delisle
    1111## Created On       : Thu May 09 16:05:36 2019
    12 ## Last Modified By :
    13 ## Last Modified On :
    14 ## Update Count     :
     12## Last Modified By : Peter A. Buhr
     13## Last Modified On : Sat Dec 14 07:29:10 2019
     14## Update Count     : 3
    1515###############################################################################
    1616
     
    3535        AST/TypeSubstitution.cpp
    3636
    37 
    38 
    3937SRC += $(SRC_AST)
    4038SRCDEMANGLE += $(SRC_AST)
Note: See TracChangeset for help on using the changeset viewer.