Changeset f0ecf9b
- Timestamp:
- Nov 1, 2017, 5:40:05 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- fde89cf6
- Parents:
- b0837e4
- Location:
- src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rb0837e4 rf0ecf9b 288 288 assertf( ! genC, "TypeDecls should not reach code generation." ); 289 289 output << typeDecl->genTypeString() << " " << typeDecl->name; 290 if ( typeDecl-> get_kind() != TypeDecl::Any && typeDecl->sized ) {290 if ( typeDecl->sized ) { 291 291 output << " | sized(" << typeDecl->name << ")"; 292 292 } -
src/GenPoly/InstantiateGeneric.cc
rb0837e4 rf0ecf9b 238 238 assertf( false, "Ttype parameters are not currently allowed as parameters to generic types." ); 239 239 break; 240 case TypeDecl::Any:241 assertf( false, " otype parameters handled by baseParam->isComplete()." );240 default: 241 assertf( false, "Unhandled type parameter kind" ); 242 242 break; 243 243 } -
src/GenPoly/ScrubTyVars.cc
rb0837e4 rf0ecf9b 40 40 if ( tyVar != tyVars->end() ) { 41 41 switch ( tyVar->second.kind ) { 42 case TypeDecl::Any:43 42 case TypeDecl::Dtype: 44 43 case TypeDecl::Ttype: -
src/Parser/DeclarationNode.cc
rb0837e4 rf0ecf9b 1031 1031 1032 1032 if ( variable.tyClass != NoTypeClass ) { 1033 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1034 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1033 // otype is internally converted to dtype + otype parameters 1034 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1035 assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." ); 1035 1036 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1036 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable. initializer ? variable.initializer->buildType() : nullptr );1037 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); 1037 1038 buildList( variable.assertions, ret->get_assertions() ); 1038 1039 return ret; -
src/Parser/TypeData.cc
rb0837e4 rf0ecf9b 406 406 void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) { 407 407 buildList( firstNode, outputList ); 408 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 408 auto n = firstNode; 409 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) { 409 410 TypeDecl * td = static_cast<TypeDecl *>(*i); 410 if ( td->get_kind() == TypeDecl::Any) {411 if ( n->variable.tyClass == DeclarationNode::Otype ) { 411 412 // add assertion parameters to `type' tyvars in reverse order 412 413 // add dtor: void ^?{}(T *) … … 798 799 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage ); 799 800 } else { 800 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl:: Any);801 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true ); 801 802 } // if 802 803 buildList( td->symbolic.params, ret->get_parameters() ); -
src/ResolvExpr/Unify.cc
rb0837e4 rf0ecf9b 138 138 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 139 139 switch ( data.kind ) { 140 case TypeDecl::Any:141 140 case TypeDecl::Dtype: 142 141 // to bind to an object type variable, the type must not be a function type. -
src/SymTab/Autogen.cc
rb0837e4 rf0ecf9b 696 696 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 697 697 if ( ! done.count( ty->get_baseType() ) ) { 698 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl:: Any);698 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true ); 699 699 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 700 700 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, -
src/SymTab/Mangler.cc
rb0837e4 rf0ecf9b 214 214 numStream << varNum->second.first; 215 215 switch ( (TypeDecl::Kind )varNum->second.second ) { 216 case TypeDecl::Any:217 mangleName << "t";218 break;219 216 case TypeDecl::Dtype: 220 217 mangleName << "d"; … … 274 271 for ( Type::ForallList::iterator i = type->forall.begin(); i != type->forall.end(); ++i ) { 275 272 switch ( (*i)->get_kind() ) { 276 case TypeDecl::Any:277 tcount++;278 break;279 273 case TypeDecl::Dtype: 280 274 dcount++; -
src/SynTree/Declaration.h
rb0837e4 rf0ecf9b 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
rb0837e4 rf0ecf9b 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 } -
src/Tuples/TupleExpansion.cc
rb0837e4 rf0ecf9b 204 204 decl->set_body( true ); 205 205 for ( size_t i = 0; i < tupleSize; ++i ) { 206 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl:: Any);206 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true ); 207 207 decl->get_members().push_back( new ObjectDecl( toString("field_", i ), Type::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) ); 208 208 decl->get_parameters().push_back( tyParam );
Note: See TracChangeset
for help on using the changeset viewer.