Spicy
hilti
toolchain
include
ast
ctors
default.h
1
// Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
2
3
#pragma once
4
5
#include <utility>
6
7
#include <hilti/ast/ctor.h>
8
#include <hilti/ast/expression.h>
9
#include <hilti/ast/type.h>
10
11
namespace
hilti::ctor {
12
14
class
Default
:
public
Ctor
{
15
public
:
16
auto
typeArguments()
const
{
return
children<Expression>(1, {}); }
17
18
QualifiedType
*
type
() const final {
return
child<QualifiedType>(0); }
19
20
void
setTypeArguments(
ASTContext
* ctx,
const
Expressions& exprs) {
21
removeChildren
(1, {});
22
addChildren
(ctx, exprs);
23
}
24
26
static
auto
create
(
ASTContext
* ctx,
UnqualifiedType
*
type
,
const
Meta
&
meta
= {}) {
27
return
ctx->
make
<
Default
>(ctx, {
QualifiedType::create
(ctx,
type
, Constness::Mutable,
meta
)},
meta
);
28
}
29
34
static
auto
create
(
ASTContext
* ctx,
UnqualifiedType
*
type
,
const
Expressions& type_args,
const
Meta
&
meta
= {}) {
35
return
ctx->
make
<
Default
>(ctx,
36
node::flatten(
QualifiedType::create
(ctx,
type
, Constness::Mutable,
meta
), type_args),
37
meta
);
38
}
39
40
protected
:
41
Default(
ASTContext
* ctx,
Nodes
children
,
Meta
meta
) :
Ctor
(ctx, NodeTags, std::move(
children
), std::move(
meta
)) {}
42
43
HILTI_NODE_1(ctor::Default, Ctor,
final
);
44
};
45
46
}
// namespace hilti::ctor
hilti::ASTContext
Definition:
ast-context.h:121
hilti::ASTContext::make
T * make(Args &&... args)
Definition:
ast-context.h:366
hilti::Ctor
Definition:
ctor.h:14
hilti::Meta
Definition:
meta.h:30
hilti::Node::children
const auto & children() const
Definition:
node.h:364
hilti::Node::meta
const auto & meta() const
Definition:
node.h:306
hilti::Node::removeChildren
void removeChildren(int begin, std::optional< int > end)
Definition:
node.h:575
hilti::Node::addChildren
void addChildren(ASTContext *ctx, const Nodes &children)
Definition:
node.h:545
hilti::Nodes
Definition:
forward.h:758
hilti::QualifiedType
Definition:
type.h:362
hilti::QualifiedType::create
static auto create(ASTContext *ctx, UnqualifiedType *t, Constness const_, Meta m=Meta())
Definition:
type.h:427
hilti::UnqualifiedType
Definition:
type.h:148
hilti::ctor::Default
Definition:
default.h:14
hilti::ctor::Default::create
static auto create(ASTContext *ctx, UnqualifiedType *type, const Meta &meta={})
Definition:
default.h:26
hilti::ctor::Default::type
QualifiedType * type() const final
Definition:
default.h:18
hilti::ctor::Default::create
static auto create(ASTContext *ctx, UnqualifiedType *type, const Expressions &type_args, const Meta &meta={})
Definition:
default.h:34
Generated by
1.9.1