Spicy
default.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 #include <vector>
7 
8 #include <hilti/ast/ctor.h>
9 #include <hilti/ast/expression.h>
10 #include <hilti/ast/type.h>
11 
12 namespace hilti {
13 namespace ctor {
14 
16 class Default : public NodeBase, public hilti::trait::isCtor {
17 public:
19  Default(Type t, Meta m = Meta()) : NodeBase({std::move(t)}, std::move(m)) {}
20 
25  Default(Type t, std::vector<Expression> type_args, Meta m = Meta())
26  : NodeBase(nodes(std::move(t), std::move(type_args)), std::move(m)) {}
27 
28  auto typeArguments() const { return children<hilti::Expression>(1, -1); }
29 
30  void setTypeArguments(std::vector<hilti::Expression> args) {
31  auto& c = children();
32  c.erase(c.begin() + 1, c.end());
33  for ( auto&& a : args )
34  c.emplace_back(std::move(a));
35  }
36 
37  bool operator==(const Default& other) const { return type() == other.type(); }
38 
40  const Type& type() const { return child<Type>(0); }
42  bool isConstant() const { return true; }
44  bool isLhs() const { return false; }
46  auto isTemporary() const { return true; }
48  auto isEqual(const Ctor& other) const { return node::isEqual(this, other); }
50  auto properties() const { return node::Properties{}; }
51 };
52 
53 } // namespace ctor
54 } // namespace hilti
Definition: default.h:16
Definition: optional.h:79
auto properties() const
Definition: default.h:50
const auto & children() const
Definition: node.h:470
const Type & type() const
Definition: default.h:40
Definition: meta.h:18
Definition: type.h:159
auto isEqual(const Ctor &other) const
Definition: default.h:48
bool isConstant() const
Definition: default.h:42
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
Default(Type t, std::vector< Expression > type_args, Meta m=Meta())
Definition: default.h:25
Default(Type t, Meta m=Meta())
Definition: default.h:19
Definition: ctor.h:15
bool isLhs() const
Definition: default.h:44
Definition: node.h:358
auto isTemporary() const
Definition: default.h:46