Changes in src/AST/Decl.hpp [07de76b:312029a]
- File:
-
- 1 edited
-
src/AST/Decl.hpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r07de76b r312029a 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 17:38:33201913 // Update Count : 2912 // Last Modified On : Wed Dec 11 08:20:20 2019 13 // Update Count : 16 14 14 // 15 15 … … 20 20 #include <unordered_map> 21 21 #include <vector> 22 #include <algorithm>23 22 24 23 #include "FunctionSpec.hpp" … … 28 27 #include "ParseNode.hpp" 29 28 #include "StorageClasses.hpp" 29 #include "TypeVar.hpp" 30 30 #include "Visitor.hpp" 31 #include "Common/utility.h" 32 #include "Common/SemanticError.h" // error_str 31 #include "Parser/ParseNode.h" // for DeclarationNode::Aggregate 33 32 34 33 // Must be included in *all* AST classes; should be #undef'd at the end of the file … … 126 125 std::vector< ptr<Expr> > withExprs; 127 126 128 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,127 FunctionDecl( const CodeLocation & loc, const std::string &name, FunctionType * type, 129 128 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 130 129 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}) … … 137 136 bool has_body() const { return stmts; } 138 137 139 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }138 const DeclWithType * accept( Visitor &v ) const override { return v.visit( this ); } 140 139 private: 141 140 FunctionDecl * clone() const override { return new FunctionDecl( *this ); } … … 164 163 /// Cforall type variable: `dtype T` 165 164 class TypeDecl final : public NamedTypeDecl { 166 public: 167 enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS }; 168 169 Kind kind; 165 public: 166 TypeVar::Kind kind; 170 167 bool sized; 171 168 ptr<Type> init; … … 173 170 /// Data extracted from a type decl 174 171 struct Data { 175 Kind kind;172 TypeVar::Kind kind; 176 173 bool isComplete; 177 174 178 Data() : kind( NUMBER_OF_KINDS), isComplete( false ) {}175 Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {} 179 176 Data( const TypeDecl * d ) : kind( d->kind ), isComplete( d->sized ) {} 180 Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}177 Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {} 181 178 Data( const Data & d1, const Data & d2 ) 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); } 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); } 186 185 }; 187 186 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 ) {}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 init( i ) {} 192 191 193 192 const char * typeString() const override; … … 199 198 200 199 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 201 private:200 private: 202 201 TypeDecl * clone() const override { return new TypeDecl{ *this }; } 203 202 MUTATE_FRIEND … … 344 343 ptr<AsmStmt> stmt; 345 344 346 AsmDecl( const CodeLocation & loc, AsmStmt * stmt )345 AsmDecl( const CodeLocation & loc, AsmStmt *stmt ) 347 346 : Decl( loc, "", {}, {} ), stmt(stmt) {} 348 347 349 const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }350 private: 351 AsmDecl * clone() const override { return new AsmDecl( *this ); }348 const AsmDecl * accept( Visitor &v ) const override { return v.visit( this ); } 349 private: 350 AsmDecl *clone() const override { return new AsmDecl( *this ); } 352 351 MUTATE_FRIEND 353 352 }; … … 361 360 : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {} 362 361 363 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }362 const StaticAssertDecl * accept( Visitor &v ) const override { return v.visit( this ); } 364 363 private: 365 364 StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
Note:
See TracChangeset
for help on using the changeset viewer.