Changeset 136ccd7 for src/SynTree
- Timestamp:
- Nov 3, 2017, 3:01:31 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4ee36bf0
- Parents:
- 4ee1efb (diff), 760ba67 (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/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r4ee1efb r136ccd7 200 200 typedef NamedTypeDecl Parent; 201 201 public: 202 enum Kind { Any,Dtype, Ftype, Ttype };202 enum Kind { Dtype, Ftype, Ttype }; 203 203 204 204 Type * init; … … 216 216 }; 217 217 218 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );218 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr ); 219 219 TypeDecl( const TypeDecl &other ); 220 220 virtual ~TypeDecl(); … … 225 225 TypeDecl * set_init( Type * newValue ) { init = newValue; return this; } 226 226 227 bool isComplete() const { return kind == Any ||sized; }227 bool isComplete() const { return sized; } 228 228 bool get_sized() const { return sized; } 229 229 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } -
src/SynTree/TypeDecl.cc
r4ee1efb r136ccd7 21 21 #include "Type.h" // for Type, Type::StorageClasses 22 22 23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype), kind( kind ) {23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) { 24 24 } 25 25 … … 32 32 33 33 std::string TypeDecl::typeString() const { 34 static const std::string kindNames[] = { "type", "incomplete type", "function type", "tuple type" }; 35 return (kind != Any && isComplete() ? "sized " : "") + kindNames[ kind ]; 34 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 35 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." ); 36 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 37 return (isComplete() ? "sized " : "") + kindNames[ kind ]; 36 38 } 37 39 38 40 std::string TypeDecl::genTypeString() const { 39 static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" }; 41 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 42 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 43 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 40 44 return kindNames[ kind ]; 41 45 }
Note: See TracChangeset
for help on using the changeset viewer.