source: src/AST/Decl.cpp @ 2bb4a01

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2bb4a01 was 2bb4a01, checked in by Aaron Moss <a3moss@…>, 5 years ago

Start on new AST

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[2bb4a01]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// Decl.cpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Thu May 9 10:00:00 2019
11// Last Modified By : Aaron B. Moss
12// Last Modified On : Thu May 9 10:00:00 2019
13// Update Count     : 1
14//
15
16#include <unordered_map>
17
18#include "Decl.hpp"
19
20#include "Fwd.hpp"   // for UniqueId
21#include "Node.hpp"  // for readonly
22
23namespace ast {
24// To canonicalize declarations
25static UniqueId lastUniqueId = 0;
26
27using IdMapType = std::unordered_map< UniqueId, readonly<Decl> >;
28static IdMapType idMap;
29
30void Decl::fixUniqueId() {
31        if ( uniqueId ) return;  // ensure only set once
32        uniqueId = ++lastUniqueId;
33        idMap[ uniqueId ] = this;
34}
35
36readonly<Decl> Decl::fromId( UniqueId id ) {
37        IdMapType::const_iterator i = idMap.find( id );
38        if ( i != idMap.end() ) return i->second;
39        return {};
40}
41}
42
43// Local Variables: //
44// tab-width: 4 //
45// mode: c++ //
46// compile-command: "make install" //
47// End: //
Note: See TracBrowser for help on using the repository browser.