source: src/GenPoly/ScrubTypeVars.hpp @ c819d90

Last change on this file since c819d90 was c92bdcc, checked in by Andrew Beach <ajbeach@…>, 6 months ago

Updated the rest of the names in src/ (except for the generated files).

  • Property mode set to 100644
File size: 2.1 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// ScrubTypeVars.hpp -- Remove polymorphic types.
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed Dec  7 16:57:00 2022
13// Update Count     : 5
14//
15
16#pragma once
17
18#include <cassert>            // for strict_dynamic_cast
19
20#include "AST/Fwd.hpp"        // for Node
21#include "GenPoly.hpp"        // for TypeVarMap
22
23namespace GenPoly {
24
25// ScrubMode and scrubTypeVarsBase are internal.
26enum class ScrubMode { FromMap, DynamicFromMap, All };
27
28const ast::Node * scrubTypeVarsBase(
29        const ast::Node * target, const TypeVarMap * typeVars, ScrubMode mode );
30
31
32/// For all polymorphic types with type variables in `typeVars`,
33/// replaces generic types, dtypes, and ftypes with the appropriate void type,
34/// and sizeof/alignof expressions with the proper variable.
35template<typename node_t>
36node_t const * scrubTypeVars(
37                node_t const * target, const TypeVarMap & typeVars ) {
38        return strict_dynamic_cast<node_t const *>(
39                        scrubTypeVarsBase( target, &typeVars, ScrubMode::FromMap ) );
40}
41
42/// For all dynamic-layout types with type variables in `typeVars`,
43/// replaces generic types, dtypes, and ftypes with the appropriate void type,
44/// and sizeof/alignof expressions with the proper variable.
45template<typename node_t>
46node_t const * scrubTypeVarsDynamic(
47                node_t const * target, const TypeVarMap & typeVars ) {
48        return strict_dynamic_cast<node_t const *>(
49                        scrubTypeVarsBase( target, &typeVars, ScrubMode::DynamicFromMap ) );
50}
51
52/// For all polymorphic types, replaces generic types, with the appropriate
53/// void type, and sizeof/alignof expressions with the proper variable.
54template<typename node_t>
55node_t const * scrubAllTypeVars( node_t const * target ) {
56        return strict_dynamic_cast<node_t const *>(
57                        scrubTypeVarsBase( target, nullptr, ScrubMode::All ) );
58}
59
60} // namespace GenPoly
61
62// Local Variables: //
63// tab-width: 4 //
64// mode: c++ //
65// compile-command: "make install" //
66// End: //
Note: See TracBrowser for help on using the repository browser.