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::ctor {
13 
15 class Default : public NodeBase, public hilti::trait::isCtor {
16 public:
18  Default(Type t, Meta m = Meta()) : NodeBase({std::move(t)}, std::move(m)) {}
19 
24  Default(Type t, std::vector<Expression> type_args, Meta m = Meta())
25  : NodeBase(nodes(std::move(t), std::move(type_args)), std::move(m)) {}
26 
27  auto typeArguments() const { return children<hilti::Expression>(1, -1); }
28 
29  void setTypeArguments(std::vector<hilti::Expression> args) {
30  auto& c = children();
31  c.erase(c.begin() + 1, c.end());
32  for ( auto&& a : args )
33  c.emplace_back(std::move(a));
34  }
35 
36  bool operator==(const Default& other) const { return type() == other.type(); }
37 
39  const Type& type() const { return child<Type>(0); }
41  bool isConstant() const { return true; }
43  bool isLhs() const { return false; }
45  auto isTemporary() const { return true; }
47  auto isEqual(const Ctor& other) const { return node::isEqual(this, other); }
49  auto properties() const { return node::Properties{}; }
50 };
51 
52 } // namespace hilti::ctor
Definition: default.h:15
Definition: optional.h:79
auto properties() const
Definition: default.h:49
const auto & children() const
Definition: node.h:472
const Type & type() const
Definition: default.h:39
Definition: meta.h:19
Definition: type.h:160
auto isEqual(const Ctor &other) const
Definition: default.h:47
bool isConstant() const
Definition: default.h:41
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:98
Default(Type t, std::vector< Expression > type_args, Meta m=Meta())
Definition: default.h:24
Default(Type t, Meta m=Meta())
Definition: default.h:18
Definition: ctor.h:15
bool isLhs() const
Definition: default.h:43
Definition: node.h:360
auto isTemporary() const
Definition: default.h:45