new-envwith_gc
Last change
on this file since 8d7bef2 was
8d7bef2,
checked in by Aaron Moss <a3moss@…>, 5 years ago
|
First compiling build of CFA-CC with GC
|
-
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 | // GcTracer.h -- |
---|
8 | // |
---|
9 | // Author : Aaron B. Moss |
---|
10 | // Created On : Thu Mar 15 14:47:00 2018 |
---|
11 | // Last Modified By : Aaron B. Moss |
---|
12 | // Last Modified On : Thu Mar 15 14:47:00 2018 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #include <list> |
---|
19 | |
---|
20 | #include "BaseSyntaxNode.h" |
---|
21 | #include "Expression.h" |
---|
22 | |
---|
23 | #include "Common/GC.h" |
---|
24 | #include "Common/PassVisitor.h" |
---|
25 | |
---|
26 | class Expression; |
---|
27 | |
---|
28 | /// Implements `trace` method for syntax nodes |
---|
29 | class GcTracer final : public WithShortCircuiting, public WithVisitorRef<GcTracer> { |
---|
30 | const GC& gc; |
---|
31 | |
---|
32 | public: |
---|
33 | GcTracer( const GC& gc ) : gc(gc) {} |
---|
34 | |
---|
35 | void previsit( BaseSyntaxNode * node ) { |
---|
36 | // skip tree if already seen |
---|
37 | if ( node->mark == gc.mark ) { |
---|
38 | visit_children = false; |
---|
39 | return; |
---|
40 | } |
---|
41 | |
---|
42 | // mark node |
---|
43 | node->mark = gc.mark; |
---|
44 | } |
---|
45 | |
---|
46 | void postvisit( Expression* expr ) { |
---|
47 | maybeAccept( expr->env, *visitor ); |
---|
48 | } |
---|
49 | }; |
---|
50 | |
---|
51 | /// Traces entire translation unit recursively |
---|
52 | static inline const GC& operator<< ( const GC& gc, const std::list<Declaration*>& translationUnit ) { |
---|
53 | PassVisitor<GcTracer> tracer{ gc }; |
---|
54 | acceptAll( const_cast<std::list<Declaration*>&>( translationUnit ), tracer ); |
---|
55 | return gc; |
---|
56 | } |
---|
57 | |
---|
58 | // Local Variables: // |
---|
59 | // tab-width: 4 // |
---|
60 | // mode: c++ // |
---|
61 | // compile-command: "make install" // |
---|
62 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.