Changeset 2c57025
- Timestamp:
- Nov 25, 2016, 6:11:03 PM (8 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:
- 0f35657
- Parents:
- 186fd86
- Location:
- src
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r186fd86 r2c57025 169 169 output << aggDecl->get_name(); 170 170 171 std::list< Declaration * > & memb = aggDecl->get_members();172 if ( ! memb.empty() ) {173 //if ( aggDecl->has_body() ) {174 //std::list< Declaration * > & memb = aggDecl->get_members();171 // std::list< Declaration * > & memb = aggDecl->get_members(); 172 // if ( ! memb.empty() ) { 173 if ( aggDecl->has_body() ) { 174 std::list< Declaration * > & memb = aggDecl->get_members(); 175 175 output << " {" << endl; 176 176 -
src/GenPoly/Box.cc
r186fd86 r2c57025 275 275 276 276 for ( std::list< TypeDecl* >::const_iterator decl = decls.begin(); decl != decls.end(); ++decl ) { 277 if ( (*decl)-> get_kind() == TypeDecl::Any) {277 if ( (*decl)->isComplete() ) { 278 278 otypeDecls.push_back( *decl ); 279 279 } … … 719 719 720 720 TypeDecl *Pass1::mutate( TypeDecl *typeDecl ) { 721 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();721 addToTyVarMap( typeDecl, scopeTyVars ); 722 722 return Mutator::mutate( typeDecl ); 723 723 } … … 774 774 ResolvExpr::EqvClass eqvClass; 775 775 assert( env ); 776 if ( tyParm->second == TypeDecl::Any) {776 if ( tyParm->second.isComplete ) { 777 777 Type *concrete = env->lookup( tyParm->first ); 778 778 if ( concrete ) { … … 1278 1278 std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin(); 1279 1279 1280 TyVarMap exprTyVars( (TypeDecl::Kind)-1);1280 TyVarMap exprTyVars( TypeDecl::Data{} ); 1281 1281 makeTyVarMap( function, exprTyVars ); 1282 1282 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); … … 1428 1428 1429 1429 // skip non-otype parameters (ftype/dtype) 1430 // xxx - should this check whether the type is complete instead? 1430 1431 if ( (*forallIt)->get_kind() != TypeDecl::Any ) continue; 1431 1432 … … 1553 1554 1554 1555 TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) { 1555 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1556 addToTyVarMap( typeDecl, scopeTyVars ); 1556 1557 if ( typeDecl->get_base() ) { 1557 1558 return handleDecl( typeDecl, typeDecl->get_base() ); … … 1597 1598 ObjectDecl *sizeParm, *alignParm; 1598 1599 // add all size and alignment parameters to parameter list 1599 if ( (*tyParm)-> get_kind() == TypeDecl::Any) {1600 if ( (*tyParm)->isComplete() ) { 1600 1601 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1601 1602 std::string parmName = mangleType( &parmType ); … … 1706 1707 1707 1708 TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) { 1708 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1709 addToTyVarMap( typeDecl, scopeTyVars ); 1709 1710 return Parent::mutate( typeDecl ); 1710 1711 } … … 1870 1871 for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) { 1871 1872 // skip non-otype parameters 1872 if ( (*baseParam)->get_kind() != TypeDecl::Any) continue;1873 if ( ! (*baseParam)->isComplete() ) continue; 1873 1874 TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam ); 1874 1875 assert( typeExpr && "all otype parameters should be type expressions" ); … … 2082 2083 // Initializer *init = 0; 2083 2084 // std::list< Expression *> designators; 2084 // scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();2085 // addToTyVarMap( typeDecl, scopeTyVars ); 2085 2086 // if ( typeDecl->get_base() ) { 2086 2087 // init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators ); … … 2088 2089 // return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init ); 2089 2090 2090 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();2091 addToTyVarMap( typeDecl, scopeTyVars ); 2091 2092 return Mutator::mutate( typeDecl ); 2092 2093 } -
src/GenPoly/GenPoly.cc
r186fd86 r2c57025 97 97 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 98 98 auto var = tyVars.find( typeInst->get_name() ); 99 if ( var != tyVars.end() && var->second == TypeDecl::Any) {99 if ( var != tyVars.end() && var->second.isComplete ) { 100 100 return typeInst; 101 101 } … … 117 117 if ( function->get_returnVals().empty() ) return 0; 118 118 119 TyVarMap forallTypes( (TypeDecl::Kind)-1);119 TyVarMap forallTypes( TypeDecl::Data{} ); 120 120 makeTyVarMap( function, forallTypes ); 121 121 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes ); … … 227 227 } 228 228 229 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) { 230 tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar }; 231 } 232 229 233 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) { 230 234 for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) { 231 235 assert( *tyVar ); 232 tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();236 addToTyVarMap( *tyVar, tyVarMap ); 233 237 } 234 238 if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) { -
src/GenPoly/GenPoly.h
r186fd86 r2c57025 30 30 31 31 namespace GenPoly { 32 typedef ErasableScopedMap< std::string, TypeDecl:: Kind> TyVarMap;32 typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap; 33 33 34 34 /// Replaces a TypeInstType by its referrent in the environment, if applicable … … 74 74 VariableExpr *getBaseVar( Expression *expr, int *levels = 0 ); 75 75 76 /// Adds the type variable `tyVar` to `tyVarMap` 77 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ); 78 76 79 /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap` 77 80 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); -
src/GenPoly/InstantiateGeneric.cc
r186fd86 r2c57025 284 284 // set concDecl to new type, insert type declaration into statements to add 285 285 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 286 concDecl->set_body( inst->get_baseStruct()->has_body() ); 286 287 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 287 288 DeclMutator::addDeclaration( concDecl ); … … 337 338 // set concDecl to new type, insert type declaration into statements to add 338 339 concDecl = new UnionDecl( typeNamer.newName( inst->get_name() ) ); 340 concDecl->set_body( inst->get_baseUnion()->has_body() ); 339 341 substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 340 342 DeclMutator::addDeclaration( concDecl ); -
src/GenPoly/PolyMutator.cc
r186fd86 r2c57025 23 23 24 24 namespace GenPoly { 25 namespace { 26 const std::list<Label> noLabels; 27 } 28 29 PolyMutator::PolyMutator() : scopeTyVars( (TypeDecl::Kind)-1 ), env( 0 ) {} 25 PolyMutator::PolyMutator() : scopeTyVars( TypeDecl::Data{} ), env( 0 ) {} 30 26 31 27 void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) { -
src/GenPoly/ScrubTyVars.cc
r186fd86 r2c57025 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ScrubTyVars.cc -- 7 // ScrubTyVars.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 28 28 TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); 29 29 if ( tyVar != tyVars.end() ) { 30 switch ( tyVar->second ) {30 switch ( tyVar->second.kind ) { 31 31 case TypeDecl::Any: 32 32 case TypeDecl::Dtype: … … 52 52 return ty; 53 53 } 54 54 55 55 Type * ScrubTyVars::mutate( StructInstType *structInst ) { 56 56 return mutateAggregateType( structInst ); -
src/ResolvExpr/AdjustExprType.cc
r186fd86 r2c57025 97 97 EqvClass eqvClass; 98 98 if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 99 if ( eqvClass. kind == TypeDecl::Ftype ) {99 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 100 100 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst ); 101 101 return pointerType; -
src/ResolvExpr/AlternativeFinder.cc
r186fd86 r2c57025 373 373 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) { 374 374 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 375 unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();375 unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar }; 376 376 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) { 377 377 needAssertions[ *assert ] = true; -
src/ResolvExpr/CommonType.cc
r186fd86 r2c57025 57 57 Type *result = visitor.get_result(); 58 58 if ( ! result ) { 59 // this appears to be handling for opaque type declarations 59 60 if ( widenSecond ) { 60 TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ); 61 if ( inst ) { 62 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 63 if ( nt ) { 64 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 65 assert( type ); 61 if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) { 62 if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) { 63 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 66 64 if ( type->get_base() ) { 67 65 Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers(); … … 145 143 } 146 144 145 /// true if a common type for t must be a complete type 146 bool requiredComplete( Type * t ) { 147 if ( TypeInstType * inst = dynamic_cast< TypeInstType * > ( t ) ) { 148 return inst->get_baseType()->isComplete(); 149 } 150 return false; 151 } 152 147 153 void CommonType::visit( PointerType *pointerType ) { 148 154 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { 149 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) ) { 155 // Note: relationship between formal and actual types is antisymmetric 156 // void free(void *); 157 // forall(otype T) void foo(T *); 158 // 159 // should be able to pass T* to free, but should not be able to pass a void* to foo. 160 // because of this, the requiredComplete check occurs only on the first, since it corresponds 161 // to the formal parameter type (though this may be incorrect in some cases, in which case 162 // perhaps the widen mode needs to incorporate another bit for whether this is a formal or actual context) 163 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) && ! requiredComplete( pointerType->get_base() ) ) { 150 164 result = otherPointer->clone(); 151 165 result->get_qualifiers() += pointerType->get_qualifiers(); … … 211 225 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 212 226 if ( nt ) { 213 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 214 assert( type ); 227 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 215 228 if ( type->get_base() ) { 216 229 Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers(); -
src/ResolvExpr/FindOpenVars.cc
r186fd86 r2c57025 48 48 if ( nextIsOpen ) { 49 49 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 50 openVars[ (*i)->get_name() ] = (*i)->get_kind();50 openVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) }; 51 51 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 52 52 needAssertions[ *assert ] = false; … … 57 57 } else { 58 58 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 59 closedVars[ (*i)->get_name() ] = (*i)->get_kind();59 closedVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) }; 60 60 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 61 61 haveAssertions[ *assert ] = false; -
src/ResolvExpr/PtrsCastable.cc
r186fd86 r2c57025 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // PtrsCastable.cc -- 7 // PtrsCastable.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 25 25 public: 26 26 PtrsCastable( Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 27 27 28 28 int get_result() const { return result; } 29 29 … … 61 61 } //if 62 62 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 63 if ( eqvClass. kind == TypeDecl::Ftype ) {63 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 64 64 return -1; 65 65 } // if -
src/ResolvExpr/TypeEnvironment.cc
r186fd86 r2c57025 94 94 dest.type = maybeClone( src.type ); 95 95 dest.allowWidening = src.allowWidening; 96 dest. kind = src.kind;96 dest.data = src.data; 97 97 } 98 98 … … 162 162 EqvClass newClass; 163 163 newClass.vars.insert( (*i)->get_name() ); 164 newClass. kind = (*i)->get_kind();164 newClass.data = TypeDecl::Data{ (*i) }; 165 165 env.push_back( newClass ); 166 166 } // for … … 177 177 sub.add( *theVar, theClass->type ); 178 178 } else if ( theVar != theClass->vars.begin() ) { 179 TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass-> kind == TypeDecl::Ftype );179 TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype ); 180 180 /// std::cout << " bound to variable " << *theClass->vars.begin() << std::endl; 181 181 sub.add( *theVar, newTypeInst ); … … 243 243 for ( std::list< EqvClass >::const_iterator eqvClass = env.begin(); eqvClass != env.end(); ++eqvClass ) { 244 244 for ( std::set< std::string >::const_iterator var = eqvClass->vars.begin(); var != eqvClass->vars.end(); ++var ) { 245 openVars[ *var ] = eqvClass-> kind;245 openVars[ *var ] = eqvClass->data; 246 246 } // for 247 247 } // for -
src/ResolvExpr/TypeEnvironment.h
r186fd86 r2c57025 32 32 }; 33 33 typedef std::map< DeclarationWithType*, bool, AssertCompare > AssertionSet; 34 typedef std::map< std::string, TypeDecl:: Kind> OpenVarSet;34 typedef std::map< std::string, TypeDecl::Data > OpenVarSet; 35 35 36 36 void printAssertionSet( const AssertionSet &, std::ostream &, int indent = 0 ); … … 41 41 Type *type; 42 42 bool allowWidening; 43 TypeDecl:: Kind kind;43 TypeDecl::Data data; 44 44 45 45 void initialize( const EqvClass &src, EqvClass &dest ); -
src/ResolvExpr/Unify.cc
r186fd86 r2c57025 109 109 newFirst->get_qualifiers() = Type::Qualifiers(); 110 110 newSecond->get_qualifiers() = Type::Qualifiers(); 111 /// std::c out<< "first is ";112 /// first->print( std::c out);113 /// std::c out<< std::endl << "second is ";114 /// second->print( std::c out);115 /// std::c out<< std::endl << "newFirst is ";116 /// newFirst->print( std::c out);117 /// std::c out<< std::endl << "newSecond is ";118 /// newSecond->print( std::c out);119 /// std::c out<< std::endl;111 /// std::cerr << "first is "; 112 /// first->print( std::cerr ); 113 /// std::cerr << std::endl << "second is "; 114 /// second->print( std::cerr ); 115 /// std::cerr << std::endl << "newFirst is "; 116 /// newFirst->print( std::cerr ); 117 /// std::cerr << std::endl << "newSecond is "; 118 /// newSecond->print( std::cerr ); 119 /// std::cerr << std::endl; 120 120 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 121 121 delete newFirst; … … 133 133 } 134 134 135 bool tyVarCompatible( TypeDecl::Kind kind, Type *type, const SymTab::Indexer &indexer ) { 136 switch ( kind ) { 135 struct CompleteTypeChecker : public Visitor { 136 virtual void visit( VoidType *basicType ) { status = false; } 137 virtual void visit( BasicType *basicType ) {} 138 virtual void visit( PointerType *pointerType ) {} 139 virtual void visit( ArrayType *arrayType ) { status = ! arrayType->get_isVarLen(); } 140 virtual void visit( FunctionType *functionType ) {} 141 virtual void visit( StructInstType *aggregateUseType ) { status = aggregateUseType->get_baseStruct()->has_body(); } 142 virtual void visit( UnionInstType *aggregateUseType ) { status = aggregateUseType->get_baseUnion()->has_body(); } 143 // xxx - enum inst does not currently contain a pointer to base, this should be fixed. 144 virtual void visit( EnumInstType *aggregateUseType ) { /* status = aggregateUseType->get_baseEnum()->hasBody(); */ } 145 virtual void visit( TraitInstType *aggregateUseType ) { assert( false ); } 146 virtual void visit( TypeInstType *aggregateUseType ) { status = aggregateUseType->get_baseType()->isComplete(); } 147 virtual void visit( TupleType *tupleType ) {} // xxx - not sure if this is right, might need to recursively check complete-ness 148 virtual void visit( TypeofType *typeofType ) { assert( false ); } 149 virtual void visit( AttrType *attrType ) { assert( false ); } // xxx - not sure what to do here 150 virtual void visit( VarArgsType *varArgsType ){} // xxx - is this right? 151 virtual void visit( ZeroType *zeroType ) {} 152 virtual void visit( OneType *oneType ) {} 153 bool status = true; 154 }; 155 bool isComplete( Type * type ) { 156 CompleteTypeChecker checker; 157 assert( type ); 158 type->accept( checker ); 159 return checker.status; 160 } 161 162 bool tyVarCompatible( const TypeDecl::Data & data, Type *type, const SymTab::Indexer &indexer ) { 163 switch ( data.kind ) { 137 164 case TypeDecl::Any: 138 165 case TypeDecl::Dtype: 139 return ! isFtype( type, indexer ); 140 166 // to bind to an object type variable, the type must not be a function type. 167 // if the type variable is specified to be a complete type then the incoming 168 // type must also be complete 169 return ! isFtype( type, indexer ) && (! data.isComplete || isComplete( type )); 141 170 case TypeDecl::Ftype: 142 171 return isFtype( type, indexer ); … … 146 175 } 147 176 148 bool bindVar( TypeInstType *typeInst, Type *other, TypeDecl::Kind kind, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {177 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 149 178 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 150 179 assert( tyvar != openVars.end() ); … … 185 214 newClass.type->get_qualifiers() = Type::Qualifiers(); 186 215 newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond; 187 newClass. kind = kind;216 newClass.data = data; 188 217 env.add( newClass ); 189 218 } // if … … 191 220 } 192 221 193 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, TypeDecl::Kind kind, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {222 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 194 223 bool result = true; 195 224 EqvClass class1, class2; … … 220 249 221 250 if ( type1 && type2 ) { 222 // std::c out<< "has type1 && type2" << std::endl;251 // std::cerr << "has type1 && type2" << std::endl; 223 252 WidenMode newWidenMode ( widen1, widen2 ); 224 253 Type *common = 0; … … 258 287 newClass.vars.insert( var2->get_name() ); 259 288 newClass.allowWidening = widen1 && widen2; 260 newClass. kind = kind;289 newClass.data = data; 261 290 env.add( newClass ); 262 291 } // if … … 321 350 } // if 322 351 #ifdef DEBUG 323 std::c out<< "============ unifyExact" << std::endl;324 std::c out<< "type1 is ";325 type1->print( std::c out);326 std::c out<< std::endl << "type2 is ";327 type2->print( std::c out);328 std::c out<< std::endl << "openVars are ";329 printOpenVarSet( openVars, std::c out, 8 );330 std::c out<< std::endl << "input env is " << std::endl;331 debugEnv.print( std::c out, 8 );332 std::c out<< std::endl << "result env is " << std::endl;333 env.print( std::c out, 8 );334 std::c out<< "result is " << result << std::endl;352 std::cerr << "============ unifyExact" << std::endl; 353 std::cerr << "type1 is "; 354 type1->print( std::cerr ); 355 std::cerr << std::endl << "type2 is "; 356 type2->print( std::cerr ); 357 std::cerr << std::endl << "openVars are "; 358 printOpenVarSet( openVars, std::cerr, 8 ); 359 std::cerr << std::endl << "input env is " << std::endl; 360 debugEnv.print( std::cerr, 8 ); 361 std::cerr << std::endl << "result env is " << std::endl; 362 env.print( std::cerr, 8 ); 363 std::cerr << "result is " << result << std::endl; 335 364 #endif 336 365 return result; … … 347 376 bool result; 348 377 #ifdef DEBUG 349 std::c out<< "unifyInexact type 1 is ";350 type1->print( std::c out);351 std::c out<< "type 2 is ";352 type2->print( std::c out);353 std::c out<< std::endl;378 std::cerr << "unifyInexact type 1 is "; 379 type1->print( std::cerr ); 380 std::cerr << "type 2 is "; 381 type2->print( std::cerr ); 382 std::cerr << std::endl; 354 383 #endif 355 384 if ( ! unifyExact( type1, type2, env, needAssertions, haveAssertions, openVars, widenMode, indexer ) ) { 356 385 #ifdef DEBUG 357 std::c out<< "unifyInexact: no exact unification found" << std::endl;386 std::cerr << "unifyInexact: no exact unification found" << std::endl; 358 387 #endif 359 388 if ( ( common = commonType( type1, type2, widenMode.widenFirst, widenMode.widenSecond, indexer, env, openVars ) ) ) { 360 389 common->get_qualifiers() = tq1 + tq2; 361 390 #ifdef DEBUG 362 std::c out<< "unifyInexact: common type is ";363 common->print( std::c out);364 std::c out<< std::endl;391 std::cerr << "unifyInexact: common type is "; 392 common->print( std::cerr ); 393 std::cerr << std::endl; 365 394 #endif 366 395 result = true; 367 396 } else { 368 397 #ifdef DEBUG 369 std::c out<< "unifyInexact: no common type found" << std::endl;398 std::cerr << "unifyInexact: no common type found" << std::endl; 370 399 #endif 371 400 result = false; … … 404 433 405 434 void markAssertionSet( AssertionSet &assertions, DeclarationWithType *assert ) { 406 /// std::c out<< "assertion set is" << std::endl;407 /// printAssertionSet( assertions, std::c out, 8 );408 /// std::c out<< "looking for ";409 /// assert->print( std::c out);410 /// std::c out<< std::endl;435 /// std::cerr << "assertion set is" << std::endl; 436 /// printAssertionSet( assertions, std::cerr, 8 ); 437 /// std::cerr << "looking for "; 438 /// assert->print( std::cerr ); 439 /// std::cerr << std::endl; 411 440 AssertionSet::iterator i = assertions.find( assert ); 412 441 if ( i != assertions.end() ) { 413 /// std::c out<< "found it!" << std::endl;442 /// std::cerr << "found it!" << std::endl; 414 443 i->second = true; 415 444 } // if -
src/SymTab/Validate.cc
r186fd86 r2c57025 361 361 void Pass2::visit( TraitInstType *contextInst ) { 362 362 Parent::visit( contextInst ); 363 if ( contextInst->get_name() == "sized" ) { 364 // "sized" is a special trait with no members - just flick the sized status on for the type variable 365 if ( contextInst->get_parameters().size() != 1 ) { 366 throw SemanticError( "incorrect number of context parameters: ", contextInst ); 367 } 368 TypeExpr * param = safe_dynamic_cast< TypeExpr * > ( contextInst->get_parameters().front() ); 369 TypeInstType * inst = safe_dynamic_cast< TypeInstType * > ( param->get_type() ); 370 TypeDecl * decl = inst->get_baseType(); 371 decl->set_sized( true ); 372 // since "sized" is special, the next few steps don't apply 373 return; 374 } 363 375 TraitDecl *ctx = indexer->lookupTrait( contextInst->get_name() ); 364 376 if ( ! ctx ) { … … 584 596 585 597 typedeclNames[ typeDecl->get_name() ] = typeDecl; 586 return typeDecl;598 return Mutator::mutate( typeDecl ); 587 599 } 588 600 -
src/SynTree/ApplicationExpr.cc
r186fd86 r2c57025 30 30 if ( &other == this ) return *this; 31 31 decl = other.decl; 32 // xxx - this looks like a memory leak 32 33 actualType = maybeClone( other.actualType ); 33 34 formalType = maybeClone( other.formalType ); -
src/SynTree/Declaration.h
r186fd86 r2c57025 176 176 public: 177 177 enum Kind { Any, Dtype, Ftype }; 178 /// Data extracted from a type decl 179 struct Data { 180 TypeDecl::Kind kind; 181 bool isComplete; 182 Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {} 183 Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {} 184 Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {} 185 bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; } 186 bool operator!=(const Data & other) const { return !(*this == other);} 187 }; 178 188 179 189 TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ); … … 182 192 Kind get_kind() const { return kind; } 183 193 194 bool isComplete() const { return kind == Any || sized; } 195 bool get_sized() const { return sized; } 196 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 197 184 198 virtual TypeDecl *clone() const { return new TypeDecl( *this ); } 185 199 virtual void accept( Visitor &v ) { v.visit( this ); } … … 188 202 virtual std::string typeString() const; 189 203 Kind kind; 204 bool sized; 190 205 }; 191 206 … … 280 295 281 296 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 297 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 282 298 283 299 #endif // DECLARATION_H -
src/SynTree/ReferenceToType.cc
r186fd86 r2c57025 128 128 } 129 129 130 TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) { 131 } 132 133 130 134 TypeInstType::~TypeInstType() { 131 135 // delete baseType; //This is shared and should not be deleted -
src/SynTree/Type.h
r186fd86 r2c57025 337 337 TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType ); 338 338 TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype ); 339 TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {}339 TypeInstType( const TypeInstType &other ); 340 340 ~TypeInstType(); 341 341 -
src/SynTree/TypeDecl.cc
r186fd86 r2c57025 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeDecl.cc -- 7 // TypeDecl.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ) {20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ) {23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) { 24 24 } 25 25 … … 29 29 } 30 30 31 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 32 return os << data.kind << ", " << data.isComplete; 33 } 34 31 35 // Local Variables: // 32 36 // tab-width: 4 // -
src/libcfa/prelude.cf
r186fd86 r2c57025 108 108 forall( otype T ) const volatile T * --?( const volatile T ** ); 109 109 110 forall( otype T) lvalue T *?( T * );111 forall( otype T) const lvalue T *?( const T * );112 forall( otype T) volatile lvalue T *?( volatile T * );113 forall( otype T) const volatile lvalue T *?( const volatile T * );110 forall( dtype T | sized(T) ) lvalue T *?( T * ); 111 forall( dtype T | sized(T) ) const lvalue T *?( const T * ); 112 forall( dtype T | sized(T) ) volatile lvalue T *?( volatile T * ); 113 forall( dtype T | sized(T) ) const volatile lvalue T *?( const volatile T * ); 114 114 forall( ftype FT ) lvalue FT *?( FT * ); 115 115 -
src/tests/Makefile.am
r186fd86 r2c57025 65 65 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} 66 66 67 completeTypeError : completeTypeError.c 68 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
r186fd86 r2c57025 673 673 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} 674 674 675 completeTypeError : completeTypeError.c 676 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} 677 675 678 # Tell versions [3.59,3.63) of GNU make to not export all variables. 676 679 # Otherwise a system limit (for SysV at least) may be exceeded.
Note: See TracChangeset
for help on using the changeset viewer.