- Timestamp:
- Apr 6, 2020, 4:46:28 PM (5 years ago)
- 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. - Location:
- src/AST
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r71d6bd8 r7030dab 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:46201913 // Update Count : 1312 // Last Modified On : Wed Dec 11 21:39:32 2019 13 // Update Count : 33 14 14 // 15 15 … … 245 245 auto decl = new StructDecl( 246 246 node->name, 247 node->kind,247 (AggregateDecl::Aggregate)node->kind, 248 248 get<Attribute>().acceptL( node->attributes ), 249 249 LinkageSpec::Spec( node->linkage.val ) … … 493 493 } 494 494 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 495 507 const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 496 508 if ( inCache( node ) ) return nullptr; … … 686 698 687 699 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 ); 703 702 auto expr = visitBaseExpr( node, 704 703 new KeywordCastExpr( … … 1247 1246 cv( node ), 1248 1247 node->name, 1249 node->kind == ast::Type Var::Ftype,1248 node->kind == ast::TypeDecl::Ftype, 1250 1249 get<Attribute>().acceptL( node->attributes ) 1251 1250 }; … … 1515 1514 old->location, 1516 1515 old->name, 1517 old->kind,1516 (ast::AggregateDecl::Aggregate)old->kind, 1518 1517 GET_ACCEPT_V(attributes, Attribute), 1519 1518 { old->linkage.val } … … 1602 1601 { old->storageClasses.val }, 1603 1602 GET_ACCEPT_1(base, Type), 1604 (ast::Type Var::Kind)(unsigned)old->kind,1603 (ast::TypeDecl::Kind)(unsigned)old->kind, 1605 1604 old->sized, 1606 1605 GET_ACCEPT_1(init, Type) … … 1883 1882 } 1884 1883 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 1885 1902 virtual void visit( const WaitForStmt * old ) override final { 1886 1903 if ( inCache( old ) ) return; … … 2056 2073 } 2057 2074 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 ); 2074 2078 this->node = visitBaseExpr( old, 2075 2079 new ast::KeywordCastExpr( … … 2599 2603 ty = new ast::TypeInstType{ 2600 2604 old->name, 2601 old->isFtype ? ast::Type Var::Ftype : ast::TypeVar::Dtype,2605 old->isFtype ? ast::TypeDecl::Ftype : ast::TypeDecl::Dtype, 2602 2606 cv( old ), 2603 2607 GET_ACCEPT_V( attributes, Attribute ) -
src/AST/Decl.cpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 16:23:15 2019 13 // Update Count : 20 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, strict_dynamic_cast 19 19 #include <iostream> 20 #include <string>21 20 #include <unordered_map> 22 21 … … 27 26 #include "Node.hpp" // for readonly 28 27 #include "Type.hpp" // for readonly 29 #include "Parser/ParseNode.h" // for DeclarationNode30 28 31 29 namespace ast { … … 58 56 // --- TypeDecl 59 57 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 ]; 58 const 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' 66 63 } 67 64 68 std::stringTypeDecl::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'skind is out of bounds." );65 const 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." ); 72 69 return kindNames[ kind ]; 73 70 } … … 75 72 std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) { 76 73 return out << data.kind << ", " << data.isComplete; 74 } 75 76 // --- AggregateDecl 77 78 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations. 79 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" }; 80 81 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) { 82 return aggregateNames[aggr]; 77 83 } 78 84 -
src/AST/Decl.hpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // 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 … … 127 128 std::vector< ptr<Expr> > withExprs; 128 129 129 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,130 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type, 130 131 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 131 132 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}) … … 138 139 bool has_body() const { return stmts; } 139 140 140 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }141 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); } 141 142 private: 142 143 FunctionDecl * clone() const override { return new FunctionDecl( *this ); } … … 151 152 std::vector<ptr<DeclWithType>> assertions; 152 153 153 NamedTypeDecl( 154 NamedTypeDecl( 154 155 const CodeLocation & loc, const std::string & name, Storage::Classes storage, 155 156 const Type * b, Linkage::Spec spec = Linkage::Cforall ) … … 157 158 158 159 /// Produces a name for the kind of alias 159 virtual std::stringtypeString() const = 0;160 virtual const char * typeString() const = 0; 160 161 161 162 private: … … 166 167 /// Cforall type variable: `dtype T` 167 168 class 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; 170 173 bool sized; 171 174 ptr<Type> init; … … 173 176 /// Data extracted from a type decl 174 177 struct Data { 175 TypeVar::Kind kind;178 Kind kind; 176 179 bool isComplete; 177 180 178 Data() : kind( (TypeVar::Kind)-1), isComplete( false ) {}181 Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {} 179 182 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 ) {} 181 184 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); } 188 189 }; 189 190 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, 192 193 const Type * b, TypeVar::Kind k, bool s, const Type * i = nullptr ) 193 194 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ), 194 195 init( i ) {} 195 196 196 std::stringtypeString() const override;197 const char * typeString() const override; 197 198 /// Produces a name for generated code 198 std::stringgenTypeString() const;199 const char * genTypeString() const; 199 200 200 201 /// convenience accessor to match Type::isComplete() … … 202 203 203 204 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 204 private:205 private: 205 206 TypeDecl * clone() const override { return new TypeDecl{ *this }; } 206 207 MUTATE_FRIEND … … 216 217 : NamedTypeDecl( loc, name, storage, b, spec ) {} 217 218 218 std::stringtypeString() const override { return "typedef"; }219 const char * typeString() const override { return "typedef"; } 219 220 220 221 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } … … 227 228 class AggregateDecl : public Decl { 228 229 public: 230 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate }; 231 static const char * aggrString( Aggregate aggr ); 232 229 233 std::vector<ptr<Decl>> members; 230 234 std::vector<ptr<TypeDecl>> params; … … 241 245 242 246 /// Produces a name for the kind of aggregate 243 virtual std::stringtypeString() const = 0;247 virtual const char * typeString() const = 0; 244 248 245 249 private: … … 251 255 class StructDecl final : public AggregateDecl { 252 256 public: 253 DeclarationNode::Aggregate kind;257 Aggregate kind; 254 258 255 259 StructDecl( const CodeLocation& loc, const std::string& name, 256 DeclarationNode::Aggregate kind = DeclarationNode::Struct,260 Aggregate kind = Struct, 257 261 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall ) 258 262 : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {} 259 263 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 ); } 267 272 268 273 private: … … 280 285 const Decl * accept( Visitor& v ) const override { return v.visit( this ); } 281 286 282 std::string typeString() const override { return "union"; }287 const char * typeString() const override { return aggrString( Union ); } 283 288 284 289 private: … … 299 304 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 300 305 301 std::string typeString() const override { return "enum"; }306 const char * typeString() const override { return aggrString( Enum ); } 302 307 303 308 private: … … 318 323 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 319 324 320 std::stringtypeString() const override { return "trait"; }325 const char * typeString() const override { return "trait"; } 321 326 322 327 private: … … 344 349 ptr<AsmStmt> stmt; 345 350 346 AsmDecl( const CodeLocation & loc, AsmStmt * stmt )351 AsmDecl( const CodeLocation & loc, AsmStmt * stmt ) 347 352 : Decl( loc, "", {}, {} ), stmt(stmt) {} 348 353 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 ); } 355 private: 356 AsmDecl * clone() const override { return new AsmDecl( *this ); } 352 357 MUTATE_FRIEND 353 358 }; … … 361 366 : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {} 362 367 363 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }368 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); } 364 369 private: 365 370 StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); } -
src/AST/Expr.cpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Andrew Beach12 // Created On : Fri Oct 4 15:34:00 201913 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Created On : Thr Jun 13 13:38:00 2019 13 // Update Count : 6 14 14 // 15 15 … … 163 163 // --- KeywordCastExpr 164 164 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]; 165 const char * KeywordCastExpr::targetString() const { 166 return AggregateDecl::aggrString( target ); 174 167 } 175 168 -
src/AST/Expr.hpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri May 10 10:30:00 2019 11 // Last Modified By : Andrew Beach12 // Created On : Thr Sep 26 12:51:00 201913 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Created On : Fri May 10 10:30:00 2019 13 // Update Count : 7 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" // for UniqueId 27 27 #include "Label.hpp" 28 #include "Decl.hpp" 28 29 #include "ParseNode.hpp" 29 30 #include "Visitor.hpp" … … 310 311 public: 311 312 ptr<Expr> arg; 312 enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS }target;313 314 KeywordCastExpr( const CodeLocation & loc, const Expr * a, Targett )313 ast::AggregateDecl::Aggregate target; 314 315 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t ) 315 316 : Expr( loc ), arg( a ), target( t ) {} 316 317 317 318 /// Get a name for the target type 318 const std::string&targetString() const;319 const char * targetString() const; 319 320 320 321 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Fwd.hpp
r71d6bd8 r7030dab 53 53 class CatchStmt; 54 54 class FinallyStmt; 55 class SuspendStmt; 55 56 class WaitForStmt; 56 57 class WithStmt; -
src/AST/Pass.hpp
r71d6bd8 r7030dab 114 114 const ast::Stmt * visit( const ast::CatchStmt * ) override final; 115 115 const ast::Stmt * visit( const ast::FinallyStmt * ) override final; 116 const ast::Stmt * visit( const ast::SuspendStmt * ) override final; 116 117 const ast::Stmt * visit( const ast::WaitForStmt * ) override final; 117 118 const ast::Decl * visit( const ast::WithStmt * ) override final; -
src/AST/Pass.impl.hpp
r71d6bd8 r7030dab 838 838 839 839 //-------------------------------------------------------------------------- 840 // FinallyStmt 841 template< typename pass_t > 842 const 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 //-------------------------------------------------------------------------- 840 853 // WaitForStmt 841 854 template< typename pass_t > -
src/AST/Print.cpp
r71d6bd8 r7030dab 674 674 safe_print( node->body ); 675 675 --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; 676 695 677 696 return node; … … 1359 1378 preprint( node ); 1360 1379 os << "instance of type " << node->name 1361 << " (" << (node->kind == ast::Type Var::Ftype ? "" : "not ") << "function type)";1380 << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)"; 1362 1381 print( node->params ); 1363 1382 -
src/AST/Stmt.hpp
r71d6bd8 r7030dab 344 344 }; 345 345 346 /// Suspend statement 347 class SuspendStmt final : public Stmt { 348 public: 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 ); } 356 private: 357 SuspendStmt * clone() const override { return new SuspendStmt{ *this }; } 358 MUTATE_FRIEND 359 }; 360 346 361 /// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...` 347 362 class WaitForStmt final : public Stmt { -
src/AST/Type.cpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon May 13 15:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Mon May 13 15:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 15 16:56:28 2019 13 // Update Count : 4 14 14 // 15 15 … … 50 50 // --- BasicType 51 51 52 const char *BasicType::typeNames[] = { 52 // GENERATED START, DO NOT EDIT 53 // GENERATED BY BasicTypes-gen.cc 54 const char * BasicType::typeNames[] = { 53 55 "_Bool", 54 56 "char", … … 88 90 "_Float128x _Complex", 89 91 }; 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 94 93 95 94 // --- ParameterizedType -
src/AST/Type.hpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:56:46 2019 13 // Update Count : 5 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" 27 27 #include "Node.hpp" // for Node, ptr, ptr_base 28 #include "TypeVar.hpp"29 28 #include "Visitor.hpp" 30 29 … … 448 447 public: 449 448 readonly<TypeDecl> base; 450 Type Var::Kind kind;449 TypeDecl::Kind kind; 451 450 452 451 TypeInstType( … … 454 453 std::vector<ptr<Attribute>> && as = {} ) 455 454 : 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 = {}, 459 456 std::vector<ptr<Attribute>> && as = {} ) 460 457 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {} -
src/AST/TypeEnvironment.cpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 29 11:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Wed May 29 11:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:49:13 2019 13 // Update Count : 4 14 14 // 15 15 … … 240 240 return true; 241 241 } else if ( auto typeInst = dynamic_cast< const TypeInstType * >( type ) ) { 242 return typeInst->kind == Type Var::Ftype;242 return typeInst->kind == TypeDecl::Ftype; 243 243 } else return false; 244 244 } … … 248 248 bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) { 249 249 switch ( data.kind ) { 250 case Type Var::Dtype:250 case TypeDecl::Dtype: 251 251 // to bind to an object type variable, the type must not be a function type. 252 252 // if the type variable is specified to be a complete type then the incoming … … 254 254 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 255 255 return ! isFtype( type ) && ( ! data.isComplete || type->isComplete() ); 256 case Type Var::Ftype:256 case TypeDecl::Ftype: 257 257 return isFtype( type ); 258 case Type Var::Ttype:258 case TypeDecl::Ttype: 259 259 // ttype unifies with any tuple type 260 260 return dynamic_cast< const TupleType * >( type ) || Tuples::isTtype( type ); -
src/AST/TypeEnvironment.hpp
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 29 11:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Wed May 29 11:00:00201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:55:54 2019 13 // Update Count : 3 14 14 // 15 15 … … 28 28 #include "Type.hpp" 29 29 #include "TypeSubstitution.hpp" 30 #include "TypeVar.hpp"31 30 #include "Common/Indenter.h" 32 31 #include "ResolvExpr/WidenMode.h" … … 107 106 /// Singleton class constructor from substitution 108 107 EqvClass( const std::string & v, const Type * b ) 109 : vars{ v }, bound( b ), allowWidening( false ), data( Type Var::Dtype, false ) {}108 : vars{ v }, bound( b ), allowWidening( false ), data( TypeDecl::Dtype, false ) {} 110 109 111 110 /// Single-var constructor (strips qualifiers from bound type) -
src/AST/Visitor.hpp
r71d6bd8 r7030dab 47 47 virtual const ast::Stmt * visit( const ast::CatchStmt * ) = 0; 48 48 virtual const ast::Stmt * visit( const ast::FinallyStmt * ) = 0; 49 virtual const ast::Stmt * visit( const ast::SuspendStmt * ) = 0; 49 50 virtual const ast::Stmt * visit( const ast::WaitForStmt * ) = 0; 50 51 virtual const ast::Decl * visit( const ast::WithStmt * ) = 0; -
src/AST/module.mk
r71d6bd8 r7030dab 10 10 ## Author : Thierry Delisle 11 11 ## 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 15 15 ############################################################################### 16 16 … … 35 35 AST/TypeSubstitution.cpp 36 36 37 38 39 37 SRC += $(SRC_AST) 40 38 SRCDEMANGLE += $(SRC_AST)
Note:
See TracChangeset
for help on using the changeset viewer.