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 childs<hilti::Expression>(1, -1); }
29 
30  bool operator==(const Default& other) const { return type() == other.type(); }
31 
33  Type type() const { return type::effectiveType(child<Type>(0)); }
35  bool isConstant() const { return true; }
37  bool isLhs() const { return false; }
39  auto isTemporary() const { return true; }
41  auto isEqual(const Ctor& other) const { return node::isEqual(this, other); }
42 
44  auto properties() const { return node::Properties{}; }
45 
53  static Ctor setTypeArguments(const Default& d, std::vector<hilti::Expression> args) {
54  auto x = Ctor(d)._clone().as<Default>();
55  x.childs() = x.childs<Node>(0, 1);
56  for ( auto&& a : args )
57  x.childs().emplace_back(std::move(a));
58 
59  return std::move(x);
60  }
61 };
62 
63 } // namespace ctor
64 } // namespace hilti
static Ctor setTypeArguments(const Default &d, std::vector< hilti::Expression > args)
Definition: default.h:53
std::vector< T > childs(int begin, int end) const
Definition: node.h:373
Definition: default.h:16
Type type() const
Definition: default.h:33
Definition: optional.h:79
auto properties() const
Definition: default.h:44
Definition: meta.h:18
auto isEqual(const Ctor &other) const
Definition: default.h:41
bool isConstant() const
Definition: default.h:35
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Default(Type t, std::vector< Expression > type_args, Meta m=Meta())
Definition: default.h:25
Definition: node.h:97
Default(Type t, Meta m=Meta())
Definition: default.h:19
Definition: ctor.h:15
bool isLhs() const
Definition: default.h:37
Definition: node.h:318
auto isTemporary() const
Definition: default.h:39