source: src/AST/Attribute.hpp @ 6d51bd7

arm-ehcleanup-dtorsjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since 6d51bd7 was 6d51bd7, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Fixes to the new templated pass and started on conversions

  • Property mode set to 100644
File size: 2.0 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// Attribute.hpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Fri May 10 10:30:00 2019
11// Last Modified By : Aaron B. Moss
12// Created On       : Fri May 10 10:30:00 2019
13// Update Count     : 1
14//
15
16#pragma once
17
18#include <string>
19#include <vector>
20
21#include "Fwd.hpp"
22#include "Node.hpp"     // for ptr
23#include "Visitor.hpp"
24
25namespace ast {
26
27class Expr;
28
29class Attribute final : public Node {
30public:
31        std::string name;
32        std::vector<ptr<Expr>> parameters;
33
34        Attribute( const std::string & name = "", std::vector<ptr<Expr>> && params = {})
35        : name( name ), parameters( params ) {}
36        virtual ~Attribute() = default;
37
38        bool empty() const { return name.empty(); }
39
40        /// strip leading/trailing underscores and lowercase
41        std::string normalizedName() const;
42
43        /// true iff this attribute is allowed to appear attached to a function parameter
44        bool isValidOnFuncParam() const;
45
46        const Attribute * accept( Visitor & v ) const override { return v.visit( this ); }
47private:
48        Attribute * clone() const override { return new Attribute{ *this }; }
49
50        /// Must be copied in ALL derived classes
51        template<typename node_t>
52        friend auto mutate(const node_t * node);
53};
54
55
56
57//=================================================================================================
58/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
59/// remove only if there is a better solution
60/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
61/// forward declarations
62inline void increment( const class Attribute * node, Node::ref_type ref ) { node->increment( ref ); }
63inline void decrement( const class Attribute * node, Node::ref_type ref ) { node->decrement( ref ); }
64}
65
66// Local Variables: //
67// tab-width: 4 //
68// mode: c++ //
69// compile-command: "make install" //
70// End: //
Note: See TracBrowser for help on using the repository browser.