Changeset a08ba92 for translator/SymTab


Ignore:
Timestamp:
May 19, 2015, 4:58:14 PM (11 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, stuck-waitfor-destruct, with_gc
Children:
843054c2
Parents:
01aeade
Message:

licencing: sixth groups of files

Location:
translator/SymTab
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • translator/SymTab/IdTable.cc

    r01aeade ra08ba92  
    139139                                std::stack<DeclEntry> stack = inner->second;
    140140                                os << "dumping a stack" << std::endl;
    141                                 while (! stack.empty()) {
     141                                while ( ! stack.empty()) {
    142142                                        DeclEntry d = stack.top();
    143143                                        os << outer->first << " (" << inner->first << ") (" << d.second << ") " << std::endl;
  • translator/SymTab/IdTable.h

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:30:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:31:45 2015
    13 // Update Count     : 3
     12// Last Modified On : Tue May 19 16:49:33 2015
     13// Update Count     : 4
    1414//
    1515
     
    2525
    2626namespace SymTab {
    27     class IdTable {
    28       public:
     27        class IdTable {
     28          public:
    2929                IdTable();
    3030 
     
    3636 
    3737                void dump( std::ostream &os ) const;                    // debugging
    38       private:
     38          private:
    3939                typedef std::pair< DeclarationWithType*, int > DeclEntry;
    4040                typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
     
    4343                OuterTableType table;
    4444                int scopeLevel;
    45     };
     45        };
    4646} // namespace SymTab
    4747
  • translator/SymTab/Indexer.cc

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:38:44 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:49:55 2015
     13// Update Count     : 3
    1414//
    1515
     
    2626
    2727namespace SymTab {
    28     Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {}
    29 
    30     Indexer::~Indexer() {}
    31 
    32     void Indexer::visit( ObjectDecl *objectDecl ) {
     28        Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {}
     29
     30        Indexer::~Indexer() {}
     31
     32        void Indexer::visit( ObjectDecl *objectDecl ) {
    3333                maybeAccept( objectDecl->get_type(), *this );
    3434                maybeAccept( objectDecl->get_init(), *this );
     
    3838                        idTable.addDecl( objectDecl );
    3939                } // if
    40     }
    41 
    42     void Indexer::visit( FunctionDecl *functionDecl ) {
     40        }
     41
     42        void Indexer::visit( FunctionDecl *functionDecl ) {
    4343                if ( functionDecl->get_name() == "" ) return;
    4444                debugPrint( "Adding function " << functionDecl->get_name() << std::endl );
     
    4949                maybeAccept( functionDecl->get_statements(), *this );
    5050                leaveScope();
    51     }
     51        }
    5252
    5353/********
     
    7070 */
    7171
    72     void Indexer::visit( TypeDecl *typeDecl ) {
     72        void Indexer::visit( TypeDecl *typeDecl ) {
    7373                // see A NOTE ON THE ORDER OF TRAVERSAL, above
    7474                // note that assertions come after the type is added to the symtab, since they aren't part
     
    8181                typeTable.add( typeDecl );
    8282                acceptAll( typeDecl->get_assertions(), *this );
    83     }
    84 
    85     void Indexer::visit( TypedefDecl *typeDecl ) {
     83        }
     84
     85        void Indexer::visit( TypedefDecl *typeDecl ) {
    8686                enterScope();
    8787                acceptAll( typeDecl->get_parameters(), *this );
     
    9090                debugPrint( "Adding typedef " << typeDecl->get_name() << std::endl );
    9191                typeTable.add( typeDecl );
    92     }
    93 
    94     void Indexer::visit( StructDecl *aggregateDecl ) {
     92        }
     93
     94        void Indexer::visit( StructDecl *aggregateDecl ) {
    9595                // make up a forward declaration and add it before processing the members
    9696                StructDecl fwdDecl( aggregateDecl->get_name() );
     
    107107                // this addition replaces the forward declaration
    108108                structTable.add( aggregateDecl );
    109     }
    110 
    111     void Indexer::visit( UnionDecl *aggregateDecl ) {
     109        }
     110
     111        void Indexer::visit( UnionDecl *aggregateDecl ) {
    112112                // make up a forward declaration and add it before processing the members
    113113                UnionDecl fwdDecl( aggregateDecl->get_name() );
     
    123123                debugPrint( "Adding union " << aggregateDecl->get_name() << std::endl );
    124124                unionTable.add( aggregateDecl );
    125     }
    126 
    127     void Indexer::visit( EnumDecl *aggregateDecl ) {
     125        }
     126
     127        void Indexer::visit( EnumDecl *aggregateDecl ) {
    128128                debugPrint( "Adding enum " << aggregateDecl->get_name() << std::endl );
    129129                enumTable.add( aggregateDecl );
    130130                // unlike structs, contexts, and unions, enums inject their members into the global scope
    131131                acceptAll( aggregateDecl->get_members(), *this );
    132     }
    133 
    134     void Indexer::visit( ContextDecl *aggregateDecl ) {
     132        }
     133
     134        void Indexer::visit( ContextDecl *aggregateDecl ) {
    135135                enterScope();
    136136                acceptAll( aggregateDecl->get_parameters(), *this );
     
    140140                debugPrint( "Adding context " << aggregateDecl->get_name() << std::endl );
    141141                contextTable.add( aggregateDecl );
    142     }
    143 
    144     void Indexer::visit( CompoundStmt *compoundStmt ) {
     142        }
     143
     144        void Indexer::visit( CompoundStmt *compoundStmt ) {
    145145                enterScope();
    146146                acceptAll( compoundStmt->get_kids(), *this );
    147147                leaveScope();
    148     }
    149 
    150     void Indexer::visit( ContextInstType *contextInst ) {
     148        }
     149
     150        void Indexer::visit( ContextInstType *contextInst ) {
    151151                acceptAll( contextInst->get_parameters(), *this );
    152152                acceptAll( contextInst->get_members(), *this );
    153     }
    154 
    155     void Indexer::visit( StructInstType *structInst ) {
     153        }
     154
     155        void Indexer::visit( StructInstType *structInst ) {
    156156                if ( ! structTable.lookup( structInst->get_name() ) ) {
    157157                        debugPrint( "Adding struct " << structInst->get_name() << " from implicit forward declaration" << std::endl );
     
    161161                acceptAll( structInst->get_parameters(), *this );
    162162                leaveScope();
    163     }
    164 
    165     void Indexer::visit( UnionInstType *unionInst ) {
     163        }
     164
     165        void Indexer::visit( UnionInstType *unionInst ) {
    166166                if ( ! unionTable.lookup( unionInst->get_name() ) ) {
    167167                        debugPrint( "Adding union " << unionInst->get_name() << " from implicit forward declaration" << std::endl );
     
    171171                acceptAll( unionInst->get_parameters(), *this );
    172172                leaveScope();
    173     }
    174 
    175     void Indexer::visit( ForStmt *forStmt ) {
    176         // for statements introduce a level of scope
    177         enterScope();
    178         Visitor::visit( forStmt );
    179         leaveScope();
    180     }
    181 
    182 
    183     void Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const {
     173        }
     174
     175        void Indexer::visit( ForStmt *forStmt ) {
     176            // for statements introduce a level of scope
     177            enterScope();
     178            Visitor::visit( forStmt );
     179            leaveScope();
     180        }
     181
     182
     183        void Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const {
    184184                idTable.lookupId( id, list );
    185     }
    186 
    187     DeclarationWithType* Indexer::lookupId( const std::string &id) const {
     185        }
     186
     187        DeclarationWithType* Indexer::lookupId( const std::string &id) const {
    188188                return idTable.lookupId(id);
    189     }
    190 
    191     NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
     189        }
     190
     191        NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
    192192                return typeTable.lookup( id );
    193     }
    194 
    195     StructDecl *Indexer::lookupStruct( const std::string &id ) const {
     193        }
     194
     195        StructDecl *Indexer::lookupStruct( const std::string &id ) const {
    196196                return structTable.lookup( id );
    197     }
    198 
    199     EnumDecl *Indexer::lookupEnum( const std::string &id ) const {
     197        }
     198
     199        EnumDecl *Indexer::lookupEnum( const std::string &id ) const {
    200200                return enumTable.lookup( id );
    201     }
    202 
    203     UnionDecl *Indexer::lookupUnion( const std::string &id ) const {
     201        }
     202
     203        UnionDecl *Indexer::lookupUnion( const std::string &id ) const {
    204204                return unionTable.lookup( id );
    205     }
    206 
    207     ContextDecl  * Indexer::lookupContext( const std::string &id ) const {
     205        }
     206
     207        ContextDecl  * Indexer::lookupContext( const std::string &id ) const {
    208208                return contextTable.lookup( id );
    209     }
    210 
    211     void Indexer::enterScope() {
     209        }
     210
     211        void Indexer::enterScope() {
    212212                if ( doDebug ) {
    213213                        std::cout << "--- Entering scope" << std::endl;
     
    219219                unionTable.enterScope();
    220220                contextTable.enterScope();
    221     }
    222 
    223     void Indexer::leaveScope() {
     221        }
     222
     223        void Indexer::leaveScope() {
    224224                using std::cout;
    225225                using std::endl;
     
    240240                unionTable.leaveScope();
    241241                contextTable.leaveScope();
    242     }
    243 
    244     void Indexer::print( std::ostream &os, int indent ) const {
    245         using std::cerr;
    246         using std::endl;
    247 
    248         cerr << "===idTable===" << endl;
    249         idTable.dump( os );
    250         cerr << "===typeTable===" << endl;
    251         typeTable.dump( os );
    252         cerr << "===structTable===" << endl;
    253         structTable.dump( os );
    254         cerr << "===enumTable===" << endl;
    255         enumTable.dump( os );
    256         cerr << "===unionTable===" << endl;
    257         unionTable.dump( os );
    258         cerr << "===contextTable===" << endl;
    259         contextTable.dump( os );
     242        }
     243
     244        void Indexer::print( std::ostream &os, int indent ) const {
     245            using std::cerr;
     246            using std::endl;
     247
     248            cerr << "===idTable===" << endl;
     249            idTable.dump( os );
     250            cerr << "===typeTable===" << endl;
     251            typeTable.dump( os );
     252            cerr << "===structTable===" << endl;
     253            structTable.dump( os );
     254            cerr << "===enumTable===" << endl;
     255            enumTable.dump( os );
     256            cerr << "===unionTable===" << endl;
     257            unionTable.dump( os );
     258            cerr << "===contextTable===" << endl;
     259            contextTable.dump( os );
    260260#if 0
    261261                idTable.dump( os );
     
    266266                contextTable.dump( os );
    267267#endif
    268     }
     268        }
    269269} // namespace SymTab
    270270
  • translator/SymTab/Indexer.h

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:38:55 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:40:17 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:51:21 2015
     13// Update Count     : 3
    1414//
    1515
     
    2727
    2828namespace SymTab {
    29     class Indexer : public Visitor {
    30       public:
    31         Indexer( bool useDebug = false );
    32         virtual ~Indexer();
     29        class Indexer : public Visitor {
     30          public:
     31                Indexer( bool useDebug = false );
     32                virtual ~Indexer();
    3333
    34         //using Visitor::visit;
    35         virtual void visit( ObjectDecl *objectDecl );
    36         virtual void visit( FunctionDecl *functionDecl );
    37         virtual void visit( TypeDecl *typeDecl );
    38         virtual void visit( TypedefDecl *typeDecl );
    39         virtual void visit( StructDecl *aggregateDecl );
    40         virtual void visit( UnionDecl *aggregateDecl );
    41         virtual void visit( EnumDecl *aggregateDecl );
    42         virtual void visit( ContextDecl *aggregateDecl );
     34                //using Visitor::visit;
     35                virtual void visit( ObjectDecl *objectDecl );
     36                virtual void visit( FunctionDecl *functionDecl );
     37                virtual void visit( TypeDecl *typeDecl );
     38                virtual void visit( TypedefDecl *typeDecl );
     39                virtual void visit( StructDecl *aggregateDecl );
     40                virtual void visit( UnionDecl *aggregateDecl );
     41                virtual void visit( EnumDecl *aggregateDecl );
     42                virtual void visit( ContextDecl *aggregateDecl );
    4343
    44         virtual void visit( CompoundStmt *compoundStmt );
     44                virtual void visit( CompoundStmt *compoundStmt );
    4545
    46         virtual void visit( ContextInstType *contextInst );
    47         virtual void visit( StructInstType *contextInst );
    48         virtual void visit( UnionInstType *contextInst );
     46                virtual void visit( ContextInstType *contextInst );
     47                virtual void visit( StructInstType *contextInst );
     48                virtual void visit( UnionInstType *contextInst );
    4949
    50         virtual void visit( ForStmt *forStmt );
     50                virtual void visit( ForStmt *forStmt );
    5151
    52         // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
    53         // explicitly when scopes begin and end
    54         void enterScope();
    55         void leaveScope();
     52                // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
     53                // explicitly when scopes begin and end
     54                void enterScope();
     55                void leaveScope();
    5656
    57         void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
    58         DeclarationWithType* lookupId( const std::string &id) const;
    59         NamedTypeDecl *lookupType( const std::string &id ) const;
    60         StructDecl *lookupStruct( const std::string &id ) const;
    61         EnumDecl *lookupEnum( const std::string &id ) const;
    62         UnionDecl *lookupUnion( const std::string &id ) const;
    63         ContextDecl *lookupContext( const std::string &id ) const;
     57                void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
     58                DeclarationWithType* lookupId( const std::string &id) const;
     59                NamedTypeDecl *lookupType( const std::string &id ) const;
     60                StructDecl *lookupStruct( const std::string &id ) const;
     61                EnumDecl *lookupEnum( const std::string &id ) const;
     62                UnionDecl *lookupUnion( const std::string &id ) const;
     63                ContextDecl *lookupContext( const std::string &id ) const;
    6464 
    65         void print( std::ostream &os, int indent = 0 ) const;
    66       private:
    67         IdTable idTable;
    68         TypeTable typeTable;
    69         StructTable structTable;
    70         EnumTable enumTable;
    71         UnionTable unionTable;
    72         ContextTable contextTable;
     65                void print( std::ostream &os, int indent = 0 ) const;
     66          private:
     67                IdTable idTable;
     68                TypeTable typeTable;
     69                StructTable structTable;
     70                EnumTable enumTable;
     71                UnionTable unionTable;
     72                ContextTable contextTable;
    7373 
    74         bool doDebug;                                   // display debugging trace
    75     };
     74                bool doDebug;                                   // display debugging trace
     75        };
    7676} // namespace SymTab
    7777
  • translator/SymTab/Mangler.cc

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:43:49 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:50:47 2015
     13// Update Count     : 3
    1414//
    1515
     
    3030
    3131namespace SymTab {
    32     Mangler::Mangler() : nextVarNum( 0 ), isTopLevel( true ) {
     32        Mangler::Mangler() : nextVarNum( 0 ), isTopLevel( true ) {
    3333        }
    3434
     
    3737//{
    3838//}
    39     Mangler::Mangler( const Mangler &rhs ) : mangleName() {
     39        Mangler::Mangler( const Mangler &rhs ) : mangleName() {
    4040                varNums = rhs.varNums;
    4141                nextVarNum = rhs.nextVarNum;
    4242                isTopLevel = rhs.isTopLevel;
    43     }
    44 
    45     void Mangler::mangleDecl( DeclarationWithType *declaration ) {
     43        }
     44
     45        void Mangler::mangleDecl( DeclarationWithType *declaration ) {
    4646                bool wasTopLevel = isTopLevel;
    4747                if ( isTopLevel ) {
     
    6060                maybeAccept( declaration->get_type(), *this );
    6161                isTopLevel = wasTopLevel;
    62     }
    63 
    64     void Mangler::visit( ObjectDecl *declaration ) {
     62        }
     63
     64        void Mangler::visit( ObjectDecl *declaration ) {
    6565                mangleDecl( declaration );
    66     }
    67 
    68     void Mangler::visit( FunctionDecl *declaration ) {
     66        }
     67
     68        void Mangler::visit( FunctionDecl *declaration ) {
    6969                mangleDecl( declaration );
    70     }
    71 
    72     void Mangler::visit( VoidType *voidType ) {
     70        }
     71
     72        void Mangler::visit( VoidType *voidType ) {
    7373                printQualifiers( voidType );
    7474                mangleName << "v";
    75     }
    76 
    77     void Mangler::visit( BasicType *basicType ) {
     75        }
     76
     77        void Mangler::visit( BasicType *basicType ) {
    7878                static const char *btLetter[] = {
    7979                        "b",    // Bool
     
    102102                printQualifiers( basicType );
    103103                mangleName << btLetter[ basicType->get_kind() ];
    104     }
    105 
    106     void Mangler::visit( PointerType *pointerType ) {
     104        }
     105
     106        void Mangler::visit( PointerType *pointerType ) {
    107107                printQualifiers( pointerType );
    108108                mangleName << "P";
    109109                maybeAccept( pointerType->get_base(), *this );
    110     }
    111 
    112     void Mangler::visit( ArrayType *arrayType ) {
     110        }
     111
     112        void Mangler::visit( ArrayType *arrayType ) {
    113113                // TODO: encode dimension
    114114                printQualifiers( arrayType );
    115115                mangleName << "A0";
    116116                maybeAccept( arrayType->get_base(), *this );
    117     }
    118 
    119     namespace {
     117        }
     118
     119        namespace {
    120120                inline std::list< Type* > getTypes( const std::list< DeclarationWithType* > decls ) {
    121121                        std::list< Type* > ret;
     
    124124                        return ret;
    125125                }
    126     }
    127 
    128     void Mangler::visit( FunctionType *functionType ) {
     126        }
     127
     128        void Mangler::visit( FunctionType *functionType ) {
    129129                printQualifiers( functionType );
    130130                mangleName << "F";
     
    135135                acceptAll( paramTypes, *this );
    136136                mangleName << "_";
    137     }
    138 
    139     void Mangler::mangleRef( ReferenceToType *refType, std::string prefix ) {
     137        }
     138
     139        void Mangler::mangleRef( ReferenceToType *refType, std::string prefix ) {
    140140                printQualifiers( refType );
    141141                mangleName << ( refType->get_name().length() + prefix.length() ) << prefix << refType->get_name();
    142     }
    143 
    144     void Mangler::visit( StructInstType *aggregateUseType ) {
     142        }
     143
     144        void Mangler::visit( StructInstType *aggregateUseType ) {
    145145                mangleRef( aggregateUseType, "s" );
    146     }
    147 
    148     void Mangler::visit( UnionInstType *aggregateUseType ) {
     146        }
     147
     148        void Mangler::visit( UnionInstType *aggregateUseType ) {
    149149                mangleRef( aggregateUseType, "u" );
    150     }
    151 
    152     void Mangler::visit( EnumInstType *aggregateUseType ) {
     150        }
     151
     152        void Mangler::visit( EnumInstType *aggregateUseType ) {
    153153                mangleRef( aggregateUseType, "e" );
    154     }
    155 
    156     void Mangler::visit( TypeInstType *typeInst ) {
     154        }
     155
     156        void Mangler::visit( TypeInstType *typeInst ) {
    157157                VarMapType::iterator varNum = varNums.find( typeInst->get_name() );
    158158                if ( varNum == varNums.end() ) {
     
    176176                        mangleName << std::string( numStream.str(), numStream.pcount() );
    177177                } // if
    178     }
    179 
    180     void Mangler::visit( TupleType *tupleType ) {
     178        }
     179
     180        void Mangler::visit( TupleType *tupleType ) {
    181181                printQualifiers( tupleType );
    182182                mangleName << "T";
    183183                acceptAll( tupleType->get_types(), *this );
    184184                mangleName << "_";
    185     }
    186 
    187     void Mangler::visit( TypeDecl *decl ) {
     185        }
     186
     187        void Mangler::visit( TypeDecl *decl ) {
    188188                static const char *typePrefix[] = { "BT", "BD", "BF" };
    189189                mangleName << typePrefix[ decl->get_kind() ] << ( decl->get_name().length() + 1 ) << decl->get_name();
    190     }
    191 
    192     void printVarMap( const std::map< std::string, std::pair< int, int > > &varMap, std::ostream &os ) {
     190        }
     191
     192        void printVarMap( const std::map< std::string, std::pair< int, int > > &varMap, std::ostream &os ) {
    193193                for ( std::map< std::string, std::pair< int, int > >::const_iterator i = varMap.begin(); i != varMap.end(); ++i ) {
    194194                        os << i->first << "(" << i->second.first << "/" << i->second.second << ")" << std::endl;
    195195                } // for
    196     }
    197 
    198     void Mangler::printQualifiers( Type *type ) {
     196        }
     197
     198        void Mangler::printQualifiers( Type *type ) {
    199199                if ( ! type->get_forall().empty() ) {
    200200                        std::list< std::string > assertionNames;
     
    242242                        mangleName << "A";
    243243                } // if
    244     }
     244        }
    245245} // namespace SymTab
    246246
  • translator/SymTab/Mangler.h

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:44:03 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:45:05 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:49:21 2015
     13// Update Count     : 3
    1414//
    1515
     
    2222
    2323namespace SymTab {
    24     class Mangler : public Visitor {
    25       public:
     24        class Mangler : public Visitor {
     25          public:
    2626                template< typename SynTreeClass >
    2727            static std::string mangle( SynTreeClass *decl ); // interface to clients
     
    4444 
    4545                std::string get_mangleName() { return std::string( mangleName.str(), mangleName.pcount() ); }
    46       private:
     46          private:
    4747                std::ostrstream mangleName;
    4848                typedef std::map< std::string, std::pair< int, int > > VarMapType;
     
    5858 
    5959                void printQualifiers( Type *type );
    60     }; // Mangler
     60        }; // Mangler
    6161
    62     template< typename SynTreeClass >
    63     std::string Mangler::mangle( SynTreeClass *decl ) {
     62        template< typename SynTreeClass >
     63        std::string Mangler::mangle( SynTreeClass *decl ) {
    6464                Mangler mangler;
    6565                maybeAccept( decl, mangler );
    6666                return mangler.get_mangleName();
    67     }
     67        }
    6868} // SymTab
    6969
  • translator/SymTab/StackTable.cc

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:45:15 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:46:59 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:51:53 2015
     13// Update Count     : 3
    1414//
    1515
     
    1919
    2020namespace SymTab {
    21     template< typename Element, typename ConflictFunction >
    22     StackTable< Element, ConflictFunction >::StackTable() : scopeLevel( 0 ) {
     21        template< typename Element, typename ConflictFunction >
     22        StackTable< Element, ConflictFunction >::StackTable() : scopeLevel( 0 ) {
    2323        }
    2424
    25     template< typename Element, typename ConflictFunction >
    26     void StackTable< Element, ConflictFunction >::enterScope() {
     25        template< typename Element, typename ConflictFunction >
     26        void StackTable< Element, ConflictFunction >::enterScope() {
    2727                scopeLevel++;
    28     }
     28        }
    2929
    30     template< typename Element, typename ConflictFunction >
    31     void StackTable< Element, ConflictFunction >::leaveScope() {
     30        template< typename Element, typename ConflictFunction >
     31        void StackTable< Element, ConflictFunction >::leaveScope() {
    3232                for ( typename TableType::iterator it = table.begin(); it != table.end(); ++it ) {
    3333                        std::stack< Entry >& entry = it->second;
     
    3838                scopeLevel--;
    3939                assert( scopeLevel >= 0 );
    40     }
     40        }
    4141
    42     template< typename Element, typename ConflictFunction >
    43     void StackTable< Element, ConflictFunction >::add( Element *type ) {
     42        template< typename Element, typename ConflictFunction >
     43        void StackTable< Element, ConflictFunction >::add( Element *type ) {
    4444                std::stack< Entry >& entry = table[ type->get_name() ];
    4545                if ( ! entry.empty() && entry.top().second == scopeLevel ) {
     
    4848                        entry.push( Entry( type, scopeLevel ) );
    4949                } // if
    50     }
     50        }
    5151
    52     template< typename Element, typename ConflictFunction >
    53     void StackTable< Element, ConflictFunction >::add( std::string fwdDeclName ) {
     52        template< typename Element, typename ConflictFunction >
     53        void StackTable< Element, ConflictFunction >::add( std::string fwdDeclName ) {
    5454                add( new Element( fwdDeclName ) );
    55     }
     55        }
    5656
    57     template< typename Element, typename ConflictFunction >
    58     Element *StackTable< Element, ConflictFunction >::lookup( std::string id ) const {
     57        template< typename Element, typename ConflictFunction >
     58        Element *StackTable< Element, ConflictFunction >::lookup( std::string id ) const {
    5959                typename TableType::const_iterator it = table.find( id );
    6060                if ( it == table.end() ) {
     
    6565                        return 0;
    6666                } // if
    67     }
     67        }
    6868
    69     template< typename Element, typename ConflictFunction >
    70     void StackTable< Element, ConflictFunction >::dump( std::ostream &os ) const {
     69        template< typename Element, typename ConflictFunction >
     70        void StackTable< Element, ConflictFunction >::dump( std::ostream &os ) const {
    7171                for ( typename TableType::const_iterator it = table.begin(); it != table.end(); ++it ) {
    7272                        const std::stack< Entry >& entry = it->second;
     
    7575                        } // if
    7676                } // for
    77     }
     77        }
    7878} // namespace SymTab
    7979
  • translator/SymTab/StackTable.h

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:47:10 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:48:15 2015
    13 // Update Count     : 3
     12// Last Modified On : Tue May 19 16:50:36 2015
     13// Update Count     : 4
    1414//
    1515
     
    2323
    2424namespace SymTab {
    25     template< typename Element, typename ConflictFunction >
     25        template< typename Element, typename ConflictFunction >
    2626        class StackTable {
    27       public:
     27          public:
    2828                StackTable();
    2929
     
    3535
    3636                void dump( std::ostream &os ) const;                    // debugging
    37       private:
     37          private:
    3838                typedef std::pair< Element*, int > Entry;
    3939                typedef std::map< std::string, std::stack< Entry > > TableType;
     
    4242                TableType table;
    4343                int scopeLevel;
    44     };
     44        };
    4545} // SymTab
    4646
  • translator/SymTab/TypeTable.h

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:48:32 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:49:49 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:50:25 2015
     13// Update Count     : 3
    1414//
    1515
     
    2727
    2828namespace SymTab {
    29     class TypeTableConflictFunction : public std::binary_function< NamedTypeDecl *, NamedTypeDecl *, NamedTypeDecl * > {
    30       public:
     29        class TypeTableConflictFunction : public std::binary_function< NamedTypeDecl *, NamedTypeDecl *, NamedTypeDecl * > {
     30          public:
    3131                NamedTypeDecl *operator()( NamedTypeDecl *existing, NamedTypeDecl *added ) {
    3232                        if ( existing->get_base() == 0 ) {
     
    4040                        return 0;
    4141                }
    42     };
     42        };
    4343
    44     typedef StackTable< NamedTypeDecl, TypeTableConflictFunction > TypeTable;
     44        typedef StackTable< NamedTypeDecl, TypeTableConflictFunction > TypeTable;
    4545} // namespace SymTab
    4646
  • translator/SymTab/Validate.cc

    r01aeade ra08ba92  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 21:53:16 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 16:50:09 2015
     13// Update Count     : 3
    1414//
    1515
     
    5757
    5858namespace SymTab {
    59     class HoistStruct : public Visitor {
    60       public:
     59        class HoistStruct : public Visitor {
     60          public:
    6161                static void hoistStruct( std::list< Declaration * > &translationUnit );
    6262 
     
    7474                virtual void visit( CaseStmt *caseStmt );
    7575                virtual void visit( CatchStmt *catchStmt );
    76       private:
     76          private:
    7777                HoistStruct();
    7878
     
    8181                std::list< Declaration * > declsToAdd;
    8282                bool inStruct;
    83     };
    84 
    85     class Pass1 : public Visitor {
     83        };
     84
     85        class Pass1 : public Visitor {
    8686                typedef Visitor Parent;
    8787                virtual void visit( EnumDecl *aggregateDecl );
    8888                virtual void visit( FunctionType *func );
    89     };
    90  
    91     class Pass2 : public Indexer {
     89        };
     90 
     91        class Pass2 : public Indexer {
    9292                typedef Indexer Parent;
    93       public:
     93          public:
    9494                Pass2( bool doDebug, const Indexer *indexer );
    95       private:
     95          private:
    9696                virtual void visit( StructInstType *structInst );
    9797                virtual void visit( UnionInstType *unionInst );
     
    107107                ForwardStructsType forwardStructs;
    108108                ForwardUnionsType forwardUnions;
    109     };
    110 
    111     class Pass3 : public Indexer {
     109        };
     110
     111        class Pass3 : public Indexer {
    112112                typedef Indexer Parent;
    113       public:
     113          public:
    114114                Pass3( const Indexer *indexer );
    115       private:
     115          private:
    116116                virtual void visit( ObjectDecl *object );
    117117                virtual void visit( FunctionDecl *func );
    118118
    119119                const Indexer *indexer;
    120     };
    121 
    122     class AddStructAssignment : public Visitor {
    123       public:
     120        };
     121
     122        class AddStructAssignment : public Visitor {
     123          public:
    124124                static void addStructAssignment( std::list< Declaration * > &translationUnit );
    125125
     
    145145
    146146                AddStructAssignment() : functionNesting( 0 ) {}
    147       private:
     147          private:
    148148                template< typename StmtClass > void visitStatement( StmtClass *stmt );
    149149 
     
    151151                std::set< std::string > structsDone;
    152152                unsigned int functionNesting;                   // current level of nested functions
    153     };
    154 
    155     class EliminateTypedef : public Mutator {
    156       public:
     153        };
     154
     155        class EliminateTypedef : public Mutator {
     156          public:
    157157                static void eliminateTypedef( std::list< Declaration * > &translationUnit );
    158       private:
     158          private:
    159159                virtual Declaration *mutate( TypedefDecl *typeDecl );
    160160                virtual TypeDecl *mutate( TypeDecl *typeDecl );
     
    166166 
    167167                std::map< std::string, TypedefDecl * > typedefNames;
    168     };
    169 
    170     void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
     168        };
     169
     170        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    171171                Pass1 pass1;
    172172                Pass2 pass2( doDebug, 0 );
     
    178178                AddStructAssignment::addStructAssignment( translationUnit );
    179179                acceptAll( translationUnit, pass3 );
    180     }
    181    
    182     void validateType( Type *type, const Indexer *indexer ) {
     180        }
     181       
     182        void validateType( Type *type, const Indexer *indexer ) {
    183183                Pass1 pass1;
    184184                Pass2 pass2( false, indexer );
     
    187187                type->accept( pass2 );
    188188                type->accept( pass3 );
    189     }
    190 
    191     template< typename Visitor >
    192     void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {
     189        }
     190
     191        template< typename Visitor >
     192        void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {
    193193                std::list< Declaration * >::iterator i = translationUnit.begin();
    194194                while ( i != translationUnit.end() ) {
     
    201201                        i = next;
    202202                } // while
    203     }
    204 
    205     void HoistStruct::hoistStruct( std::list< Declaration * > &translationUnit ) {
     203        }
     204
     205        void HoistStruct::hoistStruct( std::list< Declaration * > &translationUnit ) {
    206206                HoistStruct hoister;
    207207                acceptAndAdd( translationUnit, hoister, true );
    208     }
    209 
    210     HoistStruct::HoistStruct() : inStruct( false ) {
    211     }
    212 
    213     void filter( std::list< Declaration * > &declList, bool (*pred)( Declaration * ), bool doDelete ) {
     208        }
     209
     210        HoistStruct::HoistStruct() : inStruct( false ) {
     211        }
     212
     213        void filter( std::list< Declaration * > &declList, bool (*pred)( Declaration * ), bool doDelete ) {
    214214                std::list< Declaration * >::iterator i = declList.begin();
    215215                while ( i != declList.end() ) {
     
    224224                        i = next;
    225225                } // while
    226     }
    227 
    228     bool isStructOrUnion( Declaration *decl ) {
     226        }
     227
     228        bool isStructOrUnion( Declaration *decl ) {
    229229                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
    230     }
    231 
    232     template< typename AggDecl >
    233     void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) {
     230        }
     231
     232        template< typename AggDecl >
     233        void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) {
    234234                if ( inStruct ) {
    235235                        // Add elements in stack order corresponding to nesting structure.
     
    243243                // Always remove the hoisted aggregate from the inner structure.
    244244                filter( aggregateDecl->get_members(), isStructOrUnion, false );
    245     }
    246 
    247     void HoistStruct::visit( StructDecl *aggregateDecl ) {
     245        }
     246
     247        void HoistStruct::visit( StructDecl *aggregateDecl ) {
    248248                handleAggregate( aggregateDecl );
    249     }
    250 
    251     void HoistStruct::visit( UnionDecl *aggregateDecl ) {
     249        }
     250
     251        void HoistStruct::visit( UnionDecl *aggregateDecl ) {
    252252                handleAggregate( aggregateDecl );
    253     }
    254 
    255     void HoistStruct::visit( CompoundStmt *compoundStmt ) {
     253        }
     254
     255        void HoistStruct::visit( CompoundStmt *compoundStmt ) {
    256256                addVisit( compoundStmt, *this );
    257     }
    258 
    259     void HoistStruct::visit( IfStmt *ifStmt ) {
     257        }
     258
     259        void HoistStruct::visit( IfStmt *ifStmt ) {
    260260                addVisit( ifStmt, *this );
    261     }
    262 
    263     void HoistStruct::visit( WhileStmt *whileStmt ) {
     261        }
     262
     263        void HoistStruct::visit( WhileStmt *whileStmt ) {
    264264                addVisit( whileStmt, *this );
    265     }
    266 
    267     void HoistStruct::visit( ForStmt *forStmt ) {
     265        }
     266
     267        void HoistStruct::visit( ForStmt *forStmt ) {
    268268                addVisit( forStmt, *this );
    269     }
    270 
    271     void HoistStruct::visit( SwitchStmt *switchStmt ) {
     269        }
     270
     271        void HoistStruct::visit( SwitchStmt *switchStmt ) {
    272272                addVisit( switchStmt, *this );
    273     }
    274 
    275     void HoistStruct::visit( ChooseStmt *switchStmt ) {
     273        }
     274
     275        void HoistStruct::visit( ChooseStmt *switchStmt ) {
    276276                addVisit( switchStmt, *this );
    277     }
    278 
    279     void HoistStruct::visit( CaseStmt *caseStmt ) {
     277        }
     278
     279        void HoistStruct::visit( CaseStmt *caseStmt ) {
    280280                addVisit( caseStmt, *this );
    281     }
    282 
    283     void HoistStruct::visit( CatchStmt *cathStmt ) {
     281        }
     282
     283        void HoistStruct::visit( CatchStmt *cathStmt ) {
    284284                addVisit( cathStmt, *this );
    285     }
    286 
    287     void Pass1::visit( EnumDecl *enumDecl ) {
     285        }
     286
     287        void Pass1::visit( EnumDecl *enumDecl ) {
    288288                // Set the type of each member of the enumeration to be EnumConstant
    289289 
     
    294294                } // for
    295295                Parent::visit( enumDecl );
    296     }
    297 
    298     namespace {
     296        }
     297
     298        namespace {
    299299                template< typename DWTIterator >
    300300                void fixFunctionList( DWTIterator begin, DWTIterator end, FunctionType *func ) {
     
    323323                        } // if
    324324                }
    325     }
    326 
    327     void Pass1::visit( FunctionType *func ) {
     325        }
     326
     327        void Pass1::visit( FunctionType *func ) {
    328328                // Fix up parameters and return types
    329329                fixFunctionList( func->get_parameters().begin(), func->get_parameters().end(), func );
    330330                fixFunctionList( func->get_returnVals().begin(), func->get_returnVals().end(), func );
    331331                Visitor::visit( func );
    332     }
    333 
    334     Pass2::Pass2( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {
     332        }
     333
     334        Pass2::Pass2( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {
    335335                if ( other_indexer ) {
    336336                        indexer = other_indexer;
     
    338338                        indexer = this;
    339339                } // if
    340     }
    341 
    342     void Pass2::visit( StructInstType *structInst ) {
     340        }
     341
     342        void Pass2::visit( StructInstType *structInst ) {
    343343                Parent::visit( structInst );
    344344                StructDecl *st = indexer->lookupStruct( structInst->get_name() );
     
    352352                        forwardStructs[ structInst->get_name() ].push_back( structInst );
    353353                } // if
    354     }
    355 
    356     void Pass2::visit( UnionInstType *unionInst ) {
     354        }
     355
     356        void Pass2::visit( UnionInstType *unionInst ) {
    357357                Parent::visit( unionInst );
    358358                UnionDecl *un = indexer->lookupUnion( unionInst->get_name() );
     
    365365                        forwardUnions[ unionInst->get_name() ].push_back( unionInst );
    366366                } // if
    367     }
    368 
    369     void Pass2::visit( ContextInstType *contextInst ) {
     367        }
     368
     369        void Pass2::visit( ContextInstType *contextInst ) {
    370370                Parent::visit( contextInst );
    371371                ContextDecl *ctx = indexer->lookupContext( contextInst->get_name() );
     
    383383                } // for
    384384                applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) );
    385     }
    386 
    387     void Pass2::visit( StructDecl *structDecl ) {
     385        }
     386
     387        void Pass2::visit( StructDecl *structDecl ) {
    388388                if ( ! structDecl->get_members().empty() ) {
    389389                        ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->get_name() );
     
    396396                } // if
    397397                Indexer::visit( structDecl );
    398     }
    399 
    400     void Pass2::visit( UnionDecl *unionDecl ) {
     398        }
     399
     400        void Pass2::visit( UnionDecl *unionDecl ) {
    401401                if ( ! unionDecl->get_members().empty() ) {
    402402                        ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->get_name() );
     
    409409                } // if
    410410                Indexer::visit( unionDecl );
    411     }
    412 
    413     void Pass2::visit( TypeInstType *typeInst ) {
     411        }
     412
     413        void Pass2::visit( TypeInstType *typeInst ) {
    414414                if ( NamedTypeDecl *namedTypeDecl = lookupType( typeInst->get_name() ) ) {
    415415                        if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) {
     
    417417                        } // if
    418418                } // if
    419     }
    420 
    421     Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
     419        }
     420
     421        Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
    422422                if ( other_indexer ) {
    423423                        indexer = other_indexer;
     
    425425                        indexer = this;
    426426                } // if
    427     }
    428 
    429     void forallFixer( Type *func ) {
     427        }
     428
     429        void forallFixer( Type *func ) {
    430430                // Fix up assertions
    431431                for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
     
    454454                        } // while
    455455                } // for
    456     }
    457 
    458     void Pass3::visit( ObjectDecl *object ) {
     456        }
     457
     458        void Pass3::visit( ObjectDecl *object ) {
    459459                forallFixer( object->get_type() );
    460460                if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
     
    463463                Parent::visit( object );
    464464                object->fixUniqueId();
    465     }
    466 
    467     void Pass3::visit( FunctionDecl *func ) {
     465        }
     466
     467        void Pass3::visit( FunctionDecl *func ) {
    468468                forallFixer( func->get_type() );
    469469                Parent::visit( func );
    470470                func->fixUniqueId();
    471     }
    472 
    473     static const std::list< std::string > noLabels;
    474 
    475     void AddStructAssignment::addStructAssignment( std::list< Declaration * > &translationUnit ) {
     471        }
     472
     473        static const std::list< std::string > noLabels;
     474
     475        void AddStructAssignment::addStructAssignment( std::list< Declaration * > &translationUnit ) {
    476476                AddStructAssignment visitor;
    477477                acceptAndAdd( translationUnit, visitor, false );
    478     }
    479 
    480     template< typename OutputIterator >
    481     void makeScalarAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, OutputIterator out ) {
     478        }
     479
     480        template< typename OutputIterator >
     481        void makeScalarAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, OutputIterator out ) {
    482482                ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member );
    483483                // unnamed bit fields are not copied as they cannot be accessed
     
    497497 
    498498                *out++ = new ExprStmt( noLabels, assignExpr );
    499     }
    500 
    501     template< typename OutputIterator >
    502     void makeArrayAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, ArrayType *array, OutputIterator out ) {
     499        }
     500
     501        template< typename OutputIterator >
     502        void makeArrayAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, ArrayType *array, OutputIterator out ) {
    503503                static UniqueName indexName( "_index" );
    504504 
     
    539539 
    540540                *out++ = new ForStmt( noLabels, initStmt, cond, inc, new ExprStmt( noLabels, assignExpr ) );
    541     }
    542 
    543     Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) {
     541        }
     542
     543        Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) {
    544544                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    545545 
     
    570570 
    571571                return assignDecl;
    572     }
    573 
    574     Declaration *makeUnionAssignment( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting ) {
     572        }
     573
     574        Declaration *makeUnionAssignment( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting ) {
    575575                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    576576 
     
    598598 
    599599                return assignDecl;
    600     }
    601 
    602     void AddStructAssignment::visit( StructDecl *structDecl ) {
     600        }
     601
     602        void AddStructAssignment::visit( StructDecl *structDecl ) {
    603603                if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
    604604                        StructInstType *structInst = new StructInstType( Type::Qualifiers(), structDecl->get_name() );
     
    607607                        structsDone.insert( structDecl->get_name() );
    608608                } // if
    609     }
    610 
    611     void AddStructAssignment::visit( UnionDecl *unionDecl ) {
     609        }
     610
     611        void AddStructAssignment::visit( UnionDecl *unionDecl ) {
    612612                if ( ! unionDecl->get_members().empty() ) {
    613613                        UnionInstType *unionInst = new UnionInstType( Type::Qualifiers(), unionDecl->get_name() );
     
    615615                        declsToAdd.push_back( makeUnionAssignment( unionDecl, unionInst, functionNesting ) );
    616616                } // if
    617     }
    618 
    619     void AddStructAssignment::visit( TypeDecl *typeDecl ) {
     617        }
     618
     619        void AddStructAssignment::visit( TypeDecl *typeDecl ) {
    620620                CompoundStmt *stmts = 0;
    621621                TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
     
    636636                FunctionDecl *func = new FunctionDecl( "?=?", Declaration::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false );
    637637                declsToAdd.push_back( func );
    638     }
    639 
    640     void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
     638        }
     639
     640        void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
    641641                if ( ! declsToAdd.empty() ) {
    642642                        for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
     
    645645                        declsToAdd.clear();
    646646                } // if
    647     }
    648 
    649     void AddStructAssignment::visit( FunctionType *) {
     647        }
     648
     649        void AddStructAssignment::visit( FunctionType *) {
    650650                // ensure that we don't add assignment ops for types defined as part of the function
    651     }
    652 
    653     void AddStructAssignment::visit( PointerType *) {
     651        }
     652
     653        void AddStructAssignment::visit( PointerType *) {
    654654                // ensure that we don't add assignment ops for types defined as part of the pointer
    655     }
    656 
    657     void AddStructAssignment::visit( ContextDecl *) {
     655        }
     656
     657        void AddStructAssignment::visit( ContextDecl *) {
    658658                // ensure that we don't add assignment ops for types defined as part of the context
    659     }
    660 
    661     template< typename StmtClass >
    662     inline void AddStructAssignment::visitStatement( StmtClass *stmt ) {
     659        }
     660
     661        template< typename StmtClass >
     662        inline void AddStructAssignment::visitStatement( StmtClass *stmt ) {
    663663                std::set< std::string > oldStructs = structsDone;
    664664                addVisit( stmt, *this );
    665665                structsDone = oldStructs;
    666     }
    667 
    668     void AddStructAssignment::visit( FunctionDecl *functionDecl ) {
     666        }
     667
     668        void AddStructAssignment::visit( FunctionDecl *functionDecl ) {
    669669                maybeAccept( functionDecl->get_functionType(), *this );
    670670                acceptAll( functionDecl->get_oldDecls(), *this );
     
    672672                maybeAccept( functionDecl->get_statements(), *this );
    673673                functionNesting -= 1;
    674     }
    675 
    676     void AddStructAssignment::visit( CompoundStmt *compoundStmt ) {
     674        }
     675
     676        void AddStructAssignment::visit( CompoundStmt *compoundStmt ) {
    677677                visitStatement( compoundStmt );
    678     }
    679 
    680     void AddStructAssignment::visit( IfStmt *ifStmt ) {
     678        }
     679
     680        void AddStructAssignment::visit( IfStmt *ifStmt ) {
    681681                visitStatement( ifStmt );
    682     }
    683 
    684     void AddStructAssignment::visit( WhileStmt *whileStmt ) {
     682        }
     683
     684        void AddStructAssignment::visit( WhileStmt *whileStmt ) {
    685685                visitStatement( whileStmt );
    686     }
    687 
    688     void AddStructAssignment::visit( ForStmt *forStmt ) {
     686        }
     687
     688        void AddStructAssignment::visit( ForStmt *forStmt ) {
    689689                visitStatement( forStmt );
    690     }
    691 
    692     void AddStructAssignment::visit( SwitchStmt *switchStmt ) {
     690        }
     691
     692        void AddStructAssignment::visit( SwitchStmt *switchStmt ) {
    693693                visitStatement( switchStmt );
    694     }
    695 
    696     void AddStructAssignment::visit( ChooseStmt *switchStmt ) {
     694        }
     695
     696        void AddStructAssignment::visit( ChooseStmt *switchStmt ) {
    697697                visitStatement( switchStmt );
    698     }
    699 
    700     void AddStructAssignment::visit( CaseStmt *caseStmt ) {
     698        }
     699
     700        void AddStructAssignment::visit( CaseStmt *caseStmt ) {
    701701                visitStatement( caseStmt );
    702     }
    703 
    704     void AddStructAssignment::visit( CatchStmt *cathStmt ) {
     702        }
     703
     704        void AddStructAssignment::visit( CatchStmt *cathStmt ) {
    705705                visitStatement( cathStmt );
    706     }
    707 
    708     bool isTypedef( Declaration *decl ) {
     706        }
     707
     708        bool isTypedef( Declaration *decl ) {
    709709                return dynamic_cast< TypedefDecl * >( decl );
    710     }
    711 
    712     void EliminateTypedef::eliminateTypedef( std::list< Declaration * > &translationUnit ) {
     710        }
     711
     712        void EliminateTypedef::eliminateTypedef( std::list< Declaration * > &translationUnit ) {
    713713                EliminateTypedef eliminator;
    714714                mutateAll( translationUnit, eliminator );
    715715                filter( translationUnit, isTypedef, true );
    716     }
    717 
    718     Type *EliminateTypedef::mutate( TypeInstType *typeInst ) {
     716        }
     717
     718        Type *EliminateTypedef::mutate( TypeInstType *typeInst ) {
    719719                std::map< std::string, TypedefDecl * >::const_iterator def = typedefNames.find( typeInst->get_name() );
    720720                if ( def != typedefNames.end() ) {
     
    725725                } // if
    726726                return typeInst;
    727     }
    728 
    729     Declaration *EliminateTypedef::mutate( TypedefDecl *tyDecl ) {
     727        }
     728
     729        Declaration *EliminateTypedef::mutate( TypedefDecl *tyDecl ) {
    730730                Declaration *ret = Mutator::mutate( tyDecl );
    731731                typedefNames[ tyDecl->get_name() ] = tyDecl;
     
    745745                        return ret;
    746746                } // if
    747     }
    748 
    749     TypeDecl *EliminateTypedef::mutate( TypeDecl *typeDecl ) {
     747        }
     748
     749        TypeDecl *EliminateTypedef::mutate( TypeDecl *typeDecl ) {
    750750                std::map< std::string, TypedefDecl * >::iterator i = typedefNames.find( typeDecl->get_name() );
    751751                if ( i != typedefNames.end() ) {
     
    753753                } // if
    754754                return typeDecl;
    755     }
    756 
    757     DeclarationWithType *EliminateTypedef::mutate( FunctionDecl *funcDecl ) {
     755        }
     756
     757        DeclarationWithType *EliminateTypedef::mutate( FunctionDecl *funcDecl ) {
    758758                std::map< std::string, TypedefDecl * > oldNames = typedefNames;
    759759                DeclarationWithType *ret = Mutator::mutate( funcDecl );
    760760                typedefNames = oldNames;
    761761                return ret;
    762     }
    763 
    764     ObjectDecl *EliminateTypedef::mutate( ObjectDecl *objDecl ) {
     762        }
     763
     764        ObjectDecl *EliminateTypedef::mutate( ObjectDecl *objDecl ) {
    765765                std::map< std::string, TypedefDecl * > oldNames = typedefNames;
    766766                ObjectDecl *ret = Mutator::mutate( objDecl );
    767767                typedefNames = oldNames;
    768768                return ret;
    769     }
    770 
    771     Expression *EliminateTypedef::mutate( CastExpr *castExpr ) {
     769        }
     770
     771        Expression *EliminateTypedef::mutate( CastExpr *castExpr ) {
    772772                std::map< std::string, TypedefDecl * > oldNames = typedefNames;
    773773                Expression *ret = Mutator::mutate( castExpr );
    774774                typedefNames = oldNames;
    775775                return ret;
    776     }
    777 
    778     CompoundStmt *EliminateTypedef::mutate( CompoundStmt *compoundStmt ) {
     776        }
     777
     778        CompoundStmt *EliminateTypedef::mutate( CompoundStmt *compoundStmt ) {
    779779                std::map< std::string, TypedefDecl * > oldNames = typedefNames;
    780780                CompoundStmt *ret = Mutator::mutate( compoundStmt );
     
    793793                typedefNames = oldNames;
    794794                return ret;
    795     }
     795        }
    796796} // namespace SymTab
    797797
  • translator/SymTab/Validate.h

    r01aeade ra08ba92  
    1111// Created On       : Sun May 17 21:53:34 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun May 17 21:55:09 2015
    14 // Update Count     : 2
     13// Last Modified On : Tue May 19 16:49:43 2015
     14// Update Count     : 3
    1515//
    1616
     
    2121
    2222namespace SymTab {
    23     class Indexer;
     23        class Indexer;
    2424
    25     void validate( std::list< Declaration * > &translationUnit, bool doDebug = false );
    26     void validateType( Type *type, const Indexer *indexer );
     25        void validate( std::list< Declaration * > &translationUnit, bool doDebug = false );
     26        void validateType( Type *type, const Indexer *indexer );
    2727} // namespace SymTab
    2828
Note: See TracChangeset for help on using the changeset viewer.