source: src/AST/ForallSubstitutionTable.cpp @ a6f26ca

arm-ehjacob/cs343-translationnew-astnew-ast-unique-expr
Last change on this file since a6f26ca was e0e9a0b, checked in by Aaron Moss <a3moss@…>, 2 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.cpp --
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#include "ForallSubstitutionTable.hpp"
17
18#include <cassert>
19#include <vector>
20
21#include "Decl.hpp"
22#include "Node.hpp"
23#include "Type.hpp"
24#include "Visitor.hpp"
25
26namespace ast {
27
28std::vector< ptr< TypeDecl > > ForallSubstitutionTable::clone( 
29        const std::vector< ptr< TypeDecl > > & forall, Visitor & v
30) {
31        std::vector< ptr< TypeDecl > > new_forall;
32        new_forall.reserve( forall.size() );
33
34        for ( const ast::TypeDecl * d : forall ) {
35                // create cloned type decl and insert into substitution map before further mutation
36                auto new_d = new ast::TypeDecl{
37                        d->location, d->name, d->storage, d->base, d->kind, d->sized, d->init };
38                decls.insert( d, new_d );
39                // perform other mutations and add to output
40                auto newer_d = v.visit( new_d );
41                assert( new_d == newer_d && "Newly cloned TypeDecl must retain identity" );
42                new_forall.emplace_back( new_d );
43        }
44
45        return new_forall;
46}
47
48}
49
50// Local Variables: //
51// tab-width: 4 //
52// mode: c++ //
53// compile-command: "make install" //
54// End: //
Note: See TracBrowser for help on using the repository browser.