Changeset a7c90d4 for src/SymTab
- Timestamp:
- Mar 7, 2017, 8:33:43 AM (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:
- 64cb860, c3396e0
- Parents:
- 7fe2498
- Location:
- src/SymTab
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r7fe2498 ra7c90d4 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 3 22:00:55201713 // Update Count : 3012 // Last Modified On : Tue Mar 7 07:42:44 2017 13 // Update Count : 51 14 14 // 15 15 … … 125 125 FunctionType * genDefaultType( Type * paramType ) { 126 126 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr ); 128 128 ftype->get_parameters().push_back( dstParam ); 129 129 … … 134 134 FunctionType * genCopyType( Type * paramType ) { 135 135 FunctionType *ftype = genDefaultType( paramType ); 136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 137 137 ftype->get_parameters().push_back( srcParam ); 138 138 return ftype; … … 142 142 FunctionType * genAssignType( Type * paramType ) { 143 143 FunctionType *ftype = genCopyType( paramType ); 144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 145 145 ftype->get_returnVals().push_back( returnVal ); 146 146 return ftype; … … 161 161 // Routines at global scope marked "static" to prevent multiple definitions in separate translation units 162 162 // because each unit generates copies of the default routines for each aggregate. 163 DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 163 // DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ); 164 165 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 165 FunctionDecl * decl = new FunctionDecl( fname, sc , spec, ftype, new CompoundStmt( noLabels ),166 std::list< Attribute * >(), DeclarationNode::FuncSpecifier ( DeclarationNode::InlineSpec ) );166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 167 168 decl->fixUniqueId(); 168 169 return decl; … … 459 460 continue; 460 461 } 461 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );462 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 462 463 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 463 464 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout ); … … 539 540 for ( Declaration * member : aggregateDecl->get_members() ) { 540 541 if ( DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member ) ) { 541 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );542 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ); 542 543 543 544 FunctionType * memCtorType = ctorType->clone(); … … 604 605 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 605 606 typeInst->set_baseType( typeDecl ); 606 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr );607 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr );607 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr ); 608 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr ); 608 609 609 610 std::list< Statement * > stmts; … … 617 618 } // if 618 619 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 619 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );620 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) ); 620 621 type->get_parameters().push_back( dst ); 621 622 type->get_parameters().push_back( src ); … … 716 717 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 717 718 if ( ! done.count( ty->get_baseType() ) ) { 718 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode:: NoStorageClass, nullptr, TypeDecl::Any );719 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any ); 719 720 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 720 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, genAssignType( inst ), nullptr,721 std::list< Attribute * >(), DeclarationNode::FuncSpec ( DeclarationNode::InlineSpec ) ) );722 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr,723 std::list< Attribute * >(), DeclarationNode::FuncSpec ( DeclarationNode::InlineSpec ) ) );724 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, genCopyType( inst ), nullptr,725 std::list< Attribute * >(), DeclarationNode::FuncSpec ( DeclarationNode::InlineSpec ) ) );726 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr,727 std::list< Attribute * >(), DeclarationNode::FuncSpec ( DeclarationNode::InlineSpec ) ) );721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 728 729 typeParams.push_back( newDecl ); 729 730 done.insert( ty->get_baseType() ); -
src/SymTab/Autogen.h
r7fe2498 ra7c90d4 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 1 16:31:00201713 // Update Count : 212 // Last Modified On : Mon Mar 6 23:33:01 2017 13 // Update Count : 4 14 14 // 15 15 … … 102 102 } 103 103 104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) ); 105 105 106 106 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/FixFunction.cc
r7fe2498 ra7c90d4 10 10 // Created On : Sun May 17 16:19:49 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:31:10 201613 // Update Count : 312 // Last Modified On : Mon Mar 6 23:36:59 2017 13 // Update Count : 6 14 14 // 15 15 … … 21 21 22 22 namespace SymTab { 23 FixFunction::FixFunction() : isVoid( false ) { 24 } 23 FixFunction::FixFunction() : isVoid( false ) {} 25 24 26 25 DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) { 27 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass (), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );26 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() ); 28 27 functionDecl->get_attributes().clear(); 29 28 delete functionDecl; -
src/SymTab/Indexer.cc
r7fe2498 ra7c90d4 10 10 // Created On : Sun May 17 21:37:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:59:19201713 // Update Count : 1 312 // Last Modified On : Tue Mar 7 07:45:32 2017 13 // Update Count : 16 14 14 // 15 15 … … 738 738 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added ); 739 739 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 740 if ( newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern) {740 if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ] ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if -
src/SymTab/Validate.cc
r7fe2498 ra7c90d4 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 3 21:02:23201713 // Update Count : 3 3212 // Last Modified On : Tue Mar 7 07:51:36 2017 13 // Update Count : 349 14 14 // 15 15 … … 97 97 class ReturnTypeFixer final : public Visitor { 98 98 public: 99 100 99 typedef Visitor Parent; 101 100 using Parent::visit; … … 104 103 105 104 virtual void visit( FunctionDecl * functionDecl ); 106 107 105 virtual void visit( FunctionType * ftype ); 108 106 }; … … 161 159 private: 162 160 virtual void visit( FunctionDecl * functionDecl ); 163 164 161 virtual void visit( ReturnStmt * returnStmt ); 165 162 … … 211 208 212 209 class CompoundLiteral final : public GenPoly::DeclMutator { 213 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;210 DeclarationNode::StorageClasses storageClasses; 214 211 215 212 using GenPoly::DeclMutator::mutate; … … 694 691 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { // function type? 695 692 // replace the current object declaration with a function declaration 696 FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClass (), ret->get_linkage(), funtype, 0, objDecl->get_attributes(), ret->get_funcSpec() );693 FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClasses(), ret->get_linkage(), funtype, 0, objDecl->get_attributes(), ret->get_funcSpec() ); 697 694 objDecl->get_attributes().clear(); 698 695 objDecl->set_type( nullptr ); … … 757 754 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 758 755 } // if 759 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode:: NoStorageClass, type ) );756 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::StorageClasses(), type ) ); 760 757 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 761 758 } // if … … 811 808 812 809 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 813 storage class = objectDecl->get_storageClass();810 storageClasses = objectDecl->get_storageClasses(); 814 811 DeclarationWithType * temp = Mutator::mutate( objectDecl ); 815 storageclass = DeclarationNode::NoStorageClass;816 812 return temp; 817 813 } … … 822 818 static UniqueName indexName( "_compLit" ); 823 819 824 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storage class, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );820 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() ); 825 821 compLitExpr->set_type( 0 ); 826 822 compLitExpr->set_initializer( 0 ); … … 861 857 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 862 858 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 863 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );859 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 864 860 deleteAll( retVals ); 865 861 retVals.clear();
Note: See TracChangeset
for help on using the changeset viewer.