Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r23f99e1 r8a5530c  
    2626#include "ParseNode.hpp"
    2727#include "StorageClasses.hpp"
    28 #include "Type.hpp"            // for Type, ptr<Type>
     28#include "TypeVar.hpp"
    2929#include "Visitor.hpp"
    3030#include "Parser/ParseNode.h"  // for DeclarationNode::Aggregate
     
    119119};
    120120
     121/// Object declaration `int foo()`
    121122class FunctionDecl : public DeclWithType {
    122123public:
     
    131132          stmts( stmts ) {}
    132133
    133         const Type * get_type() const override { return type.get(); }
    134         void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); }
     134        const Type * get_type() const override;
     135        void set_type(Type * t) override;
    135136
    136137        bool has_body() const { return stmts; }
     
    166167class TypeDecl final : public NamedTypeDecl {
    167168public:
    168         /// type variable variants. otype is a specialized dtype
    169         enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS } kind;
     169        TypeVar::Kind kind;
    170170        bool sized;
    171171        ptr<Type> init;
     
    173173        /// Data extracted from a type decl
    174174        struct Data {
    175                 Kind kind;
     175                TypeVar::Kind kind;
    176176                bool isComplete;
    177177
    178                 Data() : kind( (Kind)-1 ), isComplete( false ) {}
     178                Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {}
    179179                Data( TypeDecl* d ) : kind( d->kind ), isComplete( d->sized ) {}
    180                 Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}
     180                Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {}
    181181                Data( const Data& d1, const Data& d2 )
    182182                : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
     
    189189
    190190        TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
    191                 Kind k, bool s, Type* i = nullptr )
    192         : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ), init( i ) {}
     191                TypeVar::Kind k, bool s, Type* i = nullptr )
     192        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),
     193          init( i ) {}
    193194
    194195        std::string typeString() const override;
    195196        /// Produces a name for generated code
    196197        std::string genTypeString() const;
     198
     199        /// convenience accessor to match Type::isComplete()
     200        bool isComplete() { return sized; }
    197201
    198202        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.