Changeset 8d70648 for src/SymTab
- Timestamp:
- May 30, 2019, 4:15:08 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a935892, f474e91
- Parents:
- d76c588 (diff), d88f8b3b (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/SymTab
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
rd76c588 r8d70648 41 41 42 42 namespace SymTab { 43 Type * SizeType = 0;44 45 43 /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype 46 44 struct FuncData { 47 typedef FunctionType * (*TypeGen)( Type * );45 typedef FunctionType * (*TypeGen)( Type *, bool ); 48 46 FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {} 49 47 std::string fname; … … 231 229 232 230 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 233 FunctionType * genDefaultType( Type * paramType ) { 234 const auto & typeParams = getGenericParams( paramType ); 231 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { 235 232 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 236 cloneAll( typeParams, ftype->forall ); 233 if ( maybePolymorphic ) { 234 // only copy in 235 const auto & typeParams = getGenericParams( paramType ); 236 cloneAll( typeParams, ftype->forall ); 237 } 237 238 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr ); 238 239 ftype->parameters.push_back( dstParam ); … … 241 242 242 243 /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T) 243 FunctionType * genCopyType( Type * paramType ) {244 FunctionType *ftype = genDefaultType( paramType );244 FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) { 245 FunctionType *ftype = genDefaultType( paramType, maybePolymorphic ); 245 246 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 246 247 ftype->parameters.push_back( srcParam ); … … 249 250 250 251 /// given type T, generate type of assignment, i.e. function type T (*) (T *, T) 251 FunctionType * genAssignType( Type * paramType ) {252 FunctionType *ftype = genCopyType( paramType );252 FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) { 253 FunctionType *ftype = genCopyType( paramType, maybePolymorphic ); 253 254 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 254 255 ftype->returnVals.push_back( returnVal ); … … 308 309 for ( const FuncData & d : data ) { 309 310 // generate a function (?{}, ?=?, ^?{}) based on the current FuncData. 310 FunctionType * ftype = d.genType( type );311 FunctionType * ftype = d.genType( type, true ); 311 312 312 313 // destructor for concurrent type must be mutex -
src/SymTab/Autogen.h
rd76c588 r8d70648 37 37 bool isUnnamedBitfield( ObjectDecl * obj ); 38 38 39 /// size_t type - set when size_t typedef is seen. Useful in a few places, 40 /// such as in determining array dimension type 41 extern Type * SizeType; 42 43 /// intrinsic dereference operator for unqualified types - set when *? function is seen in FindSpecialDeclarations. 44 /// Useful for creating dereference ApplicationExprs without a full resolver pass. 45 extern FunctionDecl * dereferenceOperator; 46 47 // generate the type of an assignment function for paramType 48 FunctionType * genAssignType( Type * paramType ); 49 50 // generate the type of a default constructor or destructor for paramType 51 FunctionType * genDefaultType( Type * paramType ); 52 53 // generate the type of a copy constructor for paramType 54 FunctionType * genCopyType( Type * paramType ); 39 /// generate the type of an assignment function for paramType. 40 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 41 FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true ); 42 43 /// generate the type of a default constructor or destructor for paramType. 44 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 45 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true ); 46 47 /// generate the type of a copy constructor for paramType. 48 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 49 FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true ); 55 50 56 51 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. -
src/SymTab/Validate.cc
rd76c588 r8d70648 76 76 #include "SynTree/Visitor.h" // for Visitor 77 77 #include "Validate/HandleAttributes.h" // for handleAttributes 78 #include "Validate/FindSpecialDecls.h" // for FindSpecialDecls 78 79 79 80 class CompoundStmt; … … 288 289 }; 289 290 290 FunctionDecl * dereferenceOperator = nullptr;291 struct FindSpecialDeclarations final {292 void previsit( FunctionDecl * funcDecl );293 };294 295 291 void validate( std::list< Declaration * > &translationUnit, __attribute__((unused)) bool doDebug ) { 296 292 PassVisitor<EnumAndPointerDecay> epc; … … 299 295 PassVisitor<CompoundLiteral> compoundliteral; 300 296 PassVisitor<ValidateGenericParameters> genericParams; 301 PassVisitor<FindSpecialDeclarations> finder;302 297 PassVisitor<LabelAddressFixer> labelAddrFixer; 303 298 PassVisitor<HoistTypeDecls> hoistDecls; … … 378 373 }); 379 374 Stats::Time::TimeBlock("Find Special Declarations", [&]() { 380 acceptAll( translationUnit, finder ); // xxx - remove this pass soon375 Validate::findSpecialDecls( translationUnit ); 381 376 }); 382 377 Stats::Time::TimeBlock("Fix Label Address", [&]() { … … 943 938 if ( eliminator.pass.typedefNames.count( "size_t" ) ) { 944 939 // grab and remember declaration of size_t 945 SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();940 Validate::SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone(); 946 941 } else { 947 942 // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong 948 943 // eventually should have a warning for this case. 949 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );944 Validate::SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 950 945 } 951 946 } … … 1335 1330 // need to resolve array dimensions early so that constructor code can correctly determine 1336 1331 // if a type is a VLA (and hence whether its elements need to be constructed) 1337 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );1332 ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer ); 1338 1333 1339 1334 // must re-evaluate whether a type is a VLA, now that more information is available … … 1372 1367 return addrExpr; 1373 1368 } 1374 1375 void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {1376 if ( ! dereferenceOperator ) {1377 if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) {1378 FunctionType * ftype = funcDecl->get_functionType();1379 if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {1380 dereferenceOperator = funcDecl;1381 }1382 }1383 }1384 }1385 1369 } // namespace SymTab 1386 1370
Note: See TracChangeset
for help on using the changeset viewer.