Changes in src/AST/Decl.hpp [23f99e1:8a5530c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r23f99e1 r8a5530c 26 26 #include "ParseNode.hpp" 27 27 #include "StorageClasses.hpp" 28 #include "Type .hpp" // for Type, ptr<Type>28 #include "TypeVar.hpp" 29 29 #include "Visitor.hpp" 30 30 #include "Parser/ParseNode.h" // for DeclarationNode::Aggregate … … 119 119 }; 120 120 121 /// Object declaration `int foo()` 121 122 class FunctionDecl : public DeclWithType { 122 123 public: … … 131 132 stmts( stmts ) {} 132 133 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; 135 136 136 137 bool has_body() const { return stmts; } … … 166 167 class TypeDecl final : public NamedTypeDecl { 167 168 public: 168 /// type variable variants. otype is a specialized dtype 169 enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS } kind; 169 TypeVar::Kind kind; 170 170 bool sized; 171 171 ptr<Type> init; … … 173 173 /// Data extracted from a type decl 174 174 struct Data { 175 Kind kind;175 TypeVar::Kind kind; 176 176 bool isComplete; 177 177 178 Data() : kind( ( Kind)-1 ), isComplete( false ) {}178 Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {} 179 179 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 ) {} 181 181 Data( const Data& d1, const Data& d2 ) 182 182 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {} … … 189 189 190 190 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 ) {} 193 194 194 195 std::string typeString() const override; 195 196 /// Produces a name for generated code 196 197 std::string genTypeString() const; 198 199 /// convenience accessor to match Type::isComplete() 200 bool isComplete() { return sized; } 197 201 198 202 const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset
for help on using the changeset viewer.