ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        ctor
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        gc_noraii
        jacob/cs343-translation
        jenkins-sandbox
        memory
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        string
        with_gc
      
      
        
          | Last change
 on this file since fe3b61b was             51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago | 
        
          | 
initial commit
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.4 KB | 
      
      
| Rev | Line |  | 
|---|
| [51b73452] | 1 | /* | 
|---|
|  | 2 | * This file is part of the Cforall project | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * $Id: Declaration.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $ | 
|---|
|  | 5 | * | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include <string> | 
|---|
|  | 9 | #include <map> | 
|---|
|  | 10 | #include "Declaration.h" | 
|---|
|  | 11 | #include "Expression.h" | 
|---|
|  | 12 | #include "Initializer.h" | 
|---|
|  | 13 | #include "Type.h" | 
|---|
|  | 14 | #include "utility.h" | 
|---|
|  | 15 |  | 
|---|
|  | 16 |  | 
|---|
|  | 17 | const char* Declaration::storageClassName[] = { "", "auto", "static", "extern", "register" }; | 
|---|
|  | 18 |  | 
|---|
|  | 19 | static UniqueId lastUniqueId = 0; | 
|---|
|  | 20 | typedef std::map< UniqueId, Declaration* > IdMapType; | 
|---|
|  | 21 | static IdMapType idMap; | 
|---|
|  | 22 |  | 
|---|
|  | 23 | Declaration::Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage ) | 
|---|
|  | 24 | : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 ) | 
|---|
|  | 25 | { | 
|---|
|  | 26 | } | 
|---|
|  | 27 |  | 
|---|
|  | 28 | Declaration::Declaration( const Declaration &other ) | 
|---|
|  | 29 | : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId ) | 
|---|
|  | 30 | { | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | Declaration::~Declaration() | 
|---|
|  | 34 | { | 
|---|
|  | 35 | } | 
|---|
|  | 36 |  | 
|---|
|  | 37 | void | 
|---|
|  | 38 | Declaration::fixUniqueId() | 
|---|
|  | 39 | { | 
|---|
|  | 40 | uniqueId = ++lastUniqueId; | 
|---|
|  | 41 | idMap[ uniqueId ] = this; | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | /* static class method */ | 
|---|
|  | 45 | Declaration * | 
|---|
|  | 46 | Declaration::declFromId( UniqueId id ) | 
|---|
|  | 47 | { | 
|---|
|  | 48 | IdMapType::const_iterator i = idMap.find( id ); | 
|---|
|  | 49 | if( i != idMap.end() ) { | 
|---|
|  | 50 | return i->second; | 
|---|
|  | 51 | } else { | 
|---|
|  | 52 | return 0; | 
|---|
|  | 53 | } | 
|---|
|  | 54 | } | 
|---|
|  | 55 |  | 
|---|
|  | 56 | /* static class method */ | 
|---|
|  | 57 | void | 
|---|
|  | 58 | Declaration::dumpIds( std::ostream &os ) | 
|---|
|  | 59 | { | 
|---|
|  | 60 | for( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) { | 
|---|
|  | 61 | os << i->first << " -> "; | 
|---|
|  | 62 | i->second->printShort( os ); | 
|---|
|  | 63 | os << std::endl; | 
|---|
|  | 64 | } | 
|---|
|  | 65 | } | 
|---|
|  | 66 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.