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

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6d98a07 was 6d98a07, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Fix a cyclic dependency with ptr and nodes

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[7e89526]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 "Node.hpp"     // for ptr
22#include "Visitor.hpp"
23
24namespace ast {
25
26class Expr;
27
28class Attribute final : public Node {
29public:
30        std::string name;
31        std::vector<ptr<Expr>> parameters;
32
33        Attribute( const std::string& name = "", std::vector<ptr<Expr>>&& params = {})
34        : name( name ), parameters( params ) {}
35
36        bool empty() const { return name.empty(); }
37
38        /// strip leading/trailing underscores and lowercase
39        std::string normalizedName() const;
40
41        /// true iff this attribute is allowed to appear attached to a function parameter
42        bool isValidOnFuncParam() const;
43
44        Attribute* accept( Visitor& v ) override { return v.visit( this ); }
45private:
46        Attribute* clone() const override { return new Attribute{ *this }; }
47};
48
[6d98a07]49
50
51//=================================================================================================
52/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
53/// remove only if there is a better solution
54/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
55/// forward declarations
56inline void increment( const class Attribute * node, Node::ref_type ref ) { node->increment( ref ); }
57inline void decrement( const class Attribute * node, Node::ref_type ref ) { node->decrement( ref ); }
[7e89526]58}
59
60// Local Variables: //
61// tab-width: 4 //
62// mode: c++ //
63// compile-command: "make install" //
64// End: //
Note: See TracBrowser for help on using the repository browser.