ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since 417117e was             e0e9a0b, checked in by Aaron Moss <a3moss@…>, 6 years ago | 
        
          | 
Somewhat deeper clone for types with forall qualifiers.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.4 KB | 
      
      
| Line |  | 
|---|
| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // ForallSubstitutionTable.hpp -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Aaron B. Moss | 
|---|
| 10 | // Created On       : Thu Jun 27 14:00:00 2019 | 
|---|
| 11 | // Last Modified By : Aaron B. Moss | 
|---|
| 12 | // Last Modified On : Thu Jun 27 14:00:00 2019 | 
|---|
| 13 | // Update Count     : 1 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #pragma once | 
|---|
| 17 |  | 
|---|
| 18 | #include <vector> | 
|---|
| 19 |  | 
|---|
| 20 | #include "Node.hpp"  // for ptr | 
|---|
| 21 | #include "Common/ScopedMap.h" | 
|---|
| 22 |  | 
|---|
| 23 | namespace ast { | 
|---|
| 24 |  | 
|---|
| 25 | class TypeDecl; | 
|---|
| 26 | class Visitor; | 
|---|
| 27 |  | 
|---|
| 28 | /// Wrapper for TypeDecl substitution table | 
|---|
| 29 | class ForallSubstitutionTable { | 
|---|
| 30 | ScopedMap< const TypeDecl *, const TypeDecl * > decls; | 
|---|
| 31 |  | 
|---|
| 32 | public: | 
|---|
| 33 | /// Replaces given declaration with value in the table, if present, otherwise returns argument | 
|---|
| 34 | const TypeDecl * replace( const TypeDecl * d ) { | 
|---|
| 35 | auto it = decls.find( d ); | 
|---|
| 36 | if ( it != decls.end() ) return it->second; | 
|---|
| 37 | return d; | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | /// Builds a new forall list mutated according to the given visitor | 
|---|
| 41 | std::vector< ptr< TypeDecl > > clone( | 
|---|
| 42 | const std::vector< ptr< TypeDecl > > & forall, Visitor & v ); | 
|---|
| 43 |  | 
|---|
| 44 | /// Introduces a new lexical scope | 
|---|
| 45 | void beginScope() { decls.beginScope(); } | 
|---|
| 46 |  | 
|---|
| 47 | /// Concludes a lexical scope | 
|---|
| 48 | void endScope() { decls.endScope(); } | 
|---|
| 49 | }; | 
|---|
| 50 |  | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | // Local Variables: // | 
|---|
| 54 | // tab-width: 4 // | 
|---|
| 55 | // mode: c++ // | 
|---|
| 56 | // compile-command: "make install" // | 
|---|
| 57 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.