Changeset 07de76b for src/AST/Decl.hpp
- Timestamp:
- Dec 16, 2019, 2:30:41 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- bffcd66
- Parents:
- ab5c0008
- git-author:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:23:00)
- git-committer:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:30:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
rab5c0008 r07de76b 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 08:20:20201913 // Update Count : 1612 // Last Modified On : Fri Dec 13 17:38:33 2019 13 // Update Count : 29 14 14 // 15 15 … … 20 20 #include <unordered_map> 21 21 #include <vector> 22 #include <algorithm> 22 23 23 24 #include "FunctionSpec.hpp" … … 27 28 #include "ParseNode.hpp" 28 29 #include "StorageClasses.hpp" 29 #include "TypeVar.hpp"30 30 #include "Visitor.hpp" 31 #include "Parser/ParseNode.h" // for DeclarationNode::Aggregate 31 #include "Common/utility.h" 32 #include "Common/SemanticError.h" // error_str 32 33 33 34 // Must be included in *all* AST classes; should be #undef'd at the end of the file … … 125 126 std::vector< ptr<Expr> > withExprs; 126 127 127 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,128 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type, 128 129 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 129 130 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}) … … 136 137 bool has_body() const { return stmts; } 137 138 138 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }139 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); } 139 140 private: 140 141 FunctionDecl * clone() const override { return new FunctionDecl( *this ); } … … 163 164 /// Cforall type variable: `dtype T` 164 165 class TypeDecl final : public NamedTypeDecl { 165 public: 166 TypeVar::Kind kind; 166 public: 167 enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS }; 168 169 Kind kind; 167 170 bool sized; 168 171 ptr<Type> init; … … 170 173 /// Data extracted from a type decl 171 174 struct Data { 172 TypeVar::Kind kind;175 Kind kind; 173 176 bool isComplete; 174 177 175 Data() : kind( (TypeVar::Kind)-1), isComplete( false ) {}178 Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {} 176 179 Data( const TypeDecl * d ) : kind( d->kind ), isComplete( d->sized ) {} 177 Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {}180 Data( Kind k, bool c ) : kind( k ), isComplete( c ) {} 178 181 Data( const Data & d1, const Data & d2 ) 179 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {} 180 181 bool operator== ( const Data & o ) const { 182 return kind == o.kind && isComplete == o.isComplete; 183 } 184 bool operator!= ( const Data & o ) const { return !(*this == o); } 182 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {} 183 184 bool operator==( const Data & o ) const { return kind == o.kind && isComplete == o.isComplete; } 185 bool operator!=( const Data & o ) const { return !(*this == o); } 185 186 }; 186 187 187 TypeDecl( const CodeLocation & loc, const std::string& name, Storage::Classes storage, Type* b,188 TypeVar::Kind k, bool s, Type* i = nullptr )189 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),190 188 TypeDecl( const CodeLocation & loc, const std::string & name, Storage::Classes storage, Type * b, 189 Kind k, bool s, Type * i = nullptr ) 190 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ), 191 init( i ) {} 191 192 192 193 const char * typeString() const override; … … 198 199 199 200 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 200 private:201 private: 201 202 TypeDecl * clone() const override { return new TypeDecl{ *this }; } 202 203 MUTATE_FRIEND … … 343 344 ptr<AsmStmt> stmt; 344 345 345 AsmDecl( const CodeLocation & loc, AsmStmt * stmt )346 AsmDecl( const CodeLocation & loc, AsmStmt * stmt ) 346 347 : Decl( loc, "", {}, {} ), stmt(stmt) {} 347 348 348 const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }349 private: 350 AsmDecl * clone() const override { return new AsmDecl( *this ); }349 const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); } 350 private: 351 AsmDecl * clone() const override { return new AsmDecl( *this ); } 351 352 MUTATE_FRIEND 352 353 }; … … 360 361 : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {} 361 362 362 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }363 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); } 363 364 private: 364 365 StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
Note: See TracChangeset
for help on using the changeset viewer.